test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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

UInt_t GetMVABin (int pu, double eta, double pt) const
 
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_
 
Float_t DeltaEtaTrackEcalSeed
 
Float_t deta
 
Float_t detacalo
 
Float_t dphi
 
Float_t EBremOverDeltaP
 
Float_t eleEoPout
 
Float_t eta
 
Float_t etawidth
 
Float_t EtotOvePin
 
Float_t fbrem
 
std::array< std::unique_ptr
< const GBRForest >
, ExpectedNBins
gbr
 
Float_t gsfchi2
 
Float_t HoE
 
Float_t IoEmIoP
 
Float_t kfchi2
 
Float_t kfhits
 
Float_t logSigmaEtaEta
 
Float_t nPV
 
Float_t OneMinusE1x5E5x5
 
Float_t phiwidth
 
Float_t PreShowerOverRaw
 
Float_t pt
 
Float_t R9
 
Float_t see
 
Float_t SigmaPtOverPt
 
Float_t spp
 

Detailed Description

Definition at line 14 of file SoftElectronMVAEstimator.h.

Constructor & Destructor Documentation

SoftElectronMVAEstimator::SoftElectronMVAEstimator ( const Configuration cfg)

Definition at line 10 of file SoftElectronMVAEstimator.cc.

References assert(), cfg_, gather_cfg::cout, DeltaEtaTrackEcalSeed, deta, detacalo, dphi, EBremOverDeltaP, eleEoPout, eta, etawidth, EtotOvePin, ExpectedNBins, fbrem, contentValuesFiles::fullPath, gbr, gsfchi2, HoE, i, compare_using_db::ifile, IoEmIoP, kfchi2, kfhits, logSigmaEtaEta, nPV, OneMinusE1x5E5x5, phiwidth, PreShowerOverRaw, pt, R9, see, SigmaPtOverPt, spp, AlCaHLTBitMon_QueryRunRegistry::string, groupFilesInBlocks::temp, and SoftElectronMVAEstimator::Configuration::vweightsfiles.

10  :cfg_(cfg){
11  std::vector<std::string> weightsfiles;
12  std::string path_mvaWeightFileEleID;
13  for(unsigned ifile=0 ; ifile < cfg_.vweightsfiles.size() ; ++ifile) {
14  path_mvaWeightFileEleID = edm::FileInPath ( cfg_.vweightsfiles[ifile].c_str() ).fullPath();
15  weightsfiles.push_back(path_mvaWeightFileEleID);
16  }
17 
18  //initialize
19  //Define expected number of bins
20 
21  //Check number of weight files given
22  if (ExpectedNBins != cfg_.vweightsfiles.size() ) {
23  std::cout << "Error: Expected Number of bins = " << ExpectedNBins << " does not equal to weightsfiles.size() = "
24  << cfg_.vweightsfiles.size() << std::endl;
25 
27  }
28 
29 
30  for (unsigned int i=0;i<ExpectedNBins; ++i) {
31  TMVA::Reader tmvaReader("!Color:Silent");
32  tmvaReader.AddVariable("fbrem", &fbrem);
33  tmvaReader.AddVariable("EtotOvePin", &EtotOvePin);
34  tmvaReader.AddVariable("EClusOverPout", &eleEoPout);
35  tmvaReader.AddVariable("EBremOverDeltaP", &EBremOverDeltaP);
36  tmvaReader.AddVariable("logSigmaEtaEta", &logSigmaEtaEta);
37  tmvaReader.AddVariable("DeltaEtaTrackEcalSeed", &DeltaEtaTrackEcalSeed);
38  tmvaReader.AddVariable("HoE", &HoE);
39  tmvaReader.AddVariable("gsfchi2", &gsfchi2);
40  tmvaReader.AddVariable("kfchi2", &kfchi2);
41  tmvaReader.AddVariable("kfhits", &kfhits);
42  tmvaReader.AddVariable("SigmaPtOverPt", &SigmaPtOverPt);
43  tmvaReader.AddVariable("deta", &deta);
44  tmvaReader.AddVariable("dphi", &dphi);
45  tmvaReader.AddVariable("detacalo", &detacalo);
46  tmvaReader.AddVariable("see", &see);
47  tmvaReader.AddVariable("spp", &spp);
48  tmvaReader.AddVariable("R9", &R9);
49  tmvaReader.AddVariable("etawidth", &etawidth);
50  tmvaReader.AddVariable("phiwidth", &phiwidth);
51  tmvaReader.AddVariable("e1x5e5x5", &OneMinusE1x5E5x5);
52  tmvaReader.AddVariable("IoEmIoP", &IoEmIoP);
53  tmvaReader.AddVariable("PreShowerOverRaw", &PreShowerOverRaw);
54  tmvaReader.AddVariable("nPV", &nPV);
55 
56  tmvaReader.AddVariable( "pt", &pt);
57  tmvaReader.AddVariable( "eta", &eta);
58 
59  tmvaReader.AddSpectator( "pt", &pt);
60  tmvaReader.AddSpectator( "eta", &eta);
61 
62  // Taken from Daniele (his mail from the 30/11)
63  // training of the 7/12 with Nvtx added
64  std::unique_ptr<TMVA::IMethod> temp( tmvaReader.BookMVA("BDT",weightsfiles[i]) );
65  gbr[i].reset( new GBRForest( dynamic_cast<TMVA::MethodBDT*>( tmvaReader.FindMVA("BDT") ) ) );
66  }
67 }
int i
Definition: DBlmapReader.cc:9
tuple cfg
Definition: looper.py:293
assert(m_qm.get())
std::array< std::unique_ptr< const GBRForest >, ExpectedNBins > gbr
tuple cout
Definition: gather_cfg.py:145
SoftElectronMVAEstimator::~SoftElectronMVAEstimator ( )

