CMS 3D CMS Logo

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