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 size_t dot = this->
name().find(
'.');
644 size_t underscore = this->
name().rfind(
'_', dot);
645 std::string collection =
"";
646 if (
dot != std::string::npos &&
647 underscore != std::string::npos &&
650 collection = this->
name().substr(underscore + 1,
dot - underscore - 1);
651 mva_service_name <<
"egammaMVASvc/service_mva_egamma_id"
656 mva_service_name <<
"egammaMVASvc/service_mva_egamma_id"
657 << (
void const*)
this;
661 config_mva_electron));
663 config_mva_unconverted));
665 config_mva_converted));
669 "egammaMVACalibTool/tool_mva_fwdelectron");
676 config_mva_fwdelectron));
680 config_mva_service.
setProperty(
"OutputLevel", this->msg().level()));
684 "WIP: testing GNN based calibration for Run3,"
685 "requring decorated GNN energy (gnn_energy) from input,"
686 "which should already have the layer calibration applied");
698 ATH_MSG_INFO(
"Layer recalibration already applied at cell level");
703 ATH_MSG_DEBUG(
"initializing layer recalibration tool (if needed)");
737 m_rootTool->use_uA2MeV_2015_first2weeks_correction(
746 throw std::runtime_error(
"ep combination not supported yet");
775 "cannot instantiate gain tool for this model (you can only disable "
776 "the gain tool, but not enable it)");
780 "initializing gain tool for run2 final precision recommendations");
782 "Gain corrections required but Zee scales are derived without Gain, "
783 "will cause inconsistency!");
785 "ElectronPhotonFourMomentumCorrection/v29/"
786 "gain_uncertainty_specialRun.root");
788 gain_tool_run_2_filename,
false,
"GainCorrection",
802 "ElectronPhotonFourMomentumCorrection/v25/linearity_ADC.root");
808 m_ESModel +
" recommendations use ADC corrections for scale "
809 "derivation. Disabling the ADCLinearity flag will create "
823 "ElectronPhotonFourMomentumCorrection/v33/"
824 "egammaEnergyCorrectionData.root");
825 std::unique_ptr<TFile> fCorr(
826 TFile::Open(phiUnifCorrfileName.c_str(),
"READ"));
828 dynamic_cast<TH2*
>(fCorr->Get(
"CaloDistortionPhiUniformityCorrection/"
829 "es2023_R22_Run2_v0/h2DcorrPhiUnif")));
833 m_ESModel +
" recommendations use CaloDistPhiUnif for scale "
834 "derivation. Disabling the CaloDistPhiUnif flag will create "
874 if (registry.registerSystematics(*
this) != StatusCode::SUCCESS)
875 return StatusCode::FAILURE;
885 resetAccessor (
m_accessors->gnn_energy_Acc, *
this,
"TransformerEnergy");
888 ATH_MSG_ERROR(
"Cannot select both onlyElectrons and onlyPhotons");
889 return StatusCode::FAILURE;
894 resetAccessor (
m_accessors->electronTrackAcc, *
this,
"trackParticleLinks");
899 resetAccessor (
m_accessors->photonVertexAcc, *
this,
"vertexLinks");
902 resetAccessor (
m_accessors->decEmva, *
this,
"E_mva_only");
906 return StatusCode::SUCCESS;
924 if (
acc.photonVertexAcc(particle).size() > 0)
945 throw std::runtime_error(
"particle is not electron or photon");
953 const auto cl_etaCalo =
956 return m_rootTool->resolution(particle.e(), particle.caloCluster()->eta(),
957 cl_etaCalo, ptype, withCT,
962 double energy,
double cl_eta,
double cl_etaCalo,
964 return m_rootTool->resolution(energy, cl_eta, cl_etaCalo, ptype, withCT,
972 if (
evtStore()->retrieve(event_info,
"EventInfo").isFailure()) {
984 "Non-null pointer received. "
985 "There's a possible memory leak!");
988 output->makePrivateStore(input);
997 "Non-null pointer received. "
998 "There's a possible memory leak!");
1001 output->makePrivateStore(input);
1009 const double e = new_particle->
e();
1010 delete new_particle;
1018 const double e = new_particle->
e();
1019 delete new_particle;
1034 ATH_MSG_DEBUG(
"applying energy recalibration before E0|E1|E2|E3 = "
1035 <<
acc.energyBEAcc (inputCluster, 0) <<
"|"
1036 <<
acc.energyBEAcc (inputCluster, 1) <<
"|"
1037 <<
acc.energyBEAcc (inputCluster, 2) <<
"|"
1038 <<
acc.energyBEAcc (inputCluster, 3));
1045 <<
acc.Es0Acc(inputCluster) <<
"|"
1046 <<
acc.Es1Acc(inputCluster) <<
"|"
1047 <<
acc.Es2Acc(inputCluster) <<
"|"
1048 <<
acc.Es3Acc(inputCluster) <<
"|");
1049 if (
acc.Es2Acc(inputCluster) == 0 and
acc.Es1Acc(inputCluster) == 0 and
1050 acc.Es3Acc(inputCluster) == 0 and
acc.Es0Acc(inputCluster) == 0 and
1051 (std::abs(
acc.etaAcc (input)) < 1.37 or (std::abs(
acc.etaAcc (input)) > 1.55 and std::abs(
acc.etaAcc (input)) < 2.47)))
1058 double energy =
acc.momAcc.e (input);
1062 if (
acc.authorAcc (input) ==
1069 unsigned int npv(0);
1070 for (
const auto *vtx : *pVtxCont) {
1075 gei.
acmu =
acc.actIntPerXingAcc(event_info);
1078 if (
acc.authorAcc (input) !=
1080 if (
m_MVACalibSvc->getEnergy(inputCluster.getXAODObject(), input.getXAODObject(), energy, gei)
1085 ATH_MSG_DEBUG(
"energy after MVA calibration = " << std::format(
"{:.2f}", energy));
1091 if (!
acc.gnn_energy_Acc.isAvailable(input)) {
1092 ATH_MSG_ERROR(
"GNN energy requested but decoration TransformerEnergy not found");
1095 energy =
acc.gnn_energy_Acc(input);
1096 ATH_MSG_DEBUG(
"energy after GNN calibration = " << std::format(
"{:.2f}", energy));
1101 acc.decEmva(input) = energy;
1105 if (
acc.authorAcc (input) ==
1107 setPt(input, energy);
1114 const double etaden =
1116 ?
static_cast<const xAOD::Electron&
>(input.getXAODObject()).trackParticle()->eta()
1117 :
acc.clusterEtaAcc(inputCluster);
1118 energy *=
m_rootTool->applyMCCalibration(
acc.clusterEtaAcc(inputCluster),
1119 energy / cosh(etaden), ptype);
1121 << std::format(
"{:.2f}", energy));
1133 unsigned int runNumber_for_tool = 0;
1138 runNumber_for_tool =
acc.runNumberAcc(event_info);
1140 const auto cl_eta =
acc.clusterEtaAcc(inputCluster);
1141 double etaCalo = 0, phiCalo = 0;
1143 etaCalo =
acc.etaCaloAcc(inputCluster,
acc.authorAcc(input),
false);
1146 acc.phiCaloAcc(inputCluster,
acc.authorAcc(input),
false);
1155 << std::format(
"{:.2f}", energy));
1164 double etaC =
acc.clusterEtaAcc(inputCluster);
1165 double phiC =
acc.clusterPhiAcc(inputCluster);
1167 ieta = ieta == 0 ? 1
1172 iphi = iphi == 0 ? 1
1178 "energy after phi uniformity correction (for calo distortion) = "
1179 << std::format(
"{:.2f}", energy));
1186 << std::format(
"{:.2f}", energy));
1191 double et = energy / std::cosh(cl_eta);
1196 << std::format(
"{:.2f}", energy));
1201 const auto es2 =
acc.Es2Acc.isAvailable(inputCluster)
1202 ?
acc.Es2Acc(inputCluster)
1203 :
acc.energyBEAcc (inputCluster,2);
1204 if (!(std::abs(cl_eta) < 1.52 and std::abs(cl_eta) > 1.37) and
1205 std::abs(cl_eta) < 2.4)
1207 cl_eta, energy /
GeV, es2 /
GeV,
1210 double et = energy / std::cosh(cl_eta);
1213 energy /= (1 + corr);
1215 ATH_MSG_DEBUG(
"energy after gain correction = " << std::format(
"{:.2f}", energy));
1218 if (
acc.randomrunnumber_getter.isAvailable(event_info)) {
1219 runNumber_for_tool =
acc.randomrunnumber_getter(event_info);
1222 "Pileup tool not run before using "
1223 "ElectronPhotonFourMomentumCorrection! Assuming it is 2016. If you "
1224 "want to force a specific period set the property randomRunNumber "
1225 "of the tool, e.g. in the job option: "
1226 "tool.randomRunNumber = 123456 or "
1227 "tool.randomRunNumber = "
1228 "EgammaCalibrationAndSmearingToolRunNumbersExample.run_2016");
1236 const double eraw = ((
acc.Es0Acc.isAvailable(inputCluster)
1237 ?
acc.Es0Acc(inputCluster)
1238 :
acc.energyBEAcc(inputCluster,0)) +
1239 (
acc.Es1Acc.isAvailable(inputCluster)
1240 ?
acc.Es1Acc(inputCluster)
1241 :
acc.energyBEAcc(inputCluster,1)) +
1242 (
acc.Es2Acc.isAvailable(inputCluster)
1243 ?
acc.Es2Acc(inputCluster)
1244 :
acc.energyBEAcc(inputCluster,2)) +
1245 (
acc.Es3Acc.isAvailable(inputCluster)
1246 ?
acc.Es3Acc(inputCluster)
1247 :
acc.energyBEAcc(inputCluster,3)));
1259 runNumber_for_tool, dataType,
xAOD2ptype(input),
1260 inputCluster(
acc.clusterEtaAcc),
1261 inputCluster(
acc.clusterEtaBEAcc,2),
1262 acc.etaCaloAcc(inputCluster,
acc.authorAcc (input),
false), energy,
1263 acc.Es2Acc.isAvailable(inputCluster)
1264 ?
acc.Es2Acc(inputCluster)
1265 : inputCluster(
acc.energyBEAcc,2),
1270 ATH_MSG_DEBUG(
"energy after scale/systematic correction = " << std::format(
"{:.2f}", energy));
1273 setPt(input, energy);
1278 const double new_energy2 = energy * energy;
1281 const double m2 = m * m;
1282 const double p2 = new_energy2 > m2 ? new_energy2 - m2 : 0.;
1325 const float el_tracketa = eTrack->
eta();
1326 const float el_trackmomentum = eTrack->
pt() * cosh(el->eta());
1336 return sys.find(systematic) != sys.end();
1343 affecting_systematics.
insert(it.first);
1346 affecting_systematics.
insert(it.first);
1349 return affecting_systematics;
1493 "EG_SCALE_S12EXTRALASTETABINRUN2", +1)] =
1496 "EG_SCALE_S12EXTRALASTETABINRUN2", -1)] =
1502 ScaleDecorrelation::FULL_ETA_CORRELATED or
1541 ScaleDecorrelation::FULL_ETA_CORRELATED) {
1544#define SYSMACRO(name, fullcorrelated, decorrelation, flagup, flagdown) \
1545 m_syst_description[CP::SystematicVariation(#name, +1)] = \
1546 SysInfo{always, flagup}; \
1547 m_syst_description[CP::SystematicVariation(#name, -1)] = \
1548 SysInfo{always, flagdown};
1549#include "ElectronPhotonFourMomentumCorrection/systematics_es2024_Run3_v0.def"
1554#define SYSMACRO(name, fullcorrelated, decorrelation, flagup, flagdown) \
1555 m_syst_description[CP::SystematicVariation(#name, +1)] = \
1556 SysInfo{always, flagup}; \
1557 m_syst_description[CP::SystematicVariation(#name, -1)] = \
1558 SysInfo{always, flagdown};
1559#include "ElectronPhotonFourMomentumCorrection/systematics_S12_2022.def"
1587 "EG_SCALE_LARCALIB_EXTRA2015PRE", +1)] =
1590 "EG_SCALE_LARCALIB_EXTRA2015PRE", -1)] =
1601 "EG_SCALE_LARTEMPERATURE_EXTRA2015PRE", +1)] =
1604 "EG_SCALE_LARTEMPERATURE_EXTRA2015PRE", -1)] =
1611 "EG_SCALE_LARTEMPERATURE_EXTRA2016PRE", +1)] =
1614 "EG_SCALE_LARTEMPERATURE_EXTRA2016PRE", -1)] =
1691 ScaleDecorrelation::ONENP_PLUS_UNCONR) {
1696#define SYSMACRO(name, fullcorrelated, decorrelation, flagup, flagdown) \
1697 m_syst_description[CP::SystematicVariation(#name, +1)] = \
1698 SysInfo{always, flagup}; \
1699 m_syst_description[CP::SystematicVariation(#name, -1)] = \
1700 SysInfo{always, flagdown};
1701#include "ElectronPhotonFourMomentumCorrection/systematics_1NPCOR_PLUS_UNCOR.def"
1711 "EG_SCALE_S12EXTRALASTETABINRUN2", +1)] =
1714 "EG_SCALE_S12EXTRALASTETABINRUN2", -1)] =
1719 using pairvector = std::vector<std::pair<double, double>>;
1720 const pairvector decorrelation_bins_BE = {{0., 1.45}, {1.52, 2.5}};
1721 const std::vector<double> decorrelation_edges_TWELVE = {
1722 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};
1723 std::vector<double> decorrelation_edges_MODULE = {
1724 0., 0.2, 0.4, 0.6, 0.8, 1.0, 1.2, 1.37, 1.52, 1.8};
1725 const std::vector<double> decorrelation_edges_MATERIAL = {0.0, 1.1, 1.5,
1727 std::vector<double> decorrelation_edges_S12_EXTRARUN3 = {
1730 std::vector<double> decorrelation_edges_S12;
1733 decorrelation_edges_S12.resize(5);
1734 decorrelation_edges_S12 = {0., 1.35, 1.5, 2.4, 2.5};
1738 decorrelation_edges_S12.resize(8);
1739 decorrelation_edges_S12 = {0., 0.6, 1.0, 1.35, 1.5, 1.8, 2.4, 2.5};
1742 decorrelation_edges_MODULE[7] = 1.4;
1743 decorrelation_edges_MODULE[8] = 1.5;
1748 decorrelation_edges_S12.resize(6);
1749 decorrelation_edges_S12 = {0., 0.6, 1.4, 1.5, 2.4, 2.5};
1763#define SYSMACRO(name, fullcorrelated, decorrelation, flagup, flagdown) \
1764 if (bool(fullcorrelated)) { \
1765 m_syst_description[CP::SystematicVariation(#name, +1)] = \
1766 SysInfo{always, flagup}; \
1767 m_syst_description[CP::SystematicVariation(#name, -1)] = \
1768 SysInfo{always, flagdown}; \
1771 for (const auto& p : AbsEtaCaloPredicatesFactory(decorrelation)) { \
1772 m_syst_description[CP::SystematicVariation( \
1773 #name "__ETABIN" + std::to_string(i), +1)] = SysInfo{p, flagup}; \
1774 m_syst_description[CP::SystematicVariation( \
1775 #name "__ETABIN" + std::to_string(i), -1)] = SysInfo{p, flagdown}; \
1779#include "ElectronPhotonFourMomentumCorrection/systematics.def"
1783#define SYSMACRO(name, fullcorrelated, decorrelation, flagup, flagdown) \
1784 if (bool(fullcorrelated)) { \
1785 m_syst_description[CP::SystematicVariation(#name, +1)] = \
1786 SysInfo{always, flagup}; \
1787 m_syst_description[CP::SystematicVariation(#name, -1)] = \
1788 SysInfo{always, flagdown}; \
1791 for (const auto& p : AbsEtaCaloPredicatesFactory(decorrelation)) { \
1792 m_syst_description[CP::SystematicVariation( \
1793 #name "__ETABIN" + std::to_string(i), +1)] = SysInfo{p, flagup}; \
1794 m_syst_description[CP::SystematicVariation( \
1795 #name "__ETABIN" + std::to_string(i), -1)] = SysInfo{p, flagdown}; \
1799#include "ElectronPhotonFourMomentumCorrection/systematics_S12_2022.def"
1802#define SYSMACRO(name, fullcorrelated, decorrelation, flagup, flagdown) \
1803 if (bool(fullcorrelated)) { \
1804 m_syst_description[CP::SystematicVariation(#name, +1)] = \
1805 SysInfo{always, flagup}; \
1806 m_syst_description[CP::SystematicVariation(#name, -1)] = \
1807 SysInfo{always, flagdown}; \
1810 for (const auto& p : AbsEtaCaloPredicatesFactory(decorrelation)) { \
1811 m_syst_description[CP::SystematicVariation( \
1812 #name "__ETABIN" + std::to_string(i), +1)] = SysInfo{p, flagup}; \
1813 m_syst_description[CP::SystematicVariation( \
1814 #name "__ETABIN" + std::to_string(i), -1)] = SysInfo{p, flagdown}; \
1818#include "ElectronPhotonFourMomentumCorrection/systematics_es2024_Run3_v0.def"
1821#define SYSMACRO(name, fullcorrelated, decorrelation, flagup, flagdown) \
1822 if (bool(fullcorrelated)) { \
1823 m_syst_description[CP::SystematicVariation(#name, +1)] = \
1824 SysInfo{always, flagup}; \
1825 m_syst_description[CP::SystematicVariation(#name, -1)] = \
1826 SysInfo{always, flagdown}; \
1829 for (const auto& p : AbsEtaCaloPredicatesFactory(decorrelation)) { \
1830 m_syst_description[CP::SystematicVariation( \
1831 #name "__ETABIN" + std::to_string(i), +1)] = SysInfo{p, flagup}; \
1832 m_syst_description[CP::SystematicVariation( \
1833 #name "__ETABIN" + std::to_string(i), -1)] = SysInfo{p, flagdown}; \
1837#include "ElectronPhotonFourMomentumCorrection/systematics_S12.def"
1844 const TAxis& axis_statistical_error(
m_rootTool->get_ZeeStat_eta_axis());
1845 for (
int ibin = 1; ibin <= axis_statistical_error.GetNbins(); ++ibin) {
1847 axis_statistical_error.GetBinLowEdge(ibin),
1848 axis_statistical_error.GetBinLowEdge(ibin + 1));
1850 "EG_SCALE_ZEESTAT__ETABIN" + std::to_string(i), +1)] =
1853 "EG_SCALE_ZEESTAT__ETABIN" + std::to_string(i), -1)] =
1870 "EG_SCALE_LARCALIB_EXTRA2015PRE__ETABIN0", +1)] =
1874 "EG_SCALE_LARCALIB_EXTRA2015PRE__ETABIN0", -1)] =
1878 "EG_SCALE_LARCALIB_EXTRA2015PRE__ETABIN1", +1)] =
1882 "EG_SCALE_LARCALIB_EXTRA2015PRE__ETABIN1", -1)] =
1886 "EG_SCALE_LARCALIB_EXTRA2015PRE__ETABIN2", +1)] =
1890 "EG_SCALE_LARCALIB_EXTRA2015PRE__ETABIN2", -1)] =
1902 "EG_SCALE_LARTEMPERATURE_EXTRA2015PRE__ETABIN0", +1)] =
1906 "EG_SCALE_LARTEMPERATURE_EXTRA2015PRE__ETABIN0", -1)] =
1910 "EG_SCALE_LARTEMPERATURE_EXTRA2015PRE__ETABIN1", +1)] =
1914 "EG_SCALE_LARTEMPERATURE_EXTRA2015PRE__ETABIN1", -1)] =
1922 "EG_SCALE_LARTEMPERATURE_EXTRA2016PRE__ETABIN0", +1)] =
1926 "EG_SCALE_LARTEMPERATURE_EXTRA2016PRE__ETABIN1", +1)] =
1930 "EG_SCALE_LARTEMPERATURE_EXTRA2016PRE__ETABIN0", -1)] =
1934 "EG_SCALE_LARTEMPERATURE_EXTRA2016PRE__ETABIN1", -1)] =
2031 "EG_SCALE_E4SCINTILLATOR__ETABIN0", +1)] =
2035 "EG_SCALE_E4SCINTILLATOR__ETABIN1", +1)] =
2039 "EG_SCALE_E4SCINTILLATOR__ETABIN2", +1)] =
2043 "EG_SCALE_E4SCINTILLATOR__ETABIN0", -1)] =
2047 "EG_SCALE_E4SCINTILLATOR__ETABIN1", -1)] =
2051 "EG_SCALE_E4SCINTILLATOR__ETABIN2", -1)] =
2056 "EG_SCALE_E4SCINTILLATOR__ETABIN3", +1)] =
2060 "EG_SCALE_E4SCINTILLATOR__ETABIN3", -1)] =
2083 "EG_RESOLUTION_ZSMEARING", -1)] =
2086 "EG_RESOLUTION_SAMPLINGTERM", +1)] =
2089 "EG_RESOLUTION_SAMPLINGTERM", -1)] =
2092 "EG_RESOLUTION_MATERIALID", +1)] =
2095 "EG_RESOLUTION_MATERIALID", -1)] =
2098 "EG_RESOLUTION_MATERIALCALO", +1)] =
2101 "EG_RESOLUTION_MATERIALCALO", -1)] =
2104 "EG_RESOLUTION_MATERIALGAP", +1)] =
2107 "EG_RESOLUTION_MATERIALGAP", -1)] =
2110 "EG_RESOLUTION_MATERIALCRYO", +1)] =
2113 "EG_RESOLUTION_MATERIALCRYO", -1)] =
2135 "EG_RESOLUTION_MATERIALIBL", +1)] =
2138 "EG_RESOLUTION_MATERIALIBL", -1)] =
2141 "EG_RESOLUTION_MATERIALPP0", +1)] =
2144 "EG_RESOLUTION_MATERIALPP0", -1)] =
2204 if (systConfig.
empty())
2205 return StatusCode::SUCCESS;
2210 bool first_scale =
true;
2211 bool first_resolution =
true;
2212 for (
const auto& it : systConfig) {
2215 if (not first_scale) {
2217 throw std::runtime_error(
"multiple scale variations not supported");
2219 first_scale =
false;
2226 if (not first_resolution) {
2227 ATH_MSG_ERROR(
"multiple resolution variations not supported");
2228 throw std::runtime_error(
2229 "multiple resolution variations not supported");
2231 first_resolution =
false;
2236 return StatusCode::SUCCESS;
2240 double Ecl,
double phi,
double eta)
const {
2246 double Ecl_corr = 0.;
2266 phi_mod = fmod(
phi, 2 *
pi / 16.) +
pi / 8.;
2268 phi_mod = fmod(
phi, 2 *
pi / 16.);
2271 if (std::abs(
eta) <= 1.37) {
2277 ((1 / (1 + exp((phi_mod - 2 *
pi / 32.) * 175.2759))) *
2278 (1 / (1 + exp((phi_mod - 2 *
pi / 32.) * (-189.3612))))));
2279 if (
phi < (-6 *
pi / 8) &&
phi > (-7 *
pi / 8))
2283 ((1 / (1 + exp((phi_mod - 2 *
pi / 32.) * 170.8305))) *
2284 (1 / (1 + exp((phi_mod - 2 *
pi / 32.) * (-233.3782))))));
2285 if (
phi < (-5 *
pi / 8) &&
phi > (-6 *
pi / 8))
2289 ((1 / (1 + exp((phi_mod - 2 *
pi / 32.) * 147.1451))) *
2290 (1 / (1 + exp((phi_mod - 2 *
pi / 32.) * (-139.3386))))));
2291 if (
phi < (-4 *
pi / 8) &&
phi > (-5 *
pi / 8))
2295 ((1 / (1 + exp((phi_mod - 2 *
pi / 32.) * 168.4644))) *
2296 (1 / (1 + exp((phi_mod - 2 *
pi / 32.) * (-246.2897))))));
2297 if (
phi < (-3 *
pi / 8) &&
phi > (-4 *
pi / 8))
2301 ((1 / (1 + exp((phi_mod - 2 *
pi / 32.) * 177.6703))) *
2302 (1 / (1 + exp((phi_mod - 2 *
pi / 32.) * (-198.3227))))));
2303 if (
phi < (-2 *
pi / 8) &&
phi > (-3 *
pi / 8))
2307 ((1 / (1 + exp((phi_mod - 2 *
pi / 32.) * 145.0693))) *
2308 (1 / (1 + exp((phi_mod - 2 *
pi / 32.) * (-242.1771))))));
2309 if (
phi < (-1 *
pi / 8) &&
phi > (-2 *
pi / 8))
2313 ((1 / (1 + exp((phi_mod - 2 *
pi / 32.) * 132.3303))) *
2314 (1 / (1 + exp((phi_mod - 2 *
pi / 32.) * (-166.1833))))));
2315 if (
phi < (0 *
pi / 8) &&
phi > (-1 *
pi / 8))
2319 ((1 / (1 + exp((phi_mod - 2 *
pi / 32.) * 127.6780))) *
2320 (1 / (1 + exp((phi_mod - 2 *
pi / 32.) * (-150.0700))))));
2321 if (
phi < (1 *
pi / 8) &&
phi > (0 *
pi / 8))
2325 ((1 / (1 + exp((phi_mod - 2 *
pi / 32.) * 172.0679))) *
2326 (1 / (1 + exp((phi_mod - 2 *
pi / 32.) * (-235.3293))))));
2327 if (
phi < (2 *
pi / 8) &&
phi > (1 *
pi / 8))
2331 ((1 / (1 + exp((phi_mod - 2 *
pi / 32.) * 190.3524))) *
2332 (1 / (1 + exp((phi_mod - 2 *
pi / 32.) * (-198.9400))))));
2333 if (
phi < (3 *
pi / 8) &&
phi > (2 *
pi / 8))
2337 ((1 / (1 + exp((phi_mod - 2 *
pi / 32.) * 158.0540))) *
2338 (1 / (1 + exp((phi_mod - 2 *
pi / 32.) * (-165.3893))))));
2339 if (
phi < (4 *
pi / 8) &&
phi > (3 *
pi / 8))
2343 ((1 / (1 + exp((phi_mod - 2 *
pi / 32.) * 162.2793))) *
2344 (1 / (1 + exp((phi_mod - 2 *
pi / 32.) * (-133.5131))))));
2345 if (
phi < (5 *
pi / 8) &&
phi > (4 *
pi / 8))
2349 ((1 / (1 + exp((phi_mod - 2 *
pi / 32.) * 180.5270))) *
2350 (1 / (1 + exp((phi_mod - 2 *
pi / 32.) * (-168.5074))))));
2351 if (
phi < (6 *
pi / 8) &&
phi > (5 *
pi / 8))
2355 ((1 / (1 + exp((phi_mod - 2 *
pi / 32.) * 128.2277))) *
2356 (1 / (1 + exp((phi_mod - 2 *
pi / 32.) * (-154.4455))))));
2357 if (
phi < (7 *
pi / 8) &&
phi > (6 *
pi / 8))
2361 ((1 / (1 + exp((phi_mod - 2 *
pi / 32.) * 192.1216))) *
2362 (1 / (1 + exp((phi_mod - 2 *
pi / 32.) * (-198.0727))))));
2363 if (
phi < (8 *
pi / 8) &&
phi > (7 *
pi / 8))
2367 ((1 / (1 + exp((phi_mod - 2 *
pi / 32.) * 199.1735))) *
2368 (1 / (1 + exp((phi_mod - 2 *
pi / 32.) * (-176.4056))))));
2383 DivInt = (
int)(
phi / ((2 *
pi) / 16.));
2384 double phi_mod =
phi - DivInt * (2 *
pi / 16.);
2391 if (std::abs(
eta) <= 1.4) {
2396 Ecl / (1 - 0.131 * ((1 / (1 + exp((phi_mod - 0.2) * 199.08))) *
2397 (1 / (1 + exp((phi_mod - 0.2) * (-130.36))))));
2403 Ecl / (1 - 0.0879 * ((1 / (1 + exp((phi_mod - 0.2) * 221.01))) *
2404 (1 / (1 + exp((phi_mod - 0.2) * (-149.51))))));
2409 Ecl / (1 - 0.0605 * ((1 / (1 + exp((phi_mod - 0.2) * 281.37))) *
2410 (1 / (1 + exp((phi_mod - 0.2) * (-170.29))))));
2413 if ((
phi < (-3 *
pi) / 4.) || (
phi >= (3 *
pi) / 4.)) {
2415 Ecl / (1 - 0.102 * ((1 / (1 + exp((phi_mod - 0.2) * 235.37))) *
2416 (1 / (1 + exp((phi_mod - 0.2) * (-219.04))))));
2431 constexpr double PI =
M_PI;
2437 if (
phi < (14 *
PI / 32.) &&
phi > (13 *
PI / 32.)) {
2439 }
else if (
phi < (13 *
PI / 32.) &&
phi > (12 *
PI / 32.)) {
2460 if (
phi < (-7 * 2 *
PI / 32.) &&
phi > (-8 * 2 *
PI / 32.)) {
2468 }
else if (
phi < (-4 * 2 *
PI / 32.) &&
phi > (-5 * 2 *
PI / 32.)) {
2474 if (
phi < (7 * 2 *
PI / 32.) &&
phi > (6 * 2 *
PI / 32.)) {
2480 if (
phi < (-9 * 2 *
PI / 32.) &&
phi > (-10 * 2 *
PI / 32.)) {
2482 }
else if (
phi < (-11 * 2 *
PI / 32.) &&
phi > (-12 * 2 *
PI / 32.)) {
2488 if (
phi < (-12 * 2 *
PI / 32.) &&
phi > (-13 * 2 *
PI / 32.)) {
2494 if (
phi < (-12 * 2 *
PI / 32.) &&
phi > (-13 * 2 *
PI / 32.)) {
2496 }
else if (
phi < (-8 * 2 *
PI / 32.) &&
phi > (-9 * 2 *
PI / 32.)) {
2502 if (
phi < (-9 * 2 *
PI / 32.) &&
phi > (-10 * 2 *
PI / 32.)) {
2508 if (
phi < (-6 * 2 *
PI / 32.) &&
phi > (-7 * 2 *
PI / 32.)) {
2514 if (
phi < (9 * 2 *
PI / 32.) &&
phi > (8 * 2 *
PI / 32.)) {
2520 if (
phi < (-8 * 2 *
PI / 32.) &&
phi > (-9 * 2 *
PI / 32.)) {
2522 }
else if (
phi < (5 * 2 *
PI / 32.) &&
phi > (4 * 2 *
PI / 32.)) {
2524 }
else if (
phi < (9 * 2 *
PI / 32.) &&
phi > (8 * 2 *
PI / 32.)) {
2526 }
else if (
phi < (10 * 2 *
PI / 32.) &&
phi > (9 * 2 *
PI / 32.)) {
2528 }
else if (
phi < (11 * 2 *
PI / 32.) &&
phi > (10 * 2 *
PI / 32.)) {
2539 }
else if (
phi < (-4 * 2 *
PI / 32.) &&
phi > (-5 * 2 *
PI / 32.)) {
2545 if (
phi < (7 * 2 *
PI / 32.) &&
phi > (6 * 2 *
PI / 32.)) {
2551 if (
phi < (-11 * 2 *
PI / 32.) &&
phi > (-12 * 2 *
PI / 32.)) {
2557 if (
phi < (10 * 2 *
PI / 32.) &&
phi > (9 * 2 *
PI / 32.)) {
2563 if (
phi < (-4 * 2 *
PI / 32.) &&
phi > (-5 * 2 *
PI / 32.)) {
2565 }
else if (
phi < (-6 * 2 *
PI / 32.) &&
phi > (-7 * 2 *
PI / 32.)) {
2571 if (
phi < (9 * 2 *
PI / 32.) &&
phi > (8 * 2 *
PI / 32.)) {
2577 if (
phi < (-8 * 2 *
PI / 32.) &&
phi > (-9 * 2 *
PI / 32.)) {
2579 }
else if (
phi < (5 * 2 *
PI / 32.) &&
phi > (4 * 2 *
PI / 32.)) {
2581 }
else if (
phi < (9 * 2 *
PI / 32.) &&
phi > (8 * 2 *
PI / 32.)) {
2583 }
else if (
phi < (10 * 2 *
PI / 32.) &&
phi > (9 * 2 *
PI / 32.)) {
2585 }
else if (
phi < (11 * 2 *
PI / 32.) &&
phi > (10 * 2 *
PI / 32.)) {
2594void EgammaCalibrationAndSmearingTool ::
2597 for (
auto egamma : egammas) {
2599 throw std::runtime_error (
"EgammaCalibrationAndSmearingTool::callEvents: apply failed");
2603void EgammaCalibrationAndSmearingTool ::
2607 for (
auto event : events) {
2608 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.
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
StatusCode addPrivateTool(const std::string &name, AsgComponentConfig toolConfig)
add a private tool from the given configuration
an object that can create a AsgService
::StatusCode makeService(std::shared_ptr< T > &service) const
make a service with the given configuration
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)
constexpr double electronMassInMeV
the mass of the electron (in MeV)
constexpr double photonMassInMeV
various mass-less particles
ObjectRange< MutableEgammaDef > MutableEgammaRange
ObjectId< MutableEgammaDef > MutableEgammaId
ObjectRange< EventContextDef > EventContextRange
ObjectId< ClusterDef > ClusterId
ObjectId< EgammaDef > EgammaId
ObjectId< EventInfoDef > 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
Electron_v1 Electron
Definition of the current "egamma version".
static const SG::AuxElement::Accessor< ElementLink< IParticleContainer > > acc("originalObjectLink")
Object used for setting/getting the dynamic decoration in question.
A structure holding some global event information.