Definition at line 70 of file SoftElectronMVAEstimator.cc.

71 { }

Member Function Documentation

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

Definition at line 172 of file SoftElectronMVAEstimator.cc.

References funct::abs().

Referenced by mva().

172  {
173  if( vars[0] < -1.) //fbrem
174  vars[0] = -1.;
175 
176  vars[11] = std::abs(vars[11]); // deta
177  if(vars[11] > 0.06)
178  vars[11] = 0.06;
179 
180  vars[12] = std::abs(vars[12]);
181  if(vars[12] > 0.6)
182  vars[12] = 0.6;
183 
184  //if(EoP > 20.)
185  // EoP = 20.;
186 
187  if(vars[2] > 20.) //eleEoPout
188  vars[2] = 20.;
189 
190  vars[13] = std::abs(vars[13]); //detacalo
191  if(vars[13] > 0.2)
192  vars[13] = 0.2;
193 
194  if( vars[19] < -1.) //OneMinusE1x5E5x5
195  vars[19] = -1;
196 
197  if( vars[19] > 2.) //OneMinusE1x5E5x5
198  vars[19] = 2.;
199 
200  if( vars[7] > 200.) //gsfchi2
201  vars[7] = 200;
202 
203  if( vars[8] > 10.) //kfchi2
204  vars[8] = 10.;
205 
206 }
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
UInt_t SoftElectronMVAEstimator::GetMVABin ( int  pu,
double  eta,
double  pt 
) const

Definition at line 74 of file SoftElectronMVAEstimator.cc.

References newFWLiteAna::bin, cmsHarvester::index, and nPV.

74  {
75 
76  //Default is to return the first bin
77  unsigned int bin = 0;
78 
79  bool ptrange[3],etarange[3],purange[2];
80  ptrange[0]=pt > 2 && pt < 5;
81  ptrange[1]=pt > 5 && pt < 10;
82  ptrange[2]=pt > 10;
83  etarange[0]=fabs(eta) < 0.8;
84  etarange[1]=fabs(eta) > 0.8 && fabs(eta) <1.4;
85  etarange[2]=fabs(eta) > 1.4;
86  purange[0]=nPV<=20;
87  purange[1]=nPV>20;
88 
89  int index=0;
90  for(int kPU=0;kPU<2;kPU++)
91  for(int kETA=0;kETA<3;kETA++)
92  for(int kPT=0;kPT<3;kPT++){
93  if (purange[kPU] && ptrange[kPT] && etarange[kETA]) bin=index;
94  index++;
95  }
96  return bin;
97 }
void SoftElectronMVAEstimator::init ( )
private
double SoftElectronMVAEstimator::mva ( const reco::GsfElectron myElectron,
const reco::VertexCollection pvc 
) const

