5 #include "TMVA/MethodBDT.h"
12 _MethodName(
"BDTG method"),
13 _full5x5SigmaIEtaIEtaMapLabel(conf.getParameter<edm::
InputTag>(
"full5x5SigmaIEtaIEtaMap")),
14 _full5x5SigmaIEtaIPhiMapLabel(conf.getParameter<edm::
InputTag>(
"full5x5SigmaIEtaIPhiMap")),
15 _full5x5E1x3MapLabel(conf.getParameter<edm::
InputTag>(
"full5x5E1x3Map")),
16 _full5x5E2x2MapLabel(conf.getParameter<edm::
InputTag>(
"full5x5E2x2Map")),
17 _full5x5E2x5MaxMapLabel(conf.getParameter<edm::
InputTag>(
"full5x5E2x5MaxMap")),
18 _full5x5E5x5MapLabel(conf.getParameter<edm::
InputTag>(
"full5x5E5x5Map")),
19 _esEffSigmaRRMapLabel(conf.getParameter<edm::
InputTag>(
"esEffSigmaRRMap")),
20 _phoChargedIsolationLabel(conf.getParameter<edm::
InputTag>(
"phoChargedIsolation")),
21 _phoPhotonIsolationLabel(conf.getParameter<edm::
InputTag>(
"phoPhotonIsolation")),
22 _phoWorstChargedIsolationLabel(conf.getParameter<edm::
InputTag>(
"phoWorstChargedIsolation")),
23 _rhoLabel(conf.getParameter<edm::
InputTag>(
"rho"))
30 const std::vector <std::string> weightFileNames
31 = conf.
getParameter<std::vector<std::string> >(
"weightFileNames");
35 <<
"wrong number of weightfiles" << std::endl;
54 const std::vector<float> vars = std::move(
fillMVAVariables( particle, iEvent ) );
60 printf(
"Printout of the photon variable inputs for MVA:\n");
61 printf(
" varPhi_ %f\n", vars[0] );
62 printf(
" varR9_ %f\n", vars[1] );
63 printf(
" varSieie_ %f\n", vars[2] );
64 printf(
" varSieip_ %f\n", vars[3] );
65 printf(
" varE1x3overE5x5_ %f\n", vars[4] );
66 printf(
" varE2x2overE5x5_ %f\n", vars[5] );
67 printf(
" varE2x5overE5x5_ %f\n", vars[6] );
68 printf(
" varSCEta_ %f\n", vars[7] );
69 printf(
" varRawE_ %f\n", vars[8] );
70 printf(
" varSCEtaWidth_ %f\n", vars[9] );
71 printf(
" varSCPhiWidth_ %f\n", vars[10] );
72 printf(
" varRho_ %f\n", vars[11] );
73 printf(
" varPhoIsoRaw_ %f\n", vars[12] );
74 printf(
" varChIsoRaw_ %f\n", vars[13] );
75 printf(
" varWorstChRaw_ %f\n", vars[14] );
77 printf(
" varESEnOverRawE_ %f\n", vars[15] );
78 printf(
" varESEffSigmaRR_ %f\n", vars[16] );
80 printf(
" varPt_ %f\n", vars[17] );
81 printf(
" varEta_ %f\n", vars[18] );
84 printf(
" varPt_ %f\n", vars[15] );
85 printf(
" varEta_ %f\n", vars[16] );
99 <<
" given particle is expected to be reco::Photon or pat::Photon," << std::endl
100 <<
" but appears to be neither" << std::endl;
102 const float eta = phoRecoPtr->superCluster()->eta();
138 TMVA::Reader tmpTMVAReader(
"!Color:Silent:Error" );
179 return std::unique_ptr<const GBRForest>(
new GBRForest( dynamic_cast<TMVA::MethodBDT*>( tmpTMVAReader.FindMVA(
_MethodName) ) ) );
220 if(! (full5x5SigmaIEtaIEtaMap.
isValid()
221 && full5x5SigmaIEtaIPhiMap.
isValid()
227 && phoChargedIsolationMap.
isValid()
228 && phoPhotonIsolationMap.
isValid()
229 && phoWorstChargedIsolationMap.
isValid()
232 <<
"Failed to retrieve event content needed for this MVA"
234 <<
"Check python MVA configuration file and make sure all needed"
236 <<
"producers are running upstream" << std::endl;
244 <<
" given particle is expected to be reco::Photon or pat::Photon," << std::endl
245 <<
" but appears to be neither" << std::endl;
248 auto superCluster = phoRecoPtr->superCluster();
251 float e1x3 = (*full5x5E1x3Map )[ phoRecoPtr ];
252 float e2x2 = (*full5x5E2x2Map )[ phoRecoPtr ];
253 float e2x5 = (*full5x5E2x5MaxMap)[ phoRecoPtr ];
254 float e5x5 = (*full5x5E5x5Map )[ phoRecoPtr ];
256 allMVAVars.
varPhi = phoRecoPtr->phi();
257 allMVAVars.
varR9 = phoRecoPtr->r9() ;
258 allMVAVars.
varSieie = (*full5x5SigmaIEtaIEtaMap)[ phoRecoPtr ];
259 allMVAVars.
varSieip = (*full5x5SigmaIEtaIPhiMap)[ phoRecoPtr ];
263 allMVAVars.
varSCEta = superCluster->eta();
264 allMVAVars.
varRawE = superCluster->rawEnergy();
267 allMVAVars.
varESEnOverRawE = superCluster->preshowerEnergy() / superCluster->rawEnergy();
270 allMVAVars.
varPhoIsoRaw = (*phoPhotonIsolationMap)[phoRecoPtr];
271 allMVAVars.
varChIsoRaw = (*phoChargedIsolationMap)[phoRecoPtr];
272 allMVAVars.
varWorstChRaw = (*phoWorstChargedIsolationMap)[phoRecoPtr];
274 allMVAVars.
varPt = phoRecoPtr->pt();
275 allMVAVars.
varEta = phoRecoPtr->eta();
279 std::vector<float> vars;
T getParameter(std::string const &) const
std::unique_ptr< const GBRForest > createSingleReader(const int iCategory, const edm::FileInPath &weightFile)
const edm::InputTag _esEffSigmaRRMapLabel
const edm::InputTag _full5x5E2x5MaxMapLabel
std::vector< float > fillMVAVariables(const edm::Ptr< reco::Candidate > &particle, const edm::Event &) const override
void setConsumes(edm::ConsumesCollector &&) const override
const edm::InputTag _rhoLabel
const edm::InputTag _full5x5E2x2MapLabel
const std::string _MethodName
const edm::InputTag _phoPhotonIsolationLabel
std::vector< float > packMVAVariables(const Args...args) const
const edm::InputTag _phoWorstChargedIsolationLabel
const edm::InputTag _full5x5SigmaIEtaIPhiMapLabel
bool isEndcapCategory(int category) const
bool isNull() const
Checks for null.
Abs< T >::type abs(const T &t)
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
const edm::InputTag _full5x5E5x5MapLabel
bool isEndcap(GeomDetEnumerators::SubDetector m)
const edm::InputTag _full5x5E1x3MapLabel
PhotonMVAEstimatorRun2Phys14NonTrig(const edm::ParameterSet &conf)
void constrainMVAVariables(AllVariables &vars) const
float mvaValue(const edm::Ptr< reco::Candidate > &particle, const edm::Event &) const
const edm::InputTag _full5x5SigmaIEtaIEtaMapLabel
int findCategory(const edm::Ptr< reco::Candidate > &particle) const
~PhotonMVAEstimatorRun2Phys14NonTrig()
const edm::InputTag _phoChargedIsolationLabel
std::string fullPath() const
std::vector< std::unique_ptr< const GBRForest > > _gbrForests