CMS 3D CMS Logo

List of all members | Classes | Public Types | Public Member Functions | Public Attributes | Private Attributes
ElectronMVAEstimatorRun2Spring16GeneralPurpose Class Reference

#include <ElectronMVAEstimatorRun2Spring16GeneralPurpose.h>

Inheritance diagram for ElectronMVAEstimatorRun2Spring16GeneralPurpose:
AnyMVAEstimatorRun2Base

Classes

struct  AllVariables
 

Public Types

enum  mvaCategories { UNDEFINED = -1, CAT_EB1_PT10plus = 0, CAT_EB2_PT10plus = 1, CAT_EE_PT10plus = 2 }
 

Public Member Functions

void constrainMVAVariables (AllVariables &) const
 
 ElectronMVAEstimatorRun2Spring16GeneralPurpose (const edm::ParameterSet &conf)
 
 ElectronMVAEstimatorRun2Spring16GeneralPurpose ()
 
 ElectronMVAEstimatorRun2Spring16GeneralPurpose (const std::string &mvaTag, const std::string &conversionsTag="reducedEgamma:reducedConversions", const std::string &beamspotTag="offlineBeamSpot")
 
std::vector< float > fillMVAVariables (const edm::Ptr< reco::Candidate > &particle, const edm::Event &) const override
 
std::vector< float > fillMVAVariables (const reco::GsfElectron *particle, const edm::Handle< reco::ConversionCollection > conversions, const reco::BeamSpot *beamSpot) const
 
int findCategory (const edm::Ptr< reco::Candidate > &particle) const override
 
int findCategory (const reco::GsfElectron *particle) const
 
const std::string & getName () const final
 
int getNCategories () const override
 
const std::string & getTag () const final
 
void init (const std::vector< std::string > weightFileNames)
 
bool isEndcapCategory (int category) const
 
float mvaValue (const edm::Ptr< reco::Candidate > &particle, const edm::Event &) const override
 
float mvaValue (const reco::GsfElectron *particle, const edm::EventBase &) const
 
float mvaValue (const int iCategory, const std::vector< float > &vars) const
 
void setConsumes (edm::ConsumesCollector &&) const final
 
 ~ElectronMVAEstimatorRun2Spring16GeneralPurpose () override
 
- Public Member Functions inherited from AnyMVAEstimatorRun2Base
 AnyMVAEstimatorRun2Base (const edm::ParameterSet &conf)
 
virtual void getEventContent (const edm::Event &iEvent) const final
 
template<typename... Args>
std::vector< float > packMVAVariables (const Args...args) const
 
virtual ~AnyMVAEstimatorRun2Base ()
 

Public Attributes

const int nCategories = 3
 
- Public Attributes inherited from AnyMVAEstimatorRun2Base
const edm::ParameterSet _conf
 

Private Attributes

AllVariables allMVAVars_
 
const edm::InputTag beamSpotLabel_
 
const edm::InputTag conversionsLabelAOD_
 
const edm::InputTag conversionsLabelMiniAOD_
 
std::vector< std::unique_ptr< const GBRForest > > gbrForest_s
 
const std::string MethodName_
 
const std::string name_ = "ElectronMVAEstimatorRun2Spring16GeneralPurpose"
 
const std::string tag_
 

Detailed Description

Definition at line 18 of file ElectronMVAEstimatorRun2Spring16GeneralPurpose.h.

Member Enumeration Documentation

Constructor & Destructor Documentation

ElectronMVAEstimatorRun2Spring16GeneralPurpose::ElectronMVAEstimatorRun2Spring16GeneralPurpose ( const edm::ParameterSet conf)

Definition at line 13 of file ElectronMVAEstimatorRun2Spring16GeneralPurpose.cc.

References edm::ParameterSet::getParameter(), init(), and mvaElectronID_Fall17_iso_V1_cff::weightFileNames.

