CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 (std::string fileName)
 
 ElectronMVAEstimator (const Configuration &)
 
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
 
const Configuration cfg_
 
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  :
9  cfg_{}
10 {}
const Configuration cfg_
ElectronMVAEstimator::ElectronMVAEstimator ( std::string  fileName)

Definition at line 12 of file ElectronMVAEstimator.cc.

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

Definition at line 42 of file ElectronMVAEstimator.cc.

References absdcot, absdist, cfg_, detaeleout, detain, dphiin, e1x5e5x5, ecalseed, eleopout, eop, eta, fbrem, contentValuesFiles::fullPath, hoe, compare_using_db::ifile, kfchi2, mykfhits, mymishits, myNvtx, pt, sieie, AlCaHLTBitMon_QueryRunRegistry::string, tmvaReader_, and ElectronMVAEstimator::Configuration::vweightsfiles.

42  :cfg_(cfg){
43  std::vector<std::string> weightsfiles;
44  std::string path_mvaWeightFileEleID;
45  for(unsigned ifile=0 ; ifile < cfg_.vweightsfiles.size() ; ++ifile) {
46  path_mvaWeightFileEleID = edm::FileInPath ( cfg_.vweightsfiles[ifile].c_str() ).fullPath();
47  weightsfiles.push_back(path_mvaWeightFileEleID);
48  }
49  tmvaReader_ = new TMVA::Reader("!Color:Silent");
50  tmvaReader_->AddVariable("fbrem",&fbrem);
51  tmvaReader_->AddVariable("detain", &detain);
52  tmvaReader_->AddVariable("dphiin", &dphiin);
53  tmvaReader_->AddVariable("sieie", &sieie);
54  tmvaReader_->AddVariable("hoe", &hoe);
55  tmvaReader_->AddVariable("eop", &eop);
56  tmvaReader_->AddVariable("e1x5e5x5", &e1x5e5x5);
57  tmvaReader_->AddVariable("eleopout", &eleopout);
58  tmvaReader_->AddVariable("detaeleout", &detaeleout);
59  tmvaReader_->AddVariable("kfchi2", &kfchi2);
60  tmvaReader_->AddVariable("kfhits", &mykfhits);
61  tmvaReader_->AddVariable("mishits",&mymishits);
62  tmvaReader_->AddVariable("dist", &absdist);
63  tmvaReader_->AddVariable("dcot", &absdcot);
64  tmvaReader_->AddVariable("nvtx", &myNvtx);
65 
66  tmvaReader_->AddSpectator("eta",&eta);
67  tmvaReader_->AddSpectator("pt",&pt);
68  tmvaReader_->AddSpectator("ecalseed",&ecalseed);
69 
70  // Taken from Daniele (his mail from the 30/11)
71  // tmvaReader_->BookMVA("BDTSimpleCat","../Training/weights_Root527b_3Depth_DanVarConvRej_2PtBins_10Pt_800TPrune5_Min100Events_NoBjets_half/TMVA_BDTSimpleCat.weights.xm");
72  // training of the 7/12 with Nvtx added
73 
74  tmvaReader_->BookMVA("BDTSimpleCat",weightsfiles[0]);
75 }
tuple cfg
Definition: looper.py:259
const Configuration cfg_
std::vector< std::string > vweightsfiles
ElectronMVAEstimator::~ElectronMVAEstimator ( )
inline

Definition at line 16 of file ElectronMVAEstimator.h.

16 {;}

Member Function Documentation

void ElectronMVAEstimator::bindVariables ( )
private

Definition at line 133 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().

133  {
134  if(fbrem < -1.)
135  fbrem = -1.;
136 
137  detain = fabs(detain);
138  if(detain > 0.06)
139  detain = 0.06;
140 
141 
142  dphiin = fabs(dphiin);
143  if(dphiin > 0.6)
144  dphiin = 0.6;
145 
146 
147  if(eop > 20.)
148  eop = 20.;
149 
150 
151  if(eleopout > 20.)
152  eleopout = 20;
153 
154  detaeleout = fabs(detaeleout);
155  if(detaeleout > 0.2)
156  detaeleout = 0.2;
157 
158  mykfhits = float(kfhits);
159  mymishits = float(mishits);
160 
161  if(kfchi2 < 0.)
162  kfchi2 = 0.;
163 
164  if(kfchi2 > 15.)
165  kfchi2 = 15.;
166 
167 
168  if(e1x5e5x5 < -1.)
169  e1x5e5x5 = -1;
170 
171  if(e1x5e5x5 > 2.)
172  e1x5e5x5 = 2.;
173 
174 
175  if(dist > 15.)
176  dist = 15.;
177  if(dist < -15.)
178  dist = -15.;
179 
180  if(dcot > 3.)
181  dcot = 3.;
182  if(dcot < -3.)
183  dcot = -3.;
184 
185  absdist = fabs(dist);
186  absdcot = fabs(dcot);
187  myNvtx = float(Nvtx);
188 
189 }
void ElectronMVAEstimator::init ( std::string  fileName)
private
double ElectronMVAEstimator::mva ( const reco::GsfElectron myElectron,
int  nvertices = 0 
)

