ATLAS Offline Software
Loading...
Searching...
No Matches
ElectronPhotonVariableNFCorrectionTool.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
5#ifndef ElectronPhotonVariableNFCorrectionTool_H
6#define ElectronPhotonVariableNFCorrectionTool_H
7
8
22 * @author Katerina Kazakova <katerina.kazakova@cern.ch>
23 * @date February 2026
24 */
25
26
40
41//EDM includes
42#include "xAODEgamma/Electron.h"
43#include "xAODEgamma/Photon.h"
44
45#include <memory>
46#include <vector>
47#include <string>
48
49// ===========================================================================
50// Class ElectronPhotonVariableNFCorrectionTool
51// ===========================================================================
52
54{
55
57
58public:
62 ElectronPhotonVariableNFCorrectionTool(const std::string& name);
63
66
78 virtual StatusCode initialize() override;
79
86 virtual const CP::CorrectionCode applyCorrection(xAOD::Photon& photon) const override;
87
89 virtual const CP::CorrectionCode applyCorrection(xAOD::Electron& electron) const override;
90
95 virtual const CP::CorrectionCode correctedCopy(const xAOD::Photon& in_photon,
96 xAOD::Photon*& out_photon) const override;
97
99 virtual const CP::CorrectionCode correctedCopy(const xAOD::Electron& in_electron,
100 xAOD::Electron*& out_electron) const override;
101
102
103private:
105 Gaudi::Property<std::string> m_configFile {this, "ConfigFile", "", "The configuration file for Normalizing Flows to use"};
106 Gaudi::Property<int> m_nFoldsOverride {this, "NFoldsOverride", -1, "If > 0, override the number of folds to use instead of the value from the config file (must not exceed NFolds in the config)"};
107 Gaudi::Property<std::string> m_applyToStr {this, "ApplyTo", "TruthPhotons", "TruthPhotons or All"};
108 Gaudi::Property<float> m_pTcutMeV {this, "pTcut", 10000.f, "Min photon pT in MeV"};
109
111 int m_nFolds{0};
112
114 std::string m_onnxPattern;
115
117 SG::ReadHandleKey<xAOD::EventInfo> m_eventInfoKey{this, "EventInfoKey", "EventInfo", "EventInfo key"};
118
120 enum class ApplyToMode { TruthPhotons, All };
122
125
127 bool passPhotonSelection(const xAOD::Photon& photon) const;
128
130 bool passShowerShapeCuts(const std::vector<float>& ss) const;
131
135 CP::CorrectionCode applyFallbackFudge(xAOD::Photon& photon, const std::vector<float>& ss) const;
136
138 ToolHandle<IElectronPhotonShowerShapeFudgeTool> m_fallbackFudgeTool{this, "FallbackFudgeTool", "", "Fudge tool applied to photons which fail the shower shape cuts"};
139
141 static constexpr float s_defaultValueThreshold = -100.f;
142
149
152
158 int selectFold(unsigned long long eventNumber, float phi) const;
159
161 FoldStrategy parseFoldStrategy(const std::string& s) const;
162
164 ToolHandleArray<AthOnnx::IOnnxRuntimeInferenceTool> m_onnxToolsForward{this, "OnnxInferenceToolsForward", {}, "Forward ONNX tools per fold"};
166 ToolHandleArray<AthOnnx::IOnnxRuntimeInferenceTool> m_onnxToolsBackward{this, "OnnxInferenceToolsBackward", {}, "Backward ONNX tools per fold"};
167
169 static const std::vector<std::string> s_ssVarNames;
170
172 static const std::vector<xAOD::EgammaParameters::ShowerShapeType> s_ssEnums;
173
175 struct SSAccessors {
176 std::unique_ptr<SG::Accessor<float>> original;
177 };
178
180 std::vector<SSAccessors> m_accessors;
181
182}; // end class ElectronPhotonVariableNFCorrectionTool
183
184#endif
185
Scalar phi() const
phi method
#define ASG_TOOL_CLASS(CLASSNAME, INT1)
Property holding a SG store/key/clid from which a ReadHandle is made.
Handle class for reading from StoreGate.
Base class for elements of a container that can have aux data.
static Double_t ss
struct TBPatternUnitContext Unknown
Return value from object correction CP tools.
std::vector< SSAccessors > m_accessors
Per-variable accessors aligned with s_ssVarNames.
ToolHandleArray< AthOnnx::IOnnxRuntimeInferenceTool > m_onnxToolsForward
ToolHandleArray for forward ONNX models (one tool per fold).
bool passShowerShapeCuts(const std::vector< float > &ss) const
Returns true if the shower shapes pass the cuts removing default values.
static const std::vector< std::string > s_ssVarNames
List of shower shape variable names (order must match model I/O).
FoldStrategy parseFoldStrategy(const std::string &s) const
Parse fold strategy string from config.
SG::ReadHandleKey< xAOD::EventInfo > m_eventInfoKey
ReadHandleKey for EventInfo used for fold selection.
int selectFold(unsigned long long eventNumber, float phi) const
Select fold index for the current event/photon.
virtual const CP::CorrectionCode correctedCopy(const xAOD::Photon &in_photon, xAOD::Photon *&out_photon) const override
Make a corrected copy of the passed photon.
std::string m_onnxPattern
Models path pattern string from config.
ToolHandleArray< AthOnnx::IOnnxRuntimeInferenceTool > m_onnxToolsBackward
ToolHandleArray for backward ONNX models (one tool per fold).
bool m_applyShowerShapeCuts
Cuts applied to remove default values of shower shapes.
ElectronPhotonVariableNFCorrectionTool(const std::string &name)
Standard constructor.
static const std::vector< xAOD::EgammaParameters::ShowerShapeType > s_ssEnums
Egamma shower shape enum mapping for reading/writing values (order matches s_ssVarNames).
int m_nFolds
Number of model folds configured (must match tool handle array sizes).
virtual const CP::CorrectionCode applyCorrection(xAOD::Photon &photon) const override
Apply the Normalizing Flow correction to the passed photon.
virtual StatusCode initialize() override
Initialize the class instance.
static constexpr float s_defaultValueThreshold
Original values of weta1 and wtots1 below this threshold are default values and are not fudged.
bool passPhotonSelection(const xAOD::Photon &photon) const
Returns true if the photon passes the pT and truthType selection.
Gaudi::Property< std::string > m_configFile
The configuration file for the tool, application mode and minimum photon pT cut in MeV.
FoldStrategy m_foldStrategy
Selected fold strategy (configured via FoldStrategy in the config).
ApplyToMode
NF will be applied only for TruthPhotons, or for All photons.
CP::CorrectionCode applyFallbackFudge(xAOD::Photon &photon, const std::vector< float > &ss) const
Apply the fallback fudge tool to a photon failing only the shower shape cuts.
ToolHandle< IElectronPhotonShowerShapeFudgeTool > m_fallbackFudgeTool
Fudge tool used for photons failing the shower shape cuts, empty = no fallback.
Property holding a SG store/key/clid from which a ReadHandle is made.
Base class for the dual-use tool implementation classes.
Definition AsgTool.h:47
Photon_v1 Photon
Definition of the current "egamma version".
Electron_v1 Electron
Definition of the current "egamma version".
Accessor used to decorate photons per shower shape variable.