CMS 3D CMS Logo

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

#include <ElectronMVAEstimator.h>

Classes

struct  Configuration
 

Public Member Functions

 ElectronMVAEstimator ()
 
 ElectronMVAEstimator (const Configuration &)
 
 ElectronMVAEstimator (const std::string &fileName)
 
double mva (const reco::GsfElectron &myElectron, int nvertices=0) const
 
 ~ElectronMVAEstimator ()
 

Private Member Functions

void bindVariables (float vars[18]) const
 

Private Attributes

const Configuration cfg_
 
std::vector< std::unique_ptr< const GBRForest > > gbr_
 

Detailed Description

Definition at line 10 of file ElectronMVAEstimator.h.

Constructor & Destructor Documentation

◆ ElectronMVAEstimator() [1/3]

ElectronMVAEstimator::ElectronMVAEstimator ( )

Definition at line 8 of file ElectronMVAEstimator.cc.

8 : cfg_{} {}

◆ ElectronMVAEstimator() [2/3]

ElectronMVAEstimator::ElectronMVAEstimator ( const std::string &  fileName)

Definition at line 10 of file ElectronMVAEstimator.cc.

10  : cfg_{} {
11  // Taken from Daniele (his mail from the 30/11)
12  // tmvaReader.BookMVA("BDTSimpleCat","../Training/weights_Root527b_3Depth_DanVarConvRej_2PtBins_10Pt_800TPrune5_Min100Events_NoBjets_half/TMVA_BDTSimpleCat.weights.xm");
13  // training of the 7/12 with Nvtx added
14  gbr_.push_back(createGBRForest(fileName));
15 }

◆ ElectronMVAEstimator() [3/3]

ElectronMVAEstimator::ElectronMVAEstimator ( const Configuration cfg)

Definition at line 17 of file ElectronMVAEstimator.cc.

17  : cfg_(cfg) {
18  for (const auto& weightsfile : cfg_.vweightsfiles) {
19  gbr_.push_back(createGBRForest(weightsfile));
20  }
21 }

References cfg_, createGBRForest(), gbr_, and ElectronMVAEstimator::Configuration::vweightsfiles.

◆ ~ElectronMVAEstimator()

ElectronMVAEstimator::~ElectronMVAEstimator ( )
inline

Definition at line 18 of file ElectronMVAEstimator.h.

18 { ; }

Member Function Documentation

◆ bindVariables()

void ElectronMVAEstimator::bindVariables ( float  vars[18]) const
private

Definition at line 85 of file ElectronMVAEstimator.cc.

85  {
86  if (vars[0] < -1.)
87  vars[1] = -1.;
88 
89  if (vars[1] > 0.06)
90  vars[1] = 0.06;
91 
92  if (vars[2] > 0.6)
93  vars[2] = 0.6;
94 
95  if (vars[5] > 20.)
96  vars[5] = 20.;
97 
98  if (vars[7] > 20.)
99  vars[7] = 20;
100 
101  if (vars[8] > 0.2)
102  vars[8] = 0.2;
103 
104  if (vars[9] < 0.)
105  vars[9] = 0.;
106 
107  if (vars[9] > 15.)
108  vars[9] = 15.;
109 
110  if (vars[6] < -1.)
111  vars[6] = -1;
112 
113  if (vars[6] > 2.)
114  vars[6] = 2.;
115 
116  if (vars[12] > 15.)
117  vars[12] = 15.;
118 
119  if (vars[13] > 3.)
120  vars[13] = 3.;
121 }

Referenced by mva().

◆ mva()

double ElectronMVAEstimator::mva ( const reco::GsfElectron myElectron,
int  nvertices = 0 
) const

Definition at line 23 of file ElectronMVAEstimator.cc.

