CMS 3D CMS Logo

EGammaCutBasedEleId.cc
Go to the documentation of this file.
4 
5 #include <algorithm>
6 
7 #ifndef STANDALONEID
8 
10  const reco::GsfElectron &ele,
12  const reco::BeamSpot &beamspot,
14  const double &iso_ch,
15  const double &iso_em,
16  const double &iso_nh,
17  const double &rho,
19  // get the mask
20  unsigned int mask = TestWP(workingPoint, ele, conversions, beamspot, vtxs, iso_ch, iso_em, iso_nh, rho, EAtarget);
21 
22  // check if the desired WP passed
23  if ((mask & PassAll) == PassAll)
24  return true;
25  return false;
26 }
27 
29  const reco::GsfElectronRef &ele,
31  const reco::BeamSpot &beamspot,
33  const double &iso_ch,
34  const double &iso_em,
35  const double &iso_nh,
36  const double &rho,
38  return PassWP(workingPoint, *ele, conversions, beamspot, vtxs, iso_ch, iso_em, iso_nh, rho, EAtarget);
39 }
40 
42  // get the variables
43  bool isEB = ele.isEB() ? true : false;
44  float pt = ele.pt();
47  float sigmaIEtaIEta = ele.sigmaIetaIeta();
48  float hoe = ele.hadronicOverEm();
49  float trackIso = ele.dr03TkSumPt();
50  float ecalIso = ele.dr03EcalRecHitSumEt();
51  float hcalIso = ele.dr03HcalTowerSumEt();
52 
53  // test the trigger cuts
55  triggerWorkingPoint, isEB, pt, dEtaIn, dPhiIn, sigmaIEtaIEta, hoe, trackIso, ecalIso, hcalIso);
56 }
57 
59  return EgammaCutBasedEleId::PassTriggerCuts(triggerWorkingPoint, *ele);
60 }
61 
63  // get the variables
64  float eta = ele.superCluster()->eta();
65  float eopin = ele.eSuperClusterOverP();
66  float fbrem = ele.fbrem();
67 
68  // test the eop/fbrem cuts
69  return EgammaCutBasedEleId::PassEoverPCuts(eta, eopin, fbrem);
70 }
71 
73 
75  const reco::GsfElectron &ele,
77  const reco::BeamSpot &beamspot,
79  const double &iso_ch,
80  const double &iso_em,
81  const double &iso_nh,
82  const double &rho,
84  // get the ID variables from the electron object
85 
86  // kinematic variables
87  bool isEB = ele.isEB() ? true : false;
88  float pt = ele.pt();
89  float eta = ele.superCluster()->eta();
90 
91  // id variables
94  float sigmaIEtaIEta = ele.sigmaIetaIeta();
95  float hoe = ele.hadronicOverEm();
96  float ooemoop = (1.0 / ele.ecalEnergy() - ele.eSuperClusterOverP() / ele.ecalEnergy());
97 
98  // impact parameter variables
99  float d0vtx = 0.0;
100  float dzvtx = 0.0;
101  if (!vtxs->empty()) {
102  reco::VertexRef vtx(vtxs, 0);
103  d0vtx = ele.gsfTrack()->dxy(vtx->position());
104  dzvtx = ele.gsfTrack()->dz(vtx->position());
105  } else {
106  d0vtx = ele.gsfTrack()->dxy();
107  dzvtx = ele.gsfTrack()->dz();
108  }
109 
110  // conversion rejection variables
111  bool vtxFitConversion = ConversionTools::hasMatchedConversion(ele, *conversions, beamspot.position());
112  float mHits = ele.gsfTrack()->hitPattern().numberOfLostHits(reco::HitPattern::MISSING_INNER_HITS);
113 
114  // get the mask value
115  unsigned int mask = EgammaCutBasedEleId::TestWP(workingPoint,
116  isEB,
117  pt,
118  eta,
119  dEtaIn,
120  dPhiIn,
121  sigmaIEtaIEta,
122  hoe,
123  ooemoop,
124  d0vtx,
125  dzvtx,
126  iso_ch,
127  iso_em,
128  iso_nh,
129  vtxFitConversion,
130  mHits,
131  rho,
132  EAtarget);
133 
134  // return the mask value
135  return mask;
136 }
137 
139  const reco::GsfElectronRef &ele,
141  const reco::BeamSpot &beamspot,
143  const double &iso_ch,
144  const double &iso_em,
145  const double &iso_nh,
146  const double &rho,
148  return TestWP(workingPoint, *ele, conversions, beamspot, vtxs, iso_ch, iso_em, iso_nh, rho, EAtarget);
149 }
150 
151 #endif
152 
154  const bool isEB,
155  const float pt,
156  const float eta,
157  const float dEtaIn,
158  const float dPhiIn,
159  const float sigmaIEtaIEta,
160  const float hoe,
161  const float ooemoop,
162  const float d0vtx,
163  const float dzvtx,
164  const float iso_ch,
165  const float iso_em,
166  const float iso_nh,
167  const bool vtxFitConversion,
168  const unsigned int mHits,
169  const double rho,
171  unsigned int mask = EgammaCutBasedEleId::TestWP(workingPoint,
172  isEB,
173  pt,
174  eta,
175  dEtaIn,
176  dPhiIn,
177  sigmaIEtaIEta,
178  hoe,
179  ooemoop,
180  d0vtx,
181  dzvtx,
182  iso_ch,
183  iso_em,
184  iso_nh,
185  vtxFitConversion,
186  mHits,
187  rho,
188  EAtarget);
189 
190  if ((mask & PassAll) == PassAll)
191  return true;
192  return false;
193 }
194 
196  const bool isEB,
197  const float pt,
198  const float dEtaIn,
199  const float dPhiIn,
200  const float sigmaIEtaIEta,
201  const float hoe,
202  const float trackIso,
203  const float ecalIso,
204  const float hcalIso) {
205  // choose cut if barrel or endcap
206  unsigned int idx = isEB ? 0 : 1;
207 
208  if (triggerWorkingPoint == EgammaCutBasedEleId::TRIGGERTIGHT) {
209  float cut_dEtaIn[2] = {0.007, 0.009};
210  float cut_dPhiIn[2] = {0.15, 0.10};
211  float cut_sigmaIEtaIEta[2] = {0.01, 0.03};
212  float cut_hoe[2] = {0.12, 0.10};
213  float cut_trackIso[2] = {0.20, 0.20};
214  float cut_ecalIso[2] = {0.20, 0.20};
215  float cut_hcalIso[2] = {0.20, 0.20};
216  if (fabs(dEtaIn) > cut_dEtaIn[idx])
217  return false;
218  if (fabs(dPhiIn) > cut_dPhiIn[idx])
219  return false;
220  if (sigmaIEtaIEta > cut_sigmaIEtaIEta[idx])
221  return false;
222  if (hoe > cut_hoe[idx])
223  return false;
224  if (trackIso / pt > cut_trackIso[idx])
225  return false;
226  if (ecalIso / pt > cut_ecalIso[idx])
227  return false;
228  if (hcalIso / pt > cut_hcalIso[idx])
229  return false;
230  } else if (triggerWorkingPoint == EgammaCutBasedEleId::TRIGGERWP70) {
231  float cut_dEtaIn[2] = {0.004, 0.005};
232  float cut_dPhiIn[2] = {0.03, 0.02};
233  float cut_sigmaIEtaIEta[2] = {0.01, 0.03};
234  float cut_hoe[2] = {0.025, 0.025};
235  float cut_trackIso[2] = {0.10, 0.10};
236  float cut_ecalIso[2] = {0.10, 0.05};
237  float cut_hcalIso[2] = {0.05, 0.05};
238  if (fabs(dEtaIn) > cut_dEtaIn[idx])
239  return false;
240  if (fabs(dPhiIn) > cut_dPhiIn[idx])
241  return false;
242  if (sigmaIEtaIEta > cut_sigmaIEtaIEta[idx])
243  return false;
244  if (hoe > cut_hoe[idx])
245  return false;
246  if (trackIso / pt > cut_trackIso[idx])
247  return false;
248  if (ecalIso / pt > cut_ecalIso[idx])
249  return false;
250  if (hcalIso / pt > cut_hcalIso[idx])
251  return false;
252  } else {
253  std::cout << "[EgammaCutBasedEleId::PassTriggerCuts] Undefined working point" << std::endl;
254  }
255 
256  return true;
257 }
258 
259 bool EgammaCutBasedEleId::PassEoverPCuts(const float eta, const float eopin, const float fbrem) {
260  if (fbrem > 0.15)
261  return true;
262  else if (fabs(eta) < 1.0 && eopin > 0.95)
263  return true;
264  return false;
265 }
266 
268  const bool isEB,
269  const float pt,
270  const float eta,
271  const float dEtaIn,
272  const float dPhiIn,
273  const float sigmaIEtaIEta,
274  const float hoe,
275  const float ooemoop,
276  const float d0vtx,
277  const float dzvtx,
278  const float iso_ch,
279  const float iso_em,
280  const float iso_nh,
281  const bool vtxFitConversion,
282  const unsigned int mHits,
283  const double rho,
285  unsigned int mask = 0;
286  float cut_dEtaIn[2] = {999.9, 999.9};
287  float cut_dPhiIn[2] = {999.9, 999.9};
288  float cut_sigmaIEtaIEta[2] = {999.9, 999.9};
289  float cut_hoe[2] = {999.9, 999.9};
290  float cut_ooemoop[2] = {999.9, 999.9};
291  float cut_d0vtx[2] = {999.9, 999.9};
292  float cut_dzvtx[2] = {999.9, 999.9};
293  float cut_iso[2] = {999.9, 999.9};
294  bool cut_vtxFit[2] = {false, false};
295  unsigned int cut_mHits[2] = {999, 999};
296 
298  cut_dEtaIn[0] = 0.007;
299  cut_dEtaIn[1] = 0.010;
300  cut_dPhiIn[0] = 0.800;
301  cut_dPhiIn[1] = 0.700;
302  cut_sigmaIEtaIEta[0] = 0.010;
303  cut_sigmaIEtaIEta[1] = 0.030;
304  cut_hoe[0] = 0.150;
305  cut_hoe[1] = 999.9;
306  cut_ooemoop[0] = 999.9;
307  cut_ooemoop[1] = 999.9;
308  cut_d0vtx[0] = 0.040;
309  cut_d0vtx[1] = 0.040;
310  cut_dzvtx[0] = 0.200;
311  cut_dzvtx[1] = 0.200;
312  cut_vtxFit[0] = false;
313  cut_vtxFit[1] = false;
314  cut_mHits[0] = 999;
315  cut_mHits[1] = 999;
316  cut_iso[0] = 0.150;
317  cut_iso[1] = 0.150;
319  cut_dEtaIn[0] = 0.007;
320  cut_dEtaIn[1] = 0.009;
321  cut_dPhiIn[0] = 0.150;
322  cut_dPhiIn[1] = 0.100;
323  cut_sigmaIEtaIEta[0] = 0.010;
324  cut_sigmaIEtaIEta[1] = 0.030;
325  cut_hoe[0] = 0.120;
326  cut_hoe[1] = 0.100;
327  cut_ooemoop[0] = 0.050;
328  cut_ooemoop[1] = 0.050;
329  cut_d0vtx[0] = 0.020;
330  cut_d0vtx[1] = 0.020;
331  cut_dzvtx[0] = 0.200;
332  cut_dzvtx[1] = 0.200;
333  cut_vtxFit[0] = true;
334  cut_vtxFit[1] = true;
335  cut_mHits[0] = 1;
336  cut_mHits[1] = 1;
337  if (pt >= 20.0) {
338  cut_iso[0] = 0.150;
339  cut_iso[1] = 0.150;
340  } else {
341  cut_iso[0] = 0.150;
342  cut_iso[1] = 0.100;
343  }
345  cut_dEtaIn[0] = 0.004;
346  cut_dEtaIn[1] = 0.007;
347  cut_dPhiIn[0] = 0.060;
348  cut_dPhiIn[1] = 0.030;
349  cut_sigmaIEtaIEta[0] = 0.010;
350  cut_sigmaIEtaIEta[1] = 0.030;
351  cut_hoe[0] = 0.120;
352  cut_hoe[1] = 0.100;
353  cut_ooemoop[0] = 0.050;
354  cut_ooemoop[1] = 0.050;
355  cut_d0vtx[0] = 0.020;
356  cut_d0vtx[1] = 0.020;
357  cut_dzvtx[0] = 0.100;
358  cut_dzvtx[1] = 0.100;
359  cut_vtxFit[0] = true;
360  cut_vtxFit[1] = true;
361  cut_mHits[0] = 1;
362  cut_mHits[1] = 1;
363  if (pt >= 20.0) {
364  cut_iso[0] = 0.150;
365  cut_iso[1] = 0.150;
366  } else {
367  cut_iso[0] = 0.150;
368  cut_iso[1] = 0.100;
369  }
371  cut_dEtaIn[0] = 0.004;
372  cut_dEtaIn[1] = 0.005;
373  cut_dPhiIn[0] = 0.030;
374  cut_dPhiIn[1] = 0.020;
375  cut_sigmaIEtaIEta[0] = 0.010;
376  cut_sigmaIEtaIEta[1] = 0.030;
377  cut_hoe[0] = 0.120;
378  cut_hoe[1] = 0.100;
379  cut_ooemoop[0] = 0.050;
380  cut_ooemoop[1] = 0.050;
381  cut_d0vtx[0] = 0.020;
382  cut_d0vtx[1] = 0.020;
383  cut_dzvtx[0] = 0.100;
384  cut_dzvtx[1] = 0.100;
385  cut_vtxFit[0] = true;
386  cut_vtxFit[1] = true;
387  cut_mHits[0] = 0;
388  cut_mHits[1] = 0;
389  if (pt >= 20.0) {
390  cut_iso[0] = 0.100;
391  cut_iso[1] = 0.100;
392  } else {
393  cut_iso[0] = 0.100;
394  cut_iso[1] = 0.070;
395  }
396  } else {
397  std::cout << "[EgammaCutBasedEleId::TestWP] Undefined working point" << std::endl;
398  }
399 
400  // choose cut if barrel or endcap
401  unsigned int idx = isEB ? 0 : 1;
402 
403  // effective area for isolation
406  //float AEff = ElectronEffectiveArea::GetElectronEffectiveArea(ElectronEffectiveArea::kEleGammaAndNeutralHadronIso03, eta, ElectronEffectiveArea::kEleEAData2011);
407 
408  // apply to neutrals
409  double rhoPrime = std::max(rho, 0.0);
410  double iso_n = std::max(iso_nh + iso_em - rhoPrime * AEff, 0.0);
411 
412  // compute final isolation
413  double iso = (iso_n + iso_ch) / pt;
414 
415  // test cuts
416  if (fabs(dEtaIn) < cut_dEtaIn[idx])
417  mask |= DETAIN;
418  if (fabs(dPhiIn) < cut_dPhiIn[idx])
419  mask |= DPHIIN;
420  if (sigmaIEtaIEta < cut_sigmaIEtaIEta[idx])
421  mask |= SIGMAIETAIETA;
422  if (hoe < cut_hoe[idx])
423  mask |= HOE;
424  if (fabs(ooemoop) < cut_ooemoop[idx])
425  mask |= OOEMOOP;
426  if (fabs(d0vtx) < cut_d0vtx[idx])
427  mask |= D0VTX;
428  if (fabs(dzvtx) < cut_dzvtx[idx])
429  mask |= DZVTX;
430  if (!cut_vtxFit[idx] || !vtxFitConversion)
431  mask |= VTXFIT;
432  if (mHits <= cut_mHits[idx])
433  mask |= MHITS;
434  if (iso < cut_iso[idx])
435  mask |= ISO;
436 
437  // return the mask
438  return mask;
439 }
440 
441 void EgammaCutBasedEleId::PrintDebug(unsigned int mask) {
442  printf("detain(%i), ", bool(mask & DETAIN));
443  printf("dphiin(%i), ", bool(mask & DPHIIN));
444  printf("sieie(%i), ", bool(mask & SIGMAIETAIETA));
445  printf("hoe(%i), ", bool(mask & HOE));
446  printf("ooemoop(%i), ", bool(mask & OOEMOOP));
447  printf("d0vtx(%i), ", bool(mask & D0VTX));
448  printf("dzvtx(%i), ", bool(mask & DZVTX));
449  printf("iso(%i), ", bool(mask & ISO));
450  printf("vtxfit(%i), ", bool(mask & VTXFIT));
451  printf("mhits(%i)\n", bool(mask & MHITS));
452 }
ElectronEffectiveArea::GetElectronEffectiveArea
static Double_t GetElectronEffectiveArea(ElectronEffectiveAreaType type, Double_t SCEta, ElectronEffectiveAreaTarget EffectiveAreaTarget=kEleEAData2011)
Definition: ElectronEffectiveArea.h:59
EgammaCutBasedEleId::TriggerWorkingPoint
TriggerWorkingPoint
Definition: EGammaCutBasedEleId.h:36
EgammaCutBasedEleId::DZVTX
Definition: EGammaCutBasedEleId.h:49
reco::GsfElectron::dr03TkSumPt
float dr03TkSumPt() const
Definition: GsfElectron.h:529
reco::GsfElectron::isEB
bool isEB() const
Definition: GsfElectron.h:336
reco::GsfElectron::gsfTrack
GsfTrackRef gsfTrack() const override
reference to a GsfTrack
Definition: GsfElectron.h:164
EgammaCutBasedEleId::TIGHT
Definition: EGammaCutBasedEleId.h:34
ConversionTools.h
EgammaCutBasedEleId::MHITS
Definition: EGammaCutBasedEleId.h:52
reco::GsfElectron::deltaPhiSuperClusterTrackAtVtx
float deltaPhiSuperClusterTrackAtVtx() const
Definition: GsfElectron.h:236
ElectronEffectiveArea::kEleGammaAndNeutralHadronIso03
Definition: ElectronEffectiveArea.h:40
DiDispStaMuonMonitor_cfi.pt
pt
Definition: DiDispStaMuonMonitor_cfi.py:39
EgammaCutBasedEleId::PrintDebug
void PrintDebug(unsigned int mask)
Definition: EGammaCutBasedEleId.cc:441
EgHLTOffHistBins_cfi.dEtaIn
dEtaIn
Definition: EgHLTOffHistBins_cfi.py:19
gather_cfg.cout
cout
Definition: gather_cfg.py:144
ZElectronSkim_cff.rho
rho
Definition: ZElectronSkim_cff.py:38
reco::LeafCandidate::pt
double pt() const final
transverse momentum
Definition: LeafCandidate.h:146
reco::GsfElectron::hadronicOverEm
float hadronicOverEm() const
Definition: GsfElectron.h:476
edm::Handle< reco::ConversionCollection >
training_settings.idx
idx
Definition: training_settings.py:16
reco::GsfElectron::fbrem
float fbrem() const
Definition: GsfElectron.h:734
EgammaCutBasedEleId::WorkingPoint
WorkingPoint
Definition: EGammaCutBasedEleId.h:34
EgammaCutBasedEleId::VETO
Definition: EGammaCutBasedEleId.h:34
ElectronEffectiveArea::ElectronEffectiveAreaTarget
ElectronEffectiveAreaTarget
Definition: ElectronEffectiveArea.h:57
edm::Ref
Definition: AssociativeIterator.h:58
EgammaCutBasedEleId::DETAIN
Definition: EGammaCutBasedEleId.h:43
EgammaCutBasedEleId::TRIGGERTIGHT
Definition: EGammaCutBasedEleId.h:36
PVValHelper::eta
Definition: PVValidationHelpers.h:69
ConversionTools::hasMatchedConversion
static bool hasMatchedConversion(const reco::GsfElectron &ele, const reco::ConversionCollection &convCol, const math::XYZPoint &beamspot, bool allowCkfMatch=true, float lxyMin=2.0, float probMin=1e-6, unsigned int nHitsBeforeVtxMax=0)
Definition: ConversionTools.cc:184
reco::BeamSpot
Definition: BeamSpot.h:21
beamspot
Definition: BeamSpotWrite2Txt.h:8
reco::GsfElectron
Definition: GsfElectron.h:35
EgammaCutBasedEleId::TRIGGERWP70
Definition: EGammaCutBasedEleId.h:36
badGlobalMuonTaggersAOD_cff.vtx
vtx
Definition: badGlobalMuonTaggersAOD_cff.py:5
singleTopDQM_cfi.workingPoint
workingPoint
Definition: singleTopDQM_cfi.py:66
funct::true
true
Definition: Factorize.h:173
reco::GsfElectron::deltaEtaSuperClusterTrackAtVtx
float deltaEtaSuperClusterTrackAtVtx() const
Definition: GsfElectron.h:233
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
EgHLTOffHistBins_cfi.dPhiIn
dPhiIn
Definition: EgHLTOffHistBins_cfi.py:18
EgammaCutBasedEleId::D0VTX
Definition: EGammaCutBasedEleId.h:48
EgammaCutBasedEleId::PassAll
static const unsigned int PassAll
Definition: EGammaCutBasedEleId.h:59
DPHIIN
Definition: ElectronIdentifier.h:30
EgammaCutBasedEleId::SIGMAIETAIETA
Definition: EGammaCutBasedEleId.h:45
EgammaCutBasedEleId::PassTriggerCuts
bool PassTriggerCuts(const TriggerWorkingPoint triggerWorkingPoint, const reco::GsfElectronRef &ele)
Definition: EGammaCutBasedEleId.cc:58
EgammaCutBasedEleId::VTXFIT
Definition: EGammaCutBasedEleId.h:51
EgammaCutBasedEleId::PassEoverPCuts
bool PassEoverPCuts(const reco::GsfElectronRef &ele)
Definition: EGammaCutBasedEleId.cc:72
ISO
Definition: ElectronIdentifier.h:32
EgammaCutBasedEleId::HOE
Definition: EGammaCutBasedEleId.h:46
electrons_cff.hoe
hoe
Definition: electrons_cff.py:404
reco::GsfElectron::sigmaIetaIeta
float sigmaIetaIeta() const
Definition: GsfElectron.h:419
EGammaCutBasedEleId.h
ElectronEffectiveArea.h
reco::HitPattern::MISSING_INNER_HITS
Definition: HitPattern.h:155
reco::GsfElectron::eSuperClusterOverP
float eSuperClusterOverP() const
Definition: GsfElectron.h:229
reco::GsfElectron::superCluster
SuperClusterRef superCluster() const override
reference to a SuperCluster
Definition: GsfElectron.h:163
EgammaCutBasedEleId::MEDIUM
Definition: EGammaCutBasedEleId.h:34
pwdgSkimBPark_cfi.conversions
conversions
Definition: pwdgSkimBPark_cfi.py:10
reco::GsfElectron::dr03HcalTowerSumEt
float dr03HcalTowerSumEt() const
Definition: GsfElectron.h:534
EgammaCutBasedEleId::LOOSE
Definition: EGammaCutBasedEleId.h:34
EgammaCutBasedEleId::TestWP
unsigned int TestWP(const WorkingPoint workingPoint, const reco::GsfElectronRef &ele, const edm::Handle< reco::ConversionCollection > &conversions, const reco::BeamSpot &beamspot, const edm::Handle< reco::VertexCollection > &vtxs, const double &iso_ch, const double &iso_em, const double &iso_nh, const double &rho, ElectronEffectiveArea::ElectronEffectiveAreaTarget EAtarget)
Definition: EGammaCutBasedEleId.cc:138
reco::GsfElectron::dr03EcalRecHitSumEt
float dr03EcalRecHitSumEt() const
Definition: GsfElectron.h:531
EgammaCutBasedEleId::OOEMOOP
Definition: EGammaCutBasedEleId.h:47
EgammaCutBasedEleId::PassWP
bool PassWP(const WorkingPoint workingPoint, const reco::GsfElectronRef &ele, const edm::Handle< reco::ConversionCollection > &conversions, const reco::BeamSpot &beamspot, const edm::Handle< reco::VertexCollection > &vtxs, const double &iso_ch, const double &iso_em, const double &iso_nh, const double &rho, ElectronEffectiveArea::ElectronEffectiveAreaTarget EAtarget)
Definition: EGammaCutBasedEleId.cc:28
reco::GsfElectron::ecalEnergy
float ecalEnergy() const
Definition: GsfElectron.h:820