CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
SoftElectronMVAEstimator.cc
Go to the documentation of this file.
8 
10  //Check number of weight files given
11  if (ExpectedNBins != cfg_.vweightsfiles.size()) {
12  edm::LogError("Soft Electron MVA Error")
13  << "Expected Number of bins = " << ExpectedNBins
14  << " does not equal to weightsfiles.size() = " << cfg_.vweightsfiles.size() << std::endl;
15  }
16 
17  for (auto& weightsfile : cfg_.vweightsfiles) {
18  // Taken from Daniele (his mail from the 30/11)
19  // training of the 7/12 with Nvtx added
20  gbr_.push_back(createGBRForest(weightsfile));
21  }
22 }
23 
25 
26 double SoftElectronMVAEstimator::mva(const reco::GsfElectron& myElectron, const reco::VertexCollection& pvc) const {
27  float vars[25];
28 
29  vars[0] = myElectron.fbrem(); // fbrem
30  vars[1] = myElectron.eSuperClusterOverP(); //EtotOvePin
31  vars[2] = myElectron.eEleClusterOverPout(); //eleEoPout
32 
33  float etot = myElectron.eSuperClusterOverP() * myElectron.trackMomentumAtVtx().R();
34  float eEcal = myElectron.eEleClusterOverPout() * myElectron.trackMomentumAtEleClus().R();
35  float dP = myElectron.trackMomentumAtVtx().R() - myElectron.trackMomentumAtEleClus().R();
36  vars[3] = (etot - eEcal) / dP; //EBremOverDeltaP
37  vars[4] = std::log(myElectron.sigmaEtaEta()); //logSigmaEtaEta
38  vars[5] = myElectron.deltaEtaEleClusterTrackAtCalo(); //DeltaEtaTrackEcalSeed
39  vars[6] = myElectron.hcalOverEcalBc(); //HoE
40 
41  bool validKF = false;
42  reco::TrackRef myTrackRef = myElectron.closestCtfTrackRef();
43  validKF = (myTrackRef.isAvailable() && myTrackRef.isNonnull());
44  vars[7] = myElectron.gsfTrack()->normalizedChi2(); //gsfchi2
45  vars[8] = (validKF) ? myTrackRef->normalizedChi2() : 0; //kfchi2
46  vars[9] = (validKF) ? myTrackRef->hitPattern().trackerLayersWithMeasurement() : -1.; //kfhits
47 
48  vars[10] = myElectron.gsfTrack().get()->ptModeError() / myElectron.gsfTrack().get()->ptMode(); //SigmaPtOverPt
49  vars[11] = myElectron.deltaEtaSuperClusterTrackAtVtx(); //deta
50  vars[12] = myElectron.deltaPhiSuperClusterTrackAtVtx(); //dphi
51  vars[13] = myElectron.deltaEtaSeedClusterTrackAtCalo(); //detacalo
52  vars[14] = myElectron.sigmaIetaIeta(); //see
53  vars[15] = myElectron.sigmaIphiIphi(); //spp
54  vars[16] = myElectron.r9(); //R9
55  vars[17] = myElectron.superCluster()->etaWidth(); //etawidth
56  vars[18] = myElectron.superCluster()->phiWidth(); //phiwidth
57  vars[19] = (myElectron.e5x5()) != 0. ? 1. - (myElectron.e1x5() / myElectron.e5x5()) : -1.; //OneMinusE1x5E5x5
58  vars[20] = (1.0 / myElectron.ecalEnergy()) - (1.0 / myElectron.p()); // IoEmIoP
59  vars[21] = myElectron.superCluster()->preshowerEnergy() / myElectron.superCluster()->rawEnergy(); //PreShowerOverRaw
60  vars[22] = pvc.size(); // nPV
61  vars[23] = myElectron.pt(); //pt
62  vars[24] = myElectron.eta(); //eta
63 
64  /*
65  std::cout<<"fbrem "<<fbrem<<std::endl;
66  std::cout<<"EtotOvePin "<<EtotOvePin<<std::endl;
67  std::cout<<"eleEoPout "<<eleEoPout<<std::endl;
68  std::cout<<"EBremOverDeltaP "<<EBremOverDeltaP<<std::endl;
69  std::cout<<"logSigmaEtaEta "<<logSigmaEtaEta<<std::endl;
70  std::cout<<"DeltaEtaTrackEcalSeed "<<DeltaEtaTrackEcalSeed<<std::endl;
71  std::cout<<"HoE "<<HoE<<std::endl;
72  std::cout<<"kfchi2 "<<kfchi2<<std::endl;
73  std::cout<<"kfhits "<<kfhits<<std::endl;
74  std::cout<<"gsfchi2 "<<gsfchi2<<std::endl;
75  std::cout<<"SigmaPtOverPt "<<SigmaPtOverPt<<std::endl;
76  std::cout<<"deta "<<deta<<std::endl;
77  std::cout<<"dphi "<<dphi<<std::endl;
78  std::cout<<"detacalo "<<detacalo<<std::endl;
79  std::cout<<"see "<<see<<std::endl;
80  std::cout<< "spp " << spp<< std::endl;
81  std::cout<< "R9 " << R9<< std::endl;
82  std::cout<< "IoEmIoP " << IoEmIoP<< std::endl;
83  std::cout<<"etawidth "<<etawidth<<std::endl;
84  std::cout<<"phiwidth "<<phiwidth<<std::endl;
85  std::cout<<"OneMinusE1x5E5x5 "<<OneMinusE1x5E5x5<<std::endl;
86  std::cout<<"PreShowerOverRaw "<<PreShowerOverRaw<<std::endl;
87 */
88  bindVariables(vars);
89 
90  double result = gbr_[0]->GetClassifier(vars);
91 
92  return result;
93 }
94 
96  if (vars[0] < -1.) //fbrem
97  vars[0] = -1.;
98 
99  vars[11] = std::abs(vars[11]); // deta
100  if (vars[11] > 0.06)
101  vars[11] = 0.06;
102 
103  vars[12] = std::abs(vars[12]);
104  if (vars[12] > 0.6)
105  vars[12] = 0.6;
106 
107  //if(EoP > 20.)
108  // EoP = 20.;
109 
110  if (vars[2] > 20.) //eleEoPout
111  vars[2] = 20.;
112 
113  vars[13] = std::abs(vars[13]); //detacalo
114  if (vars[13] > 0.2)
115  vars[13] = 0.2;
116 
117  if (vars[19] < -1.) //OneMinusE1x5E5x5
118  vars[19] = -1;
119 
120  if (vars[19] > 2.) //OneMinusE1x5E5x5
121  vars[19] = 2.;
122 
123  if (vars[7] > 200.) //gsfchi2
124  vars[7] = 200;
125 
126  if (vars[8] > 10.) //kfchi2
127  vars[8] = 10.;
128 }
float sigmaIphiIphi() const
Definition: GsfElectron.h:420
bool isAvailable() const
Definition: Ref.h:537
static std::vector< std::string > checklist log
virtual TrackRef closestCtfTrackRef() const
Definition: GsfElectron.h:180
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:238
tuple cfg
Definition: looper.py:296
double pt() const final
transverse momentum
float eSuperClusterOverP() const
Definition: GsfElectron.h:221
SoftElectronMVAEstimator(const Configuration &)
math::XYZVectorF trackMomentumAtVtx() const
Definition: GsfElectron.h:268
std::vector< Vertex > VertexCollection
collection of Vertex objects
Definition: VertexFwd.h:9
float fbrem() const
Definition: GsfElectron.h:809
Log< level::Error, false > LogError
tuple result
Definition: mps_fire.py:311
float hcalOverEcalBc(const ShowerShape &ss, int depth) const
Definition: GsfElectron.h:442
GsfTrackRef gsfTrack() const override
reference to a GsfTrack
Definition: GsfElectron.h:156
float deltaEtaSuperClusterTrackAtVtx() const
Definition: GsfElectron.h:225
float sigmaIetaIeta() const
Definition: GsfElectron.h:419
double p() const final
magnitude of momentum vector
float deltaPhiSuperClusterTrackAtVtx() const
Definition: GsfElectron.h:228
static constexpr unsigned int ExpectedNBins
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
float eEleClusterOverPout() const
Definition: GsfElectron.h:224
T const * get() const
Returns C++ pointer to the item.
Definition: Ref.h:232
double mva(const reco::GsfElectron &myElectron, const reco::VertexCollection &) const
std::vector< std::unique_ptr< const GBRForest > > gbr_
float deltaEtaEleClusterTrackAtCalo() const
Definition: GsfElectron.h:227
float e1x5() const
Definition: GsfElectron.h:421
void bindVariables(float vars[25]) const
float ecalEnergy() const
Definition: GsfElectron.h:896
math::XYZVectorF trackMomentumAtEleClus() const
Definition: GsfElectron.h:271
float e5x5() const
Definition: GsfElectron.h:423
float r9() const
Definition: GsfElectron.h:424
float deltaEtaSeedClusterTrackAtCalo() const
Definition: GsfElectron.h:226
vars
Definition: DeepTauId.cc:164
SuperClusterRef superCluster() const override
reference to a SuperCluster
Definition: GsfElectron.h:155
std::unique_ptr< const GBRForest > createGBRForest(const std::string &weightsFile)
float sigmaEtaEta() const
Definition: GsfElectron.h:418
double eta() const final
momentum pseudorapidity