43const double GeV = 1000.;
60 "ElectronPhotonFourMomentumCorrection/v8/FunctionsTO.root");
62 "ElectronPhotonFourMomentumCorrection/v8/FunctionsG_all.root");
63 return std::make_unique<egGain::GainTool>(gain_filename1, gain_filename2);
92 folder =
"egammaMVACalib/v1";
95 folder =
"egammaMVACalib/v1";
101 folder =
"egammaMVACalib/offline/v3";
105 folder =
"egammaMVACalib/offline/v3_E4crack_bis";
114 folder =
"egammaMVACalib/offline/v4.0";
124 folder =
"egammaMVACalib/offline/v7";
128 folder =
"egammaMVACalib/offline/v9";
131 folder =
"egammaMVACalib/offline/v10";
142 std::string tune =
"";
147 tune =
"2011_alt_with_layer2";
161 tune =
"2012_alt_with_layer2";
165 tune =
"es2017_20.7_improved";
168 tune =
"es2017_20.7_final";
176 tune =
"es2017_21.0_v0";
179 tune =
"es2018_21.0_v0";
182 tune =
"es2022_22.0_Precision";
185 tune =
"es2022_22.0_Precision_v1";
188 tune =
"es2024_run3_extrapolate_v0";
193 return std::make_unique<egammaLayerRecalibTool>(tune, enableSacc);
291 const std::string&
name)
306 auto cluster =
acc.caloClusterAcc(
egamma)[0].value();
308 std::abs(
acc.clusterPhiAcc(cluster)) * 1E6 +
309 std::abs(
acc.clusterEtaAcc(cluster)) * 1E3 +
310 acc.eventNumberAcc(ei));
312 m_accessors(std::make_unique<Accessors>(*
this)) {
314 declareProperty(
"ESModel", m_ESModel =
"");
315 declareProperty(
"decorrelationModel", m_decorrelation_model_name =
"");
316 declareProperty(
"decorrelationModelScale",
317 m_decorrelation_model_scale_name =
"");
318 declareProperty(
"decorrelationModelResolution",
319 m_decorrelation_model_resolution_name =
"");
320 declareProperty(
"ResolutionType", m_ResolutionType =
"SigmaEff90");
321 declareProperty(
"varSF", m_varSF = 1.0);
322 declareProperty(
"doScaleCorrection", m_doScaleCorrection = AUTO);
323 declareProperty(
"doSmearing", m_doSmearing = AUTO);
324 declareProperty(
"useLayerCorrection", m_useLayerCorrection = AUTO);
325 declareProperty(
"usePSCorrection", m_usePSCorrection = AUTO);
326 declareProperty(
"useS12Correction", m_useS12Correction = AUTO);
327 declareProperty(
"useSaccCorrection", m_useSaccCorrection = AUTO);
328 declareProperty(
"useIntermoduleCorrection",
329 m_useIntermoduleCorrection = AUTO);
330 declareProperty(
"usePhiUniformCorrection", m_usePhiUniformCorrection = AUTO);
331 declareProperty(
"useCaloDistPhiUnifCorrection",
332 m_useCaloDistPhiUnifCorrection = AUTO);
333 declareProperty(
"useGainCorrection", m_useGainCorrection = AUTO);
334 declareProperty(
"useGainInterpolation", m_useGainInterpolation = AUTO);
335 declareProperty(
"doADCLinearityCorrection",
336 m_doADCLinearityCorrection = AUTO);
337 declareProperty(
"doLeakageCorrection", m_doLeakageCorrection = AUTO);
338 declareProperty(
"MVAfolder", m_MVAfolder =
"");
339 declareProperty(
"layerRecalibrationTune", m_layer_recalibration_tune =
"");
340 declareProperty(
"useEPCombination", m_use_ep_combination =
false);
341 declareProperty(
"useMVACalibration", m_use_mva_calibration = AUTO);
342 declareProperty(
"use_full_statistical_error",
343 m_use_full_statistical_error =
false);
344 declareProperty(
"use_temp_correction201215",
345 m_use_temp_correction201215 = AUTO);
346 declareProperty(
"use_uA2MeV_2015_first2weeks_correction",
347 m_use_uA2MeV_2015_first2weeks_correction = AUTO);
348 declareProperty(
"randomRunNumber", m_user_random_run_number = 0);
351 declareProperty(
"useFastSim", m_useFastSim = -1,
352 "This should be explicitly set by the user depending on the "
353 "data type (int)0=full sim, (int)1=fast sim");
355 "useAFII", m_use_AFII = -1,
356 "This is now deprecated. Kept for explicit error message for now");
357 declareProperty(
"decorateEmva", m_decorateEmva =
false,
"whether to decorate the eMVA value");
392 }
else if (
m_ESModel ==
"es2015PRE_res_improved") {
396 }
else if (
m_ESModel ==
"es2015cPRE_res_improved") {
398 }
else if (
m_ESModel ==
"es2015c_summer") {
402 }
else if (
m_ESModel ==
"es2016data_mc15c") {
404 }
else if (
m_ESModel ==
"es2016data_mc15c_summer") {
406 }
else if (
m_ESModel ==
"es2016data_mc15c_summer_improved") {
408 }
else if (
m_ESModel ==
"es2016data_mc15c_final") {
412 }
else if (
m_ESModel ==
"es2017_R21_PRE") {
414 }
else if (
m_ESModel ==
"es2017_R21_v0") {
416 }
else if (
m_ESModel ==
"es2017_R21_v1") {
418 }
else if (
m_ESModel ==
"es2017_R21_ofc0_v1") {
420 }
else if (
m_ESModel ==
"es2018_R21_v0") {
422 }
else if (
m_ESModel ==
"es2018_R21_v1") {
424 }
else if (
m_ESModel ==
"es2022_R22_PRE") {
426 }
else if (
m_ESModel ==
"es2023_R22_Run2_v0") {
428 }
else if (
m_ESModel ==
"es2023_R22_Run2_v1") {
430 }
else if (
m_ESModel ==
"es2024_Run3_ofc0_v0") {
432 }
else if (
m_ESModel ==
"es2024_Run3_v0") {
434 }
else if (
m_ESModel ==
"es2025_Run3_GNN_v0") {
438 return StatusCode::FAILURE;
441 return StatusCode::FAILURE;
452 return StatusCode::FAILURE;
457 "Property useAFII is deprecated. It is now replaced with useFastSim, "
458 "which should be explicitly configured");
459 return StatusCode::FAILURE;
467 ATH_MSG_ERROR(
"Property useFastSim should be explicitly configured");
468 return StatusCode::FAILURE;
474 "Sample is FastSim but no AF3 calibration is supported with "
475 "MC23 pre-recommendations (es2022_R22_PRE and es2024_Run3_ofc0_v0). "
476 "Please swtich to Run3 consolidated recommendations (es2024_Run3_v0), "
477 "or get in touch with the EGamma CP group in case you are using this");
478 return StatusCode::FAILURE;
497 ATH_MSG_WARNING(
"no decorrelation model specified, assuming full model");
506 return StatusCode::FAILURE;
512 "flag decorrelation model ignored for scale decorrelation model");
523 ATH_MSG_FATAL(
"cannot understand the scale decorrelation model '"
525 return StatusCode::FAILURE;
539 return StatusCode::FAILURE;
543 "not information how to initialize the scale decorrelation model");
544 return StatusCode::FAILURE;
552 "flag decorrelation model ignored for resolution decorrelation "
560 ATH_MSG_FATAL(
"cannot understand the resolution decorrelation model '"
562 return StatusCode::FAILURE;
576 return StatusCode::FAILURE;
583 m_rootTool = std::make_unique<AtlasRoot::egammaEnergyCorrectionTool>();
586 return StatusCode::FAILURE;
595 "Using linear interpolation in the gain tool (uncertainties only)");
613 "egammaMVACalibTool/tool_mva_electron");
621 "egammaMVACalibTool/tool_mva_unconverted");
624 config_mva_unconverted.
setProperty(
"use_layer_corrected",
true));
628 this->msg().level()));
632 "egammaMVACalibTool/tool_mva_converted");
638 this->msg().level()));
642 std::ostringstream mva_service_name;
643 mva_service_name <<
"egammaMVASvc/service_mva_egamma_id"
644 << (
void const*)
this;
646 ATH_CHECK(config_mva_service.addPrivateTool(
"ElectronTool",
647 config_mva_electron));
648 ATH_CHECK(config_mva_service.addPrivateTool(
"UnconvertedPhotonTool",
649 config_mva_unconverted));
650 ATH_CHECK(config_mva_service.addPrivateTool(
"ConvertedPhotonTool",
651 config_mva_converted));
655 "egammaMVACalibTool/tool_mva_fwdelectron");
661 ATH_CHECK(config_mva_service.addPrivateTool(
"FwdElectronTool",
662 config_mva_fwdelectron));
664 config_mva_service.setPropertyFromString(
"folder",
m_MVAfolder);
666 config_mva_service.setProperty(
"OutputLevel", this->msg().level()));
670 "WIP: testing GNN based calibration for Run3,"
671 "requring decorated GNN energy (gnn_energy) from input,"
672 "which should already have the layer calibration applied");
684 ATH_MSG_INFO(
"Layer recalibration already applied at cell level");
689 ATH_MSG_DEBUG(
"initializing layer recalibration tool (if needed)");
723 m_rootTool->use_uA2MeV_2015_first2weeks_correction(
732 throw std::runtime_error(
"ep combination not supported yet");
761 "cannot instantiate gain tool for this model (you can only disable "
762 "the gain tool, but not enable it)");
766 "initializing gain tool for run2 final precision recommendations");
768 "Gain corrections required but Zee scales are derived without Gain, "
769 "will cause inconsistency!");
771 "ElectronPhotonFourMomentumCorrection/v29/"
772 "gain_uncertainty_specialRun.root");
774 gain_tool_run_2_filename,
false,
"GainCorrection",
788 "ElectronPhotonFourMomentumCorrection/v25/linearity_ADC.root");
794 m_ESModel +
" recommendations use ADC corrections for scale "
795 "derivation. Disabling the ADCLinearity flag will create "
809 "ElectronPhotonFourMomentumCorrection/v33/"
810 "egammaEnergyCorrectionData.root");
811 std::unique_ptr<TFile> fCorr(
812 TFile::Open(phiUnifCorrfileName.c_str(),
"READ"));
814 dynamic_cast<TH2*
>(fCorr->Get(
"CaloDistortionPhiUniformityCorrection/"
815 "es2023_R22_Run2_v0/h2DcorrPhiUnif")));
819 m_ESModel +
" recommendations use CaloDistPhiUnif for scale "
820 "derivation. Disabling the CaloDistPhiUnif flag will create "
861 return StatusCode::FAILURE;
871 resetAccessor (
m_accessors->gnn_energy_Acc, *
this,
"TransformerEnergy");
874 ATH_MSG_ERROR(
"Cannot select both onlyElectrons and onlyPhotons");
875 return StatusCode::FAILURE;
880 resetAccessor (
m_accessors->electronTrackAcc, *
this,
"trackParticleLinks");
885 resetAccessor (
m_accessors->photonVertexAcc, *
this,
"vertexLinks");
888 resetAccessor (
m_accessors->decEmva, *
this,
"E_mva_only");
892 return StatusCode::SUCCESS;
910 if (
acc.photonVertexAcc(particle).size() > 0)
931 throw std::runtime_error(
"particle is not electron or photon");
939 const auto cl_etaCalo =
942 return m_rootTool->resolution(particle.e(), particle.caloCluster()->eta(),
943 cl_etaCalo, ptype, withCT,
948 double energy,
double cl_eta,
double cl_etaCalo,
950 return m_rootTool->resolution(energy, cl_eta, cl_etaCalo, ptype, withCT,
958 if (
evtStore()->retrieve(event_info,
"EventInfo").isFailure()) {
970 "Non-null pointer received. "
971 "There's a possible memory leak!");
974 output->makePrivateStore(input);
983 "Non-null pointer received. "
984 "There's a possible memory leak!");
987 output->makePrivateStore(input);
995 const double e = new_particle->
e();
1004 const double e = new_particle->
e();
1005 delete new_particle;
1020 ATH_MSG_DEBUG(
"applying energy recalibration before E0|E1|E2|E3 = "
1021 <<
acc.energyBEAcc (inputCluster, 0) <<
"|"
1022 <<
acc.energyBEAcc (inputCluster, 1) <<
"|"
1023 <<
acc.energyBEAcc (inputCluster, 2) <<
"|"
1024 <<
acc.energyBEAcc (inputCluster, 3));
1031 <<
acc.Es0Acc(inputCluster) <<
"|"
1032 <<
acc.Es1Acc(inputCluster) <<
"|"
1033 <<
acc.Es2Acc(inputCluster) <<
"|"
1034 <<
acc.Es3Acc(inputCluster) <<
"|");
1035 if (
acc.Es2Acc(inputCluster) == 0 and
acc.Es1Acc(inputCluster) == 0 and
1036 acc.Es3Acc(inputCluster) == 0 and
acc.Es0Acc(inputCluster) == 0 and
1037 (std::abs(
acc.etaAcc (input)) < 1.37 or (std::abs(
acc.etaAcc (input)) > 1.55 and std::abs(
acc.etaAcc (input)) < 2.47)))
1044 double energy =
acc.momAcc.e (input);
1048 if (
acc.authorAcc (input) ==
1055 unsigned int npv(0);
1056 for (
const auto *vtx : *pVtxCont) {
1061 gei.
acmu =
acc.actIntPerXingAcc(event_info);
1064 if (
acc.authorAcc (input) !=
1066 if (
m_MVACalibSvc->getEnergy(inputCluster.getXAODObject(), input.getXAODObject(), energy, gei)
1071 ATH_MSG_DEBUG(
"energy after MVA calibration = " << std::format(
"{:.2f}", energy));
1077 if (!
acc.gnn_energy_Acc.isAvailable(input)) {
1078 ATH_MSG_ERROR(
"GNN energy requested but decoration TransformerEnergy not found");
1081 energy =
acc.gnn_energy_Acc(input);
1082 ATH_MSG_DEBUG(
"energy after GNN calibration = " << std::format(
"{:.2f}", energy));
1087 acc.decEmva(input) = energy;
1091 if (
acc.authorAcc (input) ==
1093 setPt(input, energy);
1100 const double etaden =
1102 ?
static_cast<const xAOD::Electron&
>(input.getXAODObject()).trackParticle()->eta()
1103 :
acc.clusterEtaAcc(inputCluster);
1104 energy *=
m_rootTool->applyMCCalibration(
acc.clusterEtaAcc(inputCluster),
1105 energy / cosh(etaden), ptype);
1107 << std::format(
"{:.2f}", energy));
1119 unsigned int runNumber_for_tool = 0;
1124 runNumber_for_tool =
acc.runNumberAcc(event_info);
1126 const auto cl_eta =
acc.clusterEtaAcc(inputCluster);
1127 double etaCalo = 0, phiCalo = 0;
1129 etaCalo =
acc.etaCaloAcc(inputCluster,
acc.authorAcc(input),
false);
1132 acc.phiCaloAcc(inputCluster,
acc.authorAcc(input),
false);
1141 << std::format(
"{:.2f}", energy));
1150 double etaC =
acc.clusterEtaAcc(inputCluster);
1151 double phiC =
acc.clusterPhiAcc(inputCluster);
1153 ieta = ieta == 0 ? 1
1158 iphi = iphi == 0 ? 1
1164 "energy after phi uniformity correction (for calo distortion) = "
1165 << std::format(
"{:.2f}", energy));
1172 << std::format(
"{:.2f}", energy));
1177 double et = energy / std::cosh(cl_eta);
1182 << std::format(
"{:.2f}", energy));
1187 const auto es2 =
acc.Es2Acc.isAvailable(inputCluster)
1188 ?
acc.Es2Acc(inputCluster)
1189 :
acc.energyBEAcc (inputCluster,2);
1190 if (!(std::abs(cl_eta) < 1.52 and std::abs(cl_eta) > 1.37) and
1191 std::abs(cl_eta) < 2.4)
1193 cl_eta, energy /
GeV, es2 /
GeV,
1196 double et = energy / std::cosh(cl_eta);
1199 energy /= (1 + corr);
1201 ATH_MSG_DEBUG(
"energy after gain correction = " << std::format(
"{:.2f}", energy));
1204 if (
acc.randomrunnumber_getter.isAvailable(event_info)) {
1205 runNumber_for_tool =
acc.randomrunnumber_getter(event_info);
1208 "Pileup tool not run before using "
1209 "ElectronPhotonFourMomentumCorrection! Assuming it is 2016. If you "
1210 "want to force a specific period set the property randomRunNumber "
1211 "of the tool, e.g. in the job option: "
1212 "tool.randomRunNumber = 123456 or "
1213 "tool.randomRunNumber = "
1214 "EgammaCalibrationAndSmearingToolRunNumbersExample.run_2016");
1222 const double eraw = ((
acc.Es0Acc.isAvailable(inputCluster)
1223 ?
acc.Es0Acc(inputCluster)
1224 :
acc.energyBEAcc(inputCluster,0)) +
1225 (
acc.Es1Acc.isAvailable(inputCluster)
1226 ?
acc.Es1Acc(inputCluster)
1227 :
acc.energyBEAcc(inputCluster,1)) +
1228 (
acc.Es2Acc.isAvailable(inputCluster)
1229 ?
acc.Es2Acc(inputCluster)
1230 :
acc.energyBEAcc(inputCluster,2)) +
1231 (
acc.Es3Acc.isAvailable(inputCluster)
1232 ?
acc.Es3Acc(inputCluster)
1233 :
acc.energyBEAcc(inputCluster,3)));
1245 runNumber_for_tool, dataType,
xAOD2ptype(input),
1246 inputCluster(
acc.clusterEtaAcc),
1247 inputCluster(
acc.clusterEtaBEAcc,2),
1248 acc.etaCaloAcc(inputCluster,
acc.authorAcc (input),
false), energy,
1249 acc.Es2Acc.isAvailable(inputCluster)
1250 ?
acc.Es2Acc(inputCluster)
1251 : inputCluster(
acc.energyBEAcc,2),
1256 ATH_MSG_DEBUG(
"energy after scale/systematic correction = " << std::format(
"{:.2f}", energy));
1259 setPt(input, energy);
1264 const double new_energy2 = energy * energy;
1266 const double m2 = m * m;
1267 const double p2 = new_energy2 > m2 ? new_energy2 - m2 : 0.;
1310 const float el_tracketa = eTrack->
eta();
1311 const float el_trackmomentum = eTrack->
pt() * cosh(el->eta());
1321 return sys.find(systematic) != sys.end();
1328 affecting_systematics.
insert(it.first);
1331 affecting_systematics.
insert(it.first);
1334 return affecting_systematics;
1478 "EG_SCALE_S12EXTRALASTETABINRUN2", +1)] =
1481 "EG_SCALE_S12EXTRALASTETABINRUN2", -1)] =
1487 ScaleDecorrelation::FULL_ETA_CORRELATED or
1526 ScaleDecorrelation::FULL_ETA_CORRELATED) {
1529#define SYSMACRO(name, fullcorrelated, decorrelation, flagup, flagdown) \
1530 m_syst_description[CP::SystematicVariation(#name, +1)] = \
1531 SysInfo{always, flagup}; \
1532 m_syst_description[CP::SystematicVariation(#name, -1)] = \
1533 SysInfo{always, flagdown};
1534#include "ElectronPhotonFourMomentumCorrection/systematics_es2024_Run3_v0.def"
1539#define SYSMACRO(name, fullcorrelated, decorrelation, flagup, flagdown) \
1540 m_syst_description[CP::SystematicVariation(#name, +1)] = \
1541 SysInfo{always, flagup}; \
1542 m_syst_description[CP::SystematicVariation(#name, -1)] = \
1543 SysInfo{always, flagdown};
1544#include "ElectronPhotonFourMomentumCorrection/systematics_S12_2022.def"
1572 "EG_SCALE_LARCALIB_EXTRA2015PRE", +1)] =
1575 "EG_SCALE_LARCALIB_EXTRA2015PRE", -1)] =
1586 "EG_SCALE_LARTEMPERATURE_EXTRA2015PRE", +1)] =
1589 "EG_SCALE_LARTEMPERATURE_EXTRA2015PRE", -1)] =
1596 "EG_SCALE_LARTEMPERATURE_EXTRA2016PRE", +1)] =
1599 "EG_SCALE_LARTEMPERATURE_EXTRA2016PRE", -1)] =
1676 ScaleDecorrelation::ONENP_PLUS_UNCONR) {
1681#define SYSMACRO(name, fullcorrelated, decorrelation, flagup, flagdown) \
1682 m_syst_description[CP::SystematicVariation(#name, +1)] = \
1683 SysInfo{always, flagup}; \
1684 m_syst_description[CP::SystematicVariation(#name, -1)] = \
1685 SysInfo{always, flagdown};
1686#include "ElectronPhotonFourMomentumCorrection/systematics_1NPCOR_PLUS_UNCOR.def"
1696 "EG_SCALE_S12EXTRALASTETABINRUN2", +1)] =
1699 "EG_SCALE_S12EXTRALASTETABINRUN2", -1)] =
1704 using pairvector = std::vector<std::pair<double, double>>;
1705 const pairvector decorrelation_bins_BE = {{0., 1.45}, {1.52, 2.5}};
1706 const std::vector<double> decorrelation_edges_TWELVE = {
1707 0., 0.2, 0.4, 0.6, 0.8, 1.0, 1.2, 1.4, 1.6, 1.8, 2.0, 2.2, 2.4};
1708 std::vector<double> decorrelation_edges_MODULE = {
1709 0., 0.2, 0.4, 0.6, 0.8, 1.0, 1.2, 1.37, 1.52, 1.8};
1710 const std::vector<double> decorrelation_edges_MATERIAL = {0.0, 1.1, 1.5,
1712 std::vector<double> decorrelation_edges_S12_EXTRARUN3 = {
1715 std::vector<double> decorrelation_edges_S12;
1718 decorrelation_edges_S12.resize(5);
1719 decorrelation_edges_S12 = {0., 1.35, 1.5, 2.4, 2.5};
1723 decorrelation_edges_S12.resize(8);
1724 decorrelation_edges_S12 = {0., 0.6, 1.0, 1.35, 1.5, 1.8, 2.4, 2.5};
1727 decorrelation_edges_MODULE[7] = 1.4;
1728 decorrelation_edges_MODULE[8] = 1.5;
1733 decorrelation_edges_S12.resize(6);
1734 decorrelation_edges_S12 = {0., 0.6, 1.4, 1.5, 2.4, 2.5};
1748#define SYSMACRO(name, fullcorrelated, decorrelation, flagup, flagdown) \
1749 if (bool(fullcorrelated)) { \
1750 m_syst_description[CP::SystematicVariation(#name, +1)] = \
1751 SysInfo{always, flagup}; \
1752 m_syst_description[CP::SystematicVariation(#name, -1)] = \
1753 SysInfo{always, flagdown}; \
1756 for (const auto& p : AbsEtaCaloPredicatesFactory(decorrelation)) { \
1757 m_syst_description[CP::SystematicVariation( \
1758 #name "__ETABIN" + std::to_string(i), +1)] = SysInfo{p, flagup}; \
1759 m_syst_description[CP::SystematicVariation( \
1760 #name "__ETABIN" + std::to_string(i), -1)] = SysInfo{p, flagdown}; \
1764#include "ElectronPhotonFourMomentumCorrection/systematics.def"
1768#define SYSMACRO(name, fullcorrelated, decorrelation, flagup, flagdown) \
1769 if (bool(fullcorrelated)) { \
1770 m_syst_description[CP::SystematicVariation(#name, +1)] = \
1771 SysInfo{always, flagup}; \
1772 m_syst_description[CP::SystematicVariation(#name, -1)] = \
1773 SysInfo{always, flagdown}; \
1776 for (const auto& p : AbsEtaCaloPredicatesFactory(decorrelation)) { \
1777 m_syst_description[CP::SystematicVariation( \
1778 #name "__ETABIN" + std::to_string(i), +1)] = SysInfo{p, flagup}; \
1779 m_syst_description[CP::SystematicVariation( \
1780 #name "__ETABIN" + std::to_string(i), -1)] = SysInfo{p, flagdown}; \
1784#include "ElectronPhotonFourMomentumCorrection/systematics_S12_2022.def"
1787#define SYSMACRO(name, fullcorrelated, decorrelation, flagup, flagdown) \
1788 if (bool(fullcorrelated)) { \
1789 m_syst_description[CP::SystematicVariation(#name, +1)] = \
1790 SysInfo{always, flagup}; \
1791 m_syst_description[CP::SystematicVariation(#name, -1)] = \
1792 SysInfo{always, flagdown}; \
1795 for (const auto& p : AbsEtaCaloPredicatesFactory(decorrelation)) { \
1796 m_syst_description[CP::SystematicVariation( \
1797 #name "__ETABIN" + std::to_string(i), +1)] = SysInfo{p, flagup}; \
1798 m_syst_description[CP::SystematicVariation( \
1799 #name "__ETABIN" + std::to_string(i), -1)] = SysInfo{p, flagdown}; \
1803#include "ElectronPhotonFourMomentumCorrection/systematics_es2024_Run3_v0.def"
1806#define SYSMACRO(name, fullcorrelated, decorrelation, flagup, flagdown) \
1807 if (bool(fullcorrelated)) { \
1808 m_syst_description[CP::SystematicVariation(#name, +1)] = \
1809 SysInfo{always, flagup}; \
1810 m_syst_description[CP::SystematicVariation(#name, -1)] = \
1811 SysInfo{always, flagdown}; \
1814 for (const auto& p : AbsEtaCaloPredicatesFactory(decorrelation)) { \
1815 m_syst_description[CP::SystematicVariation( \
1816 #name "__ETABIN" + std::to_string(i), +1)] = SysInfo{p, flagup}; \
1817 m_syst_description[CP::SystematicVariation( \
1818 #name "__ETABIN" + std::to_string(i), -1)] = SysInfo{p, flagdown}; \
1822#include "ElectronPhotonFourMomentumCorrection/systematics_S12.def"
1829 const TAxis& axis_statistical_error(
m_rootTool->get_ZeeStat_eta_axis());
1830 for (
int ibin = 1; ibin <= axis_statistical_error.GetNbins(); ++ibin) {
1832 axis_statistical_error.GetBinLowEdge(ibin),
1833 axis_statistical_error.GetBinLowEdge(ibin + 1));
1835 "EG_SCALE_ZEESTAT__ETABIN" + std::to_string(i), +1)] =
1838 "EG_SCALE_ZEESTAT__ETABIN" + std::to_string(i), -1)] =
1855 "EG_SCALE_LARCALIB_EXTRA2015PRE__ETABIN0", +1)] =
1859 "EG_SCALE_LARCALIB_EXTRA2015PRE__ETABIN0", -1)] =
1863 "EG_SCALE_LARCALIB_EXTRA2015PRE__ETABIN1", +1)] =
1867 "EG_SCALE_LARCALIB_EXTRA2015PRE__ETABIN1", -1)] =
1871 "EG_SCALE_LARCALIB_EXTRA2015PRE__ETABIN2", +1)] =
1875 "EG_SCALE_LARCALIB_EXTRA2015PRE__ETABIN2", -1)] =
1887 "EG_SCALE_LARTEMPERATURE_EXTRA2015PRE__ETABIN0", +1)] =
1891 "EG_SCALE_LARTEMPERATURE_EXTRA2015PRE__ETABIN0", -1)] =
1895 "EG_SCALE_LARTEMPERATURE_EXTRA2015PRE__ETABIN1", +1)] =
1899 "EG_SCALE_LARTEMPERATURE_EXTRA2015PRE__ETABIN1", -1)] =
1907 "EG_SCALE_LARTEMPERATURE_EXTRA2016PRE__ETABIN0", +1)] =
1911 "EG_SCALE_LARTEMPERATURE_EXTRA2016PRE__ETABIN1", +1)] =
1915 "EG_SCALE_LARTEMPERATURE_EXTRA2016PRE__ETABIN0", -1)] =
1919 "EG_SCALE_LARTEMPERATURE_EXTRA2016PRE__ETABIN1", -1)] =
2016 "EG_SCALE_E4SCINTILLATOR__ETABIN0", +1)] =
2020 "EG_SCALE_E4SCINTILLATOR__ETABIN1", +1)] =
2024 "EG_SCALE_E4SCINTILLATOR__ETABIN2", +1)] =
2028 "EG_SCALE_E4SCINTILLATOR__ETABIN0", -1)] =
2032 "EG_SCALE_E4SCINTILLATOR__ETABIN1", -1)] =
2036 "EG_SCALE_E4SCINTILLATOR__ETABIN2", -1)] =
2041 "EG_SCALE_E4SCINTILLATOR__ETABIN3", +1)] =
2045 "EG_SCALE_E4SCINTILLATOR__ETABIN3", -1)] =
2068 "EG_RESOLUTION_ZSMEARING", -1)] =
2071 "EG_RESOLUTION_SAMPLINGTERM", +1)] =
2074 "EG_RESOLUTION_SAMPLINGTERM", -1)] =
2077 "EG_RESOLUTION_MATERIALID", +1)] =
2080 "EG_RESOLUTION_MATERIALID", -1)] =
2083 "EG_RESOLUTION_MATERIALCALO", +1)] =
2086 "EG_RESOLUTION_MATERIALCALO", -1)] =
2089 "EG_RESOLUTION_MATERIALGAP", +1)] =
2092 "EG_RESOLUTION_MATERIALGAP", -1)] =
2095 "EG_RESOLUTION_MATERIALCRYO", +1)] =
2098 "EG_RESOLUTION_MATERIALCRYO", -1)] =
2120 "EG_RESOLUTION_MATERIALIBL", +1)] =
2123 "EG_RESOLUTION_MATERIALIBL", -1)] =
2126 "EG_RESOLUTION_MATERIALPP0", +1)] =
2129 "EG_RESOLUTION_MATERIALPP0", -1)] =
2189 if (systConfig.
empty())
2190 return StatusCode::SUCCESS;
2195 bool first_scale =
true;
2196 bool first_resolution =
true;
2197 for (
const auto& it : systConfig) {
2200 if (not first_scale) {
2202 throw std::runtime_error(
"multiple scale variations not supported");
2204 first_scale =
false;
2211 if (not first_resolution) {
2212 ATH_MSG_ERROR(
"multiple resolution variations not supported");
2213 throw std::runtime_error(
2214 "multiple resolution variations not supported");
2216 first_resolution =
false;
2221 return StatusCode::SUCCESS;
2225 double Ecl,
double phi,
double eta)
const {
2231 double Ecl_corr = 0.;
2251 phi_mod = fmod(
phi, 2 *
pi / 16.) +
pi / 8.;
2253 phi_mod = fmod(
phi, 2 *
pi / 16.);
2256 if (std::abs(
eta) <= 1.37) {
2262 ((1 / (1 + exp((phi_mod - 2 *
pi / 32.) * 175.2759))) *
2263 (1 / (1 + exp((phi_mod - 2 *
pi / 32.) * (-189.3612))))));
2264 if (
phi < (-6 *
pi / 8) &&
phi > (-7 *
pi / 8))
2268 ((1 / (1 + exp((phi_mod - 2 *
pi / 32.) * 170.8305))) *
2269 (1 / (1 + exp((phi_mod - 2 *
pi / 32.) * (-233.3782))))));
2270 if (
phi < (-5 *
pi / 8) &&
phi > (-6 *
pi / 8))
2274 ((1 / (1 + exp((phi_mod - 2 *
pi / 32.) * 147.1451))) *
2275 (1 / (1 + exp((phi_mod - 2 *
pi / 32.) * (-139.3386))))));
2276 if (
phi < (-4 *
pi / 8) &&
phi > (-5 *
pi / 8))
2280 ((1 / (1 + exp((phi_mod - 2 *
pi / 32.) * 168.4644))) *
2281 (1 / (1 + exp((phi_mod - 2 *
pi / 32.) * (-246.2897))))));
2282 if (
phi < (-3 *
pi / 8) &&
phi > (-4 *
pi / 8))
2286 ((1 / (1 + exp((phi_mod - 2 *
pi / 32.) * 177.6703))) *
2287 (1 / (1 + exp((phi_mod - 2 *
pi / 32.) * (-198.3227))))));
2288 if (
phi < (-2 *
pi / 8) &&
phi > (-3 *
pi / 8))
2292 ((1 / (1 + exp((phi_mod - 2 *
pi / 32.) * 145.0693))) *
2293 (1 / (1 + exp((phi_mod - 2 *
pi / 32.) * (-242.1771))))));
2294 if (
phi < (-1 *
pi / 8) &&
phi > (-2 *
pi / 8))
2298 ((1 / (1 + exp((phi_mod - 2 *
pi / 32.) * 132.3303))) *
2299 (1 / (1 + exp((phi_mod - 2 *
pi / 32.) * (-166.1833))))));
2300 if (
phi < (0 *
pi / 8) &&
phi > (-1 *
pi / 8))
2304 ((1 / (1 + exp((phi_mod - 2 *
pi / 32.) * 127.6780))) *
2305 (1 / (1 + exp((phi_mod - 2 *
pi / 32.) * (-150.0700))))));
2306 if (
phi < (1 *
pi / 8) &&
phi > (0 *
pi / 8))
2310 ((1 / (1 + exp((phi_mod - 2 *
pi / 32.) * 172.0679))) *
2311 (1 / (1 + exp((phi_mod - 2 *
pi / 32.) * (-235.3293))))));
2312 if (
phi < (2 *
pi / 8) &&
phi > (1 *
pi / 8))
2316 ((1 / (1 + exp((phi_mod - 2 *
pi / 32.) * 190.3524))) *
2317 (1 / (1 + exp((phi_mod - 2 *
pi / 32.) * (-198.9400))))));
2318 if (
phi < (3 *
pi / 8) &&
phi > (2 *
pi / 8))
2322 ((1 / (1 + exp((phi_mod - 2 *
pi / 32.) * 158.0540))) *
2323 (1 / (1 + exp((phi_mod - 2 *
pi / 32.) * (-165.3893))))));
2324 if (
phi < (4 *
pi / 8) &&
phi > (3 *
pi / 8))
2328 ((1 / (1 + exp((phi_mod - 2 *
pi / 32.) * 162.2793))) *
2329 (1 / (1 + exp((phi_mod - 2 *
pi / 32.) * (-133.5131))))));
2330 if (
phi < (5 *
pi / 8) &&
phi > (4 *
pi / 8))
2334 ((1 / (1 + exp((phi_mod - 2 *
pi / 32.) * 180.5270))) *
2335 (1 / (1 + exp((phi_mod - 2 *
pi / 32.) * (-168.5074))))));
2336 if (
phi < (6 *
pi / 8) &&
phi > (5 *
pi / 8))
2340 ((1 / (1 + exp((phi_mod - 2 *
pi / 32.) * 128.2277))) *
2341 (1 / (1 + exp((phi_mod - 2 *
pi / 32.) * (-154.4455))))));
2342 if (
phi < (7 *
pi / 8) &&
phi > (6 *
pi / 8))
2346 ((1 / (1 + exp((phi_mod - 2 *
pi / 32.) * 192.1216))) *
2347 (1 / (1 + exp((phi_mod - 2 *
pi / 32.) * (-198.0727))))));
2348 if (
phi < (8 *
pi / 8) &&
phi > (7 *
pi / 8))
2352 ((1 / (1 + exp((phi_mod - 2 *
pi / 32.) * 199.1735))) *
2353 (1 / (1 + exp((phi_mod - 2 *
pi / 32.) * (-176.4056))))));
2368 DivInt = (
int)(
phi / ((2 *
pi) / 16.));
2369 double phi_mod =
phi - DivInt * (2 *
pi / 16.);
2376 if (std::abs(
eta) <= 1.4) {
2381 Ecl / (1 - 0.131 * ((1 / (1 + exp((phi_mod - 0.2) * 199.08))) *
2382 (1 / (1 + exp((phi_mod - 0.2) * (-130.36))))));
2388 Ecl / (1 - 0.0879 * ((1 / (1 + exp((phi_mod - 0.2) * 221.01))) *
2389 (1 / (1 + exp((phi_mod - 0.2) * (-149.51))))));
2394 Ecl / (1 - 0.0605 * ((1 / (1 + exp((phi_mod - 0.2) * 281.37))) *
2395 (1 / (1 + exp((phi_mod - 0.2) * (-170.29))))));
2398 if ((
phi < (-3 *
pi) / 4.) || (
phi >= (3 *
pi) / 4.)) {
2400 Ecl / (1 - 0.102 * ((1 / (1 + exp((phi_mod - 0.2) * 235.37))) *
2401 (1 / (1 + exp((phi_mod - 0.2) * (-219.04))))));
2416 constexpr double PI =
M_PI;
2422 if (
phi < (14 *
PI / 32.) &&
phi > (13 *
PI / 32.)) {
2424 }
else if (
phi < (13 *
PI / 32.) &&
phi > (12 *
PI / 32.)) {
2445 if (
phi < (-7 * 2 *
PI / 32.) &&
phi > (-8 * 2 *
PI / 32.)) {
2453 }
else if (
phi < (-4 * 2 *
PI / 32.) &&
phi > (-5 * 2 *
PI / 32.)) {
2459 if (
phi < (7 * 2 *
PI / 32.) &&
phi > (6 * 2 *
PI / 32.)) {
2465 if (
phi < (-9 * 2 *
PI / 32.) &&
phi > (-10 * 2 *
PI / 32.)) {
2467 }
else if (
phi < (-11 * 2 *
PI / 32.) &&
phi > (-12 * 2 *
PI / 32.)) {
2473 if (
phi < (-12 * 2 *
PI / 32.) &&
phi > (-13 * 2 *
PI / 32.)) {
2479 if (
phi < (-12 * 2 *
PI / 32.) &&
phi > (-13 * 2 *
PI / 32.)) {
2481 }
else if (
phi < (-8 * 2 *
PI / 32.) &&
phi > (-9 * 2 *
PI / 32.)) {
2487 if (
phi < (-9 * 2 *
PI / 32.) &&
phi > (-10 * 2 *
PI / 32.)) {
2493 if (
phi < (-6 * 2 *
PI / 32.) &&
phi > (-7 * 2 *
PI / 32.)) {
2499 if (
phi < (9 * 2 *
PI / 32.) &&
phi > (8 * 2 *
PI / 32.)) {
2505 if (
phi < (-8 * 2 *
PI / 32.) &&
phi > (-9 * 2 *
PI / 32.)) {
2507 }
else if (
phi < (5 * 2 *
PI / 32.) &&
phi > (4 * 2 *
PI / 32.)) {
2509 }
else if (
phi < (9 * 2 *
PI / 32.) &&
phi > (8 * 2 *
PI / 32.)) {
2511 }
else if (
phi < (10 * 2 *
PI / 32.) &&
phi > (9 * 2 *
PI / 32.)) {
2513 }
else if (
phi < (11 * 2 *
PI / 32.) &&
phi > (10 * 2 *
PI / 32.)) {
2524 }
else if (
phi < (-4 * 2 *
PI / 32.) &&
phi > (-5 * 2 *
PI / 32.)) {
2530 if (
phi < (7 * 2 *
PI / 32.) &&
phi > (6 * 2 *
PI / 32.)) {
2536 if (
phi < (-11 * 2 *
PI / 32.) &&
phi > (-12 * 2 *
PI / 32.)) {
2542 if (
phi < (10 * 2 *
PI / 32.) &&
phi > (9 * 2 *
PI / 32.)) {
2548 if (
phi < (-4 * 2 *
PI / 32.) &&
phi > (-5 * 2 *
PI / 32.)) {
2550 }
else if (
phi < (-6 * 2 *
PI / 32.) &&
phi > (-7 * 2 *
PI / 32.)) {
2556 if (
phi < (9 * 2 *
PI / 32.) &&
phi > (8 * 2 *
PI / 32.)) {
2562 if (
phi < (-8 * 2 *
PI / 32.) &&
phi > (-9 * 2 *
PI / 32.)) {
2564 }
else if (
phi < (5 * 2 *
PI / 32.) &&
phi > (4 * 2 *
PI / 32.)) {
2566 }
else if (
phi < (9 * 2 *
PI / 32.) &&
phi > (8 * 2 *
PI / 32.)) {
2568 }
else if (
phi < (10 * 2 *
PI / 32.) &&
phi > (9 * 2 *
PI / 32.)) {
2570 }
else if (
phi < (11 * 2 *
PI / 32.) &&
phi > (10 * 2 *
PI / 32.)) {
2579void EgammaCalibrationAndSmearingTool ::
2582 for (
auto egamma : egammas) {
2584 throw std::runtime_error (
"EgammaCalibrationAndSmearingTool::callEvents: apply failed");
2588void EgammaCalibrationAndSmearingTool ::
2592 for (
auto event : events) {
2593 auto eventInfo =
acc.m_eventHandle(event);
Scalar eta() const
pseudorapidity method
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_WARNING(x)
Helper class to provide constant type-safe access to aux data.
std::string PathResolverFindCalibFile(const std::string &logical_file_name)
static const Attributes_t empty
ServiceHandle< StoreGateSvc > & evtStore()
Return value from object correction CP tools.
@ Error
Some error happened during the object correction.
@ Ok
The correction was done successfully.
This module implements the central registry for handling systematic uncertainties with CP tools.
static SystematicRegistry & getInstance()
Get the singleton instance of the registry for the curren thread.
StatusCode registerSystematics(const IReentrantSystematicsTool &tool)
effects: register all the systematics from the tool
Class to wrap a set of SystematicVariations.
bool empty() const
returns: whether the set is empty
void insert(const SystematicVariation &systematic)
description: insert a systematic into the set
StatusCode setProperty(const std::string &name, const T &value)
set the given property
void setPropertyFromString(const std::string &name, const std::string &value)
set a given property from a string value
an object that can create a AsgService
virtual double e() const override
The total energy of the particle.
bool eventType(EventType type) const
Check for one particular bitmask value.
@ IS_SIMULATION
true: simulation, false: data
virtual double e() const override final
The total energy of the particle.
virtual double pt() const override final
The transverse momentum ( ) of the particle.
virtual double eta() const override final
The pseudorapidity ( ) of the particle.
void Scale(TH1 *h, double d=1)
Select isolated Photons, Electrons and Muons.
std::unique_ptr< egGain::GainTool > gainToolFactory(egEnergyCorr::ESModel model)
std::string egammaMVAToolFolder(egEnergyCorr::ESModel model)
bool is_after_run1(egEnergyCorr::ESModel model)
bool use_intermodule_correction(egEnergyCorr::ESModel model)
std::unique_ptr< egammaLayerRecalibTool > egammaLayerRecalibToolFactory(egEnergyCorr::ESModel model, int enableSacc)
bool use_phi_uniform_correction(egEnergyCorr::ESModel model)
ObjectId< ContainerId::cluster > ClusterId
ObjectId< ContainerId::egamma > EgammaId
ObjectRange< ContainerId::eventContext > EventContextRange
ObjectRange< ContainerId::mutableEgamma > MutableEgammaRange
ObjectId< ContainerId::mutableEgamma > MutableEgammaId
ObjectId< ContainerId::eventInfo > EventInfoId
@ LArCalibExtra2015PreDown
@ S12ExtraLastEtaBinRun2Down
@ LArTemperature2016PreDown
@ LArTemperature2015PreUp
@ S12ExtraLastEtaBinRun2Up
@ LArTemperature2015PreDown
@ LArTemperature2016PreUp
@ es2015cPRE_res_improved
bool isConvertedPhoton(const xAOD::Egamma *eg, bool excludeTRT=false)
is the object a converted photon
bool isElectron(const xAOD::Egamma *eg)
is the object an electron (not Fwd)
bool isPhoton(const xAOD::Egamma *eg)
is the object a photon
const uint16_t AuthorFwdElectron
Electron reconstructed by the Forward cluster-based algorithm.
EventInfo_v1 EventInfo
Definition of the latest event info version.
TrackParticle_v1 TrackParticle
Reference the current persistent version:
VertexContainer_v1 VertexContainer
Definition of the current "Vertex container version".
Egamma_v1 Egamma
Definition of the current "egamma version".
float get_eta_calo(const xAOD::CaloCluster &cluster, int author, bool do_throw=false)
Photon_v1 Photon
Definition of the current "egamma version".
setBGCode setTAP setLVL2ErrorBits bool
static const SG::AuxElement::Accessor< ElementLink< IParticleContainer > > acc("originalObjectLink")
Object used for setting/getting the dynamic decoration in question.
Electron_v1 Electron
Definition of the current "egamma version".
A structure holding some global event information.