Definition at line 101 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(), dqm-mbProfile::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().

102  {
103  float vars[25];
104 
105  vars[0] = myElectron.fbrem();// fbrem
106  vars[1] = myElectron.eSuperClusterOverP(); //EtotOvePin
107  vars[2] = myElectron.eEleClusterOverPout(); //eleEoPout
108 
109  float etot = myElectron.eSuperClusterOverP()*myElectron.trackMomentumAtVtx().R();
110  float eEcal = myElectron.eEleClusterOverPout()*myElectron.trackMomentumAtEleClus().R();
111  float dP = myElectron.trackMomentumAtVtx().R()-myElectron.trackMomentumAtEleClus().R();
112  vars[3] = (etot-eEcal)/dP; //EBremOverDeltaP
113  vars[4] = std::log(myElectron.sigmaEtaEta()); //logSigmaEtaEta
114  vars[5] = myElectron.deltaEtaEleClusterTrackAtCalo(); //DeltaEtaTrackEcalSeed
115  vars[6] = myElectron.hcalOverEcalBc(); //HoE
116 
117  bool validKF= false;
118  reco::TrackRef myTrackRef = myElectron.closestCtfTrackRef();
119  validKF = (myTrackRef.isAvailable() && myTrackRef.isNonnull());
120  vars[7] = myElectron.gsfTrack()->normalizedChi2(); //gsfchi2
121  vars[8] = (validKF) ? myTrackRef->normalizedChi2() : 0 ; //kfchi2
122  vars[9] = (validKF) ? myTrackRef->hitPattern().trackerLayersWithMeasurement() : -1. ; //kfhits
123 
124  vars[10] = myElectron.gsfTrack().get()->ptModeError()/myElectron.gsfTrack().get()->ptMode() ; //SigmaPtOverPt
125  vars[11] = myElectron.deltaEtaSuperClusterTrackAtVtx(); //deta
126  vars[12] = myElectron.deltaPhiSuperClusterTrackAtVtx(); //dphi
127  vars[13] = myElectron.deltaEtaSeedClusterTrackAtCalo(); //detacalo
128  vars[14] = myElectron.sigmaIetaIeta(); //see
129  vars[15] = myElectron.sigmaIphiIphi(); //spp
130  vars[16] = myElectron.r9(); //R9
131  vars[17] = myElectron.superCluster()->etaWidth(); //etawidth
132  vars[18] = myElectron.superCluster()->phiWidth(); //phiwidth
133  vars[19] = (myElectron.e5x5()) !=0. ? 1.-(myElectron.e1x5()/myElectron.e5x5()) : -1. ; //OneMinusE1x5E5x5
134  vars[20] = (1.0/myElectron.ecalEnergy()) - (1.0 / myElectron.p()); // IoEmIoP
135  vars[21] = myElectron.superCluster()->preshowerEnergy() / myElectron.superCluster()->rawEnergy(); //PreShowerOverRaw
136  vars[22] = pvc.size(); // nPV
137  vars[23] = myElectron.pt(); //pt
138  vars[24] = myElectron.eta(); //eta
139 
140 /*
141  std::cout<<"fbrem "<<fbrem<<std::endl;
142  std::cout<<"EtotOvePin "<<EtotOvePin<<std::endl;
143  std::cout<<"eleEoPout "<<eleEoPout<<std::endl;
144  std::cout<<"EBremOverDeltaP "<<EBremOverDeltaP<<std::endl;
145  std::cout<<"logSigmaEtaEta "<<logSigmaEtaEta<<std::endl;
146  std::cout<<"DeltaEtaTrackEcalSeed "<<DeltaEtaTrackEcalSeed<<std::endl;
147  std::cout<<"HoE "<<HoE<<std::endl;
148  std::cout<<"kfchi2 "<<kfchi2<<std::endl;
149  std::cout<<"kfhits "<<kfhits<<std::endl;
150  std::cout<<"gsfchi2 "<<gsfchi2<<std::endl;
151  std::cout<<"SigmaPtOverPt "<<SigmaPtOverPt<<std::endl;
152  std::cout<<"deta "<<deta<<std::endl;
153  std::cout<<"dphi "<<dphi<<std::endl;
154  std::cout<<"detacalo "<<detacalo<<std::endl;
155  std::cout<<"see "<<see<<std::endl;
156  std::cout<< "spp " << spp<< std::endl;
157  std::cout<< "R9 " << R9<< std::endl;
158  std::cout<< "IoEmIoP " << IoEmIoP<< std::endl;
159  std::cout<<"etawidth "<<etawidth<<std::endl;
160  std::cout<<"phiwidth "<<phiwidth<<std::endl;
161  std::cout<<"OneMinusE1x5E5x5 "<<OneMinusE1x5E5x5<<std::endl;
162  std::cout<<"PreShowerOverRaw "<<PreShowerOverRaw<<std::endl;
163 */
164  bindVariables(vars);
165 
166  double result= gbr[0]->GetClassifier(vars);
167 
168  return result;
169 }
float sigmaIphiIphi() const
Definition: GsfElectron.h:417
bool isAvailable() const
Definition: Ref.h:576
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:252
float eSuperClusterOverP() const
Definition: GsfElectron.h:243
math::XYZVectorF trackMomentumAtVtx() const
Definition: GsfElectron.h:289
float fbrem() const
Definition: GsfElectron.h:698
TrackRef closestCtfTrackRef() const
Definition: GsfElectron.h:199
tuple result
Definition: mps_fire.py:83
float deltaEtaSuperClusterTrackAtVtx() const
Definition: GsfElectron.h:247
float sigmaIetaIeta() const
Definition: GsfElectron.h:416
virtual SuperClusterRef superCluster() const
reference to a SuperCluster
Definition: GsfElectron.h:182
float deltaPhiSuperClusterTrackAtVtx() const
Definition: GsfElectron.h:250
float eEleClusterOverPout() const
Definition: GsfElectron.h:246
T const * get() const
Returns C++ pointer to the item.
Definition: Ref.h:244
float hcalOverEcalBc() const
Definition: GsfElectron.h:428
float deltaEtaEleClusterTrackAtCalo() const
Definition: GsfElectron.h:249
float e1x5() const
Definition: GsfElectron.h:418
void bindVariables(float vars[25]) const
float ecalEnergy() const
Definition: GsfElectron.h:785
math::XYZVectorF trackMomentumAtEleClus() const
Definition: GsfElectron.h:292
virtual double p() const final
magnitude of momentum vector
std::array< std::unique_ptr< const GBRForest >, ExpectedNBins > gbr
float e5x5() const
Definition: GsfElectron.h:420
float r9() const
Definition: GsfElectron.h:421
float deltaEtaSeedClusterTrackAtCalo() const
Definition: GsfElectron.h:248
virtual double eta() const final
momentum pseudorapidity
float sigmaEtaEta() const
Definition: GsfElectron.h:415
virtual GsfTrackRef gsfTrack() const
reference to a GsfTrack
Definition: GsfElectron.h:183
virtual double pt() const final
transverse momentum