23  {
24  float vars[18];
25 
26  vars[0] = myElectron.fbrem();
27  vars[1] = std::abs(myElectron.deltaEtaSuperClusterTrackAtVtx());
28  vars[2] = std::abs(myElectron.deltaPhiSuperClusterTrackAtVtx());
29  vars[3] = myElectron.sigmaIetaIeta();
30  vars[4] = myElectron.hcalOverEcal();
31  vars[5] = myElectron.eSuperClusterOverP();
32  vars[6] = (myElectron.e5x5()) != 0. ? 1. - (myElectron.e1x5() / myElectron.e5x5()) : -1.;
33  vars[7] = myElectron.eEleClusterOverPout();
34  vars[8] = std::abs(myElectron.deltaEtaEleClusterTrackAtCalo());
35 
36  bool validKF = false;
37 
38  reco::TrackRef myTrackRef = myElectron.closestCtfTrackRef();
39  validKF = (myTrackRef.isNonnull() && myTrackRef.isAvailable());
40 
41  vars[9] = (validKF) ? myTrackRef->normalizedChi2() : 0;
42  vars[10] = (validKF) ? myTrackRef->hitPattern().trackerLayersWithMeasurement() : -1.;
43  vars[11] = myElectron.gsfTrack()->hitPattern().numberOfLostHits(reco::HitPattern::MISSING_INNER_HITS);
44  vars[12] = std::abs(myElectron.convDist());
45  vars[13] = std::abs(myElectron.convDcot());
46  vars[14] = nvertices;
47  vars[15] = myElectron.eta();
48  vars[16] = myElectron.pt();
49  vars[17] = myElectron.ecalDrivenSeed();
50 
52 
53  //0 pt &lt; 10 &amp;&amp; abs(eta)&lt;=1.485
54  //1 pt &gt;= 10 &amp;&amp; abs(eta)&lt;=1.485
55  //2 pt &lt; 10 &amp;&amp; abs(eta)&gt; 1.485
56  //3 pt &gt;= 10 &amp;&amp; abs(eta)&gt; 1.485
57 
58  const unsigned index = (unsigned)(myElectron.pt() >= 10) + 2 * (unsigned)(std::abs(myElectron.eta()) > 1.485);
59 
60  double result = gbr_[index]->GetAdaBoostClassifier(vars);
61  //
62  // std::cout << "fbrem" << vars[0] << std::endl;
63  // std::cout << "detain"<< vars[1] << std::endl;
64  // std::cout << "dphiin"<< vars[2] << std::endl;
65  // std::cout << "sieie"<< vars[3] << std::endl;
66  // std::cout << "hoe"<< vars[4] << std::endl;
67  // std::cout << "eop"<< vars[5] << std::endl;
68  // std::cout << "e1x5e5x5"<< vars[6] << std::endl;
69  // std::cout << "eleopout"<< vars[7] << std::endl;
70  // std::cout << "detaeleout"<< vars[8] << std::endl;
71  // std::cout << "kfchi2"<< vars[9] << std::endl;
72  // std::cout << "kfhits"<< vars[10] << std::endl;
73  // std::cout << "mishits"<<vars[11] << std::endl;
74  // std::cout << "dist"<< vars[12] << std::endl;
75  // std::cout << "dcot"<< vars[13] << std::endl;
76  // std::cout << "nvtx"<< vars[14] << std::endl;
77  // std::cout << "eta"<< vars[15] << std::endl;
78  // std::cout << "pt"<< vars[16] << std::endl;
79  // std::cout << "ecalseed"<< vars[17] << std::endl;
80  //
81  // std::cout << " MVA " << result << std::endl;
82  return result;
83 }

References funct::abs(), bindVariables(), reco::GsfElectron::closestCtfTrackRef(), reco::GsfElectron::convDcot(), reco::GsfElectron::convDist(), reco::GsfElectron::deltaEtaEleClusterTrackAtCalo(), reco::GsfElectron::deltaEtaSuperClusterTrackAtVtx(), reco::GsfElectron::deltaPhiSuperClusterTrackAtVtx(), reco::GsfElectron::e1x5(), reco::GsfElectron::e5x5(), reco::GsfElectron::ecalDrivenSeed(), reco::GsfElectron::eEleClusterOverPout(), reco::GsfElectron::eSuperClusterOverP(), reco::LeafCandidate::eta(), reco::GsfElectron::fbrem(), gbr_, reco::GsfElectron::gsfTrack(), reco::GsfElectron::hcalOverEcal(), edm::Ref< C, T, F >::isAvailable(), edm::Ref< C, T, F >::isNonnull(), reco::HitPattern::MISSING_INNER_HITS, reco::LeafCandidate::pt(), mps_fire::result, and reco::GsfElectron::sigmaIetaIeta().

