5 #include "TMVA/MethodBDT.h"
9 _MethodName(
"BDTG method"),
10 _useValueMaps(conf.getParameter<bool>(
"useValueMaps")),
11 _full5x5SigmaIEtaIEtaMapLabel(conf.getParameter<edm::
InputTag>(
"full5x5SigmaIEtaIEtaMap")),
12 _full5x5SigmaIEtaIPhiMapLabel(conf.getParameter<edm::
InputTag>(
"full5x5SigmaIEtaIPhiMap")),
13 _full5x5E1x3MapLabel(conf.getParameter<edm::
InputTag>(
"full5x5E1x3Map")),
14 _full5x5E2x2MapLabel(conf.getParameter<edm::
InputTag>(
"full5x5E2x2Map")),
15 _full5x5E2x5MaxMapLabel(conf.getParameter<edm::
InputTag>(
"full5x5E2x5MaxMap")),
16 _full5x5E5x5MapLabel(conf.getParameter<edm::
InputTag>(
"full5x5E5x5Map")),
17 _esEffSigmaRRMapLabel(conf.getParameter<edm::
InputTag>(
"esEffSigmaRRMap")),
18 _phoChargedIsolationLabel(conf.getParameter<edm::
InputTag>(
"phoChargedIsolation")),
19 _phoPhotonIsolationLabel(conf.getParameter<edm::
InputTag>(
"phoPhotonIsolation")),
20 _phoWorstChargedIsolationLabel(conf.getParameter<edm::
InputTag>(
"phoWorstChargedIsolation")),
21 _rhoLabel(conf.getParameter<edm::
InputTag>(
"rho"))
29 const std::vector <std::string> weightFileNames
30 = conf.
getParameter<std::vector<std::string> >(
"weightFileNames");
34 <<
"wrong number of weightfiles" << std::endl;
67 const bool debug =
false;
69 printf(
"Printout of the photon variable inputs for MVA:\n");
70 printf(
" varPhi_ %f\n", vars[0] );
71 printf(
" varR9_ %f\n", vars[1] );
72 printf(
" varSieie_ %f\n", vars[2] );
73 printf(
" varSieip_ %f\n", vars[3] );
74 printf(
" varE1x3overE5x5_ %f\n", vars[4] );
75 printf(
" varE2x2overE5x5_ %f\n", vars[5] );
76 printf(
" varE2x5overE5x5_ %f\n", vars[6] );
77 printf(
" varSCEta_ %f\n", vars[7] );
78 printf(
" varRawE_ %f\n", vars[8] );
79 printf(
" varSCEtaWidth_ %f\n", vars[9] );
80 printf(
" varSCPhiWidth_ %f\n", vars[10] );
81 printf(
" varRho_ %f\n", vars[11] );
82 printf(
" varPhoIsoRaw_ %f\n", vars[12] );
83 printf(
" varChIsoRaw_ %f\n", vars[13] );
84 printf(
" varWorstChRaw_ %f\n", vars[14] );
86 printf(
" varESEnOverRawE_ %f\n", vars[15] );
87 printf(
" varESEffSigmaRR_ %f\n", vars[16] );
89 printf(
" varPt_ %f\n", vars[17] );
90 printf(
" varEta_ %f\n", vars[18] );
93 printf(
" varPt_ %f\n", vars[15] );
94 printf(
" varEta_ %f\n", vars[16] );
108 <<
" given particle is expected to be reco::Photon or pat::Photon," << std::endl
109 <<
" but appears to be neither" << std::endl;
111 float eta = phoRecoPtr->superCluster()->eta();
117 const float ebeeSplit = 1.479;
147 TMVA::Reader tmpTMVAReader(
"!Color:Silent:Error" );
189 return std::unique_ptr<const GBRForest>(
new GBRForest( dynamic_cast<TMVA::MethodBDT*>( tmpTMVAReader.FindMVA(
_MethodName) ) ) );
235 && full5x5SigmaIEtaIPhiMap.
isValid()
240 && esEffSigmaRRMap.
isValid() ) )
241 && phoChargedIsolationMap.
isValid()
242 && phoPhotonIsolationMap.
isValid()
243 && phoWorstChargedIsolationMap.
isValid()
246 <<
"Failed to retrieve event content needed for this MVA"
248 <<
"Check python MVA configuration file and make sure all needed"
250 <<
"producers are running upstream" << std::endl;
257 <<
" given particle is expected to be reco::Photon or pat::Photon," << std::endl
258 <<
" but appears to be neither" << std::endl;
261 auto superCluster = phoRecoPtr->superCluster();
277 e1x3 = (*full5x5E1x3Map )[ phoRecoPtr ];
278 e2x2 = (*full5x5E2x2Map )[ phoRecoPtr ];
279 e2x5 = (*full5x5E2x5MaxMap)[ phoRecoPtr ];
280 e5x5 = (*full5x5E5x5Map )[ phoRecoPtr ];
281 full5x5_sigmaIetaIeta = (*full5x5SigmaIEtaIEtaMap)[ phoRecoPtr ];
282 full5x5_sigmaIetaIphi = (*full5x5SigmaIEtaIPhiMap)[ phoRecoPtr ];
283 effSigmaRR = (*esEffSigmaRRMap)[ phoRecoPtr ];
286 const auto& full5x5_pss = phoRecoPtr->full5x5_showerShapeVariables();
287 e1x3 = full5x5_pss.e1x3;
288 e2x2 = full5x5_pss.e2x2;
289 e2x5 = full5x5_pss.e2x5Max;
290 e5x5 = full5x5_pss.e5x5;
291 full5x5_sigmaIetaIeta = full5x5_pss.sigmaIetaIeta;
292 full5x5_sigmaIetaIphi = full5x5_pss.sigmaIetaIphi;
293 effSigmaRR = full5x5_pss.effSigmaRR;
296 allMVAVars.
varPhi = phoRecoPtr->phi();
297 allMVAVars.
varR9 = phoRecoPtr->r9() ;
298 allMVAVars.
varSieie = full5x5_sigmaIetaIeta;
299 allMVAVars.
varSieip = full5x5_sigmaIetaIphi;
303 allMVAVars.
varSCEta = superCluster->eta();
304 allMVAVars.
varRawE = superCluster->rawEnergy();
307 allMVAVars.
varESEnOverRawE = superCluster->preshowerEnergy() / superCluster->rawEnergy();
310 allMVAVars.
varPhoIsoRaw = (*phoPhotonIsolationMap)[phoRecoPtr];
311 allMVAVars.
varChIsoRaw = (*phoChargedIsolationMap)[phoRecoPtr];
312 allMVAVars.
varWorstChRaw = (*phoWorstChargedIsolationMap)[phoRecoPtr];
314 allMVAVars.
varPt = phoRecoPtr->pt();
315 allMVAVars.
varEta = phoRecoPtr->eta();
319 std::vector<float> vars;
394 "PhotonMVAEstimatorRun2Spring15NonTrig");
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
#define DEFINE_EDM_PLUGIN(factory, type, name)
~PhotonMVAEstimatorRun2Spring15NonTrig()
std::vector< std::unique_ptr< const GBRForest > > _gbrForests
std::string fullPath() const