ATLAS Offline Software
egammaLayerRecalibTool.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #include <iostream>
6 #include <exception>
7 #include <cassert>
8 #include <string>
9 #include <map>
10 #include <sstream>
11 #include <algorithm>
12 #include <cmath>
13 #include <limits>
14 
15 #include <TFile.h>
16 #include <TObjString.h>
17 
19 
22 
24 
25 namespace {
26 const float VALUE_OVERFLOW = std::numeric_limits<float>::max();
27 
28 template <typename TargetPtr, typename SourcePtr>
29 TargetPtr checked_cast(SourcePtr ptr) {
30  // Do we have ptr types
32  "attempt to cast to no ptr object");
34  "attempt to cast from no ptr object");
35 
36  // nullptr input
37  if (!ptr) {
38  throw std::runtime_error(
39  "Attempt to cast from nullptr in egammaLayerRecalibTool");
40  }
41 
42  // dynamic_cast and check
43  TargetPtr obj = dynamic_cast<TargetPtr>(ptr);
44  if (not obj) {
45  throw std::runtime_error("failed dynamic cast for " +
46  std::string(ptr->GetName()) +
47  " in egammaLayerRecalibTool");
48  }
49 
50  return obj;
51 }
52 
53 } // end anonymous namespace
54 
56  const int bin = m_histo->FindFixBin(input.eta);
57  if (m_histo->IsBinUnderflow(bin) or m_histo->IsBinOverflow(bin)) return VALUE_OVERFLOW;
58  return m_histo->GetBinContent(bin);
59 }
60 
62  const int bin = m_histo->FindFixBin(input.eta);
63  if (m_histo->IsBinUnderflow(bin) or m_histo->IsBinOverflow(bin)) return VALUE_OVERFLOW;
64  return m_histo->GetBinContent(bin) + m_histo->GetBinError(bin);
65 }
66 
68  const int bin = m_histo->FindFixBin(input.eta);
69  if (m_histo->IsBinUnderflow(bin) or m_histo->IsBinOverflow(bin)) return VALUE_OVERFLOW;
70  return m_histo->GetBinContent(bin) - m_histo->GetBinError(bin);
71 }
72 
74  const int bin = m_histo->FindFixBin(input.eta);
75  if (m_histo->IsBinUnderflow(bin) or m_histo->IsBinOverflow(bin)) return VALUE_OVERFLOW;
76  return m_histo->GetBinError(bin);
77 }
78 
80  const int bin = m_histo->FindFixBin(input.eta);
81  if (m_histo->IsBinUnderflow(bin) or m_histo->IsBinOverflow(bin)) return VALUE_OVERFLOW;
82  return -m_histo->GetBinError(bin);
83 }
84 
86  const int bin = m_histo.FindFixBin(input.eta, input.phi);
87  if (m_histo.IsBinUnderflow(bin) or m_histo.IsBinOverflow(bin)) return VALUE_OVERFLOW;
88  return m_histo.GetBinContent(bin);
89 }
90 
92  const int bin = m_histo.FindFixBin(input.etaCalo, input.RunNumber);
93  if (m_histo.IsBinUnderflow(bin) or m_histo.IsBinOverflow(bin)) return VALUE_OVERFLOW;
94  return m_histo.GetBinContent(bin);
95 }
96 
97 float GetAmountFixed::operator()(const StdCalibrationInputs & /*input*/ ) const {
98  return m_amount;
99 }
100 
102  return m_formula.Eval(input.eta, input.phi, input.RunNumber);
103 }
104 
106  return m_tool.getCorr(input.RunNumber, input.eta, input.phi);
107 }
108 
110  return m_toolEMECPS.getCorr(input.RunNumber, input.eta, input.phi);
111 }
112 
114  return m_tool->getCorr(0, input.RunNumber, input.averageInteractionsPerCrossing, input.eta);
115 }
116 
118  return m_tool->getCorr(1, input.RunNumber, input.averageInteractionsPerCrossing, input.eta);
119 }
120 
122  return m_tool->getCorr(2, input.RunNumber, input.averageInteractionsPerCrossing, input.eta);
123 }
124 
126  return m_tool->getCorr(3, input.RunNumber, input.averageInteractionsPerCrossing, input.eta);
127 }
128 
129 
131 {
132  if (amount == VALUE_OVERFLOW) return CP::CorrectionCode::OutOfValidityRange;
133  switch (m_base)
134  {
135  case SHIFT: shift_inputs(inputs, amount); return CP::CorrectionCode::Ok;
136  case SUBTRACT: shift_inputs(inputs, -amount); return CP::CorrectionCode::Ok;
137  case SCALE: scale_inputs(inputs, amount); return CP::CorrectionCode::Ok;
138  case ZEROBASED: scale_inputs(inputs, 1. + amount); return CP::CorrectionCode::Ok;
139  case ONEBASED: scale_inputs(inputs, amount); return CP::CorrectionCode::Ok;
140  case ONEBASED_ALPHA: scale_inputs(inputs, 1. / amount); return CP::CorrectionCode::Ok;
141  case ZEROBASED_ALPHA: scale_inputs(inputs, 1. / (1. + amount)); return CP::CorrectionCode::Ok;
142  default: return CP::CorrectionCode::Error;
143  };
144 }
145 
146 void ScaleE0::scale_inputs(StdCalibrationInputs & inputs, float amount) const { inputs.E0raw *= amount; }
147 void ScaleE1::scale_inputs(StdCalibrationInputs & inputs, float amount) const { inputs.E1raw *= amount; }
148 void ScaleE2::scale_inputs(StdCalibrationInputs & inputs, float amount) const { inputs.E2raw *= amount; }
149 void ScaleE3::scale_inputs(StdCalibrationInputs & inputs, float amount) const { inputs.E3raw *= amount; }
150 
151 void ScaleE0::shift_inputs(StdCalibrationInputs & inputs, float amount) const { inputs.E0raw += amount; }
152 void ScaleE1::shift_inputs(StdCalibrationInputs & inputs, float amount) const { inputs.E1raw += amount; }
153 void ScaleE2::shift_inputs(StdCalibrationInputs & inputs, float amount) const { inputs.E2raw += amount; }
154 void ScaleE3::shift_inputs(StdCalibrationInputs & inputs, float amount) const { inputs.E3raw += amount; }
155 
156 
158 {
159  const double Es1 = inputs.E1raw;
160  const double Es2 = inputs.E2raw;
161  if (Es1 == 0 and Es2 == 0) {
162  inputs.E1raw = -999;
163  inputs.E2raw = -999;
164  return;
165  }
166  const double sum = Es1 + Es2;
167  const double alpha = amount;
168  const double den = (alpha * Es1 + Es2);
169  inputs.E1raw = alpha * Es1 * sum / den;
170  inputs.E2raw = Es2 * sum / den;
171 }
172 
174 {
175  // not very useful, never used
176  throw std::runtime_error("not implemented");
177 }
178 
180 {
181  inputs.E1raw *= amount;
182  inputs.E2raw *= amount;
183  inputs.E3raw *= amount;
184 }
185 
187 {
188  inputs.E1raw += amount;
189  inputs.E2raw += amount;
190  inputs.E3raw += amount;
191 }
192 
194 {
195  inputs.E0raw *= amount;
196  inputs.E1raw *= amount;
197  inputs.E2raw *= amount;
198  inputs.E3raw *= amount;
199 }
200 
202 {
203  inputs.E0raw += amount;
204  inputs.E1raw += amount;
205  inputs.E2raw += amount;
206  inputs.E3raw += amount;
207 }
208 
209 std::string egammaLayerRecalibTool::resolve_alias(const std::string& tune) {
210 
211  if ("layer1_2012" == tune) return "layer1_2012_v5";
212  if ("layer1_alt_2012" == tune) return "layer1_alt_2012_v5";
213  if ("layer1_2011" == tune) return "layer1_2011_v5";
214  if ("layer1_alt_2011" == tune) return "layer1_alt_2011_v5";
215  if ("layer1_2010" == tune) return "layer1_2010_v5";
216  if ("ps_2012" == tune) return "ps_2012_v3";
217  if ("ps_2011" == tune) return "ps_2011_v3";
218  if ("ps_2010" == tune) return "ps_2010_v3";
219  if ("layer1_2012_up" == tune) return "layer1_2012_v5_up";
220  if ("layer1_2012_down" == tune) return "layer1_2012_v5_down";
221  if ("layer1_2012_errup" == tune) return "layer1_2012_v5_errup";
222  if ("layer1_2012_errdown" == tune) return "layer1_2012_v5_errdown";
223  if ("layer1_2011_up" == tune) return "layer1_2011_v5_up";
224  if ("layer1_2011_down" == tune) return "layer1_2011_v5_down";
225  if ("layer1_2011_errup" == tune) return "layer1_2011_v5_errup";
226  if ("layer1_2011_errdown" == tune) return "layer1_2011_v5_errdown";
227  if ("layer1_2010_up" == tune) return "layer1_2010_v5_up";
228  if ("layer1_2010_down" == tune) return "layer1_2010_v5_down";
229  if ("layer1_2010_errup" == tune) return "layer1_2010_v5_errup";
230  if ("layer1_2010_errdown" == tune) return "layer1_2010_v5_errdown";
231  if ("ps_2012_up" == tune) return "ps_2012_v3_up";
232  if ("ps_2012_down" == tune) return "ps_2012_v3_down";
233  if ("ps_2012_errup" == tune) return "ps_2012_v3_errup";
234  if ("ps_2012_errdown" == tune) return "ps_2012_v3_errdown";
235  if ("ps_2011_up" == tune) return "ps_2011_v3_up";
236  if ("ps_2011_down" == tune) return "ps_2011_v3_down";
237  if ("ps_2011_errup" == tune) return "ps_2011_v3_errup";
238  if ("ps_2011_errdown" == tune) return "ps_2011_v3_errdown";
239  if ("ps_2010_up" == tune) return "ps_2010_v3_up";
240  if ("ps_2010_down" == tune) return "ps_2010_v3_down";
241  if ("ps_2010_errup" == tune) return "ps_2010_v3_errup";
242  if ("ps_2010_errdown" == tune) return "ps_2010_v3_errdown";
243 
244  return tune;
245 }
246 
247 void egammaLayerRecalibTool::add_scale(const std::string& tuneIn)
248 {
249  ATH_MSG_INFO("using scale " << tuneIn);
250  std::string tune = resolve_alias(tuneIn);
251 
252  if (tune.empty()) { }
253  else if ("es2022_22.0_Precision" == tune) {
254  add_scale("run2_alt_with_layer2_r22_Precision");
255  }
256  else if ("es2018_21.0_v0" == tune) {
257  add_scale("run2_alt_with_layer2_r21_v1");
258  }
259  else if ("es2017_21.0_v0" == tune) {
260  add_scale("run2_alt_with_layer2_r21_v0");
261  }
262  else if ("es2017_20.7_final" == tune) {
263  add_scale("pileup_20.7");
264  add_scale("run2_alt_with_layer2_modif");
265  }
266  else if ("es2017_20.7_improved" == tune) {
267  add_scale("pileup_20.7"); // new pileup correction Guillaume for 20.7
268  //TEMPORARY HACK REMOVED (two intermediate tags with this ES model use different layer corrections)
269  add_scale("2012_alt_with_layer2_modif"); // temporary old corrections from run1 + EMECPS HV
270  }
271  else if ("pileup_20.7" == tune) {
277  }
278  //Run 2 release 22
279  else if ("run2_alt_with_layer2_r22_Precision"==tune) {
280  add_scale("layer2_alt_el_mu_comb_r21_v0");
281  add_scale("ps_mu_r21_v0");
282  if(m_doSaccCorrections) add_scale("acc_zee_r22_v0");
283  }
284  else if ("run2_alt_with_layer2_r21_v1"==tune) {
285  add_scale("layer2_alt_run2_r21_v1");
286  add_scale("ps_2016_r21_v0");
287  }
288  else if ("run2_alt_with_layer2_r21_v0"==tune) {
289  add_scale("layer2_alt_run2_r21_v0");
290  add_scale("ps_2016_r21_v0");
291  }
292  else if("run2_alt_with_layer2_modif" == tune) {
293  add_scale("ps_EMECHV1");
294  add_scale("layer2_alt_run2_v1");
295  add_scale("ps_2016");
296  }
297  // 2012
298  else if ("2012" == tune) {
299  add_scale("ps_HV1");
300  add_scale("layer1_2012");
301  add_scale("ps_2012");
302  }
303  else if("2012_with_layer2" == tune) {
304  add_scale("ps_HV1");
305  add_scale("layer2_2012_v5");
306  add_scale("ps_2012");
307  }
308  else if ("2012_alt" == tune) {
309  add_scale("ps_HV1");
310  add_scale("layer1_alt_2012");
311  add_scale("ps_2012");
312  }
313  else if("2012_alt_with_layer2" == tune) {
314  add_scale("ps_HV1");
315  add_scale("layer2_alt_2012_v5");
316  add_scale("ps_2012");
317  }
318  else if("2012_alt_with_layer2_modif" == tune) {
319  add_scale("ps_HV1");
320  add_scale("ps_EMECHV1");
321  add_scale("layer2_alt_2012_v5");
322  add_scale("ps_2012");
323  }
324  else if("2010_with_layer2" == tune) {
325  add_scale("layer2_2010_v5");
326  add_scale("ps_2010");
327  }
328  else if ("2012_layer1_up" == tune) {
329  add_scale("ps_HV1");
330  add_scale("layer1_2012_up");
331  add_scale("ps_2012");
332  }
333  else if ("2012_layer1_down" == tune) {
334  add_scale("ps_HV1");
335  add_scale("layer1_2012_down");
336  add_scale("ps_2012");
337  }
338  else if ("2012_layer1_errup" == tune) {
339  add_scale("layer1_2012_errup");
340  }
341  else if ("2012_layer1_errdown" == tune) {
342  add_scale("layer1_2012_errdown");
343  }
344  else if ("2012_ps_down" == tune) {
345  add_scale("ps_HV1");
346  add_scale("layer1_2012");
347  add_scale("ps_2012_down");
348  }
349  else if ("2012_ps_up" == tune) {
350  add_scale("ps_HV1");
351  add_scale("layer1_2012");
352  add_scale("ps_2012_up");
353  }
354  else if ("2012_ps_errdown" == tune) {
355  add_scale("ps_2012_errdown");
356  }
357  else if ("2012_ps_errup" == tune) {
358  add_scale("ps_2012_errup");
359  }
360  else if ("2012_up" == tune) {
361  add_scale("ps_HV1");
362  add_scale("layer1_2012_up");
363  add_scale("ps_2012_up");
364  }
365  else if ("2012_down" == tune) {
366  add_scale("ps_HV1");
367  add_scale("layer1_2012_down");
368  add_scale("ps_2012_down");
369  }
370  else if ("2012_errup" == tune) {
371  add_scale("layer1_2012_errup");
372  add_scale("ps_2012_errup");
373  }
374  else if ("2012_errdown" == tune) {
375  add_scale("layer1_2012_errdown");
376  add_scale("ps_2012_errdown");
377  }
378  // 2011
379  else if ("2011" == tune) {
380  add_scale("layer1_2011");
381  add_scale("ps_2011");
382  }
383  else if("2011_with_layer2" == tune) {
384  add_scale("layer2_2011_v5");
385  add_scale("ps_2011");
386  }
387  else if ("2011_alt" == tune) {
388  add_scale("layer1_alt_2011");
389  add_scale("ps_2011");
390  }
391  else if("2011_alt_with_layer2" == tune) {
392  add_scale("layer2_alt_2011_v5");
393  add_scale("ps_2011");
394  }
395  else if ("2011_layer1_up" == tune) {
396  add_scale("layer1_2011_up");
397  add_scale("ps_2011");
398  }
399  else if ("2011_layer1_down" == tune) {
400  add_scale("layer1_2011_down");
401  add_scale("ps_2011");
402  }
403  else if ("2011_layer1_errup" == tune) {
404  add_scale("layer1_2011_errup");
405  }
406  else if ("2011_layer1_errdown" == tune) {
407  add_scale("layer1_2011_errdown");
408  }
409  else if ("2011_ps_down" == tune) {
410  add_scale("layer1_2011");
411  add_scale("ps_2011_down");
412  }
413  else if ("2011_ps_up" == tune) {
414  add_scale("layer1_2011");
415  add_scale("ps_2011_up");
416  }
417  else if ("2011_ps_errdown" == tune) {
418  add_scale("ps_2011_errdown");
419  }
420  else if ("2011_ps_errup" == tune) {
421  add_scale("ps_2011_errup");
422  }
423  else if ("2011_up" == tune) {
424  add_scale("layer1_2011_up");
425  add_scale("ps_2011_up");
426  }
427  else if ("2011_down" == tune) {
428  add_scale("layer1_2011_down");
429  add_scale("ps_2011_down");
430  }
431  else if ("2011_errup" == tune) {
432  add_scale("layer1_2011_errup");
433  add_scale("ps_2011_errup");
434  }
435  else if ("2011_errdown" == tune) {
436  add_scale("layer1_2011_errdown");
437  add_scale("ps_2011_errdown");
438  }
439  // 2010
440  else if ("2010" == tune) {
441  add_scale("layer1_2010");
442  add_scale("ps_2010");
443  }
444  else if ("2010_layer1_up" == tune) {
445  add_scale("layer1_2010_up");
446  add_scale("ps_2010");
447  }
448  else if ("2010_layer1_down" == tune) {
449  add_scale("layer1_2010_down");
450  add_scale("ps_2010");
451  }
452  else if ("2010_layer1_errup" == tune) {
453  add_scale("layer1_2010_errup");
454  }
455  else if ("2010_layer1_errdown" == tune) {
456  add_scale("layer1_2010_errdown");
457  }
458  else if ("2010_ps_down" == tune) {
459  add_scale("layer1_2010");
460  add_scale("ps_2010_down");
461  }
462  else if ("2010_ps_up" == tune) {
463  add_scale("layer1_2010");
464  add_scale("ps_2010_up");
465  }
466  else if ("2010_ps_errdown" == tune) {
467  add_scale("ps_2010_errdown");
468  }
469  else if ("2010_ps_errup" == tune) {
470  add_scale("ps_2010_errup");
471  }
472  else if ("2010_up" == tune) {
473  add_scale("layer1_2010_up");
474  add_scale("ps_2010_up");
475  }
476  else if ("2010_down" == tune) {
477  add_scale("layer1_2010_down");
478  add_scale("ps_2010_down");
479  }
480  else if ("2010_errup" == tune) {
481  add_scale("layer1_2010_errup");
482  add_scale("ps_2010_errup");
483  }
484  else if ("2010_errdown" == tune) {
485  add_scale("layer1_2010_errdown");
486  add_scale("ps_2010_errdown");
487  }
488  else if ("ps_HV1" == tune) {
490  }
491  else if ("ps_EMECHV1" == tune) {
493  }
494  else if ("test1" == tune) {
495  TH1F h_presampler("h_presampler", "h_presampler", 10, -2.5, 2.5);
496  // just as an example, correct E0 by 0.1 * sign(eta)
497  // and E1 by 1%
498  for (int ibin = 1; ibin <= 5; ++ibin) {
499  h_presampler.SetBinContent(ibin, -0.1);
500  h_presampler.SetBinContent(ibin + 5, 0.1);
501  }
504  }
505  else if ("acc_zee_r22_v0" == tune) {
506  const std::string file = PathResolverFindCalibFile("egammaLayerRecalibTool/v11/egammaLayerRecalibTunes.root");
507  TFile f(file.c_str());
508  TH2F* histo_acc = static_cast<TH2F*>(f.Get("hACC_Zee_rel22"));
509  assert(histo_acc);
511  new GetAmountHisto2DEtaCaloRunNumber(*histo_acc));
512  }
513  else if ("layer1_1" == tune) {
514  TFormula f("formula_layer1_1", "(abs(x)<1.425) ? 0.97 : 1");
516  }
517  else if ("layer1_2" == tune) {
518  TFormula f("formula_layer1_2", "(abs(x)<1.425) ? 0.97 : 1.05");
520  }
521  else if ("layer1_alt_2012_v5" == tune) {
522  const std::string file = PathResolverFindCalibFile("egammaLayerRecalibTool/v1/egammaLayerRecalibTunes.root");
523  TFile f(file.c_str());
524  TH1* histo = checked_cast<TH1*>(f.Get("hE1E2ave_alt_2012"));
526  new GetAmountHisto1D(*histo));
527  }
528  else if ("layer1_2012_v5" == tune) {
529  const std::string file = PathResolverFindCalibFile("egammaLayerRecalibTool/v1/egammaLayerRecalibTunes.root");
530  TFile f(file.c_str());
531  TH1* histo = checked_cast<TH1*>(f.Get("hE1E2ave_2012"));
533  new GetAmountHisto1D(*histo));
534  }
535  else if ("layer1_2012_v5_down" == tune) {
536  const std::string file = PathResolverFindCalibFile("egammaLayerRecalibTool/v1/egammaLayerRecalibTunes.root");
537  TFile f(file.c_str());
538  TH1* histo = checked_cast<TH1*>(f.Get("hE1E2ave_2012"));
540  new GetAmountHisto1DUp(*histo));
541  }
542  else if ("layer1_2012_v5_up" == tune) {
543  const std::string file = PathResolverFindCalibFile("egammaLayerRecalibTool/v1/egammaLayerRecalibTunes.root");
544  TFile f(file.c_str());
545  TH1* histo = checked_cast<TH1*>(f.Get("hE1E2ave_2012"));
548  }
549  else if ("layer1_2012_v5_errdown" == tune) {
550  const std::string file = PathResolverFindCalibFile("egammaLayerRecalibTool/v1/egammaLayerRecalibTunes.root");
551  TFile f(file.c_str());
552  TH1* histo = checked_cast<TH1*>(f.Get("hE1E2ave_2012"));
555  }
556  else if ("layer1_2012_v5_errup" == tune) {
557  const std::string file = PathResolverFindCalibFile("egammaLayerRecalibTool/v1/egammaLayerRecalibTunes.root");
558  TFile f(file.c_str());
559  TH1* histo = checked_cast<TH1*>(f.Get("hE1E2ave_2012"));
562  }
563  else if ("layer1_alt_2011_v5" == tune) {
564  const std::string file = PathResolverFindCalibFile("egammaLayerRecalibTool/v1/egammaLayerRecalibTunes.root");
565  TFile f(file.c_str());
566  TH1* histo = checked_cast<TH1*>(f.Get("hE1E2ave_alt_2011"));
568  new GetAmountHisto1D(*histo));
569  }
570  else if ("layer1_2011_v5" == tune) {
571  const std::string file = PathResolverFindCalibFile("egammaLayerRecalibTool/v1/egammaLayerRecalibTunes.root");
572  TFile f(file.c_str());
573  TH1* histo = checked_cast<TH1*>(f.Get("hE1E2ave_2011"));
575  new GetAmountHisto1D(*histo));
576  }
577  else if ("layer1_2011_v5_down" == tune) {
578  const std::string file = PathResolverFindCalibFile("egammaLayerRecalibTool/v1/egammaLayerRecalibTunes.root");
579  TFile f(file.c_str());
580  TH1* histo = checked_cast<TH1*>(f.Get("hE1E2ave_2011"));
582  new GetAmountHisto1DUp(*histo));
583  }
584  else if ("layer1_2011_v5_up" == tune) {
585  const std::string file = PathResolverFindCalibFile("egammaLayerRecalibTool/v1/egammaLayerRecalibTunes.root");
586  TFile f(file.c_str());
587  TH1* histo = checked_cast<TH1*>(f.Get("hE1E2ave_2011"));
590  }
591  else if ("layer1_2011_v5_errdown" == tune) {
592  const std::string file = PathResolverFindCalibFile("egammaLayerRecalibTool/v1/egammaLayerRecalibTunes.root");
593  TFile f(file.c_str());
594  TH1* histo = checked_cast<TH1*>(f.Get("hE1E2ave_2011"));
597  }
598  else if ("layer1_2011_v5_errup" == tune) {
599  const std::string file = PathResolverFindCalibFile("egammaLayerRecalibTool/v1/egammaLayerRecalibTunes.root");
600  TFile f(file.c_str());
601  TH1* histo = checked_cast<TH1*>(f.Get("hE1E2ave_2011"));
604  }
605  else if ("layer1_2010_v5" == tune) {
606  const std::string file = PathResolverFindCalibFile("egammaLayerRecalibTool/v1/egammaLayerRecalibTunes.root");
607  TFile f(file.c_str());
608  TH1* histo = checked_cast<TH1*>(f.Get("hE1E2ave_2010"));
610  new GetAmountHisto1D(*histo));
611  }
612  else if ("layer1_2010_v5_down" == tune) {
613  const std::string file = PathResolverFindCalibFile("egammaLayerRecalibTool/v1/egammaLayerRecalibTunes.root");
614  TFile f(file.c_str());
615  TH1* histo = checked_cast<TH1*>(f.Get("hE1E2ave_2010"));
617  new GetAmountHisto1DUp(*histo));
618  }
619  else if ("layer1_2010_v5_up" == tune) {
620  const std::string file = PathResolverFindCalibFile("egammaLayerRecalibTool/v1/egammaLayerRecalibTunes.root");
621  TFile f(file.c_str());
622  TH1* histo = checked_cast<TH1*>(f.Get("hE1E2ave_2010"));
625  }
626  else if ("layer1_2010_v5_errdown" == tune) {
627  const std::string file = PathResolverFindCalibFile("egammaLayerRecalibTool/v1/egammaLayerRecalibTunes.root");
628  TFile f(file.c_str());
629  TH1* histo = checked_cast<TH1*>(f.Get("hE1E2ave_2010"));
632  }
633  else if ("layer1_2010_v5_errup" == tune) {
634  const std::string file = PathResolverFindCalibFile("egammaLayerRecalibTool/v1/egammaLayerRecalibTunes.root");
635  TFile f(file.c_str());
636  TH1* histo = checked_cast<TH1*>(f.Get("hE1E2ave_2010"));
639  }
640  else if("layer2_alt_el_mu_comb_r21_v0"==tune) {
641  const std::string file = PathResolverFindCalibFile("egammaLayerRecalibTool/v11/egammaLayerRecalibTunes.root");
642  TFile f(file.c_str());
643  TH1D* histo = static_cast<TH1D*>(f.Get("hE1E2_emu_run2_rel21_v0"));
644  assert(histo);
646  new GetAmountHisto1D(*histo));
647  }
648  else if("layer2_alt_run2_r21_v1"==tune) {
649  const std::string file = PathResolverFindCalibFile("egammaLayerRecalibTool/v6/egammaLayerRecalibTunes.root");
650  TFile f(file.c_str());
651  TH1* histo = checked_cast<TH1*>(f.Get("hE1E2_mu_run2_rel21_v1"));
653  new GetAmountHisto1D(*histo));
654  }
655  else if("layer2_alt_run2_r21_v0"==tune) {
656  const std::string file = PathResolverFindCalibFile("egammaLayerRecalibTool/v5/egammaLayerRecalibTunes.root");
657  TFile f(file.c_str());
658  TH1* histo = checked_cast<TH1*>(f.Get("hE1E2mu_2016_rel21_v1"));
660  new GetAmountHisto1D(*histo));
661  }
662  else if("layer2_alt_run2_v1" == tune) {
663  const std::string file = PathResolverFindCalibFile("egammaLayerRecalibTool/v3/egammaLayerRecalibTunes.root");
664  TFile f(file.c_str());
665  TH1* histo = checked_cast<TH1*>(f.Get("hE1E2mu_2016_v1"));
667  new GetAmountHisto1D(*histo));
668  }
669  else if("layer2_alt_2012_v5" == tune) {
670  const std::string file = PathResolverFindCalibFile("egammaLayerRecalibTool/v1/egammaLayerRecalibTunes.root");
671  TFile f(file.c_str());
672  TH1* histo = checked_cast<TH1*>(f.Get("hE1E2ave_alt_2012"));
674  new GetAmountHisto1D(*histo));
675  }
676  else if("layer2_2012_v5" == tune) {
677  const std::string file = PathResolverFindCalibFile("egammaLayerRecalibTool/v1/egammaLayerRecalibTunes.root");
678  TFile f(file.c_str());
679  TH1* histo = checked_cast<TH1*>(f.Get("hE1E2ave_2012"));
681  new GetAmountHisto1D(*histo));
682  }
683  else if("layer2_2012_v5_down" == tune) {
684  const std::string file = PathResolverFindCalibFile("egammaLayerRecalibTool/v1/egammaLayerRecalibTunes.root");
685  TFile f(file.c_str());
686  TH1* histo = checked_cast<TH1*>(f.Get("hE1E2ave_2012"));
689  }
690  else if("layer2_2012_v5_up" == tune) {
691  const std::string file = PathResolverFindCalibFile("egammaLayerRecalibTool/v1/egammaLayerRecalibTunes.root");
692  TFile f(file.c_str());
693  TH1* histo = checked_cast<TH1*>(f.Get("hE1E2ave_2012"));
695  new GetAmountHisto1DUp(*histo));
696  }
697  else if ("layer2_2012_v5_errdown" == tune) {
698  const std::string file = PathResolverFindCalibFile("egammaLayerRecalibTool/v1/egammaLayerRecalibTunes.root");
699  TFile f(file.c_str());
700  TH1* histo = checked_cast<TH1*>(f.Get("hE1E2ave_2012"));
703  }
704  else if ("layer2_2012_v5_errup" == tune) {
705  const std::string file = PathResolverFindCalibFile("egammaLayerRecalibTool/v1/egammaLayerRecalibTunes.root");
706  TFile f(file.c_str());
707  TH1* histo = checked_cast<TH1*>(f.Get("hE1E2ave_2012"));
710  }
711  else if("layer2_alt_2011_v5" == tune) {
712  const std::string file = PathResolverFindCalibFile("egammaLayerRecalibTool/v1/egammaLayerRecalibTunes.root");
713  TFile f(file.c_str());
714  TH1* histo = checked_cast<TH1*>(f.Get("hE1E2ave_alt_2011"));
716  new GetAmountHisto1D(*histo));
717  }
718  else if("layer2_2011_v5" == tune) {
719  const std::string file = PathResolverFindCalibFile("egammaLayerRecalibTool/v1/egammaLayerRecalibTunes.root");
720  TFile f(file.c_str());
721  TH1* histo = checked_cast<TH1*>(f.Get("hE1E2ave_2011"));
723  new GetAmountHisto1D(*histo));
724  }
725  else if("layer2_2011_v5_down" == tune) {
726  const std::string file = PathResolverFindCalibFile("egammaLayerRecalibTool/v1/egammaLayerRecalibTunes.root");
727  TFile f(file.c_str());
728  TH1* histo = checked_cast<TH1*>(f.Get("hE1E2ave_2011"));
731  }
732  else if("layer2_2011_v5_up" == tune) {
733  const std::string file = PathResolverFindCalibFile("egammaLayerRecalibTool/v1/egammaLayerRecalibTunes.root");
734  TFile f(file.c_str());
735  TH1* histo = checked_cast<TH1*>(f.Get("hE1E2ave_2011"));
737  new GetAmountHisto1DUp(*histo));
738  }
739  else if ("layer2_2011_v5_errdown" == tune) {
740  const std::string file = PathResolverFindCalibFile("egammaLayerRecalibTool/v1/egammaLayerRecalibTunes.root");
741  TFile f(file.c_str());
742  TH1* histo = checked_cast<TH1*>(f.Get("hE1E2ave_2011"));
745  }
746  else if ("layer2_2011_v5_errup" == tune) {
747  const std::string file = PathResolverFindCalibFile("egammaLayerRecalibTool/v1/egammaLayerRecalibTunes.root");
748  TFile f(file.c_str());
749  TH1* histo = checked_cast<TH1*>(f.Get("hE1E2ave_2011"));
752  }
753  else if("layer2_2010_v5" == tune) {
754  const std::string file = PathResolverFindCalibFile("egammaLayerRecalibTool/v1/egammaLayerRecalibTunes.root");
755  TFile f(file.c_str());
756  TH1* histo = checked_cast<TH1*>(f.Get("hE1E2ave_2010"));
758  new GetAmountHisto1D(*histo));
759  }
760  else if("layer2_2010_v5_down" == tune) {
761  const std::string file = PathResolverFindCalibFile("egammaLayerRecalibTool/v1/egammaLayerRecalibTunes.root");
762  TFile f(file.c_str());
763  TH1* histo = checked_cast<TH1*>(f.Get("hE1E2ave_2010"));
766  }
767  else if("layer2_2010_v5_up" == tune) {
768  const std::string file = PathResolverFindCalibFile("egammaLayerRecalibTool/v1/egammaLayerRecalibTunes.root");
769  TFile f(file.c_str());
770  TH1* histo = checked_cast<TH1*>(f.Get("hE1E2ave_2010"));
772  new GetAmountHisto1DUp(*histo));
773  }
774  else if ("layer2_2010_v5_errdown" == tune) {
775  const std::string file = PathResolverFindCalibFile("egammaLayerRecalibTool/v1/egammaLayerRecalibTunes.root");
776  TFile f(file.c_str());
777  TH1* histo = checked_cast<TH1*>(f.Get("hE1E2ave_2010"));
780  }
781  else if ("layer2_2010_v5_errup" == tune) {
782  const std::string file = PathResolverFindCalibFile("egammaLayerRecalibTool/v1/egammaLayerRecalibTunes.root");
783  TFile f(file.c_str());
784  TH1* histo = checked_cast<TH1*>(f.Get("hE1E2ave_2010"));
787  }
788  else if ("ps_2016_r21_v0" == tune) {
789  const std::string file = PathResolverFindCalibFile("egammaLayerRecalibTool/v5/egammaLayerRecalibTunes.root");
790  TFile f(file.c_str());
791  TH1* histo_ps_tot_error = checked_cast<TH1*>(f.Get("hPS_2016_rel21"));
793  new GetAmountHisto1D(*histo_ps_tot_error));
794  }
795  else if ("ps_mu_r21_v0" == tune) {
796  const std::string file = PathResolverFindCalibFile("egammaLayerRecalibTool/v11/egammaLayerRecalibTunes.root");
797  TFile f(file.c_str());
798  TH1F* histo_ps_tot_error = static_cast<TH1F*>(f.Get("hPS_MuonLowMu_rel21"));
799  assert(histo_ps_tot_error);
801  new GetAmountHisto1D(*histo_ps_tot_error));
802  }
803  else if ("ps_2016_v1" == tune) {
804  const std::string file = PathResolverFindCalibFile("egammaLayerRecalibTool/v4/egammaLayerRecalibTunes.root");
805  TFile f(file.c_str());
806  TH1* histo_ps_tot_error = checked_cast<TH1*>(f.Get("hPS_2016"));
808  new GetAmountHisto1D(*histo_ps_tot_error));
809  }
810  else if ("ps_2012_v3" == tune) {
811  const std::string file = PathResolverFindCalibFile("egammaLayerRecalibTool/v1/egammaLayerRecalibTunes.root");
812  TFile f(file.c_str());
813  TH1* histo_ps_tot_error = checked_cast<TH1*>(f.Get("hPS_2012"));
815  new GetAmountHisto1D(*histo_ps_tot_error));
816  }
817  else if ("ps_2012_v3_down" == tune) {
818  const std::string file = PathResolverFindCalibFile("egammaLayerRecalibTool/v1/egammaLayerRecalibTunes.root");
819  TFile f(file.c_str());
820  TH1* histo_ps_tot_error = checked_cast<TH1*>(f.Get("hPS_2012"));
822  new GetAmountHisto1DUp(*histo_ps_tot_error));
823  }
824  else if ("ps_2012_v3_up" == tune){
825  const std::string file = PathResolverFindCalibFile("egammaLayerRecalibTool/v1/egammaLayerRecalibTunes.root");
826  TFile f(file.c_str());
827  TH1* histo_ps_tot_error = checked_cast<TH1*>(f.Get("hPS_2012"));
829  new GetAmountHisto1DDown(*histo_ps_tot_error));
830  }
831  else if ("ps_2012_v3_errdown" == tune){
832  const std::string file = PathResolverFindCalibFile("egammaLayerRecalibTool/v1/egammaLayerRecalibTunes.root");
833  TFile f(file.c_str());
834  TH1* histo_ps_tot_error = checked_cast<TH1*>(f.Get("hPS_2012"));
836  new GetAmountHisto1DErrorUp(*histo_ps_tot_error));
837  }
838  else if ("ps_2012_v3_errup" == tune){
839  const std::string file = PathResolverFindCalibFile("egammaLayerRecalibTool/v1/egammaLayerRecalibTunes.root");
840  TFile f(file.c_str());
841  TH1* histo_ps_tot_error = checked_cast<TH1*>(f.Get("hPS_2012"));
843  new GetAmountHisto1DErrorDown(*histo_ps_tot_error));
844  }
845  else if ("ps_2011_v3" == tune) {
846  const std::string file = PathResolverFindCalibFile("egammaLayerRecalibTool/v1/egammaLayerRecalibTunes.root");
847  TFile f(file.c_str());
848  TH1* histo_ps_tot_error = checked_cast<TH1*>(f.Get("hPS_2011"));
850  new GetAmountHisto1D(*histo_ps_tot_error));
851  }
852  else if ("ps_2011_v3_down" == tune) {
853  const std::string file = PathResolverFindCalibFile("egammaLayerRecalibTool/v1/egammaLayerRecalibTunes.root");
854  TFile f(file.c_str());
855  TH1* histo_ps_tot_error = checked_cast<TH1*>(f.Get("hPS_2011"));
857  new GetAmountHisto1DUp(*histo_ps_tot_error));
858  }
859  else if ("ps_2011_v3_up" == tune){
860  const std::string file = PathResolverFindCalibFile("egammaLayerRecalibTool/v1/egammaLayerRecalibTunes.root");
861  TFile f(file.c_str());
862  TH1* histo_ps_tot_error = checked_cast<TH1*>(f.Get("hPS_2011"));
864  new GetAmountHisto1DDown(*histo_ps_tot_error));
865  }
866  else if ("ps_2011_v3_errdown" == tune){
867  const std::string file = PathResolverFindCalibFile("egammaLayerRecalibTool/v1/egammaLayerRecalibTunes.root");
868  TFile f(file.c_str());
869  TH1* histo_ps_tot_error = checked_cast<TH1*>(f.Get("hPS_2011"));
871  new GetAmountHisto1DErrorUp(*histo_ps_tot_error));
872  }
873  else if ("ps_2011_v3_errup" == tune){
874  const std::string file = PathResolverFindCalibFile("egammaLayerRecalibTool/v1/egammaLayerRecalibTunes.root");
875  TFile f(file.c_str());
876  TH1* histo_ps_tot_error = checked_cast<TH1*>(f.Get("hPS_2011"));
878  new GetAmountHisto1DErrorDown(*histo_ps_tot_error));
879  }
880  // 2010
881  else if ("ps_2010_v3" == tune) {
882  const std::string file = PathResolverFindCalibFile("egammaLayerRecalibTool/v1/egammaLayerRecalibTunes.root");
883  TFile f(file.c_str());
884  TH1* histo_ps_tot_error = checked_cast<TH1*>(f.Get("hPS_2010"));
886  new GetAmountHisto1D(*histo_ps_tot_error));
887  }
888  else if ("ps_2010_v3_down" == tune) {
889  const std::string file = PathResolverFindCalibFile("egammaLayerRecalibTool/v1/egammaLayerRecalibTunes.root");
890  TFile f(file.c_str());
891  TH1* histo_ps_tot_error = checked_cast<TH1*>(f.Get("hPS_2010"));
893  new GetAmountHisto1DUp(*histo_ps_tot_error));
894  }
895  else if ("ps_2010_v3_up" == tune) {
896  const std::string file = PathResolverFindCalibFile("egammaLayerRecalibTool/v1/egammaLayerRecalibTunes.root");
897  TFile f(file.c_str());
898  TH1* histo_ps_tot_error = checked_cast<TH1*>(f.Get("hPS_2010"));
900  new GetAmountHisto1DDown(*histo_ps_tot_error));
901  }
902  else if ("ps_2010_v3_errdown" == tune){
903  const std::string file = PathResolverFindCalibFile("egammaLayerRecalibTool/v1/egammaLayerRecalibTunes.root");
904  TFile f(file.c_str());
905  TH1* histo_ps_tot_error = checked_cast<TH1*>(f.Get("hPS_2010"));
907  new GetAmountHisto1DErrorUp(*histo_ps_tot_error));
908  }
909  else if ("ps_2010_v3_errup" == tune){
910  const std::string file = PathResolverFindCalibFile("egammaLayerRecalibTool/v1/egammaLayerRecalibTunes.root");
911  TFile f(file.c_str());
912  TH1* histo_ps_tot_error = checked_cast<TH1*>(f.Get("hPS_2010"));
914  new GetAmountHisto1DErrorDown(*histo_ps_tot_error));
915  }
916  else {
917  throw std::runtime_error(tune+" is not a valid tune");
918  }
919 }
920 
921 egammaLayerRecalibTool::egammaLayerRecalibTool(const std::string& name, const std::string& tune, int SaccEnable)
922  : asg::AsgMessaging(name), m_tune(tune), m_doSaccCorrections(SaccEnable)
923 {
924  add_scale(tune);
925 }
926 
927 
928 egammaLayerRecalibTool::egammaLayerRecalibTool(const std::string& tune, int SaccEnable)
929  : egammaLayerRecalibTool("egammaLayerRecalibTool", tune, SaccEnable) { }
930 
931 
933 {
934  m_modifiers.emplace_back(modifier, amount);
935 }
936 
938 {
940  for (const auto& modifier : m_modifiers) {
941  const float amount = (*modifier.second)(inputs);
942  const auto s = (*modifier.first)(inputs, amount);
943  ATH_MSG_DEBUG(" after E0|E1|E2|E3 = " << inputs.E0raw << "|" << inputs.E1raw << "|" << inputs.E2raw << "|" << inputs.E3raw);
944  if (s != CP::CorrectionCode::Ok) {
946  }
947  }
948  return status;
949 }
950 
952 {
953  const xAOD::CaloCluster* cluster = particle.caloCluster();
954  if (!cluster) {
955  ATH_MSG_ERROR("egamma particle without CaloCluster");
957  }
958 
959  std::string fixT = "";
960  double addE2 = 0, addE3 = 0;
961  if (m_aodFixMissingCells &&
962  event_info.runNumber() > m_Run2Run3runNumberTransition) {
963  fixT = "_egFixForTopoTimingCut";
964  unsigned short stat =
966  if (stat) {
967  ATH_MSG_WARNING("Fix for missing cells required"
968  " but some layer info is not available,"
969  " from L2 : " << stat%2 << " from L3 : " << stat/2);
970  }
971  }
972 
973  double eta_calo;
974  static const SG::AuxElement::Accessor<float> accEtaCalo("etaCalo");
976  eta_calo = cluster->eta();
977  }
978  else if (cluster->retrieveMoment(xAOD::CaloCluster::ETACALOFRAME, eta_calo)){
979 
980  }
981  else if (accEtaCalo.isAvailable(*cluster)) {
982  eta_calo = accEtaCalo(*cluster);
983  }
984  else{
985  ATH_MSG_ERROR("etaCalo not available as auxilliary variable,"
986  " using cluster eta as eta calo!");
987  eta_calo=cluster->eta();
988  }
989 
991  event_info.averageInteractionsPerCrossing(),
992  event_info.runNumber(),
993  cluster->eta(),
994  cluster->phi(),
995  cluster->energyBE(0),
996  cluster->energyBE(1),
997  cluster->energyBE(2) + addE2,
998  cluster->energyBE(3) + addE3,
999  eta_calo };
1000 
1001  bool isData = !event_info.eventType(xAOD::EventInfo::IS_SIMULATION);
1003  if (isData || m_scaleMC)
1005 
1006  static const SG::AuxElement::Decorator<double> deco_E0("correctedcl_Es0");
1007  static const SG::AuxElement::Decorator<double> deco_E1("correctedcl_Es1");
1008  static const SG::AuxElement::Decorator<double> deco_E2("correctedcl_Es2");
1009  static const SG::AuxElement::Decorator<double> deco_E3("correctedcl_Es3");
1011  deco_layer_correction("layer_correction");
1012 
1013  if (status == CP::CorrectionCode::Ok) {
1014  ATH_MSG_DEBUG("decorating cluster with corrected layer energies");
1015  deco_E0(*cluster) = m_doPSCorrections ?
1016  inputs.E0raw : cluster->energyBE(0);
1017  deco_E1(*cluster) = m_doS12Corrections or m_doSaccCorrections ?
1018  inputs.E1raw : cluster->energyBE(1);
1019  deco_E2(*cluster) = m_doS12Corrections or m_doSaccCorrections ?
1020  inputs.E2raw : cluster->energyBE(2) + addE2;
1021  deco_E3(*cluster) = m_doSaccCorrections ?
1022  inputs.E3raw : cluster->energyBE(3) + addE3;
1023  deco_layer_correction(*cluster) = isData ? m_tune+fixT : fixT;
1024  return status;
1025  }
1026 
1027  ATH_MSG_DEBUG("cannot correct layer energies:"
1028  " decorating particle with non-corrected layer energies");
1029  // this is done for safety, since when a particle is decorated
1030  // all the particle in the container are decorated
1031  // it is not possible to distinguish between decorated / non-decorated
1032  // since all are decorated
1033  deco_E0(*cluster) = cluster->energyBE(0);
1034  deco_E1(*cluster) = cluster->energyBE(1);
1035  deco_E2(*cluster) = cluster->energyBE(2) + addE2;
1036  deco_E3(*cluster) = cluster->energyBE(3) + addE3;
1037  deco_layer_correction(*cluster) = isData ? m_tune + "_Err" + fixT : fixT;
1038  return status;
1039 
1040 }
1041 
1042 
1044 {
1045  for (auto modifier : m_modifiers) {
1046  delete modifier.first;
1047  delete modifier.second;
1048  }
1049  m_modifiers.clear();
1050 }
1051 
1052 
1053 // helper
1054 std::map<std::string, std::string> parse(const std::string& list)
1055 {
1056  std::cout << "list: '" << list << "'" << std::endl;
1057  std::map<std::string, std::string> result;
1058  TIter next(TString(list).Tokenize(","));
1059  while (TObjString* sObj = (TObjString*) next())
1060  {
1061  const TString& item(sObj->GetString());
1062  std::cout << "item: '" << item << "'" << std::endl;
1063  TObjArray* item_list = TString(item).Tokenize(":");
1064  std::string key;
1065  std::string value;
1066  if (item_list->GetEntries() == 1) {
1067  key = "amount";
1068  value = static_cast<TObjString*>(item_list->At(0))->GetString().Data();
1069  }
1070  else if (item_list->GetEntries() == 2) {
1071  key = static_cast<TObjString*>(item_list->At(0))->GetString().Data();
1072  value = static_cast<TObjString*>(item_list->At(1))->GetString().Data();
1073  }
1074  else {
1075  std::cerr << "invalid string " << item << std::endl;
1076  }
1077  if (result.find(key) != result.end()) {
1078  std::cerr << "trying to insert two times key " << key << std::endl;
1079  assert(false);
1080  }
1081  result.insert(std::make_pair(key, value));
1082  }
1083  return result;
1084 }
1085 
1086 
1087 std::pair<std::string, egammaLayerRecalibTool*>
1088 egammaLayerRecalibTool::create(const std::string& type, const std::string& args)
1089 {
1090  std::map<std::string, std::string> args_map = parse(args);
1091  egammaLayerRecalibTool* tool = new egammaLayerRecalibTool("egammaLayerRecalibTool", "");
1092  std::string name = "";
1093  std::string amount_name = "";
1094  std::string type_name = "";
1095 
1096  GetAmountBase* amount_getter = nullptr;
1097  InputModifier* modifier = nullptr;
1098 
1099  if (args_map.find("amount") != args_map.end()) {
1100  std::string amount_str = args_map["amount"];
1101  bool perc = false;
1102  if (amount_str.back()=='%') {
1103  perc = true;
1104  amount_str.pop_back();
1105  }
1106  const float amount = TString(amount_str).Atof() * (perc ? 0.01 : 1);
1107 
1108  amount_getter = new GetAmountFixed(amount);
1109  std::stringstream amount_stream;
1110  amount_stream << amount;
1111  amount_name = amount_stream.str();
1112  std::replace(amount_name.begin(), amount_name.end(), '-', 'n');
1113  std::replace(amount_name.begin(), amount_name.end(), '.', 'p');
1114  }
1115  else if (args_map.find("name") != args_map.end()) {
1116  name = args_map["name"];
1117  }
1118  else if (args_map.find("histo") != args_map.end()) {
1119  int dim = 0;
1120  if (args_map.find("file") == args_map.end()) {
1121  std::cerr << "with histo you must specify file" << std::endl;
1122  assert(false);
1123  }
1124  if (args_map.find("formulax") != args_map.end()) dim = 1;
1125 
1126  if (dim == 0)
1127  {
1128  std::cerr << "with histo you must specify formulax" << std::endl;
1129  assert(false);
1130  }
1131  if (dim == 1) {
1132  TFile f(args_map["file"].c_str());
1133  std::cout << "opening histo " << args_map["histo"] << " from file " << args_map["file"] << std::endl;
1134  TH1F* histo = dynamic_cast<TH1F*>(f.Get(args_map["histo"].c_str()));
1135 
1136  if(histo){
1137  histo->SetDirectory(nullptr);
1138  amount_getter = new GetAmountHisto1D(*histo);
1139  }
1140  else{assert(false); }
1141  }
1142  else { assert(false); }
1143  }
1144  else {
1145  std::cerr << "cannot understand argument " << args << std::endl;
1146  assert(false);
1147  }
1148 
1149  if ("bias-E0" == type) { modifier = new ScaleE0(InputModifier::ZEROBASED); type_name = "E0"; }
1150  else if ("bias-E1" == type) { modifier = new ScaleE1(InputModifier::ZEROBASED); type_name = "E1"; }
1151  else if ("bias-E2" == type) { modifier = new ScaleE2(InputModifier::ZEROBASED); type_name = "E2"; }
1152  else if ("bias-E3" == type) { modifier = new ScaleE3(InputModifier::ZEROBASED); type_name = "E3"; }
1153  else if ("bias-E1overE2" == type) { modifier = new ScaleE1overE2(InputModifier::ZEROBASED); type_name = "E1overE2"; }
1154  else if ("bias-Eaccordion" == type) { modifier = new ScaleEaccordion(InputModifier::ZEROBASED); type_name = "Eaccordion"; }
1155  else if ("bias-Ecalorimeter" == type) { modifier = new ScaleEcalorimeter(InputModifier::ZEROBASED); type_name = "Ecalorimeter"; }
1156 
1157  if (not type_name.empty() and not amount_name.empty()) {
1158  name = type_name + "_" + amount_name;
1159  }
1160 
1161  if (name.empty()) {
1162  std::cerr << "you need to specify a name for the bias with type " << type << std::endl;
1163  }
1164 
1165  if (modifier and amount_getter) {
1166  tool->add_scale(modifier, amount_getter);
1167  }
1168  else{
1169  tool->add_scale(type);
1170  //release resources, if modifier false need to release amount_getter and vice versa
1171  //since they are not passed to the tool
1172  if(modifier) delete modifier;
1173  if(amount_getter) delete amount_getter;
1174  }
1175 
1176  return {name, tool};
1177 }
xAOD::CaloCluster_v1::phi
virtual double phi() const
The azimuthal angle ( ) of the particle.
Definition: CaloCluster_v1.cxx:256
InputModifier::SCALE
@ SCALE
Definition: egammaLayerRecalibTool.h:231
corr_HV_EMBPS::getCorr
float getCorr(int run, float eta, float phi) const
get correction factor to apply to raw EMBPS energy : corrected raw EMBPS energy = correction factor *...
Definition: corr_HV_EMBPS.cxx:45
replace
std::string replace(std::string s, const std::string &s2, const std::string &s3)
Definition: hcg.cxx:307
GetAmountHVPSGuillaume
Definition: egammaLayerRecalibTool.h:71
xAOD::EgammaHelpers::energyInMissingCells
unsigned short energyInMissingCells(const xAOD::Egamma &eg, double &e2, double &e3)
Get the energies in sampling 2 and 3 that are in cells rejected by the topo-cluster timing cut but th...
Definition: EgammaxAODHelpers.cxx:176
GetAmountPileupE3
Definition: egammaLayerRecalibTool.h:114
GetAmountHVPSGuillaume::m_tool
corr_HV_EMBPS m_tool
Definition: egammaLayerRecalibTool.h:74
Trk::ParticleSwitcher::particle
constexpr ParticleHypothesis particle[PARTICLEHYPOTHESES]
the array of masses
Definition: ParticleHypothesis.h:76
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
yodamerge_tmp.dim
dim
Definition: yodamerge_tmp.py:239
get_generator_info.result
result
Definition: get_generator_info.py:21
GetAmountHisto1D::operator()
virtual float operator()(const StdCalibrationInputs &input) const
Definition: egammaLayerRecalibTool.cxx:55
ScaleE3::shift_inputs
virtual void shift_inputs(StdCalibrationInputs &, float amount) const
Definition: egammaLayerRecalibTool.cxx:154
egammaLayerRecalibTool::m_aodFixMissingCells
bool m_aodFixMissingCells
Definition: egammaLayerRecalibTool.h:376
egammaLayerRecalibTool::m_pileup_tool
corr_pileupShift * m_pileup_tool
Definition: egammaLayerRecalibTool.h:374
InputModifier::ZEROBASED
@ ZEROBASED
Definition: egammaLayerRecalibTool.h:231
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
InputModifier::SHIFT
@ SHIFT
Definition: egammaLayerRecalibTool.h:231
SG::Accessor
Helper class to provide type-safe access to aux data.
Definition: Control/AthContainers/AthContainers/Accessor.h:68
GetAmountPileupE2::operator()
virtual float operator()(const StdCalibrationInputs &inputs) const
Definition: egammaLayerRecalibTool.cxx:121
GetAmountBase
Definition: egammaLayerRecalibTool.h:62
max
constexpr double max()
Definition: ap_fixedTest.cxx:33
NNPDF30NNLO.tune
tune
Definition: GeneratorFilters/share/common/NNPDF30NNLO.py:1
GetAmountPileupE0::m_tool
corr_pileupShift * m_tool
Definition: egammaLayerRecalibTool.h:91
GetAmountFixed::operator()
virtual float operator()(const StdCalibrationInputs &input) const
Definition: egammaLayerRecalibTool.cxx:97
parse
std::map< std::string, std::string > parse(const std::string &list)
Definition: egammaLayerRecalibTool.cxx:1054
asg
Definition: DataHandleTestTool.h:28
GetAmountPileupE2::m_tool
corr_pileupShift * m_tool
Definition: egammaLayerRecalibTool.h:109
bin
Definition: BinsDiffFromStripMedian.h:43
egammaLayerRecalibTool::scale_inputs
CP::CorrectionCode scale_inputs(StdCalibrationInputs &inputs) const
apply layer calibration to the
Definition: egammaLayerRecalibTool.cxx:937
athena.value
value
Definition: athena.py:124
ScaleE0::shift_inputs
virtual void shift_inputs(StdCalibrationInputs &, float amount) const
Definition: egammaLayerRecalibTool.cxx:151
GetAmountHVEMECPS207::operator()
virtual float operator()(const StdCalibrationInputs &input) const
Definition: egammaLayerRecalibTool.cxx:109
GetAmountPileupE2
Definition: egammaLayerRecalibTool.h:105
xAOD::Egamma_v1
Definition: Egamma_v1.h:56
egammaLayerRecalibTool::applyCorrection
CP::CorrectionCode applyCorrection(xAOD::Egamma &, const xAOD::EventInfo &event_info) const
Definition: egammaLayerRecalibTool.cxx:951
GetAmountPileupE1::operator()
virtual float operator()(const StdCalibrationInputs &inputs) const
Definition: egammaLayerRecalibTool.cxx:117
xAOD::EgammaParameters::AuthorFwdElectron
const uint16_t AuthorFwdElectron
Electron reconstructed by the Forward cluster-based algorithm.
Definition: EgammaDefs.h:30
GetAmountHisto1DUp::operator()
virtual float operator()(const StdCalibrationInputs &input) const
Definition: egammaLayerRecalibTool.cxx:61
GetAmountFormula::operator()
virtual float operator()(const StdCalibrationInputs &input) const
Definition: egammaLayerRecalibTool.cxx:101
dbg::ptr
void * ptr(T *p)
Definition: SGImplSvc.cxx:74
corr_pileupShift
Correction for pileup induced energy shit as function of mu per layer for 2016 data.
Definition: corr_pileupShift.h:13
InputModifier::shift_inputs
virtual void shift_inputs(StdCalibrationInputs &, float amount) const =0
xAOD::EventInfo_v1::IS_SIMULATION
@ IS_SIMULATION
true: simulation, false: data
Definition: EventInfo_v1.h:151
ScaleE3
Definition: egammaLayerRecalibTool.h:277
python.TrigEgammaMonitorHelper.TH2F
def TH2F(name, title, nxbins, bins_par2, bins_par3, bins_par4, bins_par5=None, bins_par6=None, path='', **kwargs)
Definition: TrigEgammaMonitorHelper.py:45
GetAmountHisto2DEtaCaloRunNumber
Definition: egammaLayerRecalibTool.h:196
ScaleE1overE2::scale_inputs
virtual void scale_inputs(StdCalibrationInputs &, float amount) const
Definition: egammaLayerRecalibTool.cxx:157
GetAmountHisto2D::m_histo
TH2F m_histo
Definition: egammaLayerRecalibTool.h:191
InputModifier::SUBTRACT
@ SUBTRACT
Definition: egammaLayerRecalibTool.h:231
postInclude.inputs
inputs
Definition: postInclude.SortInput.py:15
GetAmountFixed::m_amount
float m_amount
Definition: egammaLayerRecalibTool.h:212
GetAmountPileupE1::m_tool
corr_pileupShift * m_tool
Definition: egammaLayerRecalibTool.h:100
xAOD::EventInfo_v1::runNumber
uint32_t runNumber() const
The current event's run number.
GetAmountHisto2DEtaCaloRunNumber::m_histo
TH2F m_histo
Definition: egammaLayerRecalibTool.h:201
ScaleE1::shift_inputs
virtual void shift_inputs(StdCalibrationInputs &, float amount) const
Definition: egammaLayerRecalibTool.cxx:152
InputModifier::ONEBASED_ALPHA
@ ONEBASED_ALPHA
Definition: egammaLayerRecalibTool.h:231
GetAmountHisto1DErrorDown
Definition: egammaLayerRecalibTool.h:178
ScaleE0
Definition: egammaLayerRecalibTool.h:247
PyPoolBrowser.item
item
Definition: PyPoolBrowser.py:129
GetAmountHisto2DEtaCaloRunNumber::operator()
virtual float operator()(const StdCalibrationInputs &input) const
Definition: egammaLayerRecalibTool.cxx:91
CP::CorrectionCode::OutOfValidityRange
@ OutOfValidityRange
Input object is out of validity range.
Definition: CorrectionCode.h:37
CP::CorrectionCode::Error
@ Error
Some error happened during the object correction.
Definition: CorrectionCode.h:36
ScaleEcalorimeter
Definition: egammaLayerRecalibTool.h:307
xAOD::CaloCluster_v1
Description of a calorimeter cluster.
Definition: CaloCluster_v1.h:59
EgammaxAODHelpers.h
GetAmountHisto1DDown::operator()
virtual float operator()(const StdCalibrationInputs &input) const
Definition: egammaLayerRecalibTool.cxx:67
egammaLayerRecalibTool::m_modifiers
ModifiersList m_modifiers
Definition: egammaLayerRecalibTool.h:372
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
InputModifier::ONEBASED
@ ONEBASED
Definition: egammaLayerRecalibTool.h:231
convertTimingResiduals.sum
sum
Definition: convertTimingResiduals.py:55
corr_pileupShift::getCorr
float getCorr(int layer, int run, float mu, float eta) const
get shift to subtract to raw layer energy : corrected layer energy = raw energy - shift
Definition: corr_pileupShift.cxx:37
GetAmountPileupE0::operator()
virtual float operator()(const StdCalibrationInputs &inputs) const
Definition: egammaLayerRecalibTool.cxx:113
SG::Decorator
Helper class to provide type-safe access to aux data.
Definition: Decorator.h:59
fillPileUpNoiseLumi.next
next
Definition: fillPileUpNoiseLumi.py:52
xAOD::CaloCluster_v1::eta
virtual double eta() const
The pseudorapidity ( ) of the particle.
Definition: CaloCluster_v1.cxx:251
GetAmountPileupE1
Definition: egammaLayerRecalibTool.h:96
GetAmountPileupE3::m_tool
corr_pileupShift * m_tool
Definition: egammaLayerRecalibTool.h:118
egammaLayerRecalibTool::egammaLayerRecalibTool
egammaLayerRecalibTool(const std::string &name, const std::string &tune, int SaccEnable=1)
Definition: egammaLayerRecalibTool.cxx:921
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
GetAmountPileupE3::operator()
virtual float operator()(const StdCalibrationInputs &inputs) const
Definition: egammaLayerRecalibTool.cxx:125
GetAmountFormula
Definition: egammaLayerRecalibTool.h:125
GetAmountFixed
Definition: egammaLayerRecalibTool.h:206
PlotPulseshapeFromCool.input
input
Definition: PlotPulseshapeFromCool.py:106
egammaLayerRecalibTool::clear_corrections
void clear_corrections()
remove all the scale corrections
Definition: egammaLayerRecalibTool.cxx:1043
ScaleE2::scale_inputs
virtual void scale_inputs(StdCalibrationInputs &, float amount) const
Definition: egammaLayerRecalibTool.cxx:148
file
TFile * file
Definition: tile_monitor.h:29
egammaLayerRecalibTool.h
hist_file_dump.f
f
Definition: hist_file_dump.py:135
xAOD::CaloCluster_v1::retrieveMoment
bool retrieveMoment(MomentType type, double &value) const
Retrieve individual moment.
Definition: CaloCluster_v1.cxx:738
histSizes.list
def list(name, path='/')
Definition: histSizes.py:38
egammaLayerRecalibTool::m_scaleMC
bool m_scaleMC
Definition: egammaLayerRecalibTool.h:377
InputModifier::ZEROBASED_ALPHA
@ ZEROBASED_ALPHA
Definition: egammaLayerRecalibTool.h:231
GetAmountHVEMECPS207
Definition: egammaLayerRecalibTool.h:79
beamspotman.stat
stat
Definition: beamspotman.py:266
ScaleE1
Definition: egammaLayerRecalibTool.h:257
egammaLayerRecalibTool::m_doPSCorrections
bool m_doPSCorrections
Definition: egammaLayerRecalibTool.h:367
egammaLayerRecalibTool::m_doSaccCorrections
bool m_doSaccCorrections
Definition: egammaLayerRecalibTool.h:369
egammaLayerRecalibTool::m_Run2Run3runNumberTransition
static const unsigned int m_Run2Run3runNumberTransition
Definition: egammaLayerRecalibTool.h:364
xAOD::EventInfo_v1::averageInteractionsPerCrossing
float averageInteractionsPerCrossing() const
Average interactions per crossing for all BCIDs - for out-of-time pile-up.
Definition: EventInfo_v1.cxx:397
PathResolver.h
InputModifier
Definition: egammaLayerRecalibTool.h:230
ScaleEaccordion::shift_inputs
virtual void shift_inputs(StdCalibrationInputs &, float amount) const
Definition: egammaLayerRecalibTool.cxx:186
egammaLayerRecalibTool::add_scale
void add_scale(InputModifier *modifier, GetAmountBase *amount)
add custom layer scale correction.
Definition: egammaLayerRecalibTool.cxx:932
ScaleE1::scale_inputs
virtual void scale_inputs(StdCalibrationInputs &, float amount) const
Definition: egammaLayerRecalibTool.cxx:147
GetAmountHisto1DErrorUp
Definition: egammaLayerRecalibTool.h:170
ScaleE3::scale_inputs
virtual void scale_inputs(StdCalibrationInputs &, float amount) const
Definition: egammaLayerRecalibTool.cxx:149
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:225
egammaLayerRecalibTool::add_scale
void add_scale(const std::string &scale)
add scale correction from string.
Definition: egammaLayerRecalibTool.cxx:247
AtlCoolConsole.tool
tool
Definition: AtlCoolConsole.py:453
GetAmountPileupE0
Definition: egammaLayerRecalibTool.h:87
ScaleE2::shift_inputs
virtual void shift_inputs(StdCalibrationInputs &, float amount) const
Definition: egammaLayerRecalibTool.cxx:153
pool::Tokenize
void Tokenize(const std::string &str, std::vector< std::string > &tokens, const std::string &delimiters=" ")
GetAmountHisto1D
Definition: egammaLayerRecalibTool.h:135
InputModifier::scale_inputs
virtual void scale_inputs(StdCalibrationInputs &, float amount) const =0
item
Definition: ItemListSvc.h:43
make_hlt_rep.modifier
string modifier
Definition: make_hlt_rep.py:14
GetAmountHVPSGuillaume::operator()
virtual float operator()(const StdCalibrationInputs &input) const
Definition: egammaLayerRecalibTool.cxx:105
GetAmountHisto1DErrorDown::operator()
virtual float operator()(const StdCalibrationInputs &input) const
Definition: egammaLayerRecalibTool.cxx:79
xAOD::EventInfo_v1
Class describing the basic event information.
Definition: EventInfo_v1.h:43
PathResolverFindCalibFile
std::string PathResolverFindCalibFile(const std::string &logical_file_name)
Definition: PathResolver.cxx:431
egammaLayerRecalibTool
Definition: egammaLayerRecalibTool.h:317
CP::CorrectionCode::Ok
@ Ok
The correction was done successfully.
Definition: CorrectionCode.h:38
GetAmountHisto1DErrorUp::operator()
virtual float operator()(const StdCalibrationInputs &input) const
Definition: egammaLayerRecalibTool.cxx:73
ScaleEaccordion
Definition: egammaLayerRecalibTool.h:297
ScaleEcalorimeter::scale_inputs
virtual void scale_inputs(StdCalibrationInputs &, float amount) const
Definition: egammaLayerRecalibTool.cxx:193
StdCalibrationInputs
Name : egammaLayerRecalibTool.h Package : egammaLayerRecalibTool Author : R.
Definition: egammaLayerRecalibTool.h:47
ScaleE1overE2
Definition: egammaLayerRecalibTool.h:287
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
egammaLayerRecalibTool::resolve_alias
static std::string resolve_alias(const std::string &tune)
Definition: egammaLayerRecalibTool.cxx:209
egammaLayerRecalibTool::create
static std::pair< std::string, egammaLayerRecalibTool * > create(const std::string &type, const std::string &args)
helper to create a tool from a string (useful for command line arguments)
Definition: egammaLayerRecalibTool.cxx:1088
ScaleE2
Definition: egammaLayerRecalibTool.h:267
CP::CorrectionCode
Return value from object correction CP tools.
Definition: CorrectionCode.h:31
xAOD::CaloCluster_v1::energyBE
float energyBE(const unsigned layer) const
Get the energy in one layer of the EM Calo.
Definition: CaloCluster_v1.cxx:630
ScaleE0::scale_inputs
virtual void scale_inputs(StdCalibrationInputs &, float amount) const
Definition: egammaLayerRecalibTool.cxx:146
InputModifier::m_base
NullPoint m_base
Definition: egammaLayerRecalibTool.h:242
egammaLayerRecalibTool::m_doS12Corrections
bool m_doS12Corrections
Definition: egammaLayerRecalibTool.h:368
ScaleEcalorimeter::shift_inputs
virtual void shift_inputs(StdCalibrationInputs &, float amount) const
Definition: egammaLayerRecalibTool.cxx:201
SG::ConstAccessor< T, AuxAllocator_t< T > >::isAvailable
bool isAvailable(const ELT &e) const
Test to see if this variable exists in the store.
merge.status
status
Definition: merge.py:17
corr_HV_EMECPS::getCorr
float getCorr(int run, float eta, float phi) const
get correction factor to apply to raw EMECPS energy : corrected raw EMECPS energy = correction factor...
Definition: corr_HV_EMECPS.cxx:41
python.TrigEgammaMonitorHelper.TH1F
def TH1F(name, title, nxbins, bins_par2, bins_par3=None, path='', **kwargs)
Definition: TrigEgammaMonitorHelper.py:24
ScaleEaccordion::scale_inputs
virtual void scale_inputs(StdCalibrationInputs &, float amount) const
Definition: egammaLayerRecalibTool.cxx:179
GetAmountHisto1DDown
Definition: egammaLayerRecalibTool.h:162
InputModifier::operator()
CP::CorrectionCode operator()(StdCalibrationInputs &, float amount) const
Definition: egammaLayerRecalibTool.cxx:130
GetAmountHisto1DUp
Definition: egammaLayerRecalibTool.h:154
egammaLayerRecalibTool::m_tune
std::string m_tune
Definition: egammaLayerRecalibTool.h:366
GetAmountHisto2D::operator()
virtual float operator()(const StdCalibrationInputs &input) const
Definition: egammaLayerRecalibTool.cxx:85
xAOD::CaloCluster_v1::ETACALOFRAME
@ ETACALOFRAME
Eta in the calo frame (for egamma)
Definition: CaloCluster_v1.h:187
plotBeamSpotCompare.histo
histo
Definition: plotBeamSpotCompare.py:415
python.PyAthena.obj
obj
Definition: PyAthena.py:132
GetAmountHVEMECPS207::m_toolEMECPS
corr_HV_EMECPS m_toolEMECPS
Definition: egammaLayerRecalibTool.h:82
ScaleE1overE2::shift_inputs
virtual void shift_inputs(StdCalibrationInputs &, float amount) const
Definition: egammaLayerRecalibTool.cxx:173
GetAmountFormula::m_formula
TFormula m_formula
Definition: egammaLayerRecalibTool.h:130
GetAmountHisto1D::m_histo
std::unique_ptr< TH1 > m_histo
Definition: egammaLayerRecalibTool.h:149
keylayer_zslicemap.perc
perc
Definition: keylayer_zslicemap.py:62
python.CaloScaleNoiseConfig.args
args
Definition: CaloScaleNoiseConfig.py:80
xAOD::EventInfo_v1::eventType
bool eventType(EventType type) const
Check for one particular bitmask value.
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37