13  :
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")) {
20 
21  const std::vector <std::string> weightFileNames
22  = conf.getParameter<std::vector<std::string> >("weightFileNames");
23  init(weightFileNames);
24 }
T getParameter(std::string const &) const
void init(const std::vector< std::string > weightFileNames)
AnyMVAEstimatorRun2Base(const edm::ParameterSet &conf)
ElectronMVAEstimatorRun2Spring16GeneralPurpose::ElectronMVAEstimatorRun2Spring16GeneralPurpose ( )
ElectronMVAEstimatorRun2Spring16GeneralPurpose::ElectronMVAEstimatorRun2Spring16GeneralPurpose ( const std::string &  mvaTag,
const std::string &  conversionsTag = "reducedEgamma:reducedConversions",
const std::string &  beamspotTag = "offlineBeamSpot" 
)

Definition at line 48 of file ElectronMVAEstimatorRun2Spring16GeneralPurpose.cc.

References ~ElectronMVAEstimatorRun2Spring16GeneralPurpose().

ElectronMVAEstimatorRun2Spring16GeneralPurpose::~ElectronMVAEstimatorRun2Spring16GeneralPurpose ( )
override

Member Function Documentation

void ElectronMVAEstimatorRun2Spring16GeneralPurpose::constrainMVAVariables ( AllVariables allMVAVars) const

Definition at line 356 of file ElectronMVAEstimatorRun2Spring16GeneralPurpose.cc.

References ElectronMVAEstimatorRun2Spring16GeneralPurpose::AllVariables::deta, ElectronMVAEstimatorRun2Spring16GeneralPurpose::AllVariables::detacalo, ElectronMVAEstimatorRun2Spring16GeneralPurpose::AllVariables::dphi, ElectronMVAEstimatorRun2Spring16GeneralPurpose::AllVariables::eleEoPout, ElectronMVAEstimatorRun2Spring16GeneralPurpose::AllVariables::EoP, ElectronMVAEstimatorRun2Spring16GeneralPurpose::AllVariables::fbrem, ElectronMVAEstimatorRun2Spring16GeneralPurpose::AllVariables::gsfchi2, ElectronMVAEstimatorRun2Spring16GeneralPurpose::AllVariables::kfchi2, ElectronMVAEstimatorRun2Spring16GeneralPurpose::AllVariables::OneMinusE1x5E5x5, and ElectronMVAEstimatorRun2Spring16GeneralPurpose::AllVariables::R9.

Referenced by fillMVAVariables(), and getTag().

356  {
357 
358  // Check that variables do not have crazy values
359 
360  if(allMVAVars.fbrem < -1.)
361  allMVAVars.fbrem = -1.;
362 
363  allMVAVars.deta = fabs(allMVAVars.deta);
364  if(allMVAVars.deta > 0.06)
365  allMVAVars.deta = 0.06;
366 
367 
368  allMVAVars.dphi = fabs(allMVAVars.dphi);
369  if(allMVAVars.dphi > 0.6)
370  allMVAVars.dphi = 0.6;
371 
372 
373  if(allMVAVars.EoP > 20.)
374  allMVAVars.EoP = 20.;
375 
376  if(allMVAVars.eleEoPout > 20.)
377  allMVAVars.eleEoPout = 20.;
378 
379 
380  allMVAVars.detacalo = fabs(allMVAVars.detacalo);
381  if(allMVAVars.detacalo > 0.2)
382  allMVAVars.detacalo = 0.2;
383 
384  if(allMVAVars.OneMinusE1x5E5x5 < -1.)
385  allMVAVars.OneMinusE1x5E5x5 = -1;
386 
387  if(allMVAVars.OneMinusE1x5E5x5 > 2.)
388  allMVAVars.OneMinusE1x5E5x5 = 2.;
389 
390 
391  if(allMVAVars.R9 > 5)
392  allMVAVars.R9 = 5;
393 
394  if(allMVAVars.gsfchi2 > 200.)
395  allMVAVars.gsfchi2 = 200;
396 
397 
398  if(allMVAVars.kfchi2 > 10.)
399  allMVAVars.kfchi2 = 10.;
400 }
std::vector< float > ElectronMVAEstimatorRun2Spring16GeneralPurpose::fillMVAVariables ( const edm::Ptr< reco::Candidate > &  particle,
const edm::Event iEvent 
) const
overridevirtual

Implements AnyMVAEstimatorRun2Base.

