CMS 3D CMS Logo

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