Definition at line 77 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, reco::HitPattern::MISSING_INNER_HITS, Nvtx, pt, reco::LeafCandidate::pt(), query::result, sieie, reco::GsfElectron::sigmaIetaIeta(), and tmvaReader_.

Referenced by GsfElectronAlgo::setMVAOutputs().

77  {
78  fbrem = myElectron.fbrem();
81  sieie = myElectron.sigmaIetaIeta();
82  hoe = myElectron.hcalOverEcal();
83  eop = myElectron.eSuperClusterOverP();
84  e1x5e5x5 = (myElectron.e5x5()) !=0. ? 1.-(myElectron.e1x5()/myElectron.e5x5()) : -1. ;
85  eleopout = myElectron.eEleClusterOverPout();
87 
88  bool validKF= false;
89 
90  reco::TrackRef myTrackRef = myElectron.closestCtfTrackRef();
91  validKF = (myTrackRef.isAvailable());
92  validKF = (myTrackRef.isNonnull());
93 
94  kfchi2 = (validKF) ? myTrackRef->normalizedChi2() : 0 ;
95  kfhits = (validKF) ? myTrackRef->hitPattern().trackerLayersWithMeasurement() : -1.;
96  dist = myElectron.convDist();
97  dcot = myElectron.convDcot();
98  eta = myElectron.eta();
99  pt = myElectron.pt();
100 
101  mishits = myElectron.gsfTrack()->hitPattern().numberOfLostHits(reco::HitPattern::MISSING_INNER_HITS);
102  ecalseed = myElectron.ecalDrivenSeed();
103 
104  Nvtx = nvertices;
105 
106  bindVariables();
107  double result = tmvaReader_->EvaluateMVA("BDTSimpleCat");
108 //
109 // std::cout << "fbrem" <<fbrem << std::endl;
110 // std::cout << "detain"<< detain << std::endl;
111 // std::cout << "dphiin"<< dphiin << std::endl;
112 // std::cout << "sieie"<< sieie << std::endl;
113 // std::cout << "hoe"<< hoe << std::endl;
114 // std::cout << "eop"<< eop << std::endl;
115 // std::cout << "e1x5e5x5"<< e1x5e5x5 << std::endl;
116 // std::cout << "eleopout"<< eleopout << std::endl;
117 // std::cout << "detaeleout"<< detaeleout << std::endl;
118 // std::cout << "kfchi2"<< kfchi2 << std::endl;
119 // std::cout << "kfhits"<< mykfhits << std::endl;
120 // std::cout << "mishits"<<mymishits << std::endl;
121 // std::cout << "dist"<< absdist << std::endl;
122 // std::cout << "dcot"<< absdcot << std::endl;
123 //
124 // std::cout << "eta"<<eta << std::endl;
125 // std::cout << "pt"<<pt << std::endl;
126 // std::cout << "ecalseed"<<ecalseed << std::endl;
127 //
128 // std::cout << " MVA " << result << std::endl;
129  return result;
130 }
bool isAvailable() const
Definition: Ref.h:614
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:250
float eSuperClusterOverP() const
Definition: GsfElectron.h:243
float fbrem() const
Definition: GsfElectron.h:684
float convDist() const
Definition: GsfElectron.h:539
virtual double eta() const
momentum pseudorapidity
virtual double pt() const
transverse momentum
TrackRef closestCtfTrackRef() const
Definition: GsfElectron.h:199
float convDcot() const
Definition: GsfElectron.h:540
float deltaEtaSuperClusterTrackAtVtx() const
Definition: GsfElectron.h:247
float sigmaIetaIeta() const
Definition: GsfElectron.h:402
float deltaPhiSuperClusterTrackAtVtx() const
Definition: GsfElectron.h:250
tuple result
Definition: query.py:137
float hcalOverEcal() const
Definition: GsfElectron.h:410
float eEleClusterOverPout() const
Definition: GsfElectron.h:246
float deltaEtaEleClusterTrackAtCalo() const
Definition: GsfElectron.h:249
float e1x5() const
Definition: GsfElectron.h:404
float e5x5() const
Definition: GsfElectron.h:406
virtual GsfTrackRef gsfTrack() const
reference to a GsfTrack
Definition: GsfElectron.h:183
bool ecalDrivenSeed() const
Definition: GsfElectron.h:186