Definition at line 178 of file ElectronMVAEstimatorRun2Spring16GeneralPurpose.cc.

References beamSpotLabel_, conversions_cfi::conversions, conversionsLabelAOD_, conversionsLabelMiniAOD_, Exception, edm::Ptr< T >::get(), edm::Event::getByLabel(), edm::HandleBase::isValid(), nullptr, and edm::Handle< T >::product().

Referenced by getTag(), isEndcapCategory(), and mvaValue().

179  {
180 
181  //
182  // Declare all value maps corresponding to the products we defined earlier
183  //
184  edm::Handle<reco::BeamSpot> theBeamSpot;
186 
187  // Get data needed for conversion rejection
188  iEvent.getByLabel(beamSpotLabel_, theBeamSpot);
189 
190  // Conversions in miniAOD and AOD have different names,
191  // but the same type, so we use the same handle with different tokens.
192  iEvent.getByLabel(conversionsLabelAOD_, conversions);
193  if( !conversions.isValid() )
194  iEvent.getByLabel(conversionsLabelMiniAOD_, conversions);
195 
196  // Make sure everything is retrieved successfully
197  if(! (theBeamSpot.isValid()
198  && conversions.isValid() )
199  )
200  throw cms::Exception("MVA failure: ")
201  << "Failed to retrieve event content needed for this MVA"
202  << std::endl
203  << "Check python MVA configuration file."
204  << std::endl;
205 
206  // Try to cast the particle into a reco particle.
207  // This should work for both reco and pat.
208  const edm::Ptr<reco::GsfElectron> eleRecoPtr = ( edm::Ptr<reco::GsfElectron> )particle;
209  if( eleRecoPtr.get() == nullptr )
210  throw cms::Exception("MVA failure: ")
211  << " given particle is expected to be reco::GsfElectron or pat::Electron," << std::endl
212  << " but appears to be neither" << std::endl;
213  return fillMVAVariables(eleRecoPtr.get(), conversions, theBeamSpot.product());
214 }
T const * get() const
Returns C++ pointer to the item.
Definition: Ptr.h:159
#define nullptr
std::vector< float > fillMVAVariables(const edm::Ptr< reco::Candidate > &particle, const edm::Event &) const override
bool isValid() const
Definition: HandleBase.h:74
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:475
T const * product() const
Definition: Handle.h:81
std::vector< float > ElectronMVAEstimatorRun2Spring16GeneralPurpose::fillMVAVariables ( const reco::GsfElectron particle,
const edm::Handle< reco::ConversionCollection conversions,
const reco::BeamSpot beamSpot 
) const

Definition at line 218 of file ElectronMVAEstimatorRun2Spring16GeneralPurpose.cc.

