CMS 3D CMS Logo

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 */
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 }
double pt() const final
transverse momentum
SoftElectronMVAEstimator(const Configuration &)
math::XYZVectorF trackMomentumAtEleClus() const
Definition: GsfElectron.h:271
float sigmaIetaIeta() const
Definition: GsfElectron.h:419
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:238
std::vector< Vertex > VertexCollection
collection of Vertex objects
Definition: VertexFwd.h:9
float hcalOverEcalBc(const ShowerShape &ss, int depth) const
Definition: GsfElectron.h:442
Log< level::Error, false > LogError
float deltaEtaEleClusterTrackAtCalo() const
Definition: GsfElectron.h:227
float e1x5() const
Definition: GsfElectron.h:421
float eSuperClusterOverP() const
Definition: GsfElectron.h:221
float eEleClusterOverPout() const
Definition: GsfElectron.h:224
GsfTrackRef gsfTrack() const override
reference to a GsfTrack
Definition: GsfElectron.h:156
double p() const final
magnitude of momentum vector
float e5x5() const
Definition: GsfElectron.h:423
bool isAvailable() const
Definition: Ref.h:541
static constexpr unsigned int ExpectedNBins
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
math::XYZVectorF trackMomentumAtVtx() const
Definition: GsfElectron.h:268
std::vector< std::unique_ptr< const GBRForest > > gbr_
float deltaPhiSuperClusterTrackAtVtx() const
Definition: GsfElectron.h:228
float sigmaEtaEta() const
Definition: GsfElectron.h:418
float deltaEtaSuperClusterTrackAtVtx() const
Definition: GsfElectron.h:225
float ecalEnergy() const
Definition: GsfElectron.h:896
virtual TrackRef closestCtfTrackRef() const
Definition: GsfElectron.h:180
float fbrem() const
Definition: GsfElectron.h:809
float r9() const
Definition: GsfElectron.h:424
float sigmaIphiIphi() const
Definition: GsfElectron.h:420
double mva(const reco::GsfElectron &myElectron, const reco::VertexCollection &) const
T const * get() const
Returns C++ pointer to the item.
Definition: Ref.h:232
float deltaEtaSeedClusterTrackAtCalo() const
Definition: GsfElectron.h:226
void bindVariables(float vars[25]) const
vars
Definition: DeepTauId.cc:117
SuperClusterRef superCluster() const override
reference to a SuperCluster
Definition: GsfElectron.h:155
std::unique_ptr< const GBRForest > createGBRForest(const std::string &weightsFile)
double eta() const final
momentum pseudorapidity