Member Data Documentation

◆ cfg_

const Configuration ElectronMVAEstimator::cfg_
private

Definition at line 22 of file ElectronMVAEstimator.h.

Referenced by ElectronMVAEstimator().

◆ gbr_

std::vector<std::unique_ptr<const GBRForest> > ElectronMVAEstimator::gbr_
private

Definition at line 25 of file ElectronMVAEstimator.h.

Referenced by ElectronMVAEstimator(), and mva().

reco::GsfElectron::convDcot
float convDcot() const
Definition: GsfElectron.h:591
reco::GsfElectron::gsfTrack
GsfTrackRef gsfTrack() const override
reference to a GsfTrack
Definition: GsfElectron.h:164
ElectronMVAEstimator::cfg_
const Configuration cfg_
Definition: ElectronMVAEstimator.h:22
reco::GsfElectron::deltaPhiSuperClusterTrackAtVtx
float deltaPhiSuperClusterTrackAtVtx() const
Definition: GsfElectron.h:236
edm::Ref::isAvailable
bool isAvailable() const
Definition: Ref.h:537
createGBRForest
std::unique_ptr< const GBRForest > createGBRForest(const std::string &weightsFile)
Definition: GBRForestTools.cc:244
reco::LeafCandidate::pt
double pt() const final
transverse momentum
Definition: LeafCandidate.h:146
MillePedeFileConverter_cfg.fileName
fileName
Definition: MillePedeFileConverter_cfg.py:32
reco::GsfElectron::fbrem
float fbrem() const
Definition: GsfElectron.h:734
edm::Ref< TrackCollection >
vars
vars
Definition: DeepTauId.cc:158
reco::GsfElectron::ecalDrivenSeed
bool ecalDrivenSeed() const
Definition: GsfElectron.h:166
reco::GsfElectron::convDist
float convDist() const
Definition: GsfElectron.h:590
ElectronMVAEstimator::bindVariables
void bindVariables(float vars[18]) const
Definition: ElectronMVAEstimator.cc:85
reco::GsfElectron::deltaEtaSuperClusterTrackAtVtx
float deltaEtaSuperClusterTrackAtVtx() const
Definition: GsfElectron.h:233
reco::LeafCandidate::eta
double eta() const final
momentum pseudorapidity
Definition: LeafCandidate.h:152
edm::Ref::isNonnull
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:238
reco::GsfElectron::e1x5
float e1x5() const
Definition: GsfElectron.h:421
reco::GsfElectron::closestCtfTrackRef
virtual TrackRef closestCtfTrackRef() const
Definition: GsfElectron.h:188
reco::GsfElectron::hcalOverEcal
float hcalOverEcal() const
Definition: GsfElectron.h:427
looper.cfg
cfg
Definition: looper.py:297
reco::GsfElectron::sigmaIetaIeta
float sigmaIetaIeta() const
Definition: GsfElectron.h:419
ElectronMVAEstimator::Configuration::vweightsfiles
std::vector< std::string > vweightsfiles
Definition: ElectronMVAEstimator.h:13
reco::GsfElectron::e5x5
float e5x5() const
Definition: GsfElectron.h:423
ElectronMVAEstimator::gbr_
std::vector< std::unique_ptr< const GBRForest > > gbr_
Definition: ElectronMVAEstimator.h:25
reco::HitPattern::MISSING_INNER_HITS
Definition: HitPattern.h:155
reco::GsfElectron::deltaEtaEleClusterTrackAtCalo
float deltaEtaEleClusterTrackAtCalo() const
Definition: GsfElectron.h:235
reco::GsfElectron::eSuperClusterOverP
float eSuperClusterOverP() const
Definition: GsfElectron.h:229
reco::GsfElectron::eEleClusterOverPout
float eEleClusterOverPout() const
Definition: GsfElectron.h:232
AlignmentPI::index
index
Definition: AlignmentPayloadInspectorHelper.h:46
mps_fire.result
result
Definition: mps_fire.py:303
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22