![]() |
ATLAS Offline Software
|
Normalizing Flows-based correction tool for photon MC shower shape variables. More...
#include <ElectronPhotonVariableNFCorrectionTool.h>
Classes | |
| struct | SSAccessors |
| Accessor used to decorate photons per shower shape variable. More... | |
Public Member Functions | |
| ElectronPhotonVariableNFCorrectionTool (const std::string &name) | |
| Standard constructor. | |
| ~ElectronPhotonVariableNFCorrectionTool () | |
| Standard destructor. | |
| virtual StatusCode | initialize () override |
| Initialize the class instance. | |
| virtual const CP::CorrectionCode | applyCorrection (xAOD::Photon &photon) const override |
| Apply the Normalizing Flow correction to the passed photon. | |
| virtual const CP::CorrectionCode | applyCorrection (xAOD::Electron &electron) const override |
| Not supported, so electrons cannot be corrected by this tool. | |
| virtual const CP::CorrectionCode | correctedCopy (const xAOD::Photon &in_photon, xAOD::Photon *&out_photon) const override |
| Make a corrected copy of the passed photon. | |
| virtual const CP::CorrectionCode | correctedCopy (const xAOD::Electron &in_electron, xAOD::Electron *&out_electron) const override |
| Not supported, so electrons cannot be corrected by this tool. | |
| virtual void | print () const |
| Print the state of the tool. | |
| ServiceHandle< StoreGateSvc > & | evtStore () |
The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc. | |
| const ServiceHandle< StoreGateSvc > & | detStore () const |
The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc. | |
| virtual StatusCode | sysInitialize () override |
| Perform system initialization for an algorithm. | |
| virtual StatusCode | sysStart () override |
| Handle START transition. | |
| virtual std::vector< Gaudi::DataHandle * > | inputHandles () const override |
| Return this algorithm's input handles. | |
| virtual std::vector< Gaudi::DataHandle * > | outputHandles () const override |
| Return this algorithm's output handles. | |
| Gaudi::Details::PropertyBase & | declareProperty (Gaudi::Property< T, V, H > &t) |
| void | updateVHKA (Gaudi::Details::PropertyBase &) |
| MsgStream & | msg () const |
| bool | msgLvl (const MSG::Level lvl) const |
Additional helper functions, not directly mimicking Athena | |
| template<class T> | |
| const T * | getProperty (const std::string &name) const |
| Get one of the tool's properties. | |
| const std::string & | msg_level_name () const __attribute__((deprecated)) |
| A deprecated function for getting the message level's name. | |
| const std::string & | getName (const void *ptr) const |
| Get the name of an object that is / should be in the event store. | |
| SG::sgkey_t | getKey (const void *ptr) const |
| Get the (hashed) key of an object that is in the event store. | |
Protected Member Functions | |
| void | renounceArray (SG::VarHandleKeyArray &handlesArray) |
| remove all handles from I/O resolution | |
| std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > | renounce (T &h) |
| void | extraDeps_update_handler (Gaudi::Details::PropertyBase &ExtraDeps) |
| Add StoreName to extra input/output deps as needed. | |
Private Types | |
| enum class | ApplyToMode { TruthPhotons , All } |
| NF will be applied only for TruthPhotons, or for All photons. More... | |
| enum class | FoldStrategy { Unknown , EventNumber , EventNumberPhi } |
| Fold selection strategy. More... | |
| typedef ServiceHandle< StoreGateSvc > | StoreGateSvc_t |
Private Member Functions | |
| bool | passPhotonSelection (const xAOD::Photon &photon) const |
| Returns true if the photon passes the pT and truthType selection. | |
| bool | passShowerShapeCuts (const std::vector< float > &ss) const |
| Returns true if the shower shapes pass the cuts removing default values. | |
| 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. | |
| int | selectFold (unsigned long long eventNumber, float phi) const |
| Select fold index for the current event/photon. | |
| FoldStrategy | parseFoldStrategy (const std::string &s) const |
| Parse fold strategy string from config. | |
| Gaudi::Details::PropertyBase & | declareGaudiProperty (Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &) |
| specialization for handling Gaudi::Property<SG::VarHandleKey> | |
Private Attributes | |
| Gaudi::Property< std::string > | m_configFile {this, "ConfigFile", "", "The configuration file for Normalizing Flows to use"} |
| The configuration file for the tool, application mode and minimum photon pT cut in MeV. | |
| 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)"} |
| Gaudi::Property< std::string > | m_applyToStr {this, "ApplyTo", "TruthPhotons", "TruthPhotons or All"} |
| Gaudi::Property< float > | m_pTcutMeV {this, "pTcut", 10000.f, "Min photon pT in MeV"} |
| int | m_nFolds {0} |
| Number of model folds configured (must match tool handle array sizes). | |
| std::string | m_onnxPattern |
| Models path pattern string from config. | |
| SG::ReadHandleKey< xAOD::EventInfo > | m_eventInfoKey {this, "EventInfoKey", "EventInfo", "EventInfo key"} |
| ReadHandleKey for EventInfo used for fold selection. | |
| ApplyToMode | m_applyToMode {ApplyToMode::TruthPhotons} |
| bool | m_applyShowerShapeCuts {true} |
| Cuts applied to remove default values of shower shapes. | |
| ToolHandle< IElectronPhotonShowerShapeFudgeTool > | m_fallbackFudgeTool {this, "FallbackFudgeTool", "", "Fudge tool applied to photons which fail the shower shape cuts"} |
| Fudge tool used for photons failing the shower shape cuts, empty = no fallback. | |
| FoldStrategy | m_foldStrategy {FoldStrategy::EventNumber} |
| Selected fold strategy (configured via FoldStrategy in the config). | |
| ToolHandleArray< AthOnnx::IOnnxRuntimeInferenceTool > | m_onnxToolsForward {this, "OnnxInferenceToolsForward", {}, "Forward ONNX tools per fold"} |
| ToolHandleArray for forward ONNX models (one tool per fold). | |
| ToolHandleArray< AthOnnx::IOnnxRuntimeInferenceTool > | m_onnxToolsBackward {this, "OnnxInferenceToolsBackward", {}, "Backward ONNX tools per fold"} |
| ToolHandleArray for backward ONNX models (one tool per fold). | |
| std::vector< SSAccessors > | m_accessors |
| Per-variable accessors aligned with s_ssVarNames. | |
| StoreGateSvc_t | m_evtStore |
| Pointer to StoreGate (event store by default). | |
| StoreGateSvc_t | m_detStore |
| Pointer to StoreGate (detector store by default). | |
| std::vector< SG::VarHandleKeyArray * > | m_vhka |
| bool | m_varHandleArraysDeclared |
Static Private Attributes | |
| static constexpr float | s_defaultValueThreshold = -100.f |
| Original values of weta1 and wtots1 below this threshold are default values and are not fudged. | |
| static const std::vector< std::string > | s_ssVarNames |
| List of shower shape variable names (order must match model I/O). | |
| static const std::vector< xAOD::EgammaParameters::ShowerShapeType > | s_ssEnums |
| Egamma shower shape enum mapping for reading/writing values (order matches s_ssVarNames). | |
Normalizing Flows-based correction tool for photon MC shower shape variables.
The tool applies a two-step NF mapping using ONNX Runtime inference:
The correction is applied to the photon shower shape variables listed in s_ssVarNames (the order should correspond to order in a model).
The ONNX models are provided per-fold via ToolHandleArray, and the fold is selected event-by-event using EventInfo::eventNumber() (optionally including phi).
Definition at line 53 of file ElectronPhotonVariableNFCorrectionTool.h.
|
privateinherited |
Definition at line 376 of file AthCommonDataStore.h.
|
strongprivate |
NF will be applied only for TruthPhotons, or for All photons.
| Enumerator | |
|---|---|
| TruthPhotons | |
| All | |
Definition at line 120 of file ElectronPhotonVariableNFCorrectionTool.h.
|
strongprivate |
Fold selection strategy.
| Enumerator | |
|---|---|
| Unknown | |
| EventNumber | |
| EventNumberPhi | |
Definition at line 148 of file ElectronPhotonVariableNFCorrectionTool.h.
| ElectronPhotonVariableNFCorrectionTool::ElectronPhotonVariableNFCorrectionTool | ( | const std::string & | name | ) |
Standard constructor.
| name | Internal name of the tool instance |
Definition at line 43 of file ElectronPhotonVariableNFCorrectionTool.cxx.
|
inline |
|
overridevirtual |
Not supported, so electrons cannot be corrected by this tool.
Implements IElectronPhotonShowerShapeFudgeTool.
Definition at line 419 of file ElectronPhotonVariableNFCorrectionTool.cxx.
|
overridevirtual |
Apply the Normalizing Flow correction to the passed photon.
| photon | The photon to be corrected |
Reads the configured shower-shape variables from the photon, runs forward and backward ONNX inference for the selected fold, and overwrites the photon shower-shape values with the corrected outputs.
Implements IElectronPhotonShowerShapeFudgeTool.
Definition at line 255 of file ElectronPhotonVariableNFCorrectionTool.cxx.
|
private |
Apply the fallback fudge tool to a photon failing only the shower shape cuts.
weta1 and wtots1 are kept at their original values if these are below s_defaultValueThreshold
Definition at line 121 of file ElectronPhotonVariableNFCorrectionTool.cxx.
|
overridevirtual |
Not supported, so electrons cannot be corrected by this tool.
Implements IElectronPhotonShowerShapeFudgeTool.
Definition at line 435 of file ElectronPhotonVariableNFCorrectionTool.cxx.
|
overridevirtual |
Make a corrected copy of the passed photon.
| in_photon | The original photon to copy |
| out_photon | The corrected copy |
Implements IElectronPhotonShowerShapeFudgeTool.
Definition at line 426 of file ElectronPhotonVariableNFCorrectionTool.cxx.
|
inlineprivateinherited |
specialization for handling Gaudi::Property<SG::VarHandleKey>
Definition at line 156 of file AthCommonDataStore.h.
|
inlineinherited |
Definition at line 145 of file AthCommonDataStore.h.
|
inlineinherited |
The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
Definition at line 95 of file AthCommonDataStore.h.
|
inlineinherited |
The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
Definition at line 85 of file AthCommonDataStore.h.
|
protectedinherited |
Add StoreName to extra input/output deps as needed.
use the logic of the VarHandleKey to parse the DataObjID keys supplied via the ExtraInputs and ExtraOuputs Properties to add the StoreName if it's not explicitly given
|
inherited |
Get the (hashed) key of an object that is in the event store.
This is a bit of a special one. StoreGateSvc and xAOD::Event both provide ways for getting the SG::sgkey_t key for an object that is in the store, based on a bare pointer. But they provide different interfaces for doing so.
In order to allow tools to efficiently perform this operation, they can use this helper function.
| ptr | The bare pointer to the object that the event store should know about |
Definition at line 119 of file AsgTool.cxx.
Get the name of an object that is / should be in the event store.
This is a bit of a special one. StoreGateSvc and xAOD::Event both provide ways for getting the std::string name for an object that is in the store, based on a bare pointer. But they provide different interfaces for doing so.
In order to allow tools to efficiently perform this operation, they can use this helper function.
| ptr | The bare pointer to the object that the event store should know about |
Definition at line 106 of file AsgTool.cxx.
Get one of the tool's properties.
|
overridevirtual |
Initialize the class instance.
Reads the configuration file set via setProperty("ConfigFile", ...) function and sets up the class instance accordingly.
The configuration provides:
Reimplemented from asg::AsgTool.
Definition at line 147 of file ElectronPhotonVariableNFCorrectionTool.cxx.
|
overridevirtualinherited |
Return this algorithm's input handles.
We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.
|
inlineinherited |
Definition at line 24 of file AthCommonMsg.h.
|
inherited |
A deprecated function for getting the message level's name.
Instead of using this, weirdly named function, user code should get the string name of the current minimum message level (in case they really need it...), with:
This function's name doesn't follow the ATLAS coding rules, and as such will be removed in the not too distant future.
Definition at line 101 of file AsgTool.cxx.
|
inlineinherited |
Definition at line 30 of file AthCommonMsg.h.
|
overridevirtualinherited |
Return this algorithm's output handles.
We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.
|
private |
Parse fold strategy string from config.
Definition at line 64 of file ElectronPhotonVariableNFCorrectionTool.cxx.
|
private |
Returns true if the photon passes the pT and truthType selection.
Definition at line 72 of file ElectronPhotonVariableNFCorrectionTool.cxx.
|
private |
Returns true if the shower shapes pass the cuts removing default values.
Definition at line 91 of file ElectronPhotonVariableNFCorrectionTool.cxx.
|
virtualinherited |
Print the state of the tool.
Implements asg::IAsgTool.
Reimplemented in AsgHelloTool, HI::HIPileupTool, JetBottomUpSoftDrop, JetConstituentsRetriever, JetDumper, JetFinder, JetFromPseudojet, JetModifiedMassDrop, JetPileupLabelingTool, JetPruner, JetPseudojetRetriever, JetReclusterer, JetReclusteringTool, JetRecTool, JetRecursiveSoftDrop, JetSoftDrop, JetSplitter, JetSubStructureMomentToolsBase, JetToolRunner, JetTrimmer, JetTruthLabelingTool, and KtDeltaRTool.
Definition at line 131 of file AsgTool.cxx.
|
inlineprotectedinherited |
Definition at line 368 of file AthCommonDataStore.h.
|
inlineprotectedinherited |
remove all handles from I/O resolution
Definition at line 352 of file AthCommonDataStore.h.
|
private |
Select fold index for the current event/photon.
| eventNumber | EventInfo::eventNumber() |
| phi | Photon phi in radians |
Definition at line 48 of file ElectronPhotonVariableNFCorrectionTool.cxx.
|
overridevirtualinherited |
Perform system initialization for an algorithm.
We override this to declare all the elements of handle key arrays at the end of initialization. See comments on updateVHKA.
Reimplemented in asg::AsgMetadataTool, AthCheckedComponent< AthAlgTool >, and AthCheckedComponent<::AthAlgTool >.
|
overridevirtualinherited |
Handle START transition.
We override this in order to make sure that conditions handle keys can cache a pointer to the conditions container.
|
inlineinherited |
Definition at line 298 of file AthCommonDataStore.h.
|
private |
Per-variable accessors aligned with s_ssVarNames.
Definition at line 180 of file ElectronPhotonVariableNFCorrectionTool.h.
|
private |
Cuts applied to remove default values of shower shapes.
Definition at line 124 of file ElectronPhotonVariableNFCorrectionTool.h.
|
private |
Definition at line 121 of file ElectronPhotonVariableNFCorrectionTool.h.
|
private |
Definition at line 107 of file ElectronPhotonVariableNFCorrectionTool.h.
|
private |
The configuration file for the tool, application mode and minimum photon pT cut in MeV.
Definition at line 105 of file ElectronPhotonVariableNFCorrectionTool.h.
|
privateinherited |
Pointer to StoreGate (detector store by default).
Definition at line 381 of file AthCommonDataStore.h.
|
private |
ReadHandleKey for EventInfo used for fold selection.
Definition at line 117 of file ElectronPhotonVariableNFCorrectionTool.h.
|
privateinherited |
Pointer to StoreGate (event store by default).
Definition at line 378 of file AthCommonDataStore.h.
|
private |
Fudge tool used for photons failing the shower shape cuts, empty = no fallback.
Definition at line 138 of file ElectronPhotonVariableNFCorrectionTool.h.
|
private |
Selected fold strategy (configured via FoldStrategy in the config).
Definition at line 151 of file ElectronPhotonVariableNFCorrectionTool.h.
|
private |
Number of model folds configured (must match tool handle array sizes).
Definition at line 111 of file ElectronPhotonVariableNFCorrectionTool.h.
|
private |
Definition at line 106 of file ElectronPhotonVariableNFCorrectionTool.h.
|
private |
Models path pattern string from config.
Definition at line 114 of file ElectronPhotonVariableNFCorrectionTool.h.
|
private |
ToolHandleArray for backward ONNX models (one tool per fold).
Definition at line 166 of file ElectronPhotonVariableNFCorrectionTool.h.
|
private |
ToolHandleArray for forward ONNX models (one tool per fold).
Definition at line 164 of file ElectronPhotonVariableNFCorrectionTool.h.
|
private |
Definition at line 108 of file ElectronPhotonVariableNFCorrectionTool.h.
|
privateinherited |
Definition at line 387 of file AthCommonDataStore.h.
|
privateinherited |
Definition at line 386 of file AthCommonDataStore.h.
|
staticconstexprprivate |
Original values of weta1 and wtots1 below this threshold are default values and are not fudged.
Definition at line 141 of file ElectronPhotonVariableNFCorrectionTool.h.
|
staticprivate |
Egamma shower shape enum mapping for reading/writing values (order matches s_ssVarNames).
Definition at line 27 of file ElectronPhotonVariableNFCorrectionTool.h.
|
staticprivate |
List of shower shape variable names (order must match model I/O).
Definition at line 22 of file ElectronPhotonVariableNFCorrectionTool.h.