References funct::abs(), reco::Vertex::chi2(), pat::Electron::closestCtfTrackRef(), reco::GsfElectron::closestCtfTrackRef(), constexpr, constrainMVAVariables(), ElectronMVAEstimatorRun2Spring16GeneralPurpose::AllVariables::convVtxFitProbability, reco::GsfElectron::deltaEtaSeedClusterTrackAtCalo(), reco::GsfElectron::deltaEtaSuperClusterTrackAtVtx(), reco::GsfElectron::deltaPhiSuperClusterTrackAtVtx(), ElectronMVAEstimatorRun2Spring16GeneralPurpose::AllVariables::deta, ElectronMVAEstimatorRun2Spring16GeneralPurpose::AllVariables::detacalo, ElectronMVAEstimatorRun2Spring16GeneralPurpose::AllVariables::dphi, mvaElectronID_Fall17_iso_V1_cff::ebeeSplit, reco::GsfElectron::ecalEnergy(), reco::GsfElectron::eEleClusterOverPout(), ElectronMVAEstimatorRun2Spring16GeneralPurpose::AllVariables::eleEoPout, ElectronMVAEstimatorRun2Spring16GeneralPurpose::AllVariables::EoP, reco::GsfElectron::eSuperClusterOverP(), ElectronMVAEstimatorRun2Spring16GeneralPurpose::AllVariables::etawidth, ElectronMVAEstimatorRun2Spring16GeneralPurpose::AllVariables::expectedMissingInnerHits, ElectronMVAEstimatorRun2Spring16GeneralPurpose::AllVariables::fbrem, reco::GsfElectron::fbrem(), findCategory(), reco::GsfElectron::full5x5_e1x5(), reco::GsfElectron::full5x5_e5x5(), reco::GsfElectron::full5x5_hcalOverEcal(), reco::GsfElectron::full5x5_r9(), reco::GsfElectron::full5x5_sigmaIetaIeta(), reco::GsfElectron::full5x5_sigmaIphiIphi(), edm::Ref< C, T, F >::get(), ElectronMVAEstimatorRun2Spring16GeneralPurpose::AllVariables::gsfchi2, ElectronMVAEstimatorRun2Spring16GeneralPurpose::AllVariables::gsfhits, reco::GsfElectron::gsfTrack(), ElectronMVAEstimatorRun2Spring16GeneralPurpose::AllVariables::HoE, ElectronMVAEstimatorRun2Spring16GeneralPurpose::AllVariables::IoEmIoP, edm::Ref< C, T, F >::isAvailable(), ElectronMVAEstimatorRun2Spring16GeneralPurpose::AllVariables::isBarrel, ElectronMVAEstimatorRun2Spring16GeneralPurpose::AllVariables::isEndcap, isEndcapCategory(), edm::Ref< C, T, F >::isNonnull(), edm::Ref< C, T, F >::isNull(), reco::Vertex::isValid(), ElectronMVAEstimatorRun2Spring16GeneralPurpose::AllVariables::kfchi2, ElectronMVAEstimatorRun2Spring16GeneralPurpose::AllVariables::kfhits, ConversionTools::matchedConversion(), reco::HitPattern::MISSING_INNER_HITS, reco::Vertex::ndof(), ElectronMVAEstimatorRun2Spring16GeneralPurpose::AllVariables::OneMinusE1x5E5x5, AnyMVAEstimatorRun2Base::packMVAVariables(), ElectronMVAEstimatorRun2Spring16GeneralPurpose::AllVariables::phiwidth, reco::BeamSpot::position(), ElectronMVAEstimatorRun2Spring16GeneralPurpose::AllVariables::PreShowerOverRaw, ElectronMVAEstimatorRun2Spring16GeneralPurpose::AllVariables::pt, reco::LeafCandidate::pt(), ElectronMVAEstimatorRun2Spring16GeneralPurpose::AllVariables::R9, ElectronMVAEstimatorRun2Spring16GeneralPurpose::AllVariables::SCeta, ElectronMVAEstimatorRun2Spring16GeneralPurpose::AllVariables::see, ElectronMVAEstimatorRun2Spring16GeneralPurpose::AllVariables::spp, reco::GsfElectron::superCluster(), reco::GsfElectron::trackMomentumAtVtx(), and badGlobalMuonTaggersAOD_cff::vtx.

