CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
EcalIsolationCorrector.cc
Go to the documentation of this file.
1 #ifndef STANDALONE_ECALCORR
3 #else
5 #endif
6 
7 EcalIsolationCorrector::EcalIsolationCorrector(bool forElectrons):isElectron_(forElectrons)
8 {}
9 
11 
13 
14  if (runNumber <= 203755 && runNumber > 197770)
15  runRange = RunC;
16  else if (runNumber > 203755)
17  runRange = RunD;
18 
19  return runRange;
20 }
21 
22 float EcalIsolationCorrector::correctForNoise(float iso, bool isBarrel, EcalIsolationCorrector::RunRange runRange, bool isData) {
23 
24  float result = iso;
25 
26  if (!isElectron_) {
27  if (!isData) {
28  if (runRange == RunAB) {
29  if (!isBarrel)
30  result = (iso-0.2827)/1.0949;
31  else
32  result = (iso-0.0931)/1.0738;
33  } else if (runRange == RunC) {
34  if (!isBarrel)
35  result = (iso-0.5690)/0.9217;
36  else
37  result = (iso-0.1824)/0.9279;
38  } else if (runRange == RunD) {
39  if (!isBarrel)
40  result = (iso-0.9997)/0.8781;
41  else
42  result = (iso-0.0944)/0.8140;
43  }
44  } else {
45  std::cout << "Warning: you should correct MC to data" << std::endl;
46  }
47  } else {
48  if (!isData) {
49  if (runRange == RunAB) {
50  if (!isBarrel)
51  result = (iso+0.1174)/1.0012;
52  else
53  result = (iso+0.2736)/0.9948;
54  } else if (runRange == RunC) {
55  if (!isBarrel)
56  result = (iso+0.2271)/0.9684;
57  else
58  result = (iso+0.5962)/0.9568;
59  } else if (runRange == RunD) {
60  if (!isBarrel)
61  result = (iso+0.2907)/1.0005;
62  else
63  result = (iso+0.9098)/0.9395;
64  }
65  } else {
66  std::cout << "Warning: you should correct MC to data" << std::endl;
67  }
68  }
69 
70  return result;
71 }
72 
73 #ifndef STANDALONE_ECALCORR
74 // GSF Electron Methods
76 
77  if (!isElectron_)
78  std::cerr << "Warning: this corrector is setup for photons and you are passing an electron !" << std::endl;
79 
80  float iso = e.dr03EcalRecHitSumEt();
81  EcalIsolationCorrector::RunRange runRange = checkRunRange(runNumber);
82 
83  return correctForNoise(iso, e.isEB(), runRange, isData);
84 }
85 
86 float EcalIsolationCorrector::correctForNoise(reco::GsfElectron e, std::string runName, bool isData) {
87 
88  if (!isElectron_)
89  std::cerr << "Warning: this corrector is setup for photons and you are passing an electron !" << std::endl;
90 
91  float iso = e.dr03EcalRecHitSumEt();
93 
94  if (runName == "RunAB")
95  runRange = RunAB;
96  else if (runName == "RunC")
97  runRange = RunC;
98  else if (runName == "RunD")
99  runRange = RunD;
100  else {
101  std::cerr << "Error: Unknown run range " << runName << std::endl;
102  abort();
103  }
104 
105  return correctForNoise(iso, e.isEB(), runRange, isData);
106 }
107 
108 float EcalIsolationCorrector::correctForNoise(reco::GsfElectron e, bool isData, float intL_AB, float intL_C, float intL_D) {
109 
110  if (!isElectron_)
111  std::cerr << "Warning: this corrector is setup for photons and you are passing an electron !" << std::endl;
112 
113  float iso = e.dr03EcalRecHitSumEt();
114  float combination = (intL_AB * correctForNoise(iso, e.isEB(), RunAB, isData) +
115  intL_C * correctForNoise(iso, e.isEB(), RunC, isData) +
116  intL_D * correctForNoise(iso, e.isEB(), RunD, isData))/(intL_AB + intL_C + intL_D);
117 
118  return combination;
119 }
120 
121 // PAT Electron Methods
123 
124  if (!isElectron_)
125  std::cerr << "Warning: this corrector is setup for photons and you are passing an electron !" << std::endl;
126 
127  float iso = e.dr03EcalRecHitSumEt();
128  EcalIsolationCorrector::RunRange runRange = checkRunRange(runNumber);
129 
130  return correctForNoise(iso, e.isEB(), runRange, isData);
131 }
132 
133 float EcalIsolationCorrector::correctForNoise(pat::Electron e, std::string runName, bool isData) {
134 
135  if (!isElectron_)
136  std::cerr << "Warning: this corrector is setup for photons and you are passing an electron !" << std::endl;
137 
138  float iso = e.dr03EcalRecHitSumEt();
140 
141  if (runName == "RunAB")
142  runRange = RunAB;
143  else if (runName == "RunC")
144  runRange = RunC;
145  else if (runName == "RunD")
146  runRange = RunD;
147  else {
148  std::cerr << "Error: Unknown run range " << runName << std::endl;
149  abort();
150  }
151 
152  return correctForNoise(iso, e.isEB(), runRange, isData);
153 }
154 
155 float EcalIsolationCorrector::correctForNoise(pat::Electron e, bool isData, float intL_AB, float intL_C, float intL_D) {
156 
157  if (!isElectron_)
158  std::cerr << "Warning: this corrector is setup for photons and you are passing an electron !" << std::endl;
159 
160  float iso = e.dr03EcalRecHitSumEt();
161  float combination = (intL_AB * correctForNoise(iso, e.isEB(), RunAB, isData) +
162  intL_C * correctForNoise(iso, e.isEB(), RunC, isData) +
163  intL_D * correctForNoise(iso, e.isEB(), RunD, isData))/(intL_AB + intL_C + intL_D);
164 
165  return combination;
166 }
167 
168 // RECO Photon Method
170 
171  if (isElectron_)
172  std::cerr << "Warning: this corrector is setup for electrons and you are passing a photon !" << std::endl;
173 
174  float iso = p.ecalRecHitSumEtConeDR03();
175  EcalIsolationCorrector::RunRange runRange = checkRunRange(runNumber);
176 
177  return correctForNoise(iso, p.isEB(), runRange, isData);
178 }
179 
180 float EcalIsolationCorrector::correctForNoise(reco::Photon p, std::string runName, bool isData) {
181 
182  if (isElectron_)
183  std::cerr << "Warning: this corrector is setup for electrons and you are passing a photon !" << std::endl;
184 
185  float iso = p.ecalRecHitSumEtConeDR03();
187 
188  if (runName == "RunAB")
189  runRange = RunAB;
190  else if (runName == "RunC")
191  runRange = RunC;
192  else if (runName == "RunD")
193  runRange = RunD;
194  else {
195  std::cerr << "Error: Unknown run range " << runName << std::endl;
196  abort();
197  }
198 
199  return correctForNoise(iso, p.isEB(), runRange, isData);
200 }
201 
202 float EcalIsolationCorrector::correctForNoise(reco::Photon p, bool isData, float intL_AB, float intL_C, float intL_D) {
203 
204  if (isElectron_)
205  std::cerr << "Warning: this corrector is setup for electrons and you are passing a photon !" << std::endl;
206 
207  float iso = p.ecalRecHitSumEtConeDR03();
208  float combination = (intL_AB * correctForNoise(iso, p.isEB(), RunAB, isData) +
209  intL_C * correctForNoise(iso, p.isEB(), RunC, isData) +
210  intL_D * correctForNoise(iso, p.isEB(), RunD, isData))/(intL_AB + intL_C + intL_D);
211 
212  return combination;
213 }
214 
215 // PAT Photon Method
217 
218  if (isElectron_)
219  std::cerr << "Warning: this corrector is setup for electrons and you are passing a photon !" << std::endl;
220 
221  float iso = p.ecalRecHitSumEtConeDR03();
222  EcalIsolationCorrector::RunRange runRange = checkRunRange(runNumber);
223 
224  return correctForNoise(iso, p.isEB(), runRange, isData);
225 }
226 
227 float EcalIsolationCorrector::correctForNoise(pat::Photon p, std::string runName, bool isData) {
228 
229  if (isElectron_)
230  std::cerr << "Warning: this corrector is setup for electrons and you are passing a photon !" << std::endl;
231 
232  float iso = p.ecalRecHitSumEtConeDR03();
234 
235  if (runName == "RunAB")
236  runRange = RunAB;
237  else if (runName == "RunC")
238  runRange = RunC;
239  else if (runName == "RunD")
240  runRange = RunD;
241  else {
242  std::cerr << "Error: Unknown run range " << runName << std::endl;
243  abort();
244  }
245 
246  return correctForNoise(iso, p.isEB(), runRange, isData);
247 }
248 
249 float EcalIsolationCorrector::correctForNoise(pat::Photon p, bool isData, float intL_AB, float intL_C, float intL_D) {
250 
251  if (isElectron_)
252  std::cerr << "Warning: this corrector is setup for electrons and you are passing a photon !" << std::endl;
253 
254  float iso = p.ecalRecHitSumEtConeDR03();
255  float combination = (intL_AB * correctForNoise(iso, p.isEB(), RunAB, isData) +
256  intL_C * correctForNoise(iso, p.isEB(), RunC, isData) +
257  intL_D * correctForNoise(iso, p.isEB(), RunD, isData))/(intL_AB + intL_C + intL_D);
258 
259  return combination;
260 }
261 #else
262 float EcalIsolationCorrector::correctForNoise(float iso, bool isBarrel, int runNumber, bool isData) {
263 
264  EcalIsolationCorrector::RunRange runRange = checkRunRange(runNumber);
265 
266  return correctForNoise(iso, isBarrel, runRange, isData);
267 }
268 
269 float EcalIsolationCorrector::correctForNoise(float iso, bool isBarrel, std::string runName, bool isData) {
270 
272 
273  if (runName == "RunAB")
274  runRange = RunAB;
275  else if (runName == "RunC")
276  runRange = RunC;
277  else if (runName == "RunD")
278  runRange = RunD;
279  else {
280  std::cerr << "Error: Unknown run range " << runName << std::endl;
281  abort();
282  }
283 
284  return correctForNoise(iso, isBarrel, runRange, isData);
285 }
286 
287 float EcalIsolationCorrector::correctForNoise(float iso , bool isBarrel, bool isData, float intL_AB, float intL_C, float intL_D) {
288 
289  float combination = (intL_AB * correctForNoise(iso, isBarrel, RunAB, isData) +
290  intL_C * correctForNoise(iso, isBarrel, RunC, isData) +
291  intL_D * correctForNoise(iso, isBarrel, RunD, isData))/(intL_AB + intL_C + intL_D);
292 
293  return combination;
294 }
295 #endif
296 
298 
299  float result = iso;
300 
301  if (!isElectron_) {
302  if (runRange == RunAB) {
303  if (!isBarrel)
304  result = iso*0.8499-0.6510;
305  else
306  result = iso*0.8504-0.5658;
307  } else if (runRange == RunC) {
308  if (!isBarrel)
309  result = iso*0.9346-0.9987;
310  else
311  result = iso*0.8529-0.6816;
312  } else if (runRange == RunD) {
313  if (!isBarrel)
314  result = iso*0.8318-0.9999;
315  else
316  result = iso*0.8853-0.8783;
317  }
318  } else {
319  if (runRange == RunAB) {
320  if (!isBarrel)
321  result = iso*0.9849-0.6871;
322  else
323  result = iso*0.8542-0.3558;
324  } else if (runRange == RunC) {
325  if (!isBarrel)
326  result = iso*0.9996-0.8485;
327  else
328  result = iso*0.9994-0.5085;
329  } else if (runRange == RunD) {
330  if (!isBarrel)
331  result = iso*0.9467-0.9998;
332  else
333  result = iso*0.8574-0.4862;
334  }
335  }
336 
337  return result;
338 }
339 
340 #ifndef STANDALONE_ECALCORR
341 // GSF Electron Methods
343 
344  if (!isElectron_)
345  std::cerr << "Warning: this corrector is setup for photons and you are passing an electron !" << std::endl;
346 
347  float iso = e.dr03EcalRecHitSumEt();
348  EcalIsolationCorrector::RunRange runRange = checkRunRange(runNumber);
349 
350  if (!isData)
351  iso = correctForNoise(iso, e.isEB(), runRange, false);
352 
353  return correctForHLTDefinition(iso, e.isEB(), runRange);
354 }
355 
356 float EcalIsolationCorrector::correctForHLTDefinition(reco::GsfElectron e, std::string runName, bool isData) {
357 
358  if (!isElectron_)
359  std::cerr << "Warning: this corrector is setup for photons and you are passing an electron !" << std::endl;
360 
361  float iso = e.dr03EcalRecHitSumEt();
363  if (runName == "RunAB")
364  runRange = RunAB;
365  else if (runName == "RunC")
366  runRange = RunC;
367  else if (runName == "RunD")
368  runRange = RunD;
369  else {
370  std::cerr << "Error: Unknown run range " << runName << std::endl;
371  abort();
372  }
373 
374  if (!isData)
375  iso = correctForNoise(iso, e.isEB(), runRange, false);
376 
377  return correctForHLTDefinition(iso, e.isEB(), runRange);
378 }
379 
380 float EcalIsolationCorrector::correctForHLTDefinition(reco::GsfElectron e, bool isData, float intL_AB, float intL_C, float intL_D) {
381 
382  if (!isElectron_)
383  std::cerr << "Warning: this corrector is setup for photons and you are passing an electron !" << std::endl;
384 
385  float iso = e.dr03EcalRecHitSumEt();
386  if (!isData)
387  iso = correctForNoise(e, isData, intL_AB, intL_C, intL_D);
388 
389  float combination = (intL_AB * correctForHLTDefinition(iso, e.isEB(), RunAB) +
390  intL_C * correctForHLTDefinition(iso, e.isEB(), RunC ) +
391  intL_D * correctForHLTDefinition(iso, e.isEB(), RunD ))/(intL_AB + intL_C + intL_D);
392 
393  return combination;
394 }
395 
396 // PAT Electron Methods
398 
399  if (!isElectron_)
400  std::cerr << "Warning: this corrector is setup for photons and you are passing an electron !" << std::endl;
401 
402  float iso = e.dr03EcalRecHitSumEt();
403  EcalIsolationCorrector::RunRange runRange = checkRunRange(runNumber);
404 
405  if (!isData)
406  iso = correctForNoise(iso, e.isEB(), runRange, false);
407 
408  return correctForHLTDefinition(iso, e.isEB(), runRange);
409 }
410 
411 float EcalIsolationCorrector::correctForHLTDefinition(pat::Electron e, std::string runName, bool isData) {
412 
413  if (!isElectron_)
414  std::cerr << "Warning: this corrector is setup for photons and you are passing an electron !" << std::endl;
415 
416  float iso = e.dr03EcalRecHitSumEt();
418  if (runName == "RunAB")
419  runRange = RunAB;
420  else if (runName == "RunC")
421  runRange = RunC;
422  else if (runName == "RunD")
423  runRange = RunD;
424  else {
425  std::cerr << "Error: Unknown run range " << runName << std::endl;
426  abort();
427  }
428 
429  if (!isData)
430  iso = correctForNoise(iso, e.isEB(), runRange, false);
431 
432  return correctForHLTDefinition(iso, e.isEB(), runRange);
433 }
434 
435 float EcalIsolationCorrector::correctForHLTDefinition(pat::Electron e, bool isData, float intL_AB, float intL_C, float intL_D) {
436 
437  if (!isElectron_)
438  std::cerr << "Warning: this corrector is setup for photons and you are passing an electron !" << std::endl;
439 
440  float iso = e.dr03EcalRecHitSumEt();
441  if (!isData)
442  iso = correctForNoise(e, isData, intL_AB, intL_C, intL_D);
443 
444  float combination = (intL_AB * correctForHLTDefinition(iso, e.isEB(), RunAB) +
445  intL_C * correctForHLTDefinition(iso, e.isEB(), RunC ) +
446  intL_D * correctForHLTDefinition(iso, e.isEB(), RunD ))/(intL_AB + intL_C + intL_D);
447 
448  return combination;
449 }
450 
451 // RECO Photon Methods
453 
454  if (isElectron_)
455  std::cerr << "Warning: this corrector is setup for electrons and you are passing a photon !" << std::endl;
456 
457  float iso = p.ecalRecHitSumEtConeDR03();
458  EcalIsolationCorrector::RunRange runRange = checkRunRange(runNumber);
459 
460  if (!isData)
461  iso = correctForNoise(iso, p.isEB(), runRange, false);
462 
463  return correctForHLTDefinition(iso, p.isEB(), runRange);
464 }
465 
466 float EcalIsolationCorrector::correctForHLTDefinition(reco::Photon p, std::string runName, bool isData) {
467 
468  if (isElectron_)
469  std::cerr << "Warning: this corrector is setup for electrons and you are passing a photon !" << std::endl;
470 
471  float iso = p.ecalRecHitSumEtConeDR03();
472 
474  if (runName == "RunAB")
475  runRange = RunAB;
476  else if (runName == "RunC")
477  runRange = RunC;
478  else if (runName == "RunD")
479  runRange = RunD;
480  else {
481  std::cerr << "Error: Unknown run range " << runName << std::endl;
482  abort();
483  }
484 
485  if (!isData)
486  iso = correctForNoise(iso, p.isEB(), runRange, false);
487 
488  return correctForHLTDefinition(iso, p.isEB(), runRange);
489 }
490 
491 float EcalIsolationCorrector::correctForHLTDefinition(reco::Photon p, bool isData, float intL_AB, float intL_C, float intL_D) {
492 
493  if (isElectron_)
494  std::cerr << "Warning: this corrector is setup for electrons and you are passing a photon !" << std::endl;
495 
496  float iso = p.ecalRecHitSumEtConeDR03();
497 
498  if (!isData)
499  iso = correctForNoise(p, isData, intL_AB, intL_C, intL_D);
500 
501  float combination = (intL_AB * correctForHLTDefinition(iso, p.isEB(), RunAB) +
502  intL_C * correctForHLTDefinition(iso, p.isEB(), RunC ) +
503  intL_D * correctForHLTDefinition(iso, p.isEB(), RunD ))/(intL_AB + intL_C + intL_D);
504 
505  return combination;
506 }
507 
508 // PAT Photon Methods
510 
511  if (isElectron_)
512  std::cerr << "Warning: this corrector is setup for electrons and you are passing a photon !" << std::endl;
513 
514  float iso = p.ecalRecHitSumEtConeDR03();
515  EcalIsolationCorrector::RunRange runRange = checkRunRange(runNumber);
516 
517  if (!isData)
518  iso = correctForNoise(iso, p.isEB(), runRange, false);
519 
520  return correctForHLTDefinition(iso, p.isEB(), runRange);
521 }
522 
523 float EcalIsolationCorrector::correctForHLTDefinition(pat::Photon p, std::string runName, bool isData) {
524 
525  if (isElectron_)
526  std::cerr << "Warning: this corrector is setup for electrons and you are passing a photon !" << std::endl;
527 
528  float iso = p.ecalRecHitSumEtConeDR03();
529 
531  if (runName == "RunAB")
532  runRange = RunAB;
533  else if (runName == "RunC")
534  runRange = RunC;
535  else if (runName == "RunD")
536  runRange = RunD;
537  else {
538  std::cerr << "Error: Unknown run range " << runName << std::endl;
539  abort();
540  }
541 
542  if (!isData)
543  iso = correctForNoise(iso, p.isEB(), runRange, false);
544 
545  return correctForHLTDefinition(iso, p.isEB(), runRange);
546 }
547 
548 float EcalIsolationCorrector::correctForHLTDefinition(pat::Photon p, bool isData, float intL_AB, float intL_C, float intL_D) {
549 
550  if (isElectron_)
551  std::cerr << "Warning: this corrector is setup for electrons and you are passing a photon !" << std::endl;
552 
553  float iso = p.ecalRecHitSumEtConeDR03();
554 
555  if (!isData)
556  iso = correctForNoise(p, isData, intL_AB, intL_C, intL_D);
557 
558  float combination = (intL_AB * correctForHLTDefinition(iso, p.isEB(), RunAB) +
559  intL_C * correctForHLTDefinition(iso, p.isEB(), RunC ) +
560  intL_D * correctForHLTDefinition(iso, p.isEB(), RunD ))/(intL_AB + intL_C + intL_D);
561 
562  return combination;
563 }
564 #else
565 float EcalIsolationCorrector::correctForHLTDefinition(float iso, bool isBarrel, int runNumber, bool isData) {
566 
567  EcalIsolationCorrector::RunRange runRange = checkRunRange(runNumber);
568 
569  if (!isData)
570  iso = correctForNoise(iso, isBarrel, runRange, false);
571 
572  return correctForHLTDefinition(iso, isBarrel, runRange);
573 }
574 
575 float EcalIsolationCorrector::correctForHLTDefinition(float iso, bool isBarrel, std::string runName, bool isData) {
576 
578  if (runName == "RunAB")
579  runRange = RunAB;
580  else if (runName == "RunC")
581  runRange = RunC;
582  else if (runName == "RunD")
583  runRange = RunD;
584  else {
585  std::cerr << "Error: Unknown run range " << runName << std::endl;
586  abort();
587  }
588 
589  if (!isData)
590  iso = correctForNoise(iso, isBarrel, runRange, false);
591 
592  return correctForHLTDefinition(iso, isBarrel, runRange);
593 }
594 
595 float EcalIsolationCorrector::correctForHLTDefinition(float iso, bool isBarrel, bool isData, float intL_AB, float intL_C, float intL_D) {
596 
597  if (!isData)
598  iso = correctForNoise(iso, isBarrel, false, intL_AB, intL_C, intL_D);
599 
600  float combination = (intL_AB * correctForHLTDefinition(iso, isBarrel, RunAB) +
601  intL_C * correctForHLTDefinition(iso, isBarrel, RunC ) +
602  intL_D * correctForHLTDefinition(iso, isBarrel, RunD ))/(intL_AB + intL_C + intL_D);
603 
604  return combination;
605 }
606 #endif
607 
608 
Analysis-level Photon class.
Definition: Photon.h:46
float correctForNoise(reco::GsfElectron e, bool isData=false, float intL_AB=5.5, float intL_C=6.7, float intL_D=7.3)
bool isEB() const
Definition: GsfElectron.h:330
tuple result
Definition: query.py:137
RunRange checkRunRange(int runNumber)
float correctForHLTDefinition(reco::GsfElectron e, bool isData=false, float intL_AB=5.5, float intL_C=6.7, float intL_D=7.3)
Analysis-level electron class.
Definition: Electron.h:52
float dr03EcalRecHitSumEt() const
Definition: GsfElectron.h:437
bool isEB() const
Definition: Photon.h:118
float ecalRecHitSumEtConeDR03() const
Isolation variables in cone dR=0.3.
Definition: Photon.h:361
tuple cout
Definition: gather_cfg.py:121
EcalIsolationCorrector(bool forElectrons)