25const float VALUE_OVERFLOW = std::numeric_limits<float>::max();
27template <
typename TargetPtr,
typename SourcePtr>
28TargetPtr checked_cast(SourcePtr ptr) {
30 static_assert(std::is_pointer<TargetPtr>::value,
31 "attempt to cast to no ptr object");
32 static_assert(std::is_pointer<SourcePtr>::value,
33 "attempt to cast from no ptr object");
37 throw std::runtime_error(
38 "Attempt to cast from nullptr in egammaLayerRecalibTool");
42 TargetPtr
obj =
dynamic_cast<TargetPtr
>(
ptr);
44 throw std::runtime_error(
"failed dynamic cast for " +
45 std::string(
ptr->GetName()) +
46 " in egammaLayerRecalibTool");
55 const int bin =
m_histo->FindFixBin(input.eta);
61 const int bin =
m_histo->FindFixBin(input.eta);
67 const int bin =
m_histo->FindFixBin(input.eta);
73 const int bin =
m_histo->FindFixBin(input.eta);
79 const int bin =
m_histo->FindFixBin(input.eta);
85 const int bin =
m_histo.FindFixBin(input.eta, input.phi);
91 const int bin =
m_histo.FindFixBin(input.etaCalo, input.RunNumber);
101 return m_formula.Eval(input.eta, input.phi, input.RunNumber);
105 return m_tool.getCorr(input.RunNumber, input.eta, input.phi);
109 return m_toolEMECPS.getCorr(input.RunNumber, input.eta, input.phi);
113 return m_tool->getCorr(0, input.RunNumber, input.averageInteractionsPerCrossing, input.eta);
117 return m_tool->getCorr(1, input.RunNumber, input.averageInteractionsPerCrossing, input.eta);
121 return m_tool->getCorr(2, input.RunNumber, input.averageInteractionsPerCrossing, input.eta);
125 return m_tool->getCorr(3, input.RunNumber, input.averageInteractionsPerCrossing, input.eta);
158 const double Es1 = inputs.E1raw;
159 const double Es2 = inputs.E2raw;
160 if (Es1 == 0 and Es2 == 0) {
165 const double sum = Es1 + Es2;
166 const double alpha = amount;
167 const double den = (alpha * Es1 + Es2);
168 inputs.E1raw = alpha * Es1 * sum / den;
169 inputs.E2raw = Es2 * sum / den;
175 throw std::runtime_error(
"not implemented");
180 inputs.E1raw *= amount;
181 inputs.E2raw *= amount;
182 inputs.E3raw *= amount;
187 inputs.E1raw += amount;
188 inputs.E2raw += amount;
189 inputs.E3raw += amount;
194 inputs.E0raw *= amount;
195 inputs.E1raw *= amount;
196 inputs.E2raw *= amount;
197 inputs.E3raw *= amount;
202 inputs.E0raw += amount;
203 inputs.E1raw += amount;
204 inputs.E2raw += amount;
205 inputs.E3raw += amount;
210 if (
"layer1_2012" == tune)
return "layer1_2012_v5";
211 if (
"layer1_alt_2012" == tune)
return "layer1_alt_2012_v5";
212 if (
"layer1_2011" == tune)
return "layer1_2011_v5";
213 if (
"layer1_alt_2011" == tune)
return "layer1_alt_2011_v5";
214 if (
"layer1_2010" == tune)
return "layer1_2010_v5";
215 if (
"ps_2012" == tune)
return "ps_2012_v3";
216 if (
"ps_2011" == tune)
return "ps_2011_v3";
217 if (
"ps_2010" == tune)
return "ps_2010_v3";
218 if (
"layer1_2012_up" == tune)
return "layer1_2012_v5_up";
219 if (
"layer1_2012_down" == tune)
return "layer1_2012_v5_down";
220 if (
"layer1_2012_errup" == tune)
return "layer1_2012_v5_errup";
221 if (
"layer1_2012_errdown" == tune)
return "layer1_2012_v5_errdown";
222 if (
"layer1_2011_up" == tune)
return "layer1_2011_v5_up";
223 if (
"layer1_2011_down" == tune)
return "layer1_2011_v5_down";
224 if (
"layer1_2011_errup" == tune)
return "layer1_2011_v5_errup";
225 if (
"layer1_2011_errdown" == tune)
return "layer1_2011_v5_errdown";
226 if (
"layer1_2010_up" == tune)
return "layer1_2010_v5_up";
227 if (
"layer1_2010_down" == tune)
return "layer1_2010_v5_down";
228 if (
"layer1_2010_errup" == tune)
return "layer1_2010_v5_errup";
229 if (
"layer1_2010_errdown" == tune)
return "layer1_2010_v5_errdown";
230 if (
"ps_2012_up" == tune)
return "ps_2012_v3_up";
231 if (
"ps_2012_down" == tune)
return "ps_2012_v3_down";
232 if (
"ps_2012_errup" == tune)
return "ps_2012_v3_errup";
233 if (
"ps_2012_errdown" == tune)
return "ps_2012_v3_errdown";
234 if (
"ps_2011_up" == tune)
return "ps_2011_v3_up";
235 if (
"ps_2011_down" == tune)
return "ps_2011_v3_down";
236 if (
"ps_2011_errup" == tune)
return "ps_2011_v3_errup";
237 if (
"ps_2011_errdown" == tune)
return "ps_2011_v3_errdown";
238 if (
"ps_2010_up" == tune)
return "ps_2010_v3_up";
239 if (
"ps_2010_down" == tune)
return "ps_2010_v3_down";
240 if (
"ps_2010_errup" == tune)
return "ps_2010_v3_errup";
241 if (
"ps_2010_errdown" == tune)
return "ps_2010_v3_errdown";
251 if (tune.empty()) { }
252 else if (
"es2025_run3_extrapolate_gnn_v0" == tune) {
253 add_scale(
"run3_partial_ofc_extrapolate_gnn_v0");
255 else if (
"es2024_run3_extrapolate_v0" == tune) {
256 add_scale(
"run3_partial_ofc_extrapolate_v0");
259 else if (
"es2022_22.0_Precision_v1" == tune) {
260 add_scale(
"run2_alt_with_layer2_r22_Precision_v1");
262 else if (
"es2022_22.0_Precision" == tune) {
263 add_scale(
"run2_alt_with_layer2_r22_Precision");
265 else if (
"es2018_21.0_v0" == tune) {
266 add_scale(
"run2_alt_with_layer2_r21_v1");
268 else if (
"es2017_21.0_v0" == tune) {
269 add_scale(
"run2_alt_with_layer2_r21_v0");
271 else if (
"es2017_20.7_final" == tune) {
275 else if (
"es2017_20.7_improved" == tune) {
280 else if (
"pileup_20.7" == tune) {
288 else if (
"run3_partial_ofc_extrapolate_gnn_v0" == tune) {
289 add_scale(
"layer2_run3_ofc_extrapolate_v0");
293 else if (
"run3_partial_ofc_extrapolate_v0" == tune) {
294 add_scale(
"layer2_run3_ofc_extrapolate_v0");
299 else if (
"run2_alt_with_layer2_r22_Precision_v1"==tune) {
300 add_scale(
"layer2_alt_el_mu_comb_r21_v0_fix");
305 else if (
"run2_alt_with_layer2_r22_Precision"==tune) {
306 add_scale(
"layer2_alt_el_mu_comb_r21_v0");
310 else if (
"run2_alt_with_layer2_r21_v1"==tune) {
314 else if (
"run2_alt_with_layer2_r21_v0"==tune) {
318 else if(
"run2_alt_with_layer2_modif" == tune) {
324 else if (
"2012" == tune) {
329 else if(
"2012_with_layer2" == tune) {
334 else if (
"2012_alt" == tune) {
339 else if(
"2012_alt_with_layer2" == tune) {
344 else if(
"2012_alt_with_layer2_modif" == tune) {
350 else if(
"2010_with_layer2" == tune) {
354 else if (
"2012_layer1_up" == tune) {
359 else if (
"2012_layer1_down" == tune) {
364 else if (
"2012_layer1_errup" == tune) {
367 else if (
"2012_layer1_errdown" == tune) {
370 else if (
"2012_ps_down" == tune) {
375 else if (
"2012_ps_up" == tune) {
380 else if (
"2012_ps_errdown" == tune) {
383 else if (
"2012_ps_errup" == tune) {
386 else if (
"2012_up" == tune) {
391 else if (
"2012_down" == tune) {
396 else if (
"2012_errup" == tune) {
400 else if (
"2012_errdown" == tune) {
405 else if (
"2011" == tune) {
409 else if(
"2011_with_layer2" == tune) {
413 else if (
"2011_alt" == tune) {
417 else if(
"2011_alt_with_layer2" == tune) {
421 else if (
"2011_layer1_up" == tune) {
425 else if (
"2011_layer1_down" == tune) {
429 else if (
"2011_layer1_errup" == tune) {
432 else if (
"2011_layer1_errdown" == tune) {
435 else if (
"2011_ps_down" == tune) {
439 else if (
"2011_ps_up" == tune) {
443 else if (
"2011_ps_errdown" == tune) {
446 else if (
"2011_ps_errup" == tune) {
449 else if (
"2011_up" == tune) {
453 else if (
"2011_down" == tune) {
457 else if (
"2011_errup" == tune) {
461 else if (
"2011_errdown" == tune) {
466 else if (
"2010" == tune) {
470 else if (
"2010_layer1_up" == tune) {
474 else if (
"2010_layer1_down" == tune) {
478 else if (
"2010_layer1_errup" == tune) {
481 else if (
"2010_layer1_errdown" == tune) {
484 else if (
"2010_ps_down" == tune) {
488 else if (
"2010_ps_up" == tune) {
492 else if (
"2010_ps_errdown" == tune) {
495 else if (
"2010_ps_errup" == tune) {
498 else if (
"2010_up" == tune) {
502 else if (
"2010_down" == tune) {
506 else if (
"2010_errup" == tune) {
510 else if (
"2010_errdown" == tune) {
514 else if (
"ps_HV1" == tune) {
517 else if (
"ps_EMECHV1" == tune) {
520 else if (
"test1" == tune) {
521 TH1F h_presampler(
"h_presampler",
"h_presampler", 10, -2.5, 2.5);
524 for (
int ibin = 1; ibin <= 5; ++ibin) {
525 h_presampler.SetBinContent(ibin, -0.1);
526 h_presampler.SetBinContent(ibin + 5, 0.1);
531 else if (
"acc_zee_run3_gnn_v0" == tune){
533 TFile f(
file.c_str());
534 TH2F* histo_acc =
static_cast<TH2F*
>(f.Get(
"hACC_Zee_rel23_gnn"));
539 else if (
"acc_zee_run3_v0" == tune){
541 TFile f(
file.c_str());
542 TH2F* histo_acc =
static_cast<TH2F*
>(f.Get(
"hACC_Zee_rel23"));
548 else if (
"acc_zee_r22_v1" == tune) {
550 TFile f(
file.c_str());
551 TH2F* histo_acc =
static_cast<TH2F*
>(f.Get(
"hACC_Zee_rel22"));
556 else if (
"acc_zee_r22_v0" == tune) {
558 TFile f(
file.c_str());
559 TH2F* histo_acc =
static_cast<TH2F*
>(f.Get(
"hACC_Zee_rel22"));
564 else if (
"layer1_1" == tune) {
565 TFormula f(
"formula_layer1_1",
"(abs(x)<1.425) ? 0.97 : 1");
568 else if (
"layer1_2" == tune) {
569 TFormula f(
"formula_layer1_2",
"(abs(x)<1.425) ? 0.97 : 1.05");
572 else if (
"layer1_alt_2012_v5" == tune) {
574 TFile f(
file.c_str());
575 TH1* histo = checked_cast<TH1*>(f.Get(
"hE1E2ave_alt_2012"));
579 else if (
"layer1_2012_v5" == tune) {
581 TFile f(
file.c_str());
582 TH1* histo = checked_cast<TH1*>(f.Get(
"hE1E2ave_2012"));
586 else if (
"layer1_2012_v5_down" == tune) {
588 TFile f(
file.c_str());
589 TH1* histo = checked_cast<TH1*>(f.Get(
"hE1E2ave_2012"));
593 else if (
"layer1_2012_v5_up" == tune) {
595 TFile f(
file.c_str());
596 TH1* histo = checked_cast<TH1*>(f.Get(
"hE1E2ave_2012"));
600 else if (
"layer1_2012_v5_errdown" == tune) {
602 TFile f(
file.c_str());
603 TH1* histo = checked_cast<TH1*>(f.Get(
"hE1E2ave_2012"));
607 else if (
"layer1_2012_v5_errup" == tune) {
609 TFile f(
file.c_str());
610 TH1* histo = checked_cast<TH1*>(f.Get(
"hE1E2ave_2012"));
614 else if (
"layer1_alt_2011_v5" == tune) {
616 TFile f(
file.c_str());
617 TH1* histo = checked_cast<TH1*>(f.Get(
"hE1E2ave_alt_2011"));
621 else if (
"layer1_2011_v5" == tune) {
623 TFile f(
file.c_str());
624 TH1* histo = checked_cast<TH1*>(f.Get(
"hE1E2ave_2011"));
628 else if (
"layer1_2011_v5_down" == tune) {
630 TFile f(
file.c_str());
631 TH1* histo = checked_cast<TH1*>(f.Get(
"hE1E2ave_2011"));
635 else if (
"layer1_2011_v5_up" == tune) {
637 TFile f(
file.c_str());
638 TH1* histo = checked_cast<TH1*>(f.Get(
"hE1E2ave_2011"));
642 else if (
"layer1_2011_v5_errdown" == tune) {
644 TFile f(
file.c_str());
645 TH1* histo = checked_cast<TH1*>(f.Get(
"hE1E2ave_2011"));
649 else if (
"layer1_2011_v5_errup" == tune) {
651 TFile f(
file.c_str());
652 TH1* histo = checked_cast<TH1*>(f.Get(
"hE1E2ave_2011"));
656 else if (
"layer1_2010_v5" == tune) {
658 TFile f(
file.c_str());
659 TH1* histo = checked_cast<TH1*>(f.Get(
"hE1E2ave_2010"));
663 else if (
"layer1_2010_v5_down" == tune) {
665 TFile f(
file.c_str());
666 TH1* histo = checked_cast<TH1*>(f.Get(
"hE1E2ave_2010"));
670 else if (
"layer1_2010_v5_up" == tune) {
672 TFile f(
file.c_str());
673 TH1* histo = checked_cast<TH1*>(f.Get(
"hE1E2ave_2010"));
677 else if (
"layer1_2010_v5_errdown" == tune) {
679 TFile f(
file.c_str());
680 TH1* histo = checked_cast<TH1*>(f.Get(
"hE1E2ave_2010"));
684 else if (
"layer1_2010_v5_errup" == tune) {
686 TFile f(
file.c_str());
687 TH1* histo = checked_cast<TH1*>(f.Get(
"hE1E2ave_2010"));
691 else if (
"layer2_run3_ofc_extrapolate_v0"==tune){
693 TFile f(
file.c_str());
694 TH1D* histo =
static_cast<TH1D*
>(f.Get(
"hE1E2_emu_run2_rel21_v1_run3ofc"));
700 else if(
"layer2_alt_el_mu_comb_r21_v0_fix"==tune) {
702 TFile f(
file.c_str());
703 TH1D* histo =
static_cast<TH1D*
>(f.Get(
"hE1E2_emu_run2_rel21_v0_fix"));
708 else if(
"layer2_alt_el_mu_comb_r21_v0"==tune) {
710 TFile f(
file.c_str());
711 TH1D* histo =
static_cast<TH1D*
>(f.Get(
"hE1E2_emu_run2_rel21_v0"));
716 else if(
"layer2_alt_run2_r21_v1"==tune) {
718 TFile f(
file.c_str());
719 TH1* histo = checked_cast<TH1*>(f.Get(
"hE1E2_mu_run2_rel21_v1"));
723 else if(
"layer2_alt_run2_r21_v0"==tune) {
725 TFile f(
file.c_str());
726 TH1* histo = checked_cast<TH1*>(f.Get(
"hE1E2mu_2016_rel21_v1"));
730 else if(
"layer2_alt_run2_v1" == tune) {
732 TFile f(
file.c_str());
733 TH1* histo = checked_cast<TH1*>(f.Get(
"hE1E2mu_2016_v1"));
737 else if(
"layer2_alt_2012_v5" == tune) {
739 TFile f(
file.c_str());
740 TH1* histo = checked_cast<TH1*>(f.Get(
"hE1E2ave_alt_2012"));
744 else if(
"layer2_2012_v5" == tune) {
746 TFile f(
file.c_str());
747 TH1* histo = checked_cast<TH1*>(f.Get(
"hE1E2ave_2012"));
751 else if(
"layer2_2012_v5_down" == tune) {
753 TFile f(
file.c_str());
754 TH1* histo = checked_cast<TH1*>(f.Get(
"hE1E2ave_2012"));
758 else if(
"layer2_2012_v5_up" == tune) {
760 TFile f(
file.c_str());
761 TH1* histo = checked_cast<TH1*>(f.Get(
"hE1E2ave_2012"));
765 else if (
"layer2_2012_v5_errdown" == tune) {
767 TFile f(
file.c_str());
768 TH1* histo = checked_cast<TH1*>(f.Get(
"hE1E2ave_2012"));
772 else if (
"layer2_2012_v5_errup" == tune) {
774 TFile f(
file.c_str());
775 TH1* histo = checked_cast<TH1*>(f.Get(
"hE1E2ave_2012"));
779 else if(
"layer2_alt_2011_v5" == tune) {
781 TFile f(
file.c_str());
782 TH1* histo = checked_cast<TH1*>(f.Get(
"hE1E2ave_alt_2011"));
786 else if(
"layer2_2011_v5" == tune) {
788 TFile f(
file.c_str());
789 TH1* histo = checked_cast<TH1*>(f.Get(
"hE1E2ave_2011"));
793 else if(
"layer2_2011_v5_down" == tune) {
795 TFile f(
file.c_str());
796 TH1* histo = checked_cast<TH1*>(f.Get(
"hE1E2ave_2011"));
800 else if(
"layer2_2011_v5_up" == tune) {
802 TFile f(
file.c_str());
803 TH1* histo = checked_cast<TH1*>(f.Get(
"hE1E2ave_2011"));
807 else if (
"layer2_2011_v5_errdown" == tune) {
809 TFile f(
file.c_str());
810 TH1* histo = checked_cast<TH1*>(f.Get(
"hE1E2ave_2011"));
814 else if (
"layer2_2011_v5_errup" == tune) {
816 TFile f(
file.c_str());
817 TH1* histo = checked_cast<TH1*>(f.Get(
"hE1E2ave_2011"));
821 else if(
"layer2_2010_v5" == tune) {
823 TFile f(
file.c_str());
824 TH1* histo = checked_cast<TH1*>(f.Get(
"hE1E2ave_2010"));
828 else if(
"layer2_2010_v5_down" == tune) {
830 TFile f(
file.c_str());
831 TH1* histo = checked_cast<TH1*>(f.Get(
"hE1E2ave_2010"));
835 else if(
"layer2_2010_v5_up" == tune) {
837 TFile f(
file.c_str());
838 TH1* histo = checked_cast<TH1*>(f.Get(
"hE1E2ave_2010"));
842 else if (
"layer2_2010_v5_errdown" == tune) {
844 TFile f(
file.c_str());
845 TH1* histo = checked_cast<TH1*>(f.Get(
"hE1E2ave_2010"));
849 else if (
"layer2_2010_v5_errup" == tune) {
851 TFile f(
file.c_str());
852 TH1* histo = checked_cast<TH1*>(f.Get(
"hE1E2ave_2010"));
856 else if (
"ps_2016_r21_v0" == tune) {
858 TFile f(
file.c_str());
859 TH1* histo_ps_tot_error = checked_cast<TH1*>(f.Get(
"hPS_2016_rel21"));
863 else if (
"ps_run3_ofc_extrapolate_v0" == tune){
865 TFile f(
file.c_str());
866 TH1* histo_ps_tot_error =
static_cast<TH1*
>(f.Get(
"hPS_MuonLowMu_rel21_run3ofc"));
867 assert(histo_ps_tot_error);
871 else if (
"ps_mu_r21_v0" == tune) {
873 TFile f(
file.c_str());
874 TH1* histo_ps_tot_error =
static_cast<TH1*
>(f.Get(
"hPS_MuonLowMu_rel21"));
875 assert(histo_ps_tot_error);
879 else if (
"ps_2016_v1" == tune) {
881 TFile f(
file.c_str());
882 TH1* histo_ps_tot_error = checked_cast<TH1*>(f.Get(
"hPS_2016"));
886 else if (
"ps_2012_v3" == tune) {
888 TFile f(
file.c_str());
889 TH1* histo_ps_tot_error = checked_cast<TH1*>(f.Get(
"hPS_2012"));
893 else if (
"ps_2012_v3_down" == tune) {
895 TFile f(
file.c_str());
896 TH1* histo_ps_tot_error = checked_cast<TH1*>(f.Get(
"hPS_2012"));
900 else if (
"ps_2012_v3_up" == tune){
902 TFile f(
file.c_str());
903 TH1* histo_ps_tot_error = checked_cast<TH1*>(f.Get(
"hPS_2012"));
907 else if (
"ps_2012_v3_errdown" == tune){
909 TFile f(
file.c_str());
910 TH1* histo_ps_tot_error = checked_cast<TH1*>(f.Get(
"hPS_2012"));
914 else if (
"ps_2012_v3_errup" == tune){
916 TFile f(
file.c_str());
917 TH1* histo_ps_tot_error = checked_cast<TH1*>(f.Get(
"hPS_2012"));
921 else if (
"ps_2011_v3" == tune) {
923 TFile f(
file.c_str());
924 TH1* histo_ps_tot_error = checked_cast<TH1*>(f.Get(
"hPS_2011"));
928 else if (
"ps_2011_v3_down" == tune) {
930 TFile f(
file.c_str());
931 TH1* histo_ps_tot_error = checked_cast<TH1*>(f.Get(
"hPS_2011"));
935 else if (
"ps_2011_v3_up" == tune){
937 TFile f(
file.c_str());
938 TH1* histo_ps_tot_error = checked_cast<TH1*>(f.Get(
"hPS_2011"));
942 else if (
"ps_2011_v3_errdown" == tune){
944 TFile f(
file.c_str());
945 TH1* histo_ps_tot_error = checked_cast<TH1*>(f.Get(
"hPS_2011"));
949 else if (
"ps_2011_v3_errup" == tune){
951 TFile f(
file.c_str());
952 TH1* histo_ps_tot_error = checked_cast<TH1*>(f.Get(
"hPS_2011"));
957 else if (
"ps_2010_v3" == tune) {
959 TFile f(
file.c_str());
960 TH1* histo_ps_tot_error = checked_cast<TH1*>(f.Get(
"hPS_2010"));
964 else if (
"ps_2010_v3_down" == tune) {
966 TFile f(
file.c_str());
967 TH1* histo_ps_tot_error = checked_cast<TH1*>(f.Get(
"hPS_2010"));
971 else if (
"ps_2010_v3_up" == tune) {
973 TFile f(
file.c_str());
974 TH1* histo_ps_tot_error = checked_cast<TH1*>(f.Get(
"hPS_2010"));
978 else if (
"ps_2010_v3_errdown" == tune){
980 TFile f(
file.c_str());
981 TH1* histo_ps_tot_error = checked_cast<TH1*>(f.Get(
"hPS_2010"));
985 else if (
"ps_2010_v3_errup" == tune){
987 TFile f(
file.c_str());
988 TH1* histo_ps_tot_error = checked_cast<TH1*>(f.Get(
"hPS_2010"));
993 throw std::runtime_error(tune+
" is not a valid tune");
1017 const float amount = (*modifier.second)(inputs);
1018 const auto s = (*modifier.first)(inputs, amount);
1019 ATH_MSG_DEBUG(
" after E0|E1|E2|E3 = " << inputs.E0raw <<
"|" << inputs.E1raw <<
"|" << inputs.E2raw <<
"|" << inputs.E3raw);
1033 double& addE3 )
const
1043 fixT =
"_egFixForTopoTimingCut";
1044 unsigned short stat =
1048 " but some layer info is not available,"
1049 " from L2 : " << stat%2 <<
" from L3 : " << stat/2);
1054 static const SG::AuxElement::Accessor<float> accEtaCalo(
"etaCalo");
1056 eta_calo = cluster->
eta();
1061 else if (accEtaCalo.isAvailable(*cluster)) {
1062 eta_calo = accEtaCalo(*cluster);
1065 ATH_MSG_ERROR(
"etaCalo not available as auxilliary variable,"
1066 " using cluster eta as eta calo!");
1067 eta_calo=cluster->
eta();
1095 double addE2 = 0.0, addE3 = 0.0;
1104 static const SG::AuxElement::Decorator<double> deco_E0(
"correctedcl_Es0");
1105 static const SG::AuxElement::Decorator<double> deco_E1(
"correctedcl_Es1");
1106 static const SG::AuxElement::Decorator<double> deco_E2(
"correctedcl_Es2");
1107 static const SG::AuxElement::Decorator<double> deco_E3(
"correctedcl_Es3");
1108 static const SG::AuxElement::Decorator<std::string>
1109 deco_layer_correction(
"layer_correction");
1112 ATH_MSG_DEBUG(
"decorating cluster with corrected layer energies");
1114 inputs.E0raw : cluster->
energyBE(0);
1116 inputs.E1raw : cluster->
energyBE(1);
1118 inputs.E2raw : cluster->
energyBE(2) + addE2;
1120 inputs.E3raw : cluster->
energyBE(3) + addE3;
1121 deco_layer_correction(*cluster) = isData ?
m_tune+fixT : fixT;
1126 " decorating particle with non-corrected layer energies");
1131 deco_E0(*cluster) = cluster->
energyBE(0);
1132 deco_E1(*cluster) = cluster->
energyBE(1);
1133 deco_E2(*cluster) = cluster->
energyBE(2) + addE2;
1134 deco_E3(*cluster) = cluster->
energyBE(3) + addE3;
1135 deco_layer_correction(*cluster) = isData ?
m_tune +
"_Err" + fixT : fixT;
1145 double addE2 = 0.0, addE3 = 0.0;
1151 ATH_MSG_ERROR(
"Failed to read inputs, returning 1 for all layers, please check if this is expected!");
1154 ATH_MSG_WARNING(
"Some inputs are out of validity range, returning 1 for all layers; object eta: " << inputs.eta);
1156 return {1.,1.,1.,1.};
1159 auto safe_divide = [](
float a,
float b) {
return b != 0 ?
a/b : 1.f; };
1161 safe_divide(inputs.E0raw, particle.caloCluster()->energyBE(0)),
1162 safe_divide(inputs.E1raw, particle.caloCluster()->energyBE(1)),
1163 safe_divide(inputs.E2raw, particle.caloCluster()->energyBE(2) + addE2),
1164 safe_divide(inputs.E3raw, particle.caloCluster()->energyBE(3) + addE3)
1172 delete modifier.first;
1173 delete modifier.second;
1180std::map<std::string, std::string, std::less<>>
parse(
const std::string& list)
1182 std::cout <<
"list: '" << list <<
"'" << std::endl;
1183 std::map<std::string, std::string, std::less<>> result;
1184 TIter next(TString(list).Tokenize(
","));
1185 while (TObjString* sObj = (TObjString*) next())
1187 const TString& item(sObj->GetString());
1188 std::cout <<
"item: '" << item <<
"'" << std::endl;
1189 TObjArray* item_list = TString(item).Tokenize(
":");
1192 if (item_list->GetEntries() == 1) {
1194 value =
static_cast<TObjString*
>(item_list->At(0))->GetString().Data();
1196 else if (item_list->GetEntries() == 2) {
1197 key =
static_cast<TObjString*
>(item_list->At(0))->GetString().Data();
1198 value =
static_cast<TObjString*
>(item_list->At(1))->GetString().Data();
1201 std::cerr <<
"invalid string " << item << std::endl;
1203 if (result.find(key) != result.end()) {
1204 std::cerr <<
"trying to insert two times key " << key << std::endl;
1207 result.insert(std::make_pair(key, value));
1213std::pair<std::string, egammaLayerRecalibTool*>
1216 auto args_map =
parse(args);
1218 std::string name =
"";
1219 std::string amount_name =
"";
1220 std::string type_name =
"";
1225 if (
auto pa = args_map.find(
"amount"); pa != args_map.end()) {
1226 std::string amount_str = pa->second;
1228 if (amount_str.back()==
'%') {
1230 amount_str.pop_back();
1232 const float amount = TString(amount_str).Atof() * (perc ? 0.01 : 1);
1235 std::stringstream amount_stream;
1236 amount_stream << amount;
1237 amount_name = amount_stream.str();
1238 std::replace(amount_name.begin(), amount_name.end(),
'-',
'n');
1239 std::replace(amount_name.begin(), amount_name.end(),
'.',
'p');
1241 else if (
auto pn = args_map.find(
"name"); pn != args_map.end()) {
1244 else if (args_map.find(
"histo") != args_map.end()) {
1246 if (not args_map.contains(
"file")) {
1247 std::cerr <<
"with histo you must specify file" << std::endl;
1250 if (args_map.contains(
"formulax") ) dim = 1;
1254 std::cerr <<
"with histo you must specify formulax" << std::endl;
1258 TFile f(args_map[
"file"].c_str());
1259 std::cout <<
"opening histo " << args_map[
"histo"] <<
" from file " << args_map[
"file"] << std::endl;
1260 TH1F* histo =
dynamic_cast<TH1F*
>(f.Get(args_map[
"histo"].c_str()));
1263 histo->SetDirectory(
nullptr);
1266 else{assert(
false); }
1268 else { assert(
false); }
1271 std::cerr <<
"cannot understand argument " << args << std::endl;
1283 if (not type_name.empty() and not amount_name.empty()) {
1284 name = type_name +
"_" + amount_name;
1288 std::cerr <<
"you need to specify a name for the bias with type " <<
type << std::endl;
1291 if (modifier and amount_getter) {
1292 tool->add_scale(modifier, amount_getter);
1295 tool->add_scale(
type);
1298 if(modifier)
delete modifier;
1299 if(amount_getter)
delete amount_getter;
1302 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.
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