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 }
reco::GsfElectron::deltaEtaSeedClusterTrackAtCalo
float deltaEtaSeedClusterTrackAtCalo() const
Definition: GsfElectron.h:234
SoftElectronMVAEstimator::SoftElectronMVAEstimator
SoftElectronMVAEstimator(const Configuration &)
Definition: SoftElectronMVAEstimator.cc:9
reco::GsfElectron::gsfTrack
GsfTrackRef gsfTrack() const override
reference to a GsfTrack
Definition: GsfElectron.h:164
MessageLogger.h
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:257
reco::LeafCandidate::pt
double pt() const final
transverse momentum
Definition: LeafCandidate.h:146
reco::GsfElectron::fbrem
float fbrem() const
Definition: GsfElectron.h:796
edm::Ref< TrackCollection >
SoftElectronMVAEstimator::~SoftElectronMVAEstimator
~SoftElectronMVAEstimator()
Definition: SoftElectronMVAEstimator.cc:24
reco::GsfElectron::hcalOverEcalBc
float hcalOverEcalBc(const ShowerShape &ss, int depth) const
Definition: GsfElectron.h:450
SoftElectronMVAEstimator::mva
double mva(const reco::GsfElectron &myElectron, const reco::VertexCollection &) const
Definition: SoftElectronMVAEstimator.cc:26
SoftElectronMVAEstimator::Configuration::vweightsfiles
std::vector< std::string > vweightsfiles
Definition: SoftElectronMVAEstimator.h:17
Track.h
TrackFwd.h
vars
vars
Definition: DeepTauId.cc:164
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:95
reco::GsfElectron::sigmaIphiIphi
float sigmaIphiIphi() const
Definition: GsfElectron.h:428
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::e1x5
float e1x5() const
Definition: GsfElectron.h:429
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:432
reco::GsfElectron::sigmaEtaEta
float sigmaEtaEta() const
Definition: GsfElectron.h:426
SoftElectronMVAEstimator::gbr_
std::vector< std::unique_ptr< const GBRForest > > gbr_
Definition: SoftElectronMVAEstimator.h:29
looper.cfg
cfg
Definition: looper.py:296
reco::GsfElectron::sigmaIetaIeta
float sigmaIetaIeta() const
Definition: GsfElectron.h:427
GsfTrackFwd.h
reco::GsfElectron::e5x5
float e5x5() const
Definition: GsfElectron.h:431
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:883