11 #include "TMVA/MethodBDT.h"
15 _tag(conf.getParameter<std::
string>(
"mvaTag")),
16 _MethodName(
"BDTG method"),
17 _beamSpotLabel(conf.getParameter<edm::
InputTag>(
"beamSpot")),
18 _conversionsLabelAOD(conf.getParameter<edm::
InputTag>(
"conversionsAOD")),
19 _conversionsLabelMiniAOD(conf.getParameter<edm::
InputTag>(
"conversionsMiniAOD")) {
21 const std::vector <std::string> weightFileNames
22 = conf.
getParameter<std::vector<std::string> >(
"weightFileNames");
26 <<
"wrong number of weightfiles" << std::endl;
68 const bool debug =
false;
72 <<
" fbrem " << vars[11]
73 <<
" kfchi2 " << vars[9]
74 <<
" mykfhits " << vars[8]
75 <<
" gsfchi2 " << vars[10]
76 <<
" deta " << vars[18]
77 <<
" dphi " << vars[19]
78 <<
" detacalo " << vars[20]
81 <<
" etawidth " << vars[4]
82 <<
" phiwidth " << vars[5]
83 <<
" OneMinusE1x5E5x5 " << vars[2]
86 <<
" EoP " << vars[15]
87 <<
" IoEmIoP " << vars[17]
88 <<
" eleEoPout " << vars[16]
89 <<
" eta " << vars[22]
90 <<
" pt " << vars[21] << std::endl;
91 std::cout <<
" ### MVA " << result << std::endl;
104 <<
" given particle is expected to be reco::GsfElectron or pat::Electron," << std::endl
105 <<
" but appears to be neither" << std::endl;
107 float eta = eleRecoPtr->superCluster()->eta();
113 const float ebSplit = 0.800;
114 const float ebeeSplit = 1.479;
145 TMVA::Reader tmpTMVAReader(
"!Color:Silent:!Error" );
152 tmpTMVAReader.AddVariable(
"ele_oldsigmaietaieta", &
_allMVAVars.
see);
153 tmpTMVAReader.AddVariable(
"ele_oldsigmaiphiiphi", &
_allMVAVars.
spp);
192 return std::unique_ptr<const GBRForest> (
new GBRForest( dynamic_cast<TMVA::MethodBDT*>( tmpTMVAReader.FindMVA(
_MethodName) ) ) );
220 <<
"Failed to retrieve event content needed for this MVA"
222 <<
"Check python MVA configuration file."
230 <<
" given particle is expected to be reco::GsfElectron or pat::Electron," << std::endl
231 <<
" but appears to be neither" << std::endl;
235 auto superCluster = eleRecoPtr->superCluster();
240 allMVAVars.
see = eleRecoPtr->full5x5_sigmaIetaIeta();
241 allMVAVars.
spp = eleRecoPtr->full5x5_sigmaIphiIphi();
242 allMVAVars.
OneMinusE1x5E5x5 = 1. - eleRecoPtr->full5x5_e1x5() / eleRecoPtr->full5x5_e5x5();
243 allMVAVars.
R9 = eleRecoPtr->full5x5_r9();
244 allMVAVars.
etawidth = superCluster->etaWidth();
245 allMVAVars.
phiwidth = superCluster->phiWidth();
246 allMVAVars.
HoE = eleRecoPtr->hadronicOverEm();
248 allMVAVars.
PreShowerOverRaw = superCluster->preshowerEnergy() / superCluster->rawEnergy();
259 myTrackRef = elePatPtr->closestCtfTrackRef();
263 allMVAVars.
kfhits = (validKF) ? myTrackRef->hitPattern().trackerLayersWithMeasurement() : -1. ;
264 allMVAVars.
kfchi2 = (validKF) ? myTrackRef->normalizedChi2() : 0;
265 allMVAVars.
gsfchi2 = eleRecoPtr->gsfTrack()->normalizedChi2();
268 allMVAVars.
fbrem = eleRecoPtr->fbrem();
270 allMVAVars.
gsfhits = eleRecoPtr->gsfTrack()->hitPattern().trackerLayersWithMeasurement();
276 theBeamSpot->position());
277 double vertexFitProbability = -1.;
280 vertexFitProbability = TMath::Prob( vtx.
chi2(), vtx.
ndof());
285 allMVAVars.
EoP = eleRecoPtr->eSuperClusterOverP();
286 allMVAVars.
eleEoPout = eleRecoPtr->eEleClusterOverPout();
287 float pAtVertex = eleRecoPtr->trackMomentumAtVtx().R();
288 allMVAVars.
IoEmIoP = (1.0/eleRecoPtr->ecalEnergy()) - (1.0 / pAtVertex );
291 allMVAVars.
deta = eleRecoPtr->deltaEtaSuperClusterTrackAtVtx();
292 allMVAVars.
dphi = eleRecoPtr->deltaPhiSuperClusterTrackAtVtx();
293 allMVAVars.
detacalo = eleRecoPtr->deltaEtaSeedClusterTrackAtCalo();
296 allMVAVars.
pt = eleRecoPtr->pt();
297 float scEta = superCluster->eta();
298 allMVAVars.
SCeta = scEta;
302 std::vector<float> vars;
370 if(allMVAVars.
fbrem < -1.)
371 allMVAVars.
fbrem = -1.;
373 allMVAVars.
deta = fabs(allMVAVars.
deta);
374 if(allMVAVars.
deta > 0.06)
375 allMVAVars.
deta = 0.06;
378 allMVAVars.
dphi = fabs(allMVAVars.
dphi);
379 if(allMVAVars.
dphi > 0.6)
380 allMVAVars.
dphi = 0.6;
383 if(allMVAVars.
EoP > 20.)
384 allMVAVars.
EoP = 20.;
402 if(allMVAVars.
R9 > 5)
409 if(allMVAVars.
kfchi2 > 10.)
417 "ElectronMVAEstimatorRun2Spring15Trig");
T getParameter(std::string const &) const
std::unique_ptr< const GBRForest > createSingleReader(const int iCategory, const edm::FileInPath &weightFile)
bool isNonnull() const
Checks for non-null.
std::vector< std::unique_ptr< const GBRForest > > _gbrForests
const edm::InputTag _conversionsLabelAOD
T const * get() const
Returns C++ pointer to the item.
bool isValid() const
Tells whether the vertex is valid.
std::vector< float > fillMVAVariables(const edm::Ptr< reco::Candidate > &particle, const edm::Event &) const override
float expectedMissingInnerHits
const edm::InputTag _conversionsLabelMiniAOD
std::vector< Conversion > ConversionCollection
collectin of Conversion objects
void setConsumes(edm::ConsumesCollector &&) const overridefinal
std::vector< float > packMVAVariables(const Args...args) const
float mvaValue(const edm::Ptr< reco::Candidate > &particle, const edm::Event &) const override
~ElectronMVAEstimatorRun2Spring15Trig()
void constrainMVAVariables(AllVariables &) const
Abs< T >::type abs(const T &t)
double chi2() const
chi-squares
T const * get() const
Returns C++ pointer to the item.
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
bool isEndcap(GeomDetEnumerators::SubDetector m)
bool isNull() const
Checks for null.
int findCategory(const edm::Ptr< reco::Candidate > &particle) const override
ElectronMVAEstimatorRun2Spring15Trig(const edm::ParameterSet &conf)
#define DEFINE_EDM_PLUGIN(factory, type, name)
std::string fullPath() const
const edm::InputTag _beamSpotLabel
const std::string _MethodName
float convVtxFitProbability
bool isEndcapCategory(int category) const