219  {
220 
221 
222  // Both pat and reco particles have exactly the same accessors, so we use a reco ptr
223  // throughout the code, with a single exception as of this writing, handled separately below.
224  auto superCluster = eleRecoPtr->superCluster();
225 
226  AllVariables allMVAVars;
227 
228  // Pure ECAL -> shower shapes
229  allMVAVars.see = eleRecoPtr->full5x5_sigmaIetaIeta();
230  allMVAVars.spp = eleRecoPtr->full5x5_sigmaIphiIphi();
231  allMVAVars.OneMinusE1x5E5x5 = 1. - eleRecoPtr->full5x5_e1x5() / eleRecoPtr->full5x5_e5x5();
232  allMVAVars.R9 = eleRecoPtr->full5x5_r9();
233  allMVAVars.etawidth = superCluster->etaWidth();
234  allMVAVars.phiwidth = superCluster->phiWidth();
235  allMVAVars.HoE = eleRecoPtr->full5x5_hcalOverEcal(); //hadronicOverEm();
236  // Endcap only variables
237  allMVAVars.PreShowerOverRaw = superCluster->preshowerEnergy() / superCluster->rawEnergy();
238 
239  // To get to CTF track information in pat::Electron, we have to have the pointer
240  // to pat::Electron, it is not accessible from the pointer to reco::GsfElectron.
241  // This behavior is reported and is expected to change in the future (post-7.4.5 some time).
242  bool validKF= false;
243  reco::TrackRef myTrackRef = eleRecoPtr->closestCtfTrackRef();
244  const pat::Electron * elePatPtr = dynamic_cast<const pat::Electron *>(eleRecoPtr);
245  // Check if this is really a pat::Electron, and if yes, get the track ref from this new
246  // pointer instead
247  if( elePatPtr != nullptr )
248  myTrackRef = elePatPtr->closestCtfTrackRef();
249  validKF = (myTrackRef.isAvailable() && (myTrackRef.isNonnull()) );
250 
251  //Pure tracking variables
252  allMVAVars.kfhits = (validKF) ? myTrackRef->hitPattern().trackerLayersWithMeasurement() : -1. ;
253  allMVAVars.kfchi2 = (validKF) ? myTrackRef->normalizedChi2() : 0;
254  allMVAVars.gsfchi2 = eleRecoPtr->gsfTrack()->normalizedChi2();
255 
256  // Energy matching
257  allMVAVars.fbrem = eleRecoPtr->fbrem();
258 
259  allMVAVars.gsfhits = eleRecoPtr->gsfTrack()->hitPattern().trackerLayersWithMeasurement();
260  allMVAVars.expectedMissingInnerHits = eleRecoPtr->gsfTrack()
261  ->hitPattern().numberOfLostHits(reco::HitPattern::MISSING_INNER_HITS);
262 
264  conversions,
265  theBeamSpot->position());
266  double vertexFitProbability = -1.;
267  if(!conv_ref.isNull()) {
268  const reco::Vertex &vtx = conv_ref.get()->conversionVertex(); if (vtx.isValid()) {
269  vertexFitProbability = TMath::Prob( vtx.chi2(), vtx.ndof());
270  }
271  }
272  allMVAVars.convVtxFitProbability = vertexFitProbability;
273 
274  allMVAVars.EoP = eleRecoPtr->eSuperClusterOverP();
275  allMVAVars.eleEoPout = eleRecoPtr->eEleClusterOverPout();
276  float pAtVertex = eleRecoPtr->trackMomentumAtVtx().R();
277  allMVAVars.IoEmIoP = (1.0/eleRecoPtr->ecalEnergy()) - (1.0 / pAtVertex );
278 
279  // Geometrical matchings
280  allMVAVars.deta = eleRecoPtr->deltaEtaSuperClusterTrackAtVtx();
281  allMVAVars.dphi = eleRecoPtr->deltaPhiSuperClusterTrackAtVtx();
282  allMVAVars.detacalo = eleRecoPtr->deltaEtaSeedClusterTrackAtCalo();
283 
284  // Spectator variables
285  allMVAVars.pt = eleRecoPtr->pt();
286  float scEta = superCluster->eta();
287  constexpr float ebeeSplit = 1.479;
288  allMVAVars.isBarrel = ( std::abs(scEta) < ebeeSplit );
289  allMVAVars.isEndcap = ( std::abs(scEta) >= ebeeSplit );
290  allMVAVars.SCeta = scEta;
291  allMVAVars.pt = eleRecoPtr->pt();
292 
293  constrainMVAVariables(allMVAVars);
294 
295  std::vector<float> vars;
296 
297  if( isEndcapCategory( findCategory( eleRecoPtr ) ) ) {
298  vars = packMVAVariables(allMVAVars.see,
299  allMVAVars.spp,
300  allMVAVars.OneMinusE1x5E5x5,
301  allMVAVars.R9,
302  allMVAVars.etawidth,
303  allMVAVars.phiwidth,
304  allMVAVars.HoE,
305  //Pure tracking variables
306  allMVAVars.kfhits,
307  allMVAVars.kfchi2,
308  allMVAVars.gsfchi2,
309  // Energy matching
310  allMVAVars.fbrem,
311  allMVAVars.gsfhits,
312  allMVAVars.expectedMissingInnerHits,
313  allMVAVars.convVtxFitProbability,
314  allMVAVars.EoP,
315  allMVAVars.eleEoPout,
316  allMVAVars.IoEmIoP,
317  // Geometrical matchings
318  allMVAVars.deta,
319  allMVAVars.dphi,
320  allMVAVars.detacalo,
321 
322  allMVAVars.pt,
323  allMVAVars.SCeta,
324  // Endcap only variables
325  allMVAVars.PreShowerOverRaw);
326  } else {
327  vars = packMVAVariables(allMVAVars.see,
328  allMVAVars.spp,
329  allMVAVars.OneMinusE1x5E5x5,
330  allMVAVars.R9,
331  allMVAVars.etawidth,
332  allMVAVars.phiwidth,
333  allMVAVars.HoE,
334  //Pure tracking variables
335  allMVAVars.kfhits,
336  allMVAVars.kfchi2,
337  allMVAVars.gsfchi2,
338  // Energy matching
339  allMVAVars.fbrem,
340  allMVAVars.gsfhits,
341  allMVAVars.expectedMissingInnerHits,
342  allMVAVars.convVtxFitProbability,
343  allMVAVars.EoP,
344  allMVAVars.eleEoPout,
345  allMVAVars.IoEmIoP,
346  // Geometrical matchings
347  allMVAVars.deta,
348  allMVAVars.dphi,
349  allMVAVars.detacalo,
350  allMVAVars.pt,
351  allMVAVars.SCeta);
352  }
353  return vars;
354 }
bool isAvailable() const
Definition: Ref.h:577
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:253
bool isValid() const
Tells whether the vertex is valid.
Definition: Vertex.h:68
#define constexpr
std::vector< float > packMVAVariables(const Args...args) const
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
double chi2() const
chi-squares
Definition: Vertex.h:98
T const * get() const
Returns C++ pointer to the item.
Definition: Ref.h:245
int findCategory(const edm::Ptr< reco::Candidate > &particle) const override
bool isNull() const
Checks for null.
Definition: Ref.h:250
double ndof() const
Definition: Vertex.h:105
Analysis-level electron class.
Definition: Electron.h:52
reco::TrackRef closestCtfTrackRef() const override
override the reco::GsfElectron::closestCtfTrackRef method, to access the internal storage of the trac...
static reco::ConversionRef matchedConversion(const reco::GsfElectron &ele, const edm::Handle< reco::ConversionCollection > &convCol, const math::XYZPoint &beamspot, bool allowCkfMatch=true, float lxyMin=2.0, float probMin=1e-6, unsigned int nHitsBeforeVtxMax=0)
int ElectronMVAEstimatorRun2Spring16GeneralPurpose::findCategory ( const edm::Ptr< reco::Candidate > &  particle) const
overridevirtual

