CMS 3D CMS Logo

List of all members | Classes | Public Member Functions | Static Public Attributes | Private Member Functions | Private Attributes
SoftElectronMVAEstimator Class Reference

#include <SoftElectronMVAEstimator.h>

Classes

struct  Configuration
 

Public Member Functions

double mva (const reco::GsfElectron &myElectron, const reco::VertexCollection &) const
 
 SoftElectronMVAEstimator (const Configuration &)
 
 ~SoftElectronMVAEstimator ()
 

Static Public Attributes

static unsigned int ExpectedNBins = 1
 

Private Member Functions

void bindVariables (float vars[25]) const
 
void init ()
 

Private Attributes

const Configuration cfg_
 
std::vector< std::unique_ptr< const GBRForest > > gbr_
 

Detailed Description

Definition at line 14 of file SoftElectronMVAEstimator.h.

Constructor & Destructor Documentation

SoftElectronMVAEstimator::SoftElectronMVAEstimator ( const Configuration cfg)

Definition at line 7 of file SoftElectronMVAEstimator.cc.

References cfg_, GBRForestTools::createGBRForest(), ExpectedNBins, gbr_, and SoftElectronMVAEstimator::Configuration::vweightsfiles.

7  :cfg_(cfg)
8 {
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() = " <<
14  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( GBRForestTools::createGBRForest( weightsfile ));
21  }
22 }
static std::unique_ptr< const GBRForest > createGBRForest(const std::string &weightFile)
std::vector< std::unique_ptr< const GBRForest > > gbr_
SoftElectronMVAEstimator::~SoftElectronMVAEstimator ( )

Definition at line 25 of file SoftElectronMVAEstimator.cc.

26 { }

Member Function Documentation

void SoftElectronMVAEstimator::bindVariables ( float  vars[25]) const
private

Definition at line 99 of file SoftElectronMVAEstimator.cc.

References funct::abs().

Referenced by mva().

99  {
100  if( vars[0] < -1.) //fbrem
101  vars[0] = -1.;
102 
103  vars[11] = std::abs(vars[11]); // deta
104  if(vars[11] > 0.06)
105  vars[11] = 0.06;
106 
107  vars[12] = std::abs(vars[12]);
108  if(vars[12] > 0.6)
109  vars[12] = 0.6;
110 
111  //if(EoP > 20.)
112  // EoP = 20.;
113 
114  if(vars[2] > 20.) //eleEoPout
115  vars[2] = 20.;
116 
117  vars[13] = std::abs(vars[13]); //detacalo
118  if(vars[13] > 0.2)
119  vars[13] = 0.2;
120 
121  if( vars[19] < -1.) //OneMinusE1x5E5x5
122  vars[19] = -1;
123 
124  if( vars[19] > 2.) //OneMinusE1x5E5x5
125  vars[19] = 2.;
126 
127  if( vars[7] > 200.) //gsfchi2
128  vars[7] = 200;
129 
130  if( vars[8] > 10.) //kfchi2
131  vars[8] = 10.;
132 
133 }
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
void SoftElectronMVAEstimator::init ( )
private
double SoftElectronMVAEstimator::mva ( const reco::GsfElectron myElectron,
const reco::VertexCollection pvc 
) const

Definition at line 28 of file SoftElectronMVAEstimator.cc.

References bindVariables(), reco::GsfElectron::closestCtfTrackRef(), reco::GsfElectron::deltaEtaEleClusterTrackAtCalo(), reco::GsfElectron::deltaEtaSeedClusterTrackAtCalo(), reco::GsfElectron::deltaEtaSuperClusterTrackAtVtx(), reco::GsfElectron::deltaPhiSuperClusterTrackAtVtx(), reco::GsfElectron::e1x5(), reco::GsfElectron::e5x5(), reco::GsfElectron::ecalEnergy(), reco::GsfElectron::eEleClusterOverPout(), reco::GsfElectron::eSuperClusterOverP(), reco::LeafCandidate::eta(), reco::GsfElectron::fbrem(), gbr_, edm::Ref< C, T, F >::get(), reco::GsfElectron::gsfTrack(), reco::GsfElectron::hcalOverEcalBc(), edm::Ref< C, T, F >::isAvailable(), edm::Ref< C, T, F >::isNonnull(), cmsBatch::log, reco::LeafCandidate::p(), reco::LeafCandidate::pt(), reco::GsfElectron::r9(), mps_fire::result, reco::GsfElectron::sigmaEtaEta(), reco::GsfElectron::sigmaIetaIeta(), reco::GsfElectron::sigmaIphiIphi(), reco::GsfElectron::superCluster(), reco::GsfElectron::trackMomentumAtEleClus(), and reco::GsfElectron::trackMomentumAtVtx().