Member Data Documentation

Float_t ElectronMVAEstimator::absdcot
private

Definition at line 47 of file ElectronMVAEstimator.h.

Referenced by bindVariables(), and ElectronMVAEstimator().

Float_t ElectronMVAEstimator::absdist
private

Definition at line 46 of file ElectronMVAEstimator.h.

Referenced by bindVariables(), and ElectronMVAEstimator().

const Configuration ElectronMVAEstimator::cfg_
private

Definition at line 20 of file ElectronMVAEstimator.h.

Referenced by ElectronMVAEstimator().

Float_t ElectronMVAEstimator::dcot
private

Definition at line 38 of file ElectronMVAEstimator.h.

Referenced by bindVariables(), and mva().

Float_t ElectronMVAEstimator::detaeleout
private

Definition at line 35 of file ElectronMVAEstimator.h.

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

Float_t ElectronMVAEstimator::detain
private

Definition at line 28 of file ElectronMVAEstimator.h.

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

Float_t ElectronMVAEstimator::dist
private

Definition at line 37 of file ElectronMVAEstimator.h.

Referenced by bindVariables(), and mva().

Float_t ElectronMVAEstimator::dphiin
private

Definition at line 29 of file ElectronMVAEstimator.h.

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

Float_t ElectronMVAEstimator::e1x5e5x5
private

Definition at line 33 of file ElectronMVAEstimator.h.

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

Int_t ElectronMVAEstimator::ecalseed
private

Definition at line 43 of file ElectronMVAEstimator.h.

Referenced by ElectronMVAEstimator(), and mva().

Float_t ElectronMVAEstimator::eleopout
private

Definition at line 34 of file ElectronMVAEstimator.h.

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

Float_t ElectronMVAEstimator::eop
private

Definition at line 32 of file ElectronMVAEstimator.h.

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

Float_t ElectronMVAEstimator::eta
private
Float_t ElectronMVAEstimator::fbrem
private

Definition at line 27 of file ElectronMVAEstimator.h.

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

Float_t ElectronMVAEstimator::hoe
private

Definition at line 31 of file ElectronMVAEstimator.h.

Referenced by ElectronMVAEstimator(), and mva().

Float_t ElectronMVAEstimator::kfchi2
private

Definition at line 36 of file ElectronMVAEstimator.h.

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

Int_t ElectronMVAEstimator::kfhits
private

Definition at line 41 of file ElectronMVAEstimator.h.

Referenced by bindVariables(), and mva().

Int_t ElectronMVAEstimator::mishits
private

Definition at line 42 of file ElectronMVAEstimator.h.

Referenced by bindVariables(), and mva().

Float_t ElectronMVAEstimator::mykfhits
private

Definition at line 48 of file ElectronMVAEstimator.h.

Referenced by bindVariables(), and ElectronMVAEstimator().

Float_t ElectronMVAEstimator::mymishits
private

Definition at line 49 of file ElectronMVAEstimator.h.

Referenced by bindVariables(), and ElectronMVAEstimator().

Float_t ElectronMVAEstimator::myNvtx
private

Definition at line 50 of file ElectronMVAEstimator.h.

Referenced by bindVariables(), and ElectronMVAEstimator().

Int_t ElectronMVAEstimator::Nvtx
private

Definition at line 44 of file ElectronMVAEstimator.h.

Referenced by bindVariables(), and mva().

Float_t ElectronMVAEstimator::pt
private
Float_t ElectronMVAEstimator::sieie
private

Definition at line 30 of file ElectronMVAEstimator.h.

Referenced by ElectronMVAEstimator(), and mva().

TMVA::Reader* ElectronMVAEstimator::tmvaReader_
private

Definition at line 25 of file ElectronMVAEstimator.h.

Referenced by ElectronMVAEstimator(), and mva().