Implements AnyMVAEstimatorRun2Base.

Definition at line 130 of file ElectronMVAEstimatorRun2Spring16GeneralPurpose.cc.

References edm::Ptr< T >::get(), and nullptr.

Referenced by fillMVAVariables(), getTag(), and mvaValue().

130  {
131 
132  // Try to cast the particle into a reco particle.
133  // This should work for both reco and pat.
134  const edm::Ptr<reco::GsfElectron> eleRecoPtr = ( edm::Ptr<reco::GsfElectron> )particle;
135  if( eleRecoPtr.get() == nullptr )
136  throw cms::Exception("MVA failure: ")
137  << " given particle is expected to be reco::GsfElectron or pat::Electron," << std::endl
138  << " but appears to be neither" << std::endl;
139  return findCategory(eleRecoPtr.get());
140 }
T const * get() const
Returns C++ pointer to the item.
Definition: Ptr.h:159
#define nullptr
int findCategory(const edm::Ptr< reco::Candidate > &particle) const override
int ElectronMVAEstimatorRun2Spring16GeneralPurpose::findCategory ( const reco::GsfElectron particle) const

Definition at line 142 of file ElectronMVAEstimatorRun2Spring16GeneralPurpose.cc.

References funct::abs(), CAT_EB1_PT10plus, CAT_EB2_PT10plus, CAT_EE_PT10plus, mvaElectronID_Fall17_iso_V1_cff::ebeeSplit, mvaElectronID_Fall17_iso_V1_cff::ebSplit, PVValHelper::eta, isEndcapCategory(), reco::GsfElectron::superCluster(), and UNDEFINED.