29  {
30  float vars[25];
31 
32  vars[0] = myElectron.fbrem();// fbrem
33  vars[1] = myElectron.eSuperClusterOverP(); //EtotOvePin
34  vars[2] = myElectron.eEleClusterOverPout(); //eleEoPout
35 
36  float etot = myElectron.eSuperClusterOverP()*myElectron.trackMomentumAtVtx().R();
37  float eEcal = myElectron.eEleClusterOverPout()*myElectron.trackMomentumAtEleClus().R();
38  float dP = myElectron.trackMomentumAtVtx().R()-myElectron.trackMomentumAtEleClus().R();
39  vars[3] = (etot-eEcal)/dP; //EBremOverDeltaP
40  vars[4] = std::log(myElectron.sigmaEtaEta()); //logSigmaEtaEta
41  vars[5] = myElectron.deltaEtaEleClusterTrackAtCalo(); //DeltaEtaTrackEcalSeed
42  vars[6] = myElectron.hcalOverEcalBc(); //HoE
43 
44  bool validKF= false;
45  reco::TrackRef myTrackRef = myElectron.closestCtfTrackRef();
46  validKF = (myTrackRef.isAvailable() && myTrackRef.isNonnull());
47  vars[7] = myElectron.gsfTrack()->normalizedChi2(); //gsfchi2
48  vars[8] = (validKF) ? myTrackRef->normalizedChi2() : 0 ; //kfchi2
49  vars[9] = (validKF) ? myTrackRef->hitPattern().trackerLayersWithMeasurement() : -1. ; //kfhits
50 
51  vars[10] = myElectron.gsfTrack().get()->ptModeError()/myElectron.gsfTrack().get()->ptMode() ; //SigmaPtOverPt
52  vars[11] = myElectron.deltaEtaSuperClusterTrackAtVtx(); //deta
53  vars[12] = myElectron.deltaPhiSuperClusterTrackAtVtx(); //dphi
54  vars[13] = myElectron.deltaEtaSeedClusterTrackAtCalo(); //detacalo
55  vars[14] = myElectron.sigmaIetaIeta(); //see
56  vars[15] = myElectron.sigmaIphiIphi(); //spp
57  vars[16] = myElectron.r9(); //R9
58  vars[17] = myElectron.superCluster()->etaWidth(); //etawidth
59  vars[18] = myElectron.superCluster()->phiWidth(); //phiwidth
60  vars[19] = (myElectron.e5x5()) !=0. ? 1.-(myElectron.e1x5()/myElectron.e5x5()) : -1. ; //OneMinusE1x5E5x5
61  vars[20] = (1.0/myElectron.ecalEnergy()) - (1.0 / myElectron.p()); // IoEmIoP
62  vars[21] = myElectron.superCluster()->preshowerEnergy() / myElectron.superCluster()->rawEnergy(); //PreShowerOverRaw
63  vars[22] = pvc.size(); // nPV
64  vars[23] = myElectron.pt(); //pt
65  vars[24] = myElectron.eta(); //eta
66 
67 /*
68  std::cout<<"fbrem "<<fbrem<<std::endl;
69  std::cout<<"EtotOvePin "<<EtotOvePin<<std::endl;
70  std::cout<<"eleEoPout "<<eleEoPout<<std::endl;
71  std::cout<<"EBremOverDeltaP "<<EBremOverDeltaP<<std::endl;
72  std::cout<<"logSigmaEtaEta "<<logSigmaEtaEta<<std::endl;
73  std::cout<<"DeltaEtaTrackEcalSeed "<<DeltaEtaTrackEcalSeed<<std::endl;
74  std::cout<<"HoE "<<HoE<<std::endl;
75  std::cout<<"kfchi2 "<<kfchi2<<std::endl;
76  std::cout<<"kfhits "<<kfhits<<std::endl;
77  std::cout<<"gsfchi2 "<<gsfchi2<<std::endl;
78  std::cout<<"SigmaPtOverPt "<<SigmaPtOverPt<<std::endl;
79  std::cout<<"deta "<<deta<<std::endl;
80  std::cout<<"dphi "<<dphi<<std::endl;
81  std::cout<<"detacalo "<<detacalo<<std::endl;
82  std::cout<<"see "<<see<<std::endl;
83  std::cout<< "spp " << spp<< std::endl;
84  std::cout<< "R9 " << R9<< std::endl;
85  std::cout<< "IoEmIoP " << IoEmIoP<< std::endl;
86  std::cout<<"etawidth "<<etawidth<<std::endl;
87  std::cout<<"phiwidth "<<phiwidth<<std::endl;
88  std::cout<<"OneMinusE1x5E5x5 "<<OneMinusE1x5E5x5<<std::endl;
89  std::cout<<"PreShowerOverRaw "<<PreShowerOverRaw<<std::endl;
90 */
91  bindVariables(vars);
92 
93  double result= gbr_[0]->GetClassifier(vars);
94 
95  return result;
96 }
float sigmaIphiIphi() const
Definition: GsfElectron.h:437
bool isAvailable() const
Definition: Ref.h:577
GsfTrackRef gsfTrack() const override
reference to a GsfTrack
Definition: GsfElectron.h:185
virtual TrackRef closestCtfTrackRef() const
Definition: GsfElectron.h:201
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:253
double eta() const final
momentum pseudorapidity
float eSuperClusterOverP() const
Definition: GsfElectron.h:245
math::XYZVectorF trackMomentumAtVtx() const
Definition: GsfElectron.h:291
double pt() const final
transverse momentum
float fbrem() const
Definition: GsfElectron.h:761
float deltaEtaSuperClusterTrackAtVtx() const
Definition: GsfElectron.h:249
float sigmaIetaIeta() const
Definition: GsfElectron.h:436
float deltaPhiSuperClusterTrackAtVtx() const
Definition: GsfElectron.h:252
float eEleClusterOverPout() const
Definition: GsfElectron.h:248
T const * get() const
Returns C++ pointer to the item.
Definition: Ref.h:245
float hcalOverEcalBc() const
Definition: GsfElectron.h:448
std::vector< std::unique_ptr< const GBRForest > > gbr_
double p() const final
magnitude of momentum vector
float deltaEtaEleClusterTrackAtCalo() const
Definition: GsfElectron.h:251
float e1x5() const
Definition: GsfElectron.h:438
void bindVariables(float vars[25]) const
float ecalEnergy() const
Definition: GsfElectron.h:848
math::XYZVectorF trackMomentumAtEleClus() const
Definition: GsfElectron.h:294
float e5x5() const
Definition: GsfElectron.h:440
float r9() const
Definition: GsfElectron.h:441
float deltaEtaSeedClusterTrackAtCalo() const
Definition: GsfElectron.h:250
SuperClusterRef superCluster() const override
reference to a SuperCluster
Definition: GsfElectron.h:184
float sigmaEtaEta() const
Definition: GsfElectron.h:435

Member Data Documentation

const Configuration SoftElectronMVAEstimator::cfg_
private

Definition at line 31 of file SoftElectronMVAEstimator.h.

Referenced by SoftElectronMVAEstimator().

unsigned int SoftElectronMVAEstimator::ExpectedNBins = 1
static

Definition at line 16 of file SoftElectronMVAEstimator.h.

Referenced by SoftElectronMVAEstimator().

std::vector<std::unique_ptr<const GBRForest> > SoftElectronMVAEstimator::gbr_
private

Definition at line 32 of file SoftElectronMVAEstimator.h.

Referenced by mva(), and SoftElectronMVAEstimator().