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");
23 init(weightFileNames);
29 <<
"wrong number of weightfiles" << std::endl;
51 MethodName_(
"BDTG method"),
52 beamSpotLabel_(edm::
InputTag(beamspotTag)),
53 conversionsLabelAOD_(edm::
InputTag(conversionsTag)),
54 conversionsLabelMiniAOD_(conversionsLabelAOD_) {
98 mvaValue(
const int iCategory,
const std::vector<float> & vars)
const {
101 const bool debug =
false;
105 <<
" fbrem " << vars[11]
106 <<
" kfchi2 " << vars[9]
107 <<
" mykfhits " << vars[8]
108 <<
" gsfchi2 " << vars[10]
109 <<
" deta " << vars[18]
110 <<
" dphi " << vars[19]
111 <<
" detacalo " << vars[20]
112 <<
" see " << vars[0]
113 <<
" spp " << vars[1]
114 <<
" etawidth " << vars[4]
115 <<
" phiwidth " << vars[5]
116 <<
" OneMinusE1x5E5x5 " << vars[2]
118 <<
" HoE " << vars[6]
119 <<
" EoP " << vars[15]
120 <<
" IoEmIoP " << vars[17]
121 <<
" eleEoPout " << vars[16]
122 <<
" eta " << vars[24]
123 <<
" pt " << vars[21] << std::endl;
124 std::cout <<
" ### MVA " << result << std::endl;
137 <<
" given particle is expected to be reco::GsfElectron or pat::Electron," << std::endl
138 <<
" but appears to be neither" << std::endl;
143 float pt = eleRecoPtr->
pt();
150 const float ptSplit = 10;
151 const float ebSplit = 0.800;
152 const float ebeeSplit = 1.479;
154 if (pt < ptSplit &&
std::abs(eta) < ebSplit)
160 if (pt < ptSplit &&
std::abs(eta) >= ebeeSplit)
163 if (pt >= ptSplit &&
std::abs(eta) < ebSplit)
169 if (pt >= ptSplit &&
std::abs(eta) >= ebeeSplit)
192 TMVA::Reader tmpTMVAReader(
"!Color:Silent:!Error" );
201 tmpTMVAReader.AddVariable(
"ele_oldsigmaietaieta", &
allMVAVars_.
see);
202 tmpTMVAReader.AddVariable(
"ele_oldsigmaiphiiphi", &
allMVAVars_.
spp);
254 return std::unique_ptr<const GBRForest> (
new GBRForest( dynamic_cast<TMVA::MethodBDT*>( tmpTMVAReader.FindMVA(
MethodName_) ) ) );
282 <<
"Failed to retrieve event content needed for this MVA"
284 <<
"Check python MVA configuration file."
292 <<
" given particle is expected to be reco::GsfElectron or pat::Electron," << std::endl
293 <<
" but appears to be neither" << std::endl;
314 allMVAVars.
etawidth = superCluster->etaWidth();
315 allMVAVars.
phiwidth = superCluster->phiWidth();
318 allMVAVars.
PreShowerOverRaw = superCluster->preshowerEnergy() / superCluster->rawEnergy();
328 if( elePatPtr !=
NULL )
333 allMVAVars.
kfhits = (validKF) ? myTrackRef->hitPattern().trackerLayersWithMeasurement() : -1. ;
334 allMVAVars.
kfchi2 = (validKF) ? myTrackRef->normalizedChi2() : 0;
340 allMVAVars.
gsfhits = eleRecoPtr->
gsfTrack()->hitPattern().trackerLayersWithMeasurement();
347 double vertexFitProbability = -1.;
350 vertexFitProbability = TMath::Prob( vtx.
chi2(), vtx.
ndof());
366 allMVAVars.
pt = eleRecoPtr->
pt();
367 float scEta = superCluster->eta();
371 allMVAVars.
SCeta = scEta;
378 allMVAVars.
eClass = nines;
387 std::vector<float> vars;
472 if(allMVAVars.
fbrem < -1.)
473 allMVAVars.
fbrem = -1.;
475 allMVAVars.
deta = fabs(allMVAVars.
deta);
476 if(allMVAVars.
deta > 0.06)
477 allMVAVars.
deta = 0.06;
480 allMVAVars.
dphi = fabs(allMVAVars.
dphi);
481 if(allMVAVars.
dphi > 0.6)
482 allMVAVars.
dphi = 0.6;
485 if(allMVAVars.
EoP > 20.)
486 allMVAVars.
EoP = 20.;
504 if(allMVAVars.
R9 > 5)
511 if(allMVAVars.
kfchi2 > 10.)
T getParameter(std::string const &) const
bool isNonnull() const
Checks for non-null.
std::vector< std::unique_ptr< const GBRForest > > gbrForest_s
const std::string MethodName_
float eSuperClusterOverP() const
float mvaValue(const edm::Ptr< reco::Candidate > &particle, const edm::Event &) const override
const edm::InputTag conversionsLabelAOD_
float full5x5_e5x5() const
float expectedMissingInnerHits
float full5x5_e1x5() const
T const * get() const
Returns C++ pointer to the item.
bool isValid() const
Tells whether the vertex is valid.
math::XYZVectorF trackMomentumAtVtx() const
float full5x5_sigmaIphiIphi() const
const edm::InputTag beamSpotLabel_
std::unique_ptr< const GBRForest > createSingleReader(const int iCategory, const edm::FileInPath &weightFile)
float mcCBmatchingCategory
const edm::InputTag conversionsLabelMiniAOD_
std::vector< Conversion > ConversionCollection
collectin of Conversion objects
TrackRef closestCtfTrackRef() const
ElectronMVAEstimatorRun2Spring16HZZ()
float full5x5_sigmaIetaIeta() const
std::vector< float > packMVAVariables(const Args...args) const
std::vector< float > fillMVAVariables(const edm::Ptr< reco::Candidate > &particle, const edm::Event &) const override
void setConsumes(edm::ConsumesCollector &&) const overridefinal
float deltaEtaSuperClusterTrackAtVtx() const
float convVtxFitProbability
reco::TrackRef closestCtfTrackRef() const
override the reco::GsfElectron::closestCtfTrackRef method, to access the internal storage of the trac...
virtual SuperClusterRef superCluster() const
reference to a SuperCluster
float deltaPhiSuperClusterTrackAtVtx() const
bool isEndcapCategory(int category) const
Abs< T >::type abs(const T &t)
double chi2() const
chi-squares
float eEleClusterOverPout() const
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.
T const * product() const
float full5x5_hcalOverEcal() const
~ElectronMVAEstimatorRun2Spring16HZZ()
Analysis-level electron class.
float deltaEtaSeedClusterTrackAtCalo() const
bool getByLabel(InputTag const &, Handle< T > &) const
void constrainMVAVariables(AllVariables &) const
void init(const std::vector< std::string > weightFileNames)
const Point & position() const
position
std::string fullPath() const
int findCategory(const edm::Ptr< reco::Candidate > &particle) const override
virtual GsfTrackRef gsfTrack() const
reference to a GsfTrack
virtual double pt() const final
transverse momentum