CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
ElectronMVAEstimator Class Reference

#include <ElectronMVAEstimator.h>

Public Member Functions

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

Private Member Functions

void bindVariables ()
 
void init (std::string fileName)
 

Private Attributes

Float_t absdcot
 
Float_t absdist
 
Float_t dcot
 
Float_t detaeleout
 
Float_t detain
 
Float_t dist
 
Float_t dphiin
 
Float_t e1x5e5x5
 
Int_t ecalseed
 
Float_t eleopout
 
Float_t eop
 
Float_t eta
 
Float_t fbrem
 
Float_t hoe
 
Float_t kfchi2
 
Int_t kfhits
 
Int_t mishits
 
Float_t mykfhits
 
Float_t mymishits
 
Float_t myNvtx
 
Int_t Nvtx
 
Float_t pt
 
Float_t sieie
 
TMVA::Reader * tmvaReader_
 

Detailed Description

Definition at line 8 of file ElectronMVAEstimator.h.

Constructor & Destructor Documentation

ElectronMVAEstimator::ElectronMVAEstimator ( )

Definition at line 8 of file ElectronMVAEstimator.cc.

8 {}
ElectronMVAEstimator::ElectronMVAEstimator ( std::string  fileName)

Definition at line 10 of file ElectronMVAEstimator.cc.

References init().

10  {
11  init(fileName);
12 }
void init(std::string fileName)
ElectronMVAEstimator::~ElectronMVAEstimator ( )
inline

Definition at line 12 of file ElectronMVAEstimator.h.

12 {;}

Member Function Documentation

void ElectronMVAEstimator::bindVariables ( )
private

Definition at line 101 of file ElectronMVAEstimator.cc.

References absdcot, absdist, dcot, detaeleout, detain, dist, dphiin, e1x5e5x5, eleopout, eop, fbrem, kfchi2, kfhits, mishits, mykfhits, mymishits, myNvtx, and Nvtx.

Referenced by mva().

101  {
102  if(fbrem < -1.)
103  fbrem = -1.;
104 
105  detain = fabs(detain);
106  if(detain > 0.06)
107  detain = 0.06;
108 
109 
110  dphiin = fabs(dphiin);
111  if(dphiin > 0.6)
112  dphiin = 0.6;
113 
114 
115  if(eop > 20.)
116  eop = 20.;
117 
118 
119  if(eleopout > 20.)
120  eleopout = 20;
121 
122  detaeleout = fabs(detaeleout);
123  if(detaeleout > 0.2)
124  detaeleout = 0.2;
125 
126  mykfhits = float(kfhits);
127  mymishits = float(mishits);
128 
129  if(kfchi2 < 0.)
130  kfchi2 = 0.;
131 
132  if(kfchi2 > 15.)
133  kfchi2 = 15.;
134 
135 
136  if(e1x5e5x5 < -1.)
137  e1x5e5x5 = -1;
138 
139  if(e1x5e5x5 > 2.)
140  e1x5e5x5 = 2.;
141 
142 
143  if(dist > 15.)
144  dist = 15.;
145  if(dist < -15.)
146  dist = -15.;
147 
148  if(dcot > 3.)
149  dcot = 3.;
150  if(dcot < -3.)
151  dcot = -3.;
152 
153  absdist = fabs(dist);
154  absdcot = fabs(dcot);
155  myNvtx = float(Nvtx);
156 
157 }
void ElectronMVAEstimator::init ( std::string  fileName)
private

Definition at line 15 of file ElectronMVAEstimator.cc.

References absdcot, absdist, detaeleout, detain, dphiin, e1x5e5x5, ecalseed, eleopout, eop, eta, fbrem, hoe, kfchi2, mykfhits, mymishits, myNvtx, pt, sieie, and tmvaReader_.

Referenced by ElectronMVAEstimator().

15  {
16  tmvaReader_ = new TMVA::Reader("!Color:Silent");
17  tmvaReader_->AddVariable("fbrem",&fbrem);
18  tmvaReader_->AddVariable("detain", &detain);
19  tmvaReader_->AddVariable("dphiin", &dphiin);
20  tmvaReader_->AddVariable("sieie", &sieie);
21  tmvaReader_->AddVariable("hoe", &hoe);
22  tmvaReader_->AddVariable("eop", &eop);
23  tmvaReader_->AddVariable("e1x5e5x5", &e1x5e5x5);
24  tmvaReader_->AddVariable("eleopout", &eleopout);
25  tmvaReader_->AddVariable("detaeleout", &detaeleout);
26  tmvaReader_->AddVariable("kfchi2", &kfchi2);
27  tmvaReader_->AddVariable("kfhits", &mykfhits);
28  tmvaReader_->AddVariable("mishits",&mymishits);
29  tmvaReader_->AddVariable("dist", &absdist);
30  tmvaReader_->AddVariable("dcot", &absdcot);
31  tmvaReader_->AddVariable("nvtx", &myNvtx);
32 
33  tmvaReader_->AddSpectator("eta",&eta);
34  tmvaReader_->AddSpectator("pt",&pt);
35  tmvaReader_->AddSpectator("ecalseed",&ecalseed);
36 
37  // Taken from Daniele (his mail from the 30/11)
38  // tmvaReader_->BookMVA("BDTSimpleCat","../Training/weights_Root527b_3Depth_DanVarConvRej_2PtBins_10Pt_800TPrune5_Min100Events_NoBjets_half/TMVA_BDTSimpleCat.weights.xm");
39  // training of the 7/12 with Nvtx added
40  tmvaReader_->BookMVA("BDTSimpleCat",fileName.c_str());
41 }
double ElectronMVAEstimator::mva ( const reco::GsfElectron myElectron,
int  nvertices = 0 
)

