CMS 3D CMS Logo

EGammaMvaEleEstimator.h
Go to the documentation of this file.
1 //--------------------------------------------------------------------------------------------------
2 // $Id $
3 //
4 // EGammaMvaEleEstimator
5 //
6 // Helper Class for applying MVA electron ID selection
7 //
8 // Authors: D.Benedetti, E.DiMaro, S.Xie
9 //--------------------------------------------------------------------------------------------------
10 
15 
16 //#define STANDALONE // <---- this line
17 
18 #ifndef EGammaMvaEleEstimator_H
19 #define EGammaMvaEleEstimator_H
20 
21 #ifndef STANDALONE
30 #endif
31 #include <vector>
32 #include <TROOT.h>
33 #include "TMVA/Factory.h"
34 #include "TMVA/Tools.h"
35 #include "TMVA/Reader.h"
36 #include "TMVA/MethodBase.h"
37 
39 public:
42 
43  enum MVAType {
44  kTrig = 0, // MVA for triggering electrons
45  kTrigNoIP = 1, // MVA for triggering electrons without IP info
46  kNonTrig = 2, // MVA for non-triggering electrons
47  kIsoRings, // Isolation MVA for non-trigger electrons
48  kTrigIDIsoCombined, // ID+Iso Combined MVA for triggering electrons
49  kTrigIDIsoCombinedPUCorrected // ID+Iso Combined MVA for triggering electrons
50  };
51 
53  void initialize(std::string methodName,
55  Bool_t useBinnedVersion,
56  std::vector<std::string> weightsfiles);
57 
58  Bool_t isInitialized() const { return fisInitialized; }
59  UInt_t GetMVABin(double eta, double pt) const;
60 
61  void bindVariables();
62 
63 #ifndef STANDALONE
64  // for kTrig and kNonTrig algorithm
65  Double_t mvaValue(const reco::GsfElectron& ele,
66  const reco::Vertex& vertex,
67  const TransientTrackBuilder& transientTrackBuilder,
68  EcalClusterLazyTools const& myEcalCluster,
69  bool printDebug = kFALSE);
70 
71  // for kTrigNoIP algorithm
72  Double_t mvaValue(const reco::GsfElectron& ele,
73  const reco::Vertex& vertex,
74  double rho,
75  //const TransientTrackBuilder& transientTrackBuilder,
76  EcalClusterLazyTools const& myEcalCluster,
77  bool printDebug = kFALSE);
78 
79  Double_t mvaValue(const pat::Electron& ele, double rho, bool printDebug = kFALSE);
80 
81  // for kTrig, kNonTrig and kTrigNoIP algorithm
82  Double_t mvaValue(const pat::Electron& ele,
83  const reco::Vertex& vertex,
84  double rho,
85  bool useFull5x5 = kFALSE,
86  bool printDebug = kFALSE);
87 
88  Double_t isoMvaValue(const reco::GsfElectron& ele,
89  const reco::Vertex& vertex,
91  double Rho,
93  const reco::GsfElectronCollection& IdentifiedElectrons,
94  const reco::MuonCollection& IdentifiedMuons,
95  bool printDebug = kFALSE);
96 
97  Double_t IDIsoCombinedMvaValue(const reco::GsfElectron& ele,
98  const reco::Vertex& vertex,
99  const TransientTrackBuilder& transientTrackBuilder,
100  EcalClusterLazyTools const& myEcalCluster,
102  double Rho,
104  bool printDebug = kFALSE);
105 
106  Double_t isoMvaValue(Double_t Pt,
107  Double_t Eta,
108  Double_t Rho,
110  Double_t ChargedIso_DR0p0To0p1,
111  Double_t ChargedIso_DR0p1To0p2,
112  Double_t ChargedIso_DR0p2To0p3,
113  Double_t ChargedIso_DR0p3To0p4,
114  Double_t ChargedIso_DR0p4To0p5,
115  Double_t GammaIso_DR0p0To0p1,
116  Double_t GammaIso_DR0p1To0p2,
117  Double_t GammaIso_DR0p2To0p3,
118  Double_t GammaIso_DR0p3To0p4,
119  Double_t GammaIso_DR0p4To0p5,
120  Double_t NeutralHadronIso_DR0p0To0p1,
121  Double_t NeutralHadronIso_DR0p1To0p2,
122  Double_t NeutralHadronIso_DR0p2To0p3,
123  Double_t NeutralHadronIso_DR0p3To0p4,
124  Double_t NeutralHadronIso_DR0p4To0p5,
125  Bool_t printDebug = kFALSE);
126 #endif
127 
128  // for kTrig algo
129  Double_t mvaValue(Double_t fbrem,
130  Double_t kfchi2,
131  Int_t kfhits,
132  Double_t gsfchi2,
133  Double_t deta,
134  Double_t dphi,
135  Double_t detacalo,
136  Double_t see,
137  Double_t spp,
138  Double_t etawidth,
139  Double_t phiwidth,
140  Double_t e1x5e5x5,
141  Double_t R9,
142  Double_t HoE,
143  Double_t EoP,
144  Double_t IoEmIoP,
145  Double_t eleEoPout,
146  Double_t PreShowerOverRaw,
147  Double_t d0,
148  Double_t ip3d,
149  Double_t eta,
150  Double_t pt,
151  Bool_t printDebug = kFALSE);
152 
153  // for kTrigNoIP algo
154  Double_t mvaValue(Double_t fbrem,
155  Double_t kfchi2,
156  Int_t kfhits,
157  Double_t gsfchi2,
158  Double_t deta,
159  Double_t dphi,
160  Double_t detacalo,
161  Double_t see,
162  Double_t spp,
163  Double_t etawidth,
164  Double_t phiwidth,
165  Double_t e1x5e5x5,
166  Double_t R9,
167  Double_t HoE,
168  Double_t EoP,
169  Double_t IoEmIoP,
170  Double_t eleEoPout,
171  Double_t rho,
172  Double_t PreShowerOverRaw,
173  Double_t eta,
174  Double_t pt,
175  Bool_t printDebug = kFALSE);
176 
177  // for kNonTrig algo
178  Double_t mvaValue(Double_t fbrem,
179  Double_t kfchi2,
180  Int_t kfhits,
181  Double_t gsfchi2,
182  Double_t deta,
183  Double_t dphi,
184  Double_t detacalo,
185  Double_t see,
186  Double_t spp,
187  Double_t etawidth,
188  Double_t phiwidth,
189  Double_t e1x5e5x5,
190  Double_t R9,
191  Double_t HoE,
192  Double_t EoP,
193  Double_t IoEmIoP,
194  Double_t eleEoPout,
195  Double_t PreShowerOverRaw,
196  Double_t eta,
197  Double_t pt,
198  Bool_t printDebug = kFALSE);
199 
200  Double_t IDIsoCombinedMvaValue(Double_t fbrem,
201  Double_t kfchi2,
202  Int_t kfhits,
203  Double_t gsfchi2,
204  Double_t deta,
205  Double_t dphi,
206  Double_t detacalo,
207  Double_t see,
208  Double_t spp,
209  Double_t etawidth,
210  Double_t phiwidth,
211  Double_t OneMinusE1x5E5x5,
212  Double_t R9,
213  Double_t HoE,
214  Double_t EoP,
215  Double_t IoEmIoP,
216  Double_t eleEoPout,
217  Double_t PreShowerOverRaw,
218  Double_t d0,
219  Double_t ip3d,
220  Double_t ChargedIso_DR0p0To0p1,
221  Double_t ChargedIso_DR0p1To0p2,
222  Double_t ChargedIso_DR0p2To0p3,
223  Double_t ChargedIso_DR0p3To0p4,
224  Double_t ChargedIso_DR0p4To0p5,
225  Double_t GammaIso_DR0p0To0p1,
226  Double_t GammaIso_DR0p1To0p2,
227  Double_t GammaIso_DR0p2To0p3,
228  Double_t GammaIso_DR0p3To0p4,
229  Double_t GammaIso_DR0p4To0p5,
230  Double_t NeutralHadronIso_DR0p0To0p1,
231  Double_t NeutralHadronIso_DR0p1To0p2,
232  Double_t NeutralHadronIso_DR0p2To0p3,
233  Double_t NeutralHadronIso_DR0p3To0p4,
234  Double_t NeutralHadronIso_DR0p4To0p5,
235  Double_t Rho,
236  Double_t eta,
237  Double_t pt,
238  Bool_t printDebug = kFALSE);
239 
240 private:
241  std::vector<TMVA::Reader*> fTMVAReader;
242  std::vector<TMVA::MethodBase*> fTMVAMethod;
247  UInt_t fNMVABins;
248 
249  Float_t fMVAVar_fbrem;
250  Float_t fMVAVar_kfchi2;
251  Float_t fMVAVar_kfhits; //number of layers
252  Float_t fMVAVar_kfhitsall; //number of hits
254 
255  Float_t fMVAVar_deta;
256  Float_t fMVAVar_dphi;
258 
259  Float_t fMVAVar_see;
260  Float_t fMVAVar_spp;
264  Float_t fMVAVar_R9;
265 
266  Float_t fMVAVar_HoE;
267  Float_t fMVAVar_EoP;
270  Float_t fMVAVar_EoPout;
272 
273  Float_t fMVAVar_d0;
274  Float_t fMVAVar_ip3d;
276 
277  Float_t fMVAVar_eta;
278  Float_t fMVAVar_pt;
279  Float_t fMVAVar_rho;
280 
296 };
297 
298 #endif
EGammaMvaEleEstimator
Definition: EGammaMvaEleEstimator.h:38
EGammaMvaEleEstimator::fMVAVar_GammaIso_DR0p1To0p2
Float_t fMVAVar_GammaIso_DR0p1To0p2
Definition: EGammaMvaEleEstimator.h:287
HLT_FULL_cff.printDebug
printDebug
Definition: HLT_FULL_cff.py:35519
EGammaMvaEleEstimator::fMVAVar_HoE
Float_t fMVAVar_HoE
Definition: EGammaMvaEleEstimator.h:266
EGammaMvaEleEstimator::fNMVABins
UInt_t fNMVABins
Definition: EGammaMvaEleEstimator.h:247
EGammaMvaEleEstimator::fMVAVar_kfhits
Float_t fMVAVar_kfhits
Definition: EGammaMvaEleEstimator.h:251
EGammaMvaEleEstimator::GetMVABin
UInt_t GetMVABin(double eta, double pt) const
Definition: EGammaMvaEleEstimator.cc:399
EGammaMvaEleEstimator::fMVAVar_GammaIso_DR0p2To0p3
Float_t fMVAVar_GammaIso_DR0p2To0p3
Definition: EGammaMvaEleEstimator.h:288
EGammaMvaEleEstimator::fMVAVar_fbrem
Float_t fMVAVar_fbrem
Definition: EGammaMvaEleEstimator.h:249
EGammaMvaEleEstimator::fMVAVar_dphi
Float_t fMVAVar_dphi
Definition: EGammaMvaEleEstimator.h:256
EGammaMvaEleEstimator::fisInitialized
Bool_t fisInitialized
Definition: EGammaMvaEleEstimator.h:244
EGammaMvaEleEstimator::fMethodname
std::string fMethodname
Definition: EGammaMvaEleEstimator.h:243
EGammaMvaEleEstimator::fMVAVar_R9
Float_t fMVAVar_R9
Definition: EGammaMvaEleEstimator.h:264
EGammaMvaEleEstimator::fMVAVar_phiwidth
Float_t fMVAVar_phiwidth
Definition: EGammaMvaEleEstimator.h:262
EGammaMvaEleEstimator::fMVAVar_ip3d
Float_t fMVAVar_ip3d
Definition: EGammaMvaEleEstimator.h:274
EGammaMvaEleEstimator::fMVAVar_ChargedIso_DR0p1To0p2
Float_t fMVAVar_ChargedIso_DR0p1To0p2
Definition: EGammaMvaEleEstimator.h:282
EGammaMvaEleEstimator::fMVAVar_kfchi2
Float_t fMVAVar_kfchi2
Definition: EGammaMvaEleEstimator.h:250
DiDispStaMuonMonitor_cfi.pt
pt
Definition: DiDispStaMuonMonitor_cfi.py:39
EGammaMvaEleEstimator::fMVAVar_NeutralHadronIso_DR0p2To0p3
Float_t fMVAVar_NeutralHadronIso_DR0p2To0p3
Definition: EGammaMvaEleEstimator.h:293
EGammaMvaEleEstimator::kTrig
Definition: EGammaMvaEleEstimator.h:44
EGammaMvaEleEstimator::fMVAVar_etawidth
Float_t fMVAVar_etawidth
Definition: EGammaMvaEleEstimator.h:261
EGammaMvaEleEstimator::fMVAVar_deta
Float_t fMVAVar_deta
Definition: EGammaMvaEleEstimator.h:255
EGammaMvaEleEstimator::fMVAVar_IoEmIoP
Float_t fMVAVar_IoEmIoP
Definition: EGammaMvaEleEstimator.h:268
EGammaMvaEleEstimator::fMVAVar_ChargedIso_DR0p3To0p4
Float_t fMVAVar_ChargedIso_DR0p3To0p4
Definition: EGammaMvaEleEstimator.h:284
EGammaMvaEleEstimator::kTrigNoIP
Definition: EGammaMvaEleEstimator.h:45
EGammaMvaEleEstimator::initialize
void initialize(std::string methodName, std::string weightsfile, EGammaMvaEleEstimator::MVAType type)
Definition: EGammaMvaEleEstimator.cc:42
reco::GsfElectronCollection
std::vector< GsfElectron > GsfElectronCollection
collection of GsfElectron objects
Definition: GsfElectronFwd.h:14
EGammaMvaEleEstimator::fMVAVar_EoP
Float_t fMVAVar_EoP
Definition: EGammaMvaEleEstimator.h:267
EcalClusterLazyTools.h
EGammaMvaEleEstimator::fMVAVar_ip3dSig
Float_t fMVAVar_ip3dSig
Definition: EGammaMvaEleEstimator.h:275
EGammaMvaEleEstimator::fMVAVar_see
Float_t fMVAVar_see
Definition: EGammaMvaEleEstimator.h:259
EGammaMvaEleEstimator::fMVAVar_eleEoPout
Float_t fMVAVar_eleEoPout
Definition: EGammaMvaEleEstimator.h:269
EGammaMvaEleEstimator::MVAType
MVAType
Definition: EGammaMvaEleEstimator.h:43
jetMETAnalyzer_cfi.PFCandidates
PFCandidates
Definition: jetMETAnalyzer_cfi.py:129
EGammaMvaEleEstimator::IDIsoCombinedMvaValue
Double_t IDIsoCombinedMvaValue(const reco::GsfElectron &ele, const reco::Vertex &vertex, const TransientTrackBuilder &transientTrackBuilder, EcalClusterLazyTools const &myEcalCluster, const reco::PFCandidateCollection &PFCandidates, double Rho, ElectronEffectiveArea::ElectronEffectiveAreaTarget EATarget, bool printDebug=kFALSE)
Definition: EGammaMvaEleEstimator.cc:1619
ElectronEffectiveArea::ElectronEffectiveAreaTarget
ElectronEffectiveAreaTarget
Definition: ElectronEffectiveArea.h:57
EGammaMvaEleEstimator::fMVAVar_GammaIso_DR0p0To0p1
Float_t fMVAVar_GammaIso_DR0p0To0p1
Definition: EGammaMvaEleEstimator.h:286
EGammaMvaEleEstimator::kIsoRings
Definition: EGammaMvaEleEstimator.h:47
EGammaMvaEleEstimator::bindVariables
void bindVariables()
Definition: EGammaMvaEleEstimator.cc:1929
EGammaMvaEleEstimator::isInitialized
Bool_t isInitialized() const
Definition: EGammaMvaEleEstimator.h:58
PVValHelper::eta
Definition: PVValidationHelpers.h:70
EGammaMvaEleEstimator::fMVAVar_OneMinusE1x5E5x5
Float_t fMVAVar_OneMinusE1x5E5x5
Definition: EGammaMvaEleEstimator.h:263
MuonFwd.h
EGammaMvaEleEstimator::fMVAVar_rho
Float_t fMVAVar_rho
Definition: EGammaMvaEleEstimator.h:279
reco::MuonCollection
std::vector< Muon > MuonCollection
collection of Muon objects
Definition: MuonFwd.h:9
EGammaMvaEleEstimator::fMVAVar_ChargedIso_DR0p2To0p3
Float_t fMVAVar_ChargedIso_DR0p2To0p3
Definition: EGammaMvaEleEstimator.h:283
reco::GsfElectron
Definition: GsfElectron.h:34
EGammaMvaEleEstimator::kTrigIDIsoCombined
Definition: EGammaMvaEleEstimator.h:48
EGammaMvaEleEstimator::fMVAVar_EoPout
Float_t fMVAVar_EoPout
Definition: EGammaMvaEleEstimator.h:270
EcalClusterLazyTools
EGammaMvaEleEstimator::fMVAVar_NeutralHadronIso_DR0p0To0p1
Float_t fMVAVar_NeutralHadronIso_DR0p0To0p1
Definition: EGammaMvaEleEstimator.h:291
DDAxes::rho
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
EGammaMvaEleEstimator::fMVAVar_spp
Float_t fMVAVar_spp
Definition: EGammaMvaEleEstimator.h:260
EGammaMvaEleEstimator::fMVAVar_pt
Float_t fMVAVar_pt
Definition: EGammaMvaEleEstimator.h:278
bphysicsOniaDQM_cfi.vertex
vertex
Definition: bphysicsOniaDQM_cfi.py:7
GsfElectronFwd.h
TransientTrackBuilder.h
EGammaMvaEleEstimator::fMVAVar_ChargedIso_DR0p4To0p5
Float_t fMVAVar_ChargedIso_DR0p4To0p5
Definition: EGammaMvaEleEstimator.h:285
type
type
Definition: SiPixelVCal_PayloadInspector.cc:37
EGammaMvaEleEstimator::fMVAVar_NeutralHadronIso_DR0p1To0p2
Float_t fMVAVar_NeutralHadronIso_DR0p1To0p2
Definition: EGammaMvaEleEstimator.h:292
EGammaMvaEleEstimator::fMVAVar_d0
Float_t fMVAVar_d0
Definition: EGammaMvaEleEstimator.h:273
electrons_cff.ip3d
ip3d
Definition: electrons_cff.py:357
EGammaMvaEleEstimator::fMVAVar_gsfchi2
Float_t fMVAVar_gsfchi2
Definition: EGammaMvaEleEstimator.h:253
TransientTrackBuilder
Definition: TransientTrackBuilder.h:16
EGammaMvaEleEstimator::fMVAVar_NeutralHadronIso_DR0p3To0p4
Float_t fMVAVar_NeutralHadronIso_DR0p3To0p4
Definition: EGammaMvaEleEstimator.h:294
EGammaMvaEleEstimator::isoMvaValue
Double_t isoMvaValue(const reco::GsfElectron &ele, const reco::Vertex &vertex, const reco::PFCandidateCollection &PFCandidates, double Rho, ElectronEffectiveArea::ElectronEffectiveAreaTarget EATarget, const reco::GsfElectronCollection &IdentifiedElectrons, const reco::MuonCollection &IdentifiedMuons, bool printDebug=kFALSE)
Definition: EGammaMvaEleEstimator.cc:1348
EGammaMvaEleEstimator::kNonTrig
Definition: EGammaMvaEleEstimator.h:46
VertexFwd.h
ElectronEffectiveArea.h
EGammaMvaEleEstimator::mvaValue
Double_t mvaValue(const reco::GsfElectron &ele, const reco::Vertex &vertex, const TransientTrackBuilder &transientTrackBuilder, EcalClusterLazyTools const &myEcalCluster, bool printDebug=kFALSE)
Definition: EGammaMvaEleEstimator.cc:954
EGammaMvaEleEstimator::fTMVAReader
std::vector< TMVA::Reader * > fTMVAReader
Definition: EGammaMvaEleEstimator.h:241
EGammaMvaEleEstimator::fMVAVar_ChargedIso_DR0p0To0p1
Float_t fMVAVar_ChargedIso_DR0p0To0p1
Definition: EGammaMvaEleEstimator.h:281
EGammaMvaEleEstimator::fTMVAMethod
std::vector< TMVA::MethodBase * > fTMVAMethod
Definition: EGammaMvaEleEstimator.h:242
reco::PFCandidateCollection
std::vector< reco::PFCandidate > PFCandidateCollection
collection of PFCandidates
Definition: PFCandidateFwd.h:12
EGammaMvaEleEstimator::fMVAVar_kfhitsall
Float_t fMVAVar_kfhitsall
Definition: EGammaMvaEleEstimator.h:252
Electron.h
EGammaMvaEleEstimator::fMVAType
MVAType fMVAType
Definition: EGammaMvaEleEstimator.h:245
EGammaMvaEleEstimator::fMVAVar_GammaIso_DR0p4To0p5
Float_t fMVAVar_GammaIso_DR0p4To0p5
Definition: EGammaMvaEleEstimator.h:290
EGammaMvaEleEstimator::fMVAVar_NeutralHadronIso_DR0p4To0p5
Float_t fMVAVar_NeutralHadronIso_DR0p4To0p5
Definition: EGammaMvaEleEstimator.h:295
EGammaMvaEleEstimator::~EGammaMvaEleEstimator
~EGammaMvaEleEstimator()
Definition: EGammaMvaEleEstimator.cc:34
pat::Electron
Analysis-level electron class.
Definition: Electron.h:51
EGammaMvaEleEstimator::fMVAVar_PreShowerOverRaw
Float_t fMVAVar_PreShowerOverRaw
Definition: EGammaMvaEleEstimator.h:271
EGammaMvaEleEstimator::kTrigIDIsoCombinedPUCorrected
Definition: EGammaMvaEleEstimator.h:49
EGammaMvaEleEstimator::fMVAVar_eta
Float_t fMVAVar_eta
Definition: EGammaMvaEleEstimator.h:277
EGammaMvaEleEstimator::fMVAVar_GammaIso_DR0p3To0p4
Float_t fMVAVar_GammaIso_DR0p3To0p4
Definition: EGammaMvaEleEstimator.h:289
d0
static constexpr float d0
Definition: L1EGammaCrystalsEmulatorProducer.cc:85
EGammaMvaEleEstimator::fMVAVar_detacalo
Float_t fMVAVar_detacalo
Definition: EGammaMvaEleEstimator.h:257
EGammaMvaEleEstimator::EGammaMvaEleEstimator
EGammaMvaEleEstimator()
Definition: EGammaMvaEleEstimator.cc:28
reco::Vertex
Definition: Vertex.h:35
EGammaMvaEleEstimator::fUseBinnedVersion
Bool_t fUseBinnedVersion
Definition: EGammaMvaEleEstimator.h:246
PFCandidateFwd.h