142  {
143  float eta = eleRecoPtr->superCluster()->eta();
144 
145  //
146  // Determine the category
147  //
148  int iCategory = UNDEFINED;
149  const float ebSplit = 0.800;// barrel is split into two regions
150  const float ebeeSplit = 1.479; // division between barrel and endcap
151 
152 
153  if (std::abs(eta) < ebSplit)
154  iCategory = CAT_EB1_PT10plus;
155 
156  if (std::abs(eta) >= ebSplit && std::abs(eta) < ebeeSplit)
157  iCategory = CAT_EB2_PT10plus;
158 
159  if (std::abs(eta) >= ebeeSplit)
160  iCategory = CAT_EE_PT10plus;
161 
162  return iCategory;
163 }
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
const std::string& ElectronMVAEstimatorRun2Spring16GeneralPurpose::getName ( void  ) const
inlinefinalvirtual
int ElectronMVAEstimatorRun2Spring16GeneralPurpose::getNCategories ( ) const
inlineoverridevirtual
const std::string& ElectronMVAEstimatorRun2Spring16GeneralPurpose::getTag ( ) const
inlinefinalvirtual
void ElectronMVAEstimatorRun2Spring16GeneralPurpose::init ( const std::vector< std::string >  weightFileNames)

Definition at line 26 of file ElectronMVAEstimatorRun2Spring16GeneralPurpose.cc.

References GBRForestTools::createGBRForest(), Exception, gbrForest_s, mps_fire::i, nCategories, and electrons_cff::weightFile.

Referenced by ElectronMVAEstimatorRun2Spring16GeneralPurpose().

26  {
27  if( (int)(weightFileNames.size()) != nCategories )
28  throw cms::Exception("MVA config failure: ")
29  << "wrong number of weightfiles" << std::endl;
30 
31  gbrForest_s.clear();
32  // Create a TMVA reader object for each category
33  for(int i=0; i<nCategories; i++){
34 
35  // Use unique_ptr so that all readers are properly cleaned up
36  // when the vector clear() is called in the destructor
37 
40 
41  }
42 
43 }
static std::unique_ptr< const GBRForest > createGBRForest(const std::string &weightFile)
bool ElectronMVAEstimatorRun2Spring16GeneralPurpose::isEndcapCategory ( int  category) const
float ElectronMVAEstimatorRun2Spring16GeneralPurpose::mvaValue ( const edm::Ptr< reco::Candidate > &  particle,
const edm::Event iEvent 
) const
overridevirtual

Implements AnyMVAEstimatorRun2Base.

Definition at line 79 of file ElectronMVAEstimatorRun2Spring16GeneralPurpose.cc.

References fillMVAVariables(), and findCategory().

Referenced by mvaValue(), and setConsumes().

79  {
80 
81  const int iCategory = findCategory( particle );
82  const std::vector<float> vars = fillMVAVariables( particle, iEvent );
83  return mvaValue(iCategory, vars);
84 }
float mvaValue(const edm::Ptr< reco::Candidate > &particle, const edm::Event &) const override
std::vector< float > fillMVAVariables(const edm::Ptr< reco::Candidate > &particle, const edm::Event &) const override
int findCategory(const edm::Ptr< reco::Candidate > &particle) const override
float ElectronMVAEstimatorRun2Spring16GeneralPurpose::mvaValue ( const reco::GsfElectron particle,
const edm::EventBase iEvent 
) const

Definition at line 87 of file ElectronMVAEstimatorRun2Spring16GeneralPurpose.cc.

References ecalDrivenElectronSeedsParameters_cff::beamSpot, beamSpotLabel_, conversions_cfi::conversions, conversionsLabelAOD_, fillMVAVariables(), findCategory(), edm::EventBase::getByLabel(), mvaValue(), and edm::Handle< T >::product().