Member Data Documentation

const Configuration SoftElectronMVAEstimator::cfg_
private

Definition at line 31 of file SoftElectronMVAEstimator.h.

Referenced by SoftElectronMVAEstimator().

Float_t SoftElectronMVAEstimator::DeltaEtaTrackEcalSeed
private

Definition at line 38 of file SoftElectronMVAEstimator.h.

Referenced by SoftElectronMVAEstimator().

Float_t SoftElectronMVAEstimator::deta
private

Definition at line 45 of file SoftElectronMVAEstimator.h.

Referenced by SoftElectronMVAEstimator().

Float_t SoftElectronMVAEstimator::detacalo
private

Definition at line 47 of file SoftElectronMVAEstimator.h.

Referenced by SoftElectronMVAEstimator().

Float_t SoftElectronMVAEstimator::dphi
private

Definition at line 46 of file SoftElectronMVAEstimator.h.

Referenced by SoftElectronMVAEstimator().

Float_t SoftElectronMVAEstimator::EBremOverDeltaP
private

Definition at line 36 of file SoftElectronMVAEstimator.h.

Referenced by SoftElectronMVAEstimator().

Float_t SoftElectronMVAEstimator::eleEoPout
private

Definition at line 56 of file SoftElectronMVAEstimator.h.

Referenced by SoftElectronMVAEstimator().

