5 #include "TMVA/MethodBDT.h"
9 _MethodName(
"BDTG method"),
10 _full5x5SigmaIEtaIEtaMapLabel(conf.getParameter<edm::
InputTag>(
"full5x5SigmaIEtaIEtaMap")),
11 _full5x5SigmaIEtaIPhiMapLabel(conf.getParameter<edm::
InputTag>(
"full5x5SigmaIEtaIPhiMap")),
12 _full5x5E1x3MapLabel(conf.getParameter<edm::
InputTag>(
"full5x5E1x3Map")),
13 _full5x5E2x2MapLabel(conf.getParameter<edm::
InputTag>(
"full5x5E2x2Map")),
14 _full5x5E2x5MaxMapLabel(conf.getParameter<edm::
InputTag>(
"full5x5E2x5MaxMap")),
15 _full5x5E5x5MapLabel(conf.getParameter<edm::
InputTag>(
"full5x5E5x5Map")),
16 _esEffSigmaRRMapLabel(conf.getParameter<edm::
InputTag>(
"esEffSigmaRRMap")),
17 _phoChargedIsolationLabel(conf.getParameter<edm::
InputTag>(
"phoChargedIsolation")),
18 _phoPhotonIsolationLabel(conf.getParameter<edm::
InputTag>(
"phoPhotonIsolation")),
19 _phoWorstChargedIsolationLabel(conf.getParameter<edm::
InputTag>(
"phoWorstChargedIsolation")),
20 _rhoLabel(conf.getParameter<edm::
InputTag>(
"rho"))
28 const std::vector <std::string> weightFileNames
29 = conf.
getParameter<std::vector<std::string> >(
"weightFileNames");
33 <<
"wrong number of weightfiles" << std::endl;
61 const std::vector<float> vars = std::move(
fillMVAVariables( particle, iEvent ) );
66 const bool debug =
false;
68 printf(
"Printout of the photon variable inputs for MVA:\n");
69 printf(
" varPhi_ %f\n", vars[0] );
70 printf(
" varR9_ %f\n", vars[1] );
71 printf(
" varSieie_ %f\n", vars[2] );
72 printf(
" varSieip_ %f\n", vars[3] );
73 printf(
" varE1x3overE5x5_ %f\n", vars[4] );
74 printf(
" varE2x2overE5x5_ %f\n", vars[5] );
75 printf(
" varE2x5overE5x5_ %f\n", vars[6] );
76 printf(
" varSCEta_ %f\n", vars[7] );
77 printf(
" varRawE_ %f\n", vars[8] );
78 printf(
" varSCEtaWidth_ %f\n", vars[9] );
79 printf(
" varSCPhiWidth_ %f\n", vars[10] );
80 printf(
" varRho_ %f\n", vars[11] );
81 printf(
" varPhoIsoRaw_ %f\n", vars[12] );
82 printf(
" varChIsoRaw_ %f\n", vars[13] );
83 printf(
" varWorstChRaw_ %f\n", vars[14] );
85 printf(
" varESEnOverRawE_ %f\n", vars[15] );
86 printf(
" varESEffSigmaRR_ %f\n", vars[16] );
88 printf(
" varPt_ %f\n", vars[17] );
89 printf(
" varEta_ %f\n", vars[18] );
92 printf(
" varPt_ %f\n", vars[15] );
93 printf(
" varEta_ %f\n", vars[16] );
107 <<
" given particle is expected to be reco::Photon or pat::Photon," << std::endl
108 <<
" but appears to be neither" << std::endl;
110 float eta = phoRecoPtr->superCluster()->eta();
116 const float ebeeSplit = 1.479;
146 TMVA::Reader tmpTMVAReader(
"!Color:Silent:Error" );
188 return std::unique_ptr<const GBRForest>(
new GBRForest( dynamic_cast<TMVA::MethodBDT*>( tmpTMVAReader.FindMVA(
_MethodName) ) ) );
231 if(! (full5x5SigmaIEtaIEtaMap.
isValid()
232 && full5x5SigmaIEtaIPhiMap.
isValid()
238 && phoChargedIsolationMap.
isValid()
239 && phoPhotonIsolationMap.
isValid()
240 && phoWorstChargedIsolationMap.
isValid()
243 <<
"Failed to retrieve event content needed for this MVA"
245 <<
"Check python MVA configuration file and make sure all needed"
247 <<
"producers are running upstream" << std::endl;
254 <<
" given particle is expected to be reco::Photon or pat::Photon," << std::endl
255 <<
" but appears to be neither" << std::endl;
258 auto superCluster = phoRecoPtr->superCluster();
261 const float e1x3 = (*full5x5E1x3Map )[ phoRecoPtr ];
262 const float e2x2 = (*full5x5E2x2Map )[ phoRecoPtr ];
263 const float e2x5 = (*full5x5E2x5MaxMap)[ phoRecoPtr ];
264 const float e5x5 = (*full5x5E5x5Map )[ phoRecoPtr ];
268 allMVAVars.
varPhi = phoRecoPtr->phi();
269 allMVAVars.
varR9 = phoRecoPtr->r9() ;
270 allMVAVars.
varSieie = (*full5x5SigmaIEtaIEtaMap)[ phoRecoPtr ];
271 allMVAVars.
varSieip = (*full5x5SigmaIEtaIPhiMap)[ phoRecoPtr ];
275 allMVAVars.
varSCEta = superCluster->eta();
276 allMVAVars.
varRawE = superCluster->rawEnergy();
279 allMVAVars.
varESEnOverRawE = superCluster->preshowerEnergy() / superCluster->rawEnergy();
282 allMVAVars.
varPhoIsoRaw = (*phoPhotonIsolationMap)[phoRecoPtr];
283 allMVAVars.
varChIsoRaw = (*phoChargedIsolationMap)[phoRecoPtr];
284 allMVAVars.
varWorstChRaw = (*phoWorstChargedIsolationMap)[phoRecoPtr];
286 allMVAVars.
varPt = phoRecoPtr->pt();
287 allMVAVars.
varEta = phoRecoPtr->eta();
291 std::vector<float> vars;
T getParameter(std::string const &) const
const edm::InputTag _phoWorstChargedIsolationLabel
const edm::InputTag _full5x5E1x3MapLabel
const edm::InputTag _full5x5E2x2MapLabel
float mvaValue(const edm::Ptr< reco::Candidate > &particle, const edm::Event &) const
std::unique_ptr< const GBRForest > createSingleReader(const int iCategory, const edm::FileInPath &weightFile)
bool isEndcapCategory(int category) const
const edm::InputTag _phoChargedIsolationLabel
const edm::InputTag _full5x5SigmaIEtaIEtaMapLabel
const edm::InputTag _full5x5E5x5MapLabel
const std::string _MethodName
std::vector< float > packMVAVariables(const Args...args) const
const edm::InputTag _phoPhotonIsolationLabel
PhotonMVAEstimatorRun2Spring15NonTrig(const edm::ParameterSet &conf)
const edm::InputTag _full5x5E2x5MaxMapLabel
bool isNull() const
Checks for null.
Abs< T >::type abs(const T &t)
void constrainMVAVariables(AllVariables &) const
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
bool isEndcap(GeomDetEnumerators::SubDetector m)
const edm::InputTag _full5x5SigmaIEtaIPhiMapLabel
std::vector< float > fillMVAVariables(const edm::Ptr< reco::Candidate > &particle, const edm::Event &iEvent) const override
const edm::InputTag _rhoLabel
const edm::InputTag _esEffSigmaRRMapLabel
int findCategory(const edm::Ptr< reco::Candidate > &particle) const override
void setConsumes(edm::ConsumesCollector &&) const override
~PhotonMVAEstimatorRun2Spring15NonTrig()
std::vector< std::unique_ptr< const GBRForest > > _gbrForests
std::string fullPath() const