Definition at line 45 of file ElectronMVAEstimator.cc.

References bindVariables(), reco::GsfElectron::closestCtfTrackRef(), reco::GsfElectron::convDcot(), reco::GsfElectron::convDist(), dcot, reco::GsfElectron::deltaEtaEleClusterTrackAtCalo(), reco::GsfElectron::deltaEtaSuperClusterTrackAtVtx(), reco::GsfElectron::deltaPhiSuperClusterTrackAtVtx(), detaeleout, detain, dist, dphiin, reco::GsfElectron::e1x5(), e1x5e5x5, reco::GsfElectron::e5x5(), reco::GsfElectron::ecalDrivenSeed(), ecalseed, reco::GsfElectron::eEleClusterOverPout(), eleopout, eop, reco::GsfElectron::eSuperClusterOverP(), eta, reco::LeafCandidate::eta(), fbrem, reco::GsfElectron::fbrem(), reco::GsfElectron::gsfTrack(), reco::GsfElectron::hcalOverEcal(), hoe, edm::Ref< C, T, F >::isAvailable(), edm::Ref< C, T, F >::isNonnull(), kfchi2, kfhits, mishits, Nvtx, pt, reco::LeafCandidate::pt(), query::result, sieie, reco::GsfElectron::sigmaIetaIeta(), and tmvaReader_.

45  {
46  fbrem = myElectron.fbrem();
49  sieie = myElectron.sigmaIetaIeta();
50  hoe = myElectron.hcalOverEcal();
51  eop = myElectron.eSuperClusterOverP();
52  e1x5e5x5 = (myElectron.e5x5()) !=0. ? 1.-(myElectron.e1x5()/myElectron.e5x5()) : -1. ;
53  eleopout = myElectron.eEleClusterOverPout();
55 
56  bool validKF= false;
57 
58  reco::TrackRef myTrackRef = myElectron.closestCtfTrackRef();
59  validKF = (myTrackRef.isAvailable());
60  validKF = (myTrackRef.isNonnull());
61 
62  kfchi2 = (validKF) ? myTrackRef->normalizedChi2() : 0 ;
63  kfhits = (validKF) ? myTrackRef->hitPattern().trackerLayersWithMeasurement() : -1. ;
64  dist = myElectron.convDist();
65  dcot = myElectron.convDcot();
66  eta = myElectron.eta();
67  pt = myElectron.pt();
68 
69  mishits = myElectron.gsfTrack()->trackerExpectedHitsInner().numberOfLostHits();
70  ecalseed = myElectron.ecalDrivenSeed();
71 
72  Nvtx = nvertices;
73 
74  bindVariables();
75  double result = tmvaReader_->EvaluateMVA("BDTSimpleCat");
76 //
77 // std::cout << "fbrem" <<fbrem << std::endl;
78 // std::cout << "detain"<< detain << std::endl;
79 // std::cout << "dphiin"<< dphiin << std::endl;
80 // std::cout << "sieie"<< sieie << std::endl;
81 // std::cout << "hoe"<< hoe << std::endl;
82 // std::cout << "eop"<< eop << std::endl;
83 // std::cout << "e1x5e5x5"<< e1x5e5x5 << std::endl;
84 // std::cout << "eleopout"<< eleopout << std::endl;
85 // std::cout << "detaeleout"<< detaeleout << std::endl;
86 // std::cout << "kfchi2"<< kfchi2 << std::endl;
87 // std::cout << "kfhits"<< mykfhits << std::endl;
88 // std::cout << "mishits"<<mymishits << std::endl;
89 // std::cout << "dist"<< absdist << std::endl;
90 // std::cout << "dcot"<< absdcot << std::endl;
91 //
92 // std::cout << "eta"<<eta << std::endl;
93 // std::cout << "pt"<<pt << std::endl;
94 // std::cout << "ecalseed"<<ecalseed << std::endl;
95 //
96 // std::cout << " MVA " << result << std::endl;
97  return result;
98 }
float eSuperClusterOverP() const
Definition: GsfElectron.h:229
float fbrem() const
Definition: GsfElectron.h:639
bool isAvailable() const
Definition: Ref.h:276
float convDist() const
Definition: GsfElectron.h:498
virtual double eta() const
momentum pseudorapidity
TrackRef closestCtfTrackRef() const
Definition: GsfElectron.h:185
float convDcot() const
Definition: GsfElectron.h:499
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:250
float deltaEtaSuperClusterTrackAtVtx() const
Definition: GsfElectron.h:233
float sigmaIetaIeta() const
Definition: GsfElectron.h:382
float deltaPhiSuperClusterTrackAtVtx() const
Definition: GsfElectron.h:236
tuple result
Definition: query.py:137
float hcalOverEcal() const
Definition: GsfElectron.h:390
float eEleClusterOverPout() const
Definition: GsfElectron.h:232
float deltaEtaEleClusterTrackAtCalo() const
Definition: GsfElectron.h:235
virtual double pt() const
transverse momentum
float e1x5() const
Definition: GsfElectron.h:384
float e5x5() const
Definition: GsfElectron.h:386
virtual GsfTrackRef gsfTrack() const
reference to a GsfTrack
Definition: GsfElectron.h:169
bool ecalDrivenSeed() const
Definition: GsfElectron.h:172