87  {
90  iEvent.getByLabel(conversionsLabelAOD_, conversions);
91  iEvent.getByLabel(beamSpotLabel_, beamSpot);
92  const int iCategory = findCategory( particle );
93  const std::vector<float> vars = fillMVAVariables( particle, conversions, beamSpot.product() );
94  return mvaValue(iCategory, vars);
95 }
float mvaValue(const edm::Ptr< reco::Candidate > &particle, const edm::Event &) const override
std::vector< float > fillMVAVariables(const edm::Ptr< reco::Candidate > &particle, const edm::Event &) const override
int findCategory(const edm::Ptr< reco::Candidate > &particle) const override
T const * product() const
Definition: Handle.h:81
bool getByLabel(InputTag const &, Handle< T > &) const
Definition: EventBase.h:94
float ElectronMVAEstimatorRun2Spring16GeneralPurpose::mvaValue ( const int  iCategory,
const std::vector< float > &  vars 
) const

Definition at line 98 of file ElectronMVAEstimatorRun2Spring16GeneralPurpose.cc.

References gather_cfg::cout, debug, gbrForest_s, MethodName_, and mps_fire::result.

98  {
99  const float result = gbrForest_s.at(iCategory)->GetClassifier(vars.data());
100 
101  const bool debug = false;
102  if(debug) {
103  std::cout << " *** Inside the class MethodName_ " << MethodName_ << std::endl;
104  std::cout << " bin " << iCategory
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]
117  << " R9 " << vars[3]
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;
125  }
126 
127  return result;
128 }
#define debug
Definition: HDRShower.cc:19
void ElectronMVAEstimatorRun2Spring16GeneralPurpose::setConsumes ( edm::ConsumesCollector &&  cc) const
finalvirtual

Reimplemented from AnyMVAEstimatorRun2Base.

Definition at line 64 of file ElectronMVAEstimatorRun2Spring16GeneralPurpose.cc.

References beamSpotLabel_, conversionsLabelAOD_, conversionsLabelMiniAOD_, and mvaValue().

Referenced by getTag().

64  {
65 
66  // All tokens for event content needed by this MVA
67 
68  // Beam spot (same for AOD and miniAOD)
70 
71  // Conversions collection (different names in AOD and miniAOD)
74 
75 
76 }
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
EDGetTokenT< ProductType > mayConsume(edm::InputTag const &tag)
std::vector< Conversion > ConversionCollection
collectin of Conversion objects
Definition: ConversionFwd.h:9

Member Data Documentation

AllVariables ElectronMVAEstimatorRun2Spring16GeneralPurpose::allMVAVars_
private
const edm::InputTag ElectronMVAEstimatorRun2Spring16GeneralPurpose::beamSpotLabel_
private
const edm::InputTag ElectronMVAEstimatorRun2Spring16GeneralPurpose::conversionsLabelAOD_
private
const edm::InputTag ElectronMVAEstimatorRun2Spring16GeneralPurpose::conversionsLabelMiniAOD_
private
std::vector< std::unique_ptr<const GBRForest> > ElectronMVAEstimatorRun2Spring16GeneralPurpose::gbrForest_s
private

Definition at line 129 of file ElectronMVAEstimatorRun2Spring16GeneralPurpose.h.

Referenced by init(), and mvaValue().

const std::string ElectronMVAEstimatorRun2Spring16GeneralPurpose::MethodName_
private

Definition at line 132 of file ElectronMVAEstimatorRun2Spring16GeneralPurpose.h.

Referenced by mvaValue().

const std::string ElectronMVAEstimatorRun2Spring16GeneralPurpose::name_ = "ElectronMVAEstimatorRun2Spring16GeneralPurpose"
private

Definition at line 122 of file ElectronMVAEstimatorRun2Spring16GeneralPurpose.h.

Referenced by getName().

const int ElectronMVAEstimatorRun2Spring16GeneralPurpose::nCategories = 3

Definition at line 24 of file ElectronMVAEstimatorRun2Spring16GeneralPurpose.h.

Referenced by getNCategories(), and init().

const std::string ElectronMVAEstimatorRun2Spring16GeneralPurpose::tag_
private

Definition at line 126 of file ElectronMVAEstimatorRun2Spring16GeneralPurpose.h.

Referenced by getTag().