ATLAS Offline Software
AsgPhotonEfficiencyCorrectionTool.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 // Dear emacs, this is -*-c++-*-
6 
7 #ifndef PHOTONEFFICIENCYCORRECTION_ASGPHOTONEFFICIENCYCORRECTIONTOOL
8 #define PHOTONEFFICIENCYCORRECTION_ASGPHOTONEFFICIENCYCORRECTIONTOOL
9 
18 // STL includes
19 #include <vector>
20 #include <string>
21 #include <fstream>
22 #include <unordered_map>
23 
24 //xAOD includes
25 #include "AsgTools/AsgTool.h"
32 
40 
42  : virtual public IAsgPhotonEfficiencyCorrectionTool,
43  virtual public CP::ISystematicsTool,
44  public asg::AsgTool,
45  public columnar::ColumnarTool<>
46 {
48 
49 public:
51  AsgPhotonEfficiencyCorrectionTool ( const std::string& myname );
52 
55 
57  virtual StatusCode initialize() override;
58 
59 
60 public:
62  virtual CP::CorrectionCode getEfficiencyScaleFactor(const xAOD::Egamma& inputObject, double& efficiencyScaleFactor) const override;
63  CP::CorrectionCode getEfficiencyScaleFactor(columnar::EgammaId inputObject, columnar::EventInfoId eventInfo, double& efficiencyScaleFactor) const;
64  virtual CP::CorrectionCode getEfficiencyScaleFactorError(const xAOD::Egamma& inputObject, double& efficiencyScaleFactorError) const override;
65  CP::CorrectionCode getEfficiencyScaleFactorError(columnar::EgammaId inputObject, columnar::EventInfoId eventInfo, double& efficiencyScaleFactorError) const;
66  virtual CP::CorrectionCode applyEfficiencyScaleFactor(xAOD::Egamma& inputObject) const override;
67 
69 
71  virtual bool isAffectedBySystematic( const CP::SystematicVariation& systematic ) const override;
72 
74  virtual CP::SystematicSet affectingSystematics() const override;
75 
77  virtual CP::SystematicSet recommendedSystematics() const override;
78 
81  assert (m_appliedSystematics != nullptr);
82  return *m_appliedSystematics;
83  }
84 
86  virtual StatusCode applySystematicVariation ( const CP::SystematicSet& systConfig ) override;
87 
89 
90  // Private member variables
91 private:
95 
99 
101  std::unordered_map<CP::SystematicSet, CP::SystematicSet> m_systFilter;
102 
105 
106  // The prefix for the systematic name
107  std::string m_sysSubstring;
108 
109  // Get the correction filename from the map
110  std::string getFileName(const std::string& isoWP, const std::string& trigWP, bool isConv);
111 
112  // Set prefix of the corresponding calibration filenames:
113  std::string m_file_prefix_ID="efficiencySF.offline.";
114  std::string m_file_prefix_ISO="efficiencySF.Isolation.";
115  std::string m_file_prefix_Trig="efficiencySF.";
116  std::string m_file_prefix_TrigEff="efficiency.";
117 
118  // Properties
119 
121  std::string m_corrFileNameConv;
122  std::string m_corrFileNameUnconv;
123 
125  std::string m_resultPrefix;
126 
128  std::string m_resultName;
129 
132 
134  std::string m_isoWP;
135 
137  std::string m_trigger;
138 
140  std::string m_mapFile;
141 
142  // bin boundaries of correction files
143  std::map<float, std::vector<float>> m_pteta_bins;
144 
145  //use RandomRun Number
148 
149  // remove TRT converted photon for Run-3
151 
152  Gaudi::Property<bool> m_allowMissingLinks{ this, "AllowMissingLinks", false, "Allow missing links in the input objects. This should only be used by experts running on expert formats." };
153 
154  // an accessor structure that hides the columnar accessors from the
155  // root dictionaries that can't handle them. these dictionaries are
156  // used by some users to instantiate the tools (instead of using the
157  // factory mechanism).
159  {
161 
167 
169 
174 
178  };
179  std::unique_ptr<Accessors> m_accessors {std::make_unique<Accessors>(*this)};
180 
181 
182 public:
183 
185  void callEvents (columnar::EventContextRange events) const override;
186 
187 }; // End: class definition
188 
189 
190 #endif
191 
AsgPhotonEfficiencyCorrectionTool::Accessors::clusterEAcc
columnar::ClusterAccessor< float > clusterEAcc
Definition: AsgPhotonEfficiencyCorrectionTool.h:176
AsgPhotonEfficiencyCorrectionTool::getEfficiencyScaleFactorError
virtual CP::CorrectionCode getEfficiencyScaleFactorError(const xAOD::Egamma &inputObject, double &efficiencyScaleFactorError) const override
Get the "photon scale factor error" as a return value.
Definition: AsgPhotonEfficiencyCorrectionTool.cxx:330
AsgPhotonEfficiencyCorrectionTool::m_dataTypeOverwrite
int m_dataTypeOverwrite
Force the data type to a given value.
Definition: AsgPhotonEfficiencyCorrectionTool.h:131
asg::AsgTool
Base class for the dual-use tool implementation classes.
Definition: AsgTool.h:47
PropertyWrapper.h
AsgPhotonEfficiencyCorrectionTool::callEvents
void callEvents(columnar::EventContextRange events) const override
Definition: AsgPhotonEfficiencyCorrectionTool.cxx:502
LinkColumn.h
AsgPhotonEfficiencyCorrectionTool::affectingSystematics
virtual CP::SystematicSet affectingSystematics() const override
returns: the list of all systematics this tool can be affected by
Definition: AsgPhotonEfficiencyCorrectionTool.cxx:378
get_generator_info.result
result
Definition: get_generator_info.py:21
AsgPhotonEfficiencyCorrectionTool::AsgPhotonEfficiencyCorrectionTool
AsgPhotonEfficiencyCorrectionTool(const std::string &myname)
Standard constructor.
Definition: AsgPhotonEfficiencyCorrectionTool.cxx:42
AsgPhotonEfficiencyCorrectionTool::m_defaultRandomRunNumber
int m_defaultRandomRunNumber
Definition: AsgPhotonEfficiencyCorrectionTool.h:147
AsgPhotonEfficiencyCorrectionTool::Accessors::randomRunNumberAcc
columnar::EventInfoAccessor< uint32_t > randomRunNumberAcc
Definition: AsgPhotonEfficiencyCorrectionTool.h:168
IAsgPhotonEfficiencyCorrectionTool
Definition: IAsgPhotonEfficiencyCorrectionTool.h:23
AsgPhotonEfficiencyCorrectionTool::m_pteta_bins
std::map< float, std::vector< float > > m_pteta_bins
Definition: AsgPhotonEfficiencyCorrectionTool.h:143
AsgPhotonEfficiencyCorrectionTool::m_useRandomRunNumber
bool m_useRandomRunNumber
Definition: AsgPhotonEfficiencyCorrectionTool.h:146
AsgPhotonEfficiencyCorrectionTool::Accessors::caloClusterAcc
columnar::EgammaAccessor< std::vector< columnar::OptClusterId > > caloClusterAcc
Definition: AsgPhotonEfficiencyCorrectionTool.h:175
AsgPhotonEfficiencyCorrectionTool::m_file_prefix_ID
std::string m_file_prefix_ID
Definition: AsgPhotonEfficiencyCorrectionTool.h:113
CP::SystematicSet
Class to wrap a set of SystematicVariations.
Definition: SystematicSet.h:31
AsgPhotonEfficiencyCorrectionTool::Accessors::eventInfoAcc
columnar::EventInfoAccessor< columnar::ObjectColumn > eventInfoAcc
Definition: AsgPhotonEfficiencyCorrectionTool.h:162
AsgPhotonEfficiencyCorrectionTool::m_file_prefix_TrigEff
std::string m_file_prefix_TrigEff
Definition: AsgPhotonEfficiencyCorrectionTool.h:116
AsgPhotonEfficiencyCorrectionTool::getFileName
std::string getFileName(const std::string &isoWP, const std::string &trigWP, bool isConv)
Definition: AsgPhotonEfficiencyCorrectionTool.cxx:436
AsgPhotonEfficiencyCorrectionTool::~AsgPhotonEfficiencyCorrectionTool
virtual ~AsgPhotonEfficiencyCorrectionTool()
Standard destructor.
Definition: AsgPhotonEfficiencyCorrectionTool.cxx:90
xAOD::Egamma_v1
Definition: Egamma_v1.h:56
AsgPhotonEfficiencyCorrectionTool::m_rootTool_unc
Root::TElectronEfficiencyCorrectionTool * m_rootTool_unc
Pointer to the underlying ROOT based tool.
Definition: AsgPhotonEfficiencyCorrectionTool.h:97
IAsgPhotonEfficiencyCorrectionTool.h
AsgPhotonEfficiencyCorrectionTool::applyEfficiencyScaleFactor
virtual CP::CorrectionCode applyEfficiencyScaleFactor(xAOD::Egamma &inputObject) const override
Decorate the photon with its scale factor.
Definition: AsgPhotonEfficiencyCorrectionTool.cxx:356
CP::SystematicVariation
Definition: SystematicVariation.h:47
AsgPhotonEfficiencyCorrectionTool::initialize
virtual StatusCode initialize() override
Gaudi Service Interface method implementations.
Definition: AsgPhotonEfficiencyCorrectionTool.cxx:99
columnar::ObjectRange
a class representing a continuous sequence of objects (a.k.a. a container)
Definition: ContainerId.h:177
python.DataFormatRates.events
events
Definition: DataFormatRates.py:105
AsgPhotonEfficiencyCorrectionTool::Accessors::tracksAcc
columnar::TrackAccessor< columnar::ObjectColumn > tracksAcc
Definition: AsgPhotonEfficiencyCorrectionTool.h:166
AsgPhotonEfficiencyCorrectionTool::isAffectedBySystematic
virtual bool isAffectedBySystematic(const CP::SystematicVariation &systematic) const override
The methods below should notify the user of what is actually in the list , without him having to go i...
Definition: AsgPhotonEfficiencyCorrectionTool.cxx:368
AsgPhotonEfficiencyCorrectionTool::m_accessors
std::unique_ptr< Accessors > m_accessors
Definition: AsgPhotonEfficiencyCorrectionTool.h:179
AsgPhotonEfficiencyCorrectionTool::Accessors::Accessors
Accessors(AsgPhotonEfficiencyCorrectionTool &tool)
Definition: AsgPhotonEfficiencyCorrectionTool.h:160
ISystematicsTool.h
AsgPhotonEfficiencyCorrectionTool::m_file_prefix_ISO
std::string m_file_prefix_ISO
Definition: AsgPhotonEfficiencyCorrectionTool.h:114
columnar::ClusterHelpers::EtaBEAccessor
Definition: ClusterHelpers.h:60
Root::TElectronEfficiencyCorrectionTool::Result
Definition: TElectronEfficiencyCorrectionTool.h:42
AsgPhotonEfficiencyCorrectionTool::Accessors::sfDec
columnar::EgammaDecorator< float > sfDec
Definition: AsgPhotonEfficiencyCorrectionTool.h:172
AsgPhotonEfficiencyCorrectionTool::m_isoWP
std::string m_isoWP
Isolation working point.
Definition: AsgPhotonEfficiencyCorrectionTool.h:134
event
POOL::TEvent event(POOL::TEvent::kClassAccess)
AsgPhotonEfficiencyCorrectionTool::m_resultName
std::string m_resultName
The string for the result.
Definition: AsgPhotonEfficiencyCorrectionTool.h:128
AsgPhotonEfficiencyCorrectionTool::m_resultPrefix
std::string m_resultPrefix
The prefix string for the result.
Definition: AsgPhotonEfficiencyCorrectionTool.h:125
AsgPhotonEfficiencyCorrectionTool::getEfficiencyScaleFactor
virtual CP::CorrectionCode getEfficiencyScaleFactor(const xAOD::Egamma &inputObject, double &efficiencyScaleFactor) const override
Add some method for now as a first step to move the tool to then new interface.
Definition: AsgPhotonEfficiencyCorrectionTool.cxx:296
SystematicRegistry.h
AsgPhotonEfficiencyCorrectionTool::recommendedSystematics
virtual CP::SystematicSet recommendedSystematics() const override
returns: the list of all systematics this tool recommends to use
Definition: AsgPhotonEfficiencyCorrectionTool.cxx:399
EgammaHelpers.h
EventInfoDef.h
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ColumnAccessor.h
AsgPhotonEfficiencyCorrectionTool::Accessors::verticesAcc
columnar::VertexAccessor< columnar::ObjectColumn > verticesAcc
Definition: AsgPhotonEfficiencyCorrectionTool.h:165
AsgPhotonEfficiencyCorrectionTool::m_allowMissingLinks
Gaudi::Property< bool > m_allowMissingLinks
Definition: AsgPhotonEfficiencyCorrectionTool.h:152
AsgPhotonEfficiencyCorrectionTool::Accessors::validDec
columnar::EgammaDecorator< char > validDec
Definition: AsgPhotonEfficiencyCorrectionTool.h:173
AsgPhotonEfficiencyCorrectionTool::Accessors::photonsAcc
columnar::EgammaAccessor< columnar::ObjectColumn > photonsAcc
Definition: AsgPhotonEfficiencyCorrectionTool.h:163
ObjectColumn.h
ClusterHelpers.h
AsgPhotonEfficiencyCorrectionTool::m_systFilter
std::unordered_map< CP::SystematicSet, CP::SystematicSet > m_systFilter
Systematics filter map.
Definition: AsgPhotonEfficiencyCorrectionTool.h:101
VectorColumn.h
AsgPhotonEfficiencyCorrectionTool::Accessors::clusterAcc
columnar::ClusterAccessor< columnar::ObjectColumn > clusterAcc
Definition: AsgPhotonEfficiencyCorrectionTool.h:164
AsgPhotonEfficiencyCorrectionTool
Definition: AsgPhotonEfficiencyCorrectionTool.h:46
AsgPhotonEfficiencyCorrectionTool::m_file_prefix_Trig
std::string m_file_prefix_Trig
Definition: AsgPhotonEfficiencyCorrectionTool.h:115
Root::TElectronEfficiencyCorrectionTool
Definition: TElectronEfficiencyCorrectionTool.h:36
AsgPhotonEfficiencyCorrectionTool::callSingleEvent
void callSingleEvent(columnar::EgammaRange photons, columnar::EventInfoId event) const
Definition: AsgPhotonEfficiencyCorrectionTool.cxx:479
AsgPhotonEfficiencyCorrectionTool::Accessors::etaAcc
columnar::EgammaAccessor< float > etaAcc
Definition: AsgPhotonEfficiencyCorrectionTool.h:170
AsgPhotonEfficiencyCorrectionTool::Result
Root::TElectronEfficiencyCorrectionTool::Result Result
Definition: AsgPhotonEfficiencyCorrectionTool.h:92
AsgPhotonEfficiencyCorrectionTool::applySystematicVariation
virtual StatusCode applySystematicVariation(const CP::SystematicSet &systConfig) override
Configure this tool for the given systematics.
Definition: AsgPhotonEfficiencyCorrectionTool.cxx:409
columnar::EgammaHelpers::IsConvertedPhotonAccessor
Definition: EgammaHelpers.h:51
columnar::ObjectId
a class representing a single object (electron, muons, etc.)
Definition: ContainerId.h:178
AsgPhotonEfficiencyCorrectionTool::m_mapFile
std::string m_mapFile
map filename
Definition: AsgPhotonEfficiencyCorrectionTool.h:140
AsgPhotonEfficiencyCorrectionTool::registerSystematics
StatusCode registerSystematics()
Register the systematics with the registry and add them to the recommended list.
Definition: AsgPhotonEfficiencyCorrectionTool.cxx:389
AtlCoolConsole.tool
tool
Definition: AtlCoolConsole.py:452
CP::ISystematicsTool
Interface for all CP tools supporting systematic variations.
Definition: ISystematicsTool.h:32
AsgPhotonEfficiencyCorrectionTool::m_corrFileNameUnconv
std::string m_corrFileNameUnconv
Definition: AsgPhotonEfficiencyCorrectionTool.h:122
AsgPhotonEfficiencyCorrectionTool::Accessors
Definition: AsgPhotonEfficiencyCorrectionTool.h:159
AsgPhotonEfficiencyCorrectionTool::m_rootTool_con
Root::TElectronEfficiencyCorrectionTool * m_rootTool_con
Definition: AsgPhotonEfficiencyCorrectionTool.h:98
AsgPhotonEfficiencyCorrectionTool::appliedSystematics
const CP::SystematicSet & appliedSystematics() const
returns: the currently applied systematics
Definition: AsgPhotonEfficiencyCorrectionTool.h:80
AsgPhotonEfficiencyCorrectionTool::m_appliedSystematics
CP::SystematicSet * m_appliedSystematics
Currently applied systematics.
Definition: AsgPhotonEfficiencyCorrectionTool.h:104
columnar
Definition: ClusterDef.h:16
AsgPhotonEfficiencyCorrectionTool::m_trigger
std::string m_trigger
Trigger name for trigger SF.
Definition: AsgPhotonEfficiencyCorrectionTool.h:137
AsgPhotonEfficiencyCorrectionTool::calculate
CP::CorrectionCode calculate(columnar::EgammaId egam, columnar::EventInfoId eventInfo, Result &result) const
I think these calculate methods are only used internally.
Definition: AsgPhotonEfficiencyCorrectionTool.cxx:181
columnar::ColumnarTool
the base class for all columnar components
Definition: ColumnAccessorDataArray.h:17
ASG_TOOL_CLASS3
#define ASG_TOOL_CLASS3(CLASSNAME, INT1, INT2, INT3)
Definition: AsgToolMacros.h:85
CP::CorrectionCode
Return value from object correction CP tools.
Definition: CorrectionCode.h:31
CP::IReentrantSystematicsTool
interface for all CP tools supporting systematic variations within a reentrant algorithm
Definition: IReentrantSystematicsTool.h:58
CorrectionCode.h
AsgPhotonEfficiencyCorrectionTool::Accessors::clusterEtaBEAcc
columnar::ClusterHelpers::EtaBEAccessor clusterEtaBEAcc
Definition: AsgPhotonEfficiencyCorrectionTool.h:177
AsgPhotonEfficiencyCorrectionTool::Accessors::isConvertedPhotonAcc
columnar::EgammaHelpers::IsConvertedPhotonAccessor isConvertedPhotonAcc
Definition: AsgPhotonEfficiencyCorrectionTool.h:171
TElectronEfficiencyCorrectionTool.h
columnar::AccessorTemplate
the raw column accessor template class
Definition: ColumnAccessor.h:81
AsgPhotonEfficiencyCorrectionTool::m_sysSubstring
std::string m_sysSubstring
Definition: AsgPhotonEfficiencyCorrectionTool.h:107
AsgPhotonEfficiencyCorrectionTool::m_corrFileNameConv
std::string m_corrFileNameConv
The list of input file names.
Definition: AsgPhotonEfficiencyCorrectionTool.h:121
AsgTool.h
AsgPhotonEfficiencyCorrectionTool::m_removeTRTConversion
bool m_removeTRTConversion
Definition: AsgPhotonEfficiencyCorrectionTool.h:150