16#include <TObjString.h>
24const float VALUE_OVERFLOW = std::numeric_limits<float>::max();
26template <
typename TargetPtr,
typename SourcePtr>
27TargetPtr checked_cast(SourcePtr ptr) {
29 static_assert(std::is_pointer<TargetPtr>::value,
30 "attempt to cast to no ptr object");
31 static_assert(std::is_pointer<SourcePtr>::value,
32 "attempt to cast from no ptr object");
36 throw std::runtime_error(
37 "Attempt to cast from nullptr in egammaLayerRecalibTool");
41 TargetPtr
obj =
dynamic_cast<TargetPtr
>(
ptr);
43 throw std::runtime_error(
"failed dynamic cast for " +
44 std::string(
ptr->GetName()) +
45 " in egammaLayerRecalibTool");
54 const int bin =
m_histo->FindFixBin(input.eta);
60 const int bin =
m_histo->FindFixBin(input.eta);
66 const int bin =
m_histo->FindFixBin(input.eta);
72 const int bin =
m_histo->FindFixBin(input.eta);
78 const int bin =
m_histo->FindFixBin(input.eta);
84 const int bin =
m_histo.FindFixBin(input.eta, input.phi);
90 const int bin =
m_histo.FindFixBin(input.etaCalo, input.RunNumber);
100 return m_formula.Eval(input.eta, input.phi, input.RunNumber);
104 return m_tool.getCorr(input.RunNumber, input.eta, input.phi);
108 return m_toolEMECPS.getCorr(input.RunNumber, input.eta, input.phi);
112 return m_tool->getCorr(0, input.RunNumber, input.averageInteractionsPerCrossing, input.eta);
116 return m_tool->getCorr(1, input.RunNumber, input.averageInteractionsPerCrossing, input.eta);
120 return m_tool->getCorr(2, input.RunNumber, input.averageInteractionsPerCrossing, input.eta);
124 return m_tool->getCorr(3, input.RunNumber, input.averageInteractionsPerCrossing, input.eta);
157 const double Es1 = inputs.E1raw;
158 const double Es2 = inputs.E2raw;
159 if (Es1 == 0 and Es2 == 0) {
164 const double sum = Es1 + Es2;
165 const double alpha = amount;
166 const double den = (alpha * Es1 + Es2);
167 inputs.E1raw = alpha * Es1 * sum / den;
168 inputs.E2raw = Es2 * sum / den;
174 throw std::runtime_error(
"not implemented");
179 inputs.E1raw *= amount;
180 inputs.E2raw *= amount;
181 inputs.E3raw *= amount;
186 inputs.E1raw += amount;
187 inputs.E2raw += amount;
188 inputs.E3raw += amount;
193 inputs.E0raw *= amount;
194 inputs.E1raw *= amount;
195 inputs.E2raw *= amount;
196 inputs.E3raw *= amount;
201 inputs.E0raw += amount;
202 inputs.E1raw += amount;
203 inputs.E2raw += amount;
204 inputs.E3raw += amount;
209 if (
"layer1_2012" == tune)
return "layer1_2012_v5";
210 if (
"layer1_alt_2012" == tune)
return "layer1_alt_2012_v5";
211 if (
"layer1_2011" == tune)
return "layer1_2011_v5";
212 if (
"layer1_alt_2011" == tune)
return "layer1_alt_2011_v5";
213 if (
"layer1_2010" == tune)
return "layer1_2010_v5";
214 if (
"ps_2012" == tune)
return "ps_2012_v3";
215 if (
"ps_2011" == tune)
return "ps_2011_v3";
216 if (
"ps_2010" == tune)
return "ps_2010_v3";
217 if (
"layer1_2012_up" == tune)
return "layer1_2012_v5_up";
218 if (
"layer1_2012_down" == tune)
return "layer1_2012_v5_down";
219 if (
"layer1_2012_errup" == tune)
return "layer1_2012_v5_errup";
220 if (
"layer1_2012_errdown" == tune)
return "layer1_2012_v5_errdown";
221 if (
"layer1_2011_up" == tune)
return "layer1_2011_v5_up";
222 if (
"layer1_2011_down" == tune)
return "layer1_2011_v5_down";
223 if (
"layer1_2011_errup" == tune)
return "layer1_2011_v5_errup";
224 if (
"layer1_2011_errdown" == tune)
return "layer1_2011_v5_errdown";
225 if (
"layer1_2010_up" == tune)
return "layer1_2010_v5_up";
226 if (
"layer1_2010_down" == tune)
return "layer1_2010_v5_down";
227 if (
"layer1_2010_errup" == tune)
return "layer1_2010_v5_errup";
228 if (
"layer1_2010_errdown" == tune)
return "layer1_2010_v5_errdown";
229 if (
"ps_2012_up" == tune)
return "ps_2012_v3_up";
230 if (
"ps_2012_down" == tune)
return "ps_2012_v3_down";
231 if (
"ps_2012_errup" == tune)
return "ps_2012_v3_errup";
232 if (
"ps_2012_errdown" == tune)
return "ps_2012_v3_errdown";
233 if (
"ps_2011_up" == tune)
return "ps_2011_v3_up";
234 if (
"ps_2011_down" == tune)
return "ps_2011_v3_down";
235 if (
"ps_2011_errup" == tune)
return "ps_2011_v3_errup";
236 if (
"ps_2011_errdown" == tune)
return "ps_2011_v3_errdown";
237 if (
"ps_2010_up" == tune)
return "ps_2010_v3_up";
238 if (
"ps_2010_down" == tune)
return "ps_2010_v3_down";
239 if (
"ps_2010_errup" == tune)
return "ps_2010_v3_errup";
240 if (
"ps_2010_errdown" == tune)
return "ps_2010_v3_errdown";
250 if (tune.empty()) { }
251 else if (
"es2025_run3_extrapolate_gnn_v0" == tune) {
252 add_scale(
"run3_partial_ofc_extrapolate_gnn_v0");
254 else if (
"es2024_run3_extrapolate_v0" == tune) {
255 add_scale(
"run3_partial_ofc_extrapolate_v0");
258 else if (
"es2022_22.0_Precision_v1" == tune) {
259 add_scale(
"run2_alt_with_layer2_r22_Precision_v1");
261 else if (
"es2022_22.0_Precision" == tune) {
262 add_scale(
"run2_alt_with_layer2_r22_Precision");
264 else if (
"es2018_21.0_v0" == tune) {
265 add_scale(
"run2_alt_with_layer2_r21_v1");
267 else if (
"es2017_21.0_v0" == tune) {
268 add_scale(
"run2_alt_with_layer2_r21_v0");
270 else if (
"es2017_20.7_final" == tune) {
274 else if (
"es2017_20.7_improved" == tune) {
279 else if (
"pileup_20.7" == tune) {
287 else if (
"run3_partial_ofc_extrapolate_gnn_v0" == tune) {
288 add_scale(
"layer2_run3_ofc_extrapolate_v0");
292 else if (
"run3_partial_ofc_extrapolate_v0" == tune) {
293 add_scale(
"layer2_run3_ofc_extrapolate_v0");
298 else if (
"run2_alt_with_layer2_r22_Precision_v1"==tune) {
299 add_scale(
"layer2_alt_el_mu_comb_r21_v0_fix");
304 else if (
"run2_alt_with_layer2_r22_Precision"==tune) {
305 add_scale(
"layer2_alt_el_mu_comb_r21_v0");
309 else if (
"run2_alt_with_layer2_r21_v1"==tune) {
313 else if (
"run2_alt_with_layer2_r21_v0"==tune) {
317 else if(
"run2_alt_with_layer2_modif" == tune) {
323 else if (
"2012" == tune) {
328 else if(
"2012_with_layer2" == tune) {
333 else if (
"2012_alt" == tune) {
338 else if(
"2012_alt_with_layer2" == tune) {
343 else if(
"2012_alt_with_layer2_modif" == tune) {
349 else if(
"2010_with_layer2" == tune) {
353 else if (
"2012_layer1_up" == tune) {
358 else if (
"2012_layer1_down" == tune) {
363 else if (
"2012_layer1_errup" == tune) {
366 else if (
"2012_layer1_errdown" == tune) {
369 else if (
"2012_ps_down" == tune) {
374 else if (
"2012_ps_up" == tune) {
379 else if (
"2012_ps_errdown" == tune) {
382 else if (
"2012_ps_errup" == tune) {
385 else if (
"2012_up" == tune) {
390 else if (
"2012_down" == tune) {
395 else if (
"2012_errup" == tune) {
399 else if (
"2012_errdown" == tune) {
404 else if (
"2011" == tune) {
408 else if(
"2011_with_layer2" == tune) {
412 else if (
"2011_alt" == tune) {
416 else if(
"2011_alt_with_layer2" == tune) {
420 else if (
"2011_layer1_up" == tune) {
424 else if (
"2011_layer1_down" == tune) {
428 else if (
"2011_layer1_errup" == tune) {
431 else if (
"2011_layer1_errdown" == tune) {
434 else if (
"2011_ps_down" == tune) {
438 else if (
"2011_ps_up" == tune) {
442 else if (
"2011_ps_errdown" == tune) {
445 else if (
"2011_ps_errup" == tune) {
448 else if (
"2011_up" == tune) {
452 else if (
"2011_down" == tune) {
456 else if (
"2011_errup" == tune) {
460 else if (
"2011_errdown" == tune) {
465 else if (
"2010" == tune) {
469 else if (
"2010_layer1_up" == tune) {
473 else if (
"2010_layer1_down" == tune) {
477 else if (
"2010_layer1_errup" == tune) {
480 else if (
"2010_layer1_errdown" == tune) {
483 else if (
"2010_ps_down" == tune) {
487 else if (
"2010_ps_up" == tune) {
491 else if (
"2010_ps_errdown" == tune) {
494 else if (
"2010_ps_errup" == tune) {
497 else if (
"2010_up" == tune) {
501 else if (
"2010_down" == tune) {
505 else if (
"2010_errup" == tune) {
509 else if (
"2010_errdown" == tune) {
513 else if (
"ps_HV1" == tune) {
516 else if (
"ps_EMECHV1" == tune) {
519 else if (
"test1" == tune) {
520 TH1F h_presampler(
"h_presampler",
"h_presampler", 10, -2.5, 2.5);
523 for (
int ibin = 1; ibin <= 5; ++ibin) {
524 h_presampler.SetBinContent(ibin, -0.1);
525 h_presampler.SetBinContent(ibin + 5, 0.1);
530 else if (
"acc_zee_run3_gnn_v0" == tune){
532 TFile f(
file.c_str());
533 TH2F* histo_acc =
static_cast<TH2F*
>(f.Get(
"hACC_Zee_rel23_gnn"));
538 else if (
"acc_zee_run3_v0" == tune){
540 TFile f(
file.c_str());
541 TH2F* histo_acc =
static_cast<TH2F*
>(f.Get(
"hACC_Zee_rel23"));
547 else if (
"acc_zee_r22_v1" == tune) {
549 TFile f(
file.c_str());
550 TH2F* histo_acc =
static_cast<TH2F*
>(f.Get(
"hACC_Zee_rel22"));
555 else if (
"acc_zee_r22_v0" == tune) {
557 TFile f(
file.c_str());
558 TH2F* histo_acc =
static_cast<TH2F*
>(f.Get(
"hACC_Zee_rel22"));
563 else if (
"layer1_1" == tune) {
564 TFormula f(
"formula_layer1_1",
"(abs(x)<1.425) ? 0.97 : 1");
567 else if (
"layer1_2" == tune) {
568 TFormula f(
"formula_layer1_2",
"(abs(x)<1.425) ? 0.97 : 1.05");
571 else if (
"layer1_alt_2012_v5" == tune) {
573 TFile f(
file.c_str());
574 TH1* histo = checked_cast<TH1*>(f.Get(
"hE1E2ave_alt_2012"));
578 else if (
"layer1_2012_v5" == tune) {
580 TFile f(
file.c_str());
581 TH1* histo = checked_cast<TH1*>(f.Get(
"hE1E2ave_2012"));
585 else if (
"layer1_2012_v5_down" == tune) {
587 TFile f(
file.c_str());
588 TH1* histo = checked_cast<TH1*>(f.Get(
"hE1E2ave_2012"));
592 else if (
"layer1_2012_v5_up" == tune) {
594 TFile f(
file.c_str());
595 TH1* histo = checked_cast<TH1*>(f.Get(
"hE1E2ave_2012"));
599 else if (
"layer1_2012_v5_errdown" == tune) {
601 TFile f(
file.c_str());
602 TH1* histo = checked_cast<TH1*>(f.Get(
"hE1E2ave_2012"));
606 else if (
"layer1_2012_v5_errup" == tune) {
608 TFile f(
file.c_str());
609 TH1* histo = checked_cast<TH1*>(f.Get(
"hE1E2ave_2012"));
613 else if (
"layer1_alt_2011_v5" == tune) {
615 TFile f(
file.c_str());
616 TH1* histo = checked_cast<TH1*>(f.Get(
"hE1E2ave_alt_2011"));
620 else if (
"layer1_2011_v5" == tune) {
622 TFile f(
file.c_str());
623 TH1* histo = checked_cast<TH1*>(f.Get(
"hE1E2ave_2011"));
627 else if (
"layer1_2011_v5_down" == tune) {
629 TFile f(
file.c_str());
630 TH1* histo = checked_cast<TH1*>(f.Get(
"hE1E2ave_2011"));
634 else if (
"layer1_2011_v5_up" == tune) {
636 TFile f(
file.c_str());
637 TH1* histo = checked_cast<TH1*>(f.Get(
"hE1E2ave_2011"));
641 else if (
"layer1_2011_v5_errdown" == tune) {
643 TFile f(
file.c_str());
644 TH1* histo = checked_cast<TH1*>(f.Get(
"hE1E2ave_2011"));
648 else if (
"layer1_2011_v5_errup" == tune) {
650 TFile f(
file.c_str());
651 TH1* histo = checked_cast<TH1*>(f.Get(
"hE1E2ave_2011"));
655 else if (
"layer1_2010_v5" == tune) {
657 TFile f(
file.c_str());
658 TH1* histo = checked_cast<TH1*>(f.Get(
"hE1E2ave_2010"));
662 else if (
"layer1_2010_v5_down" == tune) {
664 TFile f(
file.c_str());
665 TH1* histo = checked_cast<TH1*>(f.Get(
"hE1E2ave_2010"));
669 else if (
"layer1_2010_v5_up" == tune) {
671 TFile f(
file.c_str());
672 TH1* histo = checked_cast<TH1*>(f.Get(
"hE1E2ave_2010"));
676 else if (
"layer1_2010_v5_errdown" == tune) {
678 TFile f(
file.c_str());
679 TH1* histo = checked_cast<TH1*>(f.Get(
"hE1E2ave_2010"));
683 else if (
"layer1_2010_v5_errup" == tune) {
685 TFile f(
file.c_str());
686 TH1* histo = checked_cast<TH1*>(f.Get(
"hE1E2ave_2010"));
690 else if (
"layer2_run3_ofc_extrapolate_v0"==tune){
692 TFile f(
file.c_str());
693 TH1D* histo =
static_cast<TH1D*
>(f.Get(
"hE1E2_emu_run2_rel21_v1_run3ofc"));
699 else if(
"layer2_alt_el_mu_comb_r21_v0_fix"==tune) {
701 TFile f(
file.c_str());
702 TH1D* histo =
static_cast<TH1D*
>(f.Get(
"hE1E2_emu_run2_rel21_v0_fix"));
707 else if(
"layer2_alt_el_mu_comb_r21_v0"==tune) {
709 TFile f(
file.c_str());
710 TH1D* histo =
static_cast<TH1D*
>(f.Get(
"hE1E2_emu_run2_rel21_v0"));
715 else if(
"layer2_alt_run2_r21_v1"==tune) {
717 TFile f(
file.c_str());
718 TH1* histo = checked_cast<TH1*>(f.Get(
"hE1E2_mu_run2_rel21_v1"));
722 else if(
"layer2_alt_run2_r21_v0"==tune) {
724 TFile f(
file.c_str());
725 TH1* histo = checked_cast<TH1*>(f.Get(
"hE1E2mu_2016_rel21_v1"));
729 else if(
"layer2_alt_run2_v1" == tune) {
731 TFile f(
file.c_str());
732 TH1* histo = checked_cast<TH1*>(f.Get(
"hE1E2mu_2016_v1"));
736 else if(
"layer2_alt_2012_v5" == tune) {
738 TFile f(
file.c_str());
739 TH1* histo = checked_cast<TH1*>(f.Get(
"hE1E2ave_alt_2012"));
743 else if(
"layer2_2012_v5" == tune) {
745 TFile f(
file.c_str());
746 TH1* histo = checked_cast<TH1*>(f.Get(
"hE1E2ave_2012"));
750 else if(
"layer2_2012_v5_down" == tune) {
752 TFile f(
file.c_str());
753 TH1* histo = checked_cast<TH1*>(f.Get(
"hE1E2ave_2012"));
757 else if(
"layer2_2012_v5_up" == tune) {
759 TFile f(
file.c_str());
760 TH1* histo = checked_cast<TH1*>(f.Get(
"hE1E2ave_2012"));
764 else if (
"layer2_2012_v5_errdown" == tune) {
766 TFile f(
file.c_str());
767 TH1* histo = checked_cast<TH1*>(f.Get(
"hE1E2ave_2012"));
771 else if (
"layer2_2012_v5_errup" == tune) {
773 TFile f(
file.c_str());
774 TH1* histo = checked_cast<TH1*>(f.Get(
"hE1E2ave_2012"));
778 else if(
"layer2_alt_2011_v5" == tune) {
780 TFile f(
file.c_str());
781 TH1* histo = checked_cast<TH1*>(f.Get(
"hE1E2ave_alt_2011"));
785 else if(
"layer2_2011_v5" == tune) {
787 TFile f(
file.c_str());
788 TH1* histo = checked_cast<TH1*>(f.Get(
"hE1E2ave_2011"));
792 else if(
"layer2_2011_v5_down" == tune) {
794 TFile f(
file.c_str());
795 TH1* histo = checked_cast<TH1*>(f.Get(
"hE1E2ave_2011"));
799 else if(
"layer2_2011_v5_up" == tune) {
801 TFile f(
file.c_str());
802 TH1* histo = checked_cast<TH1*>(f.Get(
"hE1E2ave_2011"));
806 else if (
"layer2_2011_v5_errdown" == tune) {
808 TFile f(
file.c_str());
809 TH1* histo = checked_cast<TH1*>(f.Get(
"hE1E2ave_2011"));
813 else if (
"layer2_2011_v5_errup" == tune) {
815 TFile f(
file.c_str());
816 TH1* histo = checked_cast<TH1*>(f.Get(
"hE1E2ave_2011"));
820 else if(
"layer2_2010_v5" == tune) {
822 TFile f(
file.c_str());
823 TH1* histo = checked_cast<TH1*>(f.Get(
"hE1E2ave_2010"));
827 else if(
"layer2_2010_v5_down" == tune) {
829 TFile f(
file.c_str());
830 TH1* histo = checked_cast<TH1*>(f.Get(
"hE1E2ave_2010"));
834 else if(
"layer2_2010_v5_up" == tune) {
836 TFile f(
file.c_str());
837 TH1* histo = checked_cast<TH1*>(f.Get(
"hE1E2ave_2010"));
841 else if (
"layer2_2010_v5_errdown" == tune) {
843 TFile f(
file.c_str());
844 TH1* histo = checked_cast<TH1*>(f.Get(
"hE1E2ave_2010"));
848 else if (
"layer2_2010_v5_errup" == tune) {
850 TFile f(
file.c_str());
851 TH1* histo = checked_cast<TH1*>(f.Get(
"hE1E2ave_2010"));
855 else if (
"ps_2016_r21_v0" == tune) {
857 TFile f(
file.c_str());
858 TH1* histo_ps_tot_error = checked_cast<TH1*>(f.Get(
"hPS_2016_rel21"));
862 else if (
"ps_run3_ofc_extrapolate_v0" == tune){
864 TFile f(
file.c_str());
865 TH1F* histo_ps_tot_error =
static_cast<TH1F*
>(f.Get(
"hPS_MuonLowMu_rel21_run3ofc"));
866 assert(histo_ps_tot_error);
870 else if (
"ps_mu_r21_v0" == tune) {
872 TFile f(
file.c_str());
873 TH1F* histo_ps_tot_error =
static_cast<TH1F*
>(f.Get(
"hPS_MuonLowMu_rel21"));
874 assert(histo_ps_tot_error);
878 else if (
"ps_2016_v1" == tune) {
880 TFile f(
file.c_str());
881 TH1* histo_ps_tot_error = checked_cast<TH1*>(f.Get(
"hPS_2016"));
885 else if (
"ps_2012_v3" == tune) {
887 TFile f(
file.c_str());
888 TH1* histo_ps_tot_error = checked_cast<TH1*>(f.Get(
"hPS_2012"));
892 else if (
"ps_2012_v3_down" == tune) {
894 TFile f(
file.c_str());
895 TH1* histo_ps_tot_error = checked_cast<TH1*>(f.Get(
"hPS_2012"));
899 else if (
"ps_2012_v3_up" == tune){
901 TFile f(
file.c_str());
902 TH1* histo_ps_tot_error = checked_cast<TH1*>(f.Get(
"hPS_2012"));
906 else if (
"ps_2012_v3_errdown" == tune){
908 TFile f(
file.c_str());
909 TH1* histo_ps_tot_error = checked_cast<TH1*>(f.Get(
"hPS_2012"));
913 else if (
"ps_2012_v3_errup" == tune){
915 TFile f(
file.c_str());
916 TH1* histo_ps_tot_error = checked_cast<TH1*>(f.Get(
"hPS_2012"));
920 else if (
"ps_2011_v3" == tune) {
922 TFile f(
file.c_str());
923 TH1* histo_ps_tot_error = checked_cast<TH1*>(f.Get(
"hPS_2011"));
927 else if (
"ps_2011_v3_down" == tune) {
929 TFile f(
file.c_str());
930 TH1* histo_ps_tot_error = checked_cast<TH1*>(f.Get(
"hPS_2011"));
934 else if (
"ps_2011_v3_up" == tune){
936 TFile f(
file.c_str());
937 TH1* histo_ps_tot_error = checked_cast<TH1*>(f.Get(
"hPS_2011"));
941 else if (
"ps_2011_v3_errdown" == tune){
943 TFile f(
file.c_str());
944 TH1* histo_ps_tot_error = checked_cast<TH1*>(f.Get(
"hPS_2011"));
948 else if (
"ps_2011_v3_errup" == tune){
950 TFile f(
file.c_str());
951 TH1* histo_ps_tot_error = checked_cast<TH1*>(f.Get(
"hPS_2011"));
956 else if (
"ps_2010_v3" == tune) {
958 TFile f(
file.c_str());
959 TH1* histo_ps_tot_error = checked_cast<TH1*>(f.Get(
"hPS_2010"));
963 else if (
"ps_2010_v3_down" == tune) {
965 TFile f(
file.c_str());
966 TH1* histo_ps_tot_error = checked_cast<TH1*>(f.Get(
"hPS_2010"));
970 else if (
"ps_2010_v3_up" == tune) {
972 TFile f(
file.c_str());
973 TH1* histo_ps_tot_error = checked_cast<TH1*>(f.Get(
"hPS_2010"));
977 else if (
"ps_2010_v3_errdown" == tune){
979 TFile f(
file.c_str());
980 TH1* histo_ps_tot_error = checked_cast<TH1*>(f.Get(
"hPS_2010"));
984 else if (
"ps_2010_v3_errup" == tune){
986 TFile f(
file.c_str());
987 TH1* histo_ps_tot_error = checked_cast<TH1*>(f.Get(
"hPS_2010"));
992 throw std::runtime_error(tune+
" is not a valid tune");
1016 const float amount = (*modifier.second)(inputs);
1017 const auto s = (*modifier.first)(inputs, amount);
1018 ATH_MSG_DEBUG(
" after E0|E1|E2|E3 = " << inputs.E0raw <<
"|" << inputs.E1raw <<
"|" << inputs.E2raw <<
"|" << inputs.E3raw);
1032 double& addE3 )
const
1042 fixT =
"_egFixForTopoTimingCut";
1043 unsigned short stat =
1047 " but some layer info is not available,"
1048 " from L2 : " << stat%2 <<
" from L3 : " << stat/2);
1055 eta_calo = cluster->
eta();
1061 eta_calo = accEtaCalo(*cluster);
1064 ATH_MSG_ERROR(
"etaCalo not available as auxilliary variable,"
1065 " using cluster eta as eta calo!");
1066 eta_calo=cluster->
eta();
1094 double addE2 = 0.0, addE3 = 0.0;
1108 deco_layer_correction(
"layer_correction");
1111 ATH_MSG_DEBUG(
"decorating cluster with corrected layer energies");
1113 inputs.E0raw : cluster->
energyBE(0);
1115 inputs.E1raw : cluster->
energyBE(1);
1117 inputs.E2raw : cluster->
energyBE(2) + addE2;
1119 inputs.E3raw : cluster->
energyBE(3) + addE3;
1120 deco_layer_correction(*cluster) = isData ?
m_tune+fixT : fixT;
1125 " decorating particle with non-corrected layer energies");
1130 deco_E0(*cluster) = cluster->
energyBE(0);
1131 deco_E1(*cluster) = cluster->
energyBE(1);
1132 deco_E2(*cluster) = cluster->
energyBE(2) + addE2;
1133 deco_E3(*cluster) = cluster->
energyBE(3) + addE3;
1134 deco_layer_correction(*cluster) = isData ?
m_tune +
"_Err" + fixT : fixT;
1144 double addE2 = 0.0, addE3 = 0.0;
1150 ATH_MSG_ERROR(
"Failed to read inputs, returning 1 for all layers, please check if this is expected!");
1153 ATH_MSG_WARNING(
"Some inputs are out of validity range, returning 1 for all layers; object eta: " << inputs.eta);
1155 return {1.,1.,1.,1.};
1158 auto safe_divide = [](
float a,
float b) {
return b != 0 ?
a/b : 1.f; };
1160 safe_divide(inputs.E0raw, particle.caloCluster()->energyBE(0)),
1161 safe_divide(inputs.E1raw, particle.caloCluster()->energyBE(1)),
1162 safe_divide(inputs.E2raw, particle.caloCluster()->energyBE(2) + addE2),
1163 safe_divide(inputs.E3raw, particle.caloCluster()->energyBE(3) + addE3)
1171 delete modifier.first;
1172 delete modifier.second;
1179std::map<std::string, std::string>
parse(
const std::string& list)
1181 std::cout <<
"list: '" << list <<
"'" << std::endl;
1182 std::map<std::string, std::string> result;
1183 TIter next(TString(list).Tokenize(
","));
1184 while (TObjString* sObj = (TObjString*) next())
1186 const TString& item(sObj->GetString());
1187 std::cout <<
"item: '" << item <<
"'" << std::endl;
1188 TObjArray* item_list = TString(item).Tokenize(
":");
1191 if (item_list->GetEntries() == 1) {
1193 value =
static_cast<TObjString*
>(item_list->At(0))->GetString().Data();
1195 else if (item_list->GetEntries() == 2) {
1196 key =
static_cast<TObjString*
>(item_list->At(0))->GetString().Data();
1197 value =
static_cast<TObjString*
>(item_list->At(1))->GetString().Data();
1200 std::cerr <<
"invalid string " << item << std::endl;
1202 if (result.find(key) != result.end()) {
1203 std::cerr <<
"trying to insert two times key " << key << std::endl;
1206 result.insert(std::make_pair(key, value));
1212std::pair<std::string, egammaLayerRecalibTool*>
1215 std::map<std::string, std::string> args_map =
parse(args);
1217 std::string name =
"";
1218 std::string amount_name =
"";
1219 std::string type_name =
"";
1224 if (args_map.find(
"amount") != args_map.end()) {
1225 std::string amount_str = args_map[
"amount"];
1227 if (amount_str.back()==
'%') {
1229 amount_str.pop_back();
1231 const float amount = TString(amount_str).Atof() * (perc ? 0.01 : 1);
1234 std::stringstream amount_stream;
1235 amount_stream << amount;
1236 amount_name = amount_stream.str();
1237 std::replace(amount_name.begin(), amount_name.end(),
'-',
'n');
1238 std::replace(amount_name.begin(), amount_name.end(),
'.',
'p');
1240 else if (args_map.find(
"name") != args_map.end()) {
1241 name = args_map[
"name"];
1243 else if (args_map.find(
"histo") != args_map.end()) {
1245 if (args_map.find(
"file") == args_map.end()) {
1246 std::cerr <<
"with histo you must specify file" << std::endl;
1249 if (args_map.find(
"formulax") != args_map.end()) dim = 1;
1253 std::cerr <<
"with histo you must specify formulax" << std::endl;
1257 TFile f(args_map[
"file"].c_str());
1258 std::cout <<
"opening histo " << args_map[
"histo"] <<
" from file " << args_map[
"file"] << std::endl;
1259 TH1F* histo =
dynamic_cast<TH1F*
>(f.Get(args_map[
"histo"].c_str()));
1262 histo->SetDirectory(
nullptr);
1265 else{assert(
false); }
1267 else { assert(
false); }
1270 std::cerr <<
"cannot understand argument " << args << std::endl;
1282 if (not type_name.empty() and not amount_name.empty()) {
1283 name = type_name +
"_" + amount_name;
1287 std::cerr <<
"you need to specify a name for the bias with type " <<
type << std::endl;
1290 if (modifier and amount_getter) {
1291 tool->add_scale(modifier, amount_getter);
1294 tool->add_scale(
type);
1297 if(modifier)
delete modifier;
1298 if(amount_getter)
delete amount_getter;
1301 return {name, tool};
#define ATH_MSG_WARNING(x)
std::string PathResolverFindCalibFile(const std::string &logical_file_name)
Return value from object correction CP tools.
@ Error
Some error happened during the object correction.
@ OutOfValidityRange
Input object is out of validity range.
@ Ok
The correction was done successfully.
SG::Decorator< T, ALLOC > Decorator
SG::Accessor< T, ALLOC > Accessor
bool isAvailable(const ELT &e) const
Test to see if this variable exists in the store.
AsgMessaging(const std::string &name)
Constructor with a name.
Correction for pileup induced energy shit as function of mu per layer for 2016 data.
bool retrieveMoment(MomentType type, double &value) const
Retrieve individual moment.
virtual double eta() const
The pseudorapidity ( ) of the particle.
float energyBE(const unsigned layer) const
Get the energy in one layer of the EM Calo.
virtual double phi() const
The azimuthal angle ( ) of the particle.
@ ETACALOFRAME
Eta in the calo frame (for egamma)
bool eventType(EventType type) const
Check for one particular bitmask value.
float averageInteractionsPerCrossing() const
Average interactions per crossing for all BCIDs - for out-of-time pile-up.
@ IS_SIMULATION
true: simulation, false: data
uint32_t runNumber() const
The current event's run number.
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...
const uint16_t AuthorFwdElectron
Electron reconstructed by the Forward cluster-based algorithm.
EventInfo_v1 EventInfo
Definition of the latest event info version.
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.
Egamma_v1 Egamma
Definition of the current "egamma version".
virtual float operator()(const StdCalibrationInputs &input) const
corr_HV_EMECPS m_toolEMECPS
virtual float operator()(const StdCalibrationInputs &input) const
virtual float operator()(const StdCalibrationInputs &input) const
virtual float operator()(const StdCalibrationInputs &input) const
virtual float operator()(const StdCalibrationInputs &input) const
virtual float operator()(const StdCalibrationInputs &input) const
virtual float operator()(const StdCalibrationInputs &input) const
std::unique_ptr< TH1 > m_histo
virtual float operator()(const StdCalibrationInputs &input) const
virtual float operator()(const StdCalibrationInputs &input) const
virtual float operator()(const StdCalibrationInputs &input) const
corr_pileupShift * m_tool
virtual float operator()(const StdCalibrationInputs &inputs) const
corr_pileupShift * m_tool
virtual float operator()(const StdCalibrationInputs &inputs) const
virtual float operator()(const StdCalibrationInputs &inputs) const
corr_pileupShift * m_tool
corr_pileupShift * m_tool
virtual float operator()(const StdCalibrationInputs &inputs) const
virtual void scale_inputs(StdCalibrationInputs &, float amount) const
virtual void shift_inputs(StdCalibrationInputs &, float amount) const
virtual void scale_inputs(StdCalibrationInputs &, float amount) const
virtual void shift_inputs(StdCalibrationInputs &, float amount) const
virtual void shift_inputs(StdCalibrationInputs &, float amount) const
virtual void scale_inputs(StdCalibrationInputs &, float amount) const
virtual void scale_inputs(StdCalibrationInputs &, float amount) const
virtual void shift_inputs(StdCalibrationInputs &, float amount) const
virtual void scale_inputs(StdCalibrationInputs &, float amount) const
virtual void shift_inputs(StdCalibrationInputs &, float amount) const
virtual void shift_inputs(StdCalibrationInputs &, float amount) const
virtual void scale_inputs(StdCalibrationInputs &, float amount) const
virtual void shift_inputs(StdCalibrationInputs &, float amount) const
virtual void scale_inputs(StdCalibrationInputs &, float amount) const