Member Data Documentation

Float_t ElectronMVAEstimator::absdcot
private

Definition at line 42 of file ElectronMVAEstimator.h.

Referenced by bindVariables(), and init().

Float_t ElectronMVAEstimator::absdist
private

Definition at line 41 of file ElectronMVAEstimator.h.

Referenced by bindVariables(), and init().

Float_t ElectronMVAEstimator::dcot
private

Definition at line 33 of file ElectronMVAEstimator.h.

Referenced by bindVariables(), and mva().

Float_t ElectronMVAEstimator::detaeleout
private

Definition at line 30 of file ElectronMVAEstimator.h.

Referenced by bindVariables(), init(), and mva().

Float_t ElectronMVAEstimator::detain
private

Definition at line 23 of file ElectronMVAEstimator.h.

Referenced by bindVariables(), init(), and mva().

Float_t ElectronMVAEstimator::dist
private

Definition at line 32 of file ElectronMVAEstimator.h.

Referenced by bindVariables(), and mva().

Float_t ElectronMVAEstimator::dphiin
private

Definition at line 24 of file ElectronMVAEstimator.h.

Referenced by bindVariables(), init(), and mva().

Float_t ElectronMVAEstimator::e1x5e5x5
private

Definition at line 28 of file ElectronMVAEstimator.h.

Referenced by bindVariables(), init(), and mva().

Int_t ElectronMVAEstimator::ecalseed
private

Definition at line 38 of file ElectronMVAEstimator.h.

Referenced by init(), and mva().

Float_t ElectronMVAEstimator::eleopout
private

Definition at line 29 of file ElectronMVAEstimator.h.

Referenced by bindVariables(), init(), and mva().

Float_t ElectronMVAEstimator::eop
private

Definition at line 27 of file ElectronMVAEstimator.h.

Referenced by bindVariables(), init(), and mva().

Float_t ElectronMVAEstimator::eta
private

Definition at line 34 of file ElectronMVAEstimator.h.

Referenced by init(), and mva().

Float_t ElectronMVAEstimator::fbrem
private

Definition at line 22 of file ElectronMVAEstimator.h.

Referenced by bindVariables(), init(), and mva().

Float_t ElectronMVAEstimator::hoe
private

Definition at line 26 of file ElectronMVAEstimator.h.

Referenced by init(), and mva().

Float_t ElectronMVAEstimator::kfchi2
private

Definition at line 31 of file ElectronMVAEstimator.h.

Referenced by bindVariables(), init(), and mva().

Int_t ElectronMVAEstimator::kfhits
private

Definition at line 36 of file ElectronMVAEstimator.h.

Referenced by bindVariables(), and mva().

Int_t ElectronMVAEstimator::mishits
private

Definition at line 37 of file ElectronMVAEstimator.h.

Referenced by bindVariables(), and mva().

Float_t ElectronMVAEstimator::mykfhits
private

Definition at line 43 of file ElectronMVAEstimator.h.

Referenced by bindVariables(), and init().

Float_t ElectronMVAEstimator::mymishits
private

Definition at line 44 of file ElectronMVAEstimator.h.

Referenced by bindVariables(), and init().

Float_t ElectronMVAEstimator::myNvtx
private

Definition at line 45 of file ElectronMVAEstimator.h.

Referenced by bindVariables(), and init().

Int_t ElectronMVAEstimator::Nvtx
private

Definition at line 39 of file ElectronMVAEstimator.h.

Referenced by bindVariables(), and mva().

Float_t ElectronMVAEstimator::pt
private

Definition at line 35 of file ElectronMVAEstimator.h.

Referenced by init(), and mva().

Float_t ElectronMVAEstimator::sieie
private

Definition at line 25 of file ElectronMVAEstimator.h.

Referenced by init(), and mva().

TMVA::Reader* ElectronMVAEstimator::tmvaReader_
private

Definition at line 20 of file ElectronMVAEstimator.h.

Referenced by init(), and mva().