CMS 3D CMS Logo

ElectronMVAEstimator.cc
Go to the documentation of this file.
7 
9  cfg_{}
10 {}
11 
13  cfg_{}
14 {
15  // Taken from Daniele (his mail from the 30/11)
16  // tmvaReader.BookMVA("BDTSimpleCat","../Training/weights_Root527b_3Depth_DanVarConvRej_2PtBins_10Pt_800TPrune5_Min100Events_NoBjets_half/TMVA_BDTSimpleCat.weights.xm");
17  // training of the 7/12 with Nvtx added
18  gbr_.push_back( createGBRForest(fileName) );
19 }
20 
22 {
23  for(const auto& weightsfile : cfg_.vweightsfiles) {
24  gbr_.push_back( createGBRForest(weightsfile) );
25  }
26 }
27 
28 double ElectronMVAEstimator::mva(const reco::GsfElectron& myElectron, int nvertices ) const {
29  float vars[18];
30 
31  vars[0] = myElectron.fbrem();
32  vars[1] = std::abs(myElectron.deltaEtaSuperClusterTrackAtVtx());
33  vars[2] = std::abs(myElectron.deltaPhiSuperClusterTrackAtVtx());
34  vars[3] = myElectron.sigmaIetaIeta();
35  vars[4] = myElectron.hcalOverEcal();
36  vars[5] = myElectron.eSuperClusterOverP();
37  vars[6] = (myElectron.e5x5()) !=0. ? 1.-(myElectron.e1x5()/myElectron.e5x5()) : -1. ;
38  vars[7] = myElectron.eEleClusterOverPout();
39  vars[8] = std::abs(myElectron.deltaEtaEleClusterTrackAtCalo());
40 
41  bool validKF= false;
42 
43  reco::TrackRef myTrackRef = myElectron.closestCtfTrackRef();
44  validKF = (myTrackRef.isNonnull() && myTrackRef.isAvailable());
45 
46  vars[9] = (validKF) ? myTrackRef->normalizedChi2() : 0 ;
47  vars[10] = (validKF) ? myTrackRef->hitPattern().trackerLayersWithMeasurement() : -1.;
48  vars[11] = myElectron.gsfTrack()->hitPattern().numberOfLostHits(reco::HitPattern::MISSING_INNER_HITS);
49  vars[12] = std::abs(myElectron.convDist());
50  vars[13] = std::abs(myElectron.convDcot());
51  vars[14] = nvertices;
52  vars[15] = myElectron.eta();
53  vars[16] = myElectron.pt();
54  vars[17] = myElectron.ecalDrivenSeed();
55 
56  bindVariables(vars);
57 
58  //0 pt < 10 && abs(eta)<=1.485
59  //1 pt >= 10 && abs(eta)<=1.485
60  //2 pt < 10 && abs(eta)> 1.485
61  //3 pt >= 10 && abs(eta)> 1.485
62 
63  const unsigned index = (unsigned)(myElectron.pt() >= 10) + 2*(unsigned)(std::abs(myElectron.eta()) > 1.485);
64 
65  double result = gbr_[index]->GetAdaBoostClassifier(vars);
66 //
67 // std::cout << "fbrem" << vars[0] << std::endl;
68 // std::cout << "detain"<< vars[1] << std::endl;
69 // std::cout << "dphiin"<< vars[2] << std::endl;
70 // std::cout << "sieie"<< vars[3] << std::endl;
71 // std::cout << "hoe"<< vars[4] << std::endl;
72 // std::cout << "eop"<< vars[5] << std::endl;
73 // std::cout << "e1x5e5x5"<< vars[6] << std::endl;
74 // std::cout << "eleopout"<< vars[7] << std::endl;
75 // std::cout << "detaeleout"<< vars[8] << std::endl;
76 // std::cout << "kfchi2"<< vars[9] << std::endl;
77 // std::cout << "kfhits"<< vars[10] << std::endl;
78 // std::cout << "mishits"<<vars[11] << std::endl;
79 // std::cout << "dist"<< vars[12] << std::endl;
80 // std::cout << "dcot"<< vars[13] << std::endl;
81 // std::cout << "nvtx"<< vars[14] << std::endl;
82 // std::cout << "eta"<< vars[15] << std::endl;
83 // std::cout << "pt"<< vars[16] << std::endl;
84 // std::cout << "ecalseed"<< vars[17] << std::endl;
85 //
86 // std::cout << " MVA " << result << std::endl;
87  return result;
88 }
89 
90 
92  if(vars[0] < -1.)
93  vars[1] = -1.;
94 
95  if(vars[1] > 0.06)
96  vars[1] = 0.06;
97 
98  if(vars[2] > 0.6)
99  vars[2] = 0.6;
100 
101  if(vars[5] > 20.)
102  vars[5] = 20.;
103 
104  if(vars[7] > 20.)
105  vars[7] = 20;
106 
107  if(vars[8] > 0.2)
108  vars[8] = 0.2;
109 
110  if(vars[9] < 0.)
111  vars[9] = 0.;
112 
113  if(vars[9] > 15.)
114  vars[9] = 15.;
115 
116  if(vars[6] < -1.)
117  vars[6] = -1;
118 
119  if(vars[6] > 2.)
120  vars[6] = 2.;
121 
122  if(vars[12] > 15.)
123  vars[12] = 15.;
124 
125  if(vars[13] > 3.)
126  vars[13] = 3.;
127 }
bool isAvailable() const
Definition: Ref.h:575
GsfTrackRef gsfTrack() const override
reference to a GsfTrack
Definition: GsfElectron.h:186
double mva(const reco::GsfElectron &myElectron, int nvertices=0) const
virtual TrackRef closestCtfTrackRef() const
Definition: GsfElectron.h:205
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:251
double eta() const final
momentum pseudorapidity
float eSuperClusterOverP() const
Definition: GsfElectron.h:249
std::vector< std::unique_ptr< const GBRForest > > gbr_
double pt() const final
transverse momentum
void bindVariables(float vars[18]) const
float fbrem() const
Definition: GsfElectron.h:772
float convDist() const
Definition: GsfElectron.h:618
float convDcot() const
Definition: GsfElectron.h:619
float deltaEtaSuperClusterTrackAtVtx() const
Definition: GsfElectron.h:253
float sigmaIetaIeta() const
Definition: GsfElectron.h:440
float deltaPhiSuperClusterTrackAtVtx() const
Definition: GsfElectron.h:256
const Configuration cfg_
float hcalOverEcal() const
Definition: GsfElectron.h:448
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
float eEleClusterOverPout() const
Definition: GsfElectron.h:252
float deltaEtaEleClusterTrackAtCalo() const
Definition: GsfElectron.h:255
float e1x5() const
Definition: GsfElectron.h:442
std::vector< std::string > vweightsfiles
float e5x5() const
Definition: GsfElectron.h:444
vars
Definition: DeepTauId.cc:77
std::unique_ptr< const GBRForest > createGBRForest(const std::string &weightsFile)
bool ecalDrivenSeed() const
Definition: GsfElectron.h:188