CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ElectronMVAEstimator.cc
Go to the documentation of this file.
7 
9 
11  init(fileName);
12 }
13 
14 
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 }
42 
43 
44 
45 double ElectronMVAEstimator::mva(const reco::GsfElectron& myElectron, int nvertices ) {
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 }
99 
100 
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 }
float eSuperClusterOverP() const
Definition: GsfElectron.h:230
float fbrem() const
Definition: GsfElectron.h:653
bool isAvailable() const
Definition: Ref.h:276
float convDist() const
Definition: GsfElectron.h:505
TrackRef closestCtfTrackRef() const
Definition: GsfElectron.h:186
float convDcot() const
Definition: GsfElectron.h:506
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:250
float deltaEtaSuperClusterTrackAtVtx() const
Definition: GsfElectron.h:234
float sigmaIetaIeta() const
Definition: GsfElectron.h:386
float deltaPhiSuperClusterTrackAtVtx() const
Definition: GsfElectron.h:237
tuple result
Definition: query.py:137
float hcalOverEcal() const
Definition: GsfElectron.h:394
float eEleClusterOverPout() const
Definition: GsfElectron.h:233
virtual float eta() const GCC11_FINAL
momentum pseudorapidity
float deltaEtaEleClusterTrackAtCalo() const
Definition: GsfElectron.h:236
float e1x5() const
Definition: GsfElectron.h:388
void init(std::string fileName)
float e5x5() const
Definition: GsfElectron.h:390
double mva(const reco::GsfElectron &myElectron, int nvertices=0)
virtual float pt() const GCC11_FINAL
transverse momentum
virtual GsfTrackRef gsfTrack() const
reference to a GsfTrack
Definition: GsfElectron.h:170
bool ecalDrivenSeed() const
Definition: GsfElectron.h:173