Float_t SoftElectronMVAEstimator::eta
private
Float_t SoftElectronMVAEstimator::etawidth
private

Definition at line 50 of file SoftElectronMVAEstimator.h.

Referenced by SoftElectronMVAEstimator().

Float_t SoftElectronMVAEstimator::EtotOvePin
private

Definition at line 35 of file SoftElectronMVAEstimator.h.

Referenced by SoftElectronMVAEstimator().

unsigned int SoftElectronMVAEstimator::ExpectedNBins = 1
static

Definition at line 16 of file SoftElectronMVAEstimator.h.

Referenced by SoftElectronMVAEstimator().

Float_t SoftElectronMVAEstimator::fbrem
private

Definition at line 34 of file SoftElectronMVAEstimator.h.

Referenced by SoftElectronMVAEstimator().

std::array<std::unique_ptr<const GBRForest>, ExpectedNBins> SoftElectronMVAEstimator::gbr
private

Definition at line 32 of file SoftElectronMVAEstimator.h.

Referenced by mva(), and SoftElectronMVAEstimator().

Float_t SoftElectronMVAEstimator::gsfchi2
private

Definition at line 41 of file SoftElectronMVAEstimator.h.

Referenced by SoftElectronMVAEstimator().

Float_t SoftElectronMVAEstimator::HoE
private

Definition at line 54 of file SoftElectronMVAEstimator.h.

Referenced by SoftElectronMVAEstimator().

Float_t SoftElectronMVAEstimator::IoEmIoP
private

Definition at line 60 of file SoftElectronMVAEstimator.h.

Referenced by SoftElectronMVAEstimator().

Float_t SoftElectronMVAEstimator::kfchi2
private

Definition at line 39 of file SoftElectronMVAEstimator.h.

Referenced by SoftElectronMVAEstimator().

Float_t SoftElectronMVAEstimator::kfhits
private

Definition at line 40 of file SoftElectronMVAEstimator.h.

Referenced by SoftElectronMVAEstimator().

Float_t SoftElectronMVAEstimator::logSigmaEtaEta
private

Definition at line 37 of file SoftElectronMVAEstimator.h.

Referenced by SoftElectronMVAEstimator().

Float_t SoftElectronMVAEstimator::nPV
private

Definition at line 67 of file SoftElectronMVAEstimator.h.

Referenced by GetMVABin(), and SoftElectronMVAEstimator().

Float_t SoftElectronMVAEstimator::OneMinusE1x5E5x5
private

Definition at line 52 of file SoftElectronMVAEstimator.h.

Referenced by SoftElectronMVAEstimator().

Float_t SoftElectronMVAEstimator::phiwidth
private

Definition at line 51 of file SoftElectronMVAEstimator.h.

Referenced by SoftElectronMVAEstimator().

Float_t SoftElectronMVAEstimator::PreShowerOverRaw
private

Definition at line 61 of file SoftElectronMVAEstimator.h.

Referenced by SoftElectronMVAEstimator().

Float_t SoftElectronMVAEstimator::pt
private
Float_t SoftElectronMVAEstimator::R9
private

Definition at line 59 of file SoftElectronMVAEstimator.h.

Referenced by SoftElectronMVAEstimator().

Float_t SoftElectronMVAEstimator::see
private

Definition at line 49 of file SoftElectronMVAEstimator.h.

Referenced by SoftElectronMVAEstimator().

Float_t SoftElectronMVAEstimator::SigmaPtOverPt
private

Definition at line 42 of file SoftElectronMVAEstimator.h.

Referenced by SoftElectronMVAEstimator().

Float_t SoftElectronMVAEstimator::spp
private

Definition at line 58 of file SoftElectronMVAEstimator.h.

Referenced by SoftElectronMVAEstimator().