ATLAS Offline Software
Loading...
Searching...
No Matches
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
17
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
41namespace ADD_CMODE(CP)
42{
43
44class AsgPhotonEfficiencyCorrectionTool
46 virtual public CP::ISystematicsTool,
47 public asg::AsgTool,
49{
51
52public:
54 AsgPhotonEfficiencyCorrectionTool ( const std::string& myname );
55
57 virtual ~AsgPhotonEfficiencyCorrectionTool();
58
60 virtual StatusCode initialize() override;
61
62
63public:
65 virtual CP::CorrectionCode getEfficiencyScaleFactor(const xAOD::Egamma& inputObject, double& efficiencyScaleFactor) const override;
66 CP::CorrectionCode getEfficiencyScaleFactor(columnar::EgammaId inputObject, columnar::EventInfoId eventInfo, double& efficiencyScaleFactor) const;
67 virtual CP::CorrectionCode getEfficiencyScaleFactorError(const xAOD::Egamma& inputObject, double& efficiencyScaleFactorError) const override;
68 CP::CorrectionCode getEfficiencyScaleFactorError(columnar::EgammaId inputObject, columnar::EventInfoId eventInfo, double& efficiencyScaleFactorError) const;
69 virtual CP::CorrectionCode applyEfficiencyScaleFactor(xAOD::Egamma& inputObject) const override;
70
72
74 virtual bool isAffectedBySystematic( const CP::SystematicVariation& systematic ) const override;
75
77 virtual CP::SystematicSet affectingSystematics() const override;
78
80 virtual CP::SystematicSet recommendedSystematics() const override;
81
83 const CP::SystematicSet& appliedSystematics() const {
84 assert (m_appliedSystematics != nullptr);
85 return *m_appliedSystematics;
86 }
87
89 virtual StatusCode applySystematicVariation ( const CP::SystematicSet& systConfig ) override;
90
91 StatusCode registerSystematics();
92
93 // Private member variables
94private:
97 CP::CorrectionCode calculate( columnar::EgammaId egam, columnar::EventInfoId eventInfo, Result& result ) const;
98
102
104 std::unordered_map<CP::SystematicSet, CP::SystematicSet> m_systFilter;
105
107 CP::SystematicSet* m_appliedSystematics = nullptr;
108
109 // The prefix for the systematic name
110 std::string m_sysSubstring;
111
112 // Get the correction filename from the map
113 std::string getFileName(const std::string& isoWP, const std::string& trigWP, bool isConv);
114
115 // Set prefix of the corresponding calibration filenames:
116 std::string m_file_prefix_ID="efficiencySF.offline.";
117 std::string m_file_prefix_ISO="efficiencySF.Isolation.";
118 std::string m_file_prefix_Trig="efficiencySF.";
119 std::string m_file_prefix_TrigEff="efficiency.";
120
121 // Properties
122
124 std::string m_corrFileNameConv;
125 std::string m_corrFileNameUnconv;
126
128 std::string m_resultPrefix;
129
131 std::string m_resultName;
132
134 int m_dataTypeOverwrite;
135
137 std::string m_isoWP;
138
140 std::string m_trigger;
141
143 std::string m_mapFile;
144
145 // bin boundaries of correction files
146 std::map<float, std::vector<float>> m_pteta_bins;
147
148 //use RandomRun Number
149 bool m_useRandomRunNumber;
150 int m_defaultRandomRunNumber;
151
152 // remove TRT converted photon for Run-3
153 bool m_removeTRTConversion;
154
155 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." };
156
157 // an accessor structure that hides the columnar accessors from the
158 // root dictionaries that can't handle them. these dictionaries are
159 // used by some users to instantiate the tools (instead of using the
160 // factory mechanism).
161 struct Accessors : public columnar::ColumnarTool<>
162 {
163 Accessors(AsgPhotonEfficiencyCorrectionTool& tool) : columnar::ColumnarTool<>(&tool) {}
164
165 columnar::EventInfoAccessor<columnar::ObjectColumn> eventInfoAcc {*this, "EventInfo", {.addMTDependency=true}};
166 columnar::EgammaAccessor<columnar::ObjectColumn> photonsAcc {*this, "Photons"};
167 columnar::ClusterAccessor<columnar::ObjectColumn> clusterAcc {*this, "egammaClusters"};
168 columnar::VertexAccessor<columnar::ObjectColumn> verticesAcc {*this, "GSFConversionVertices"};
169 columnar::TrackAccessor<columnar::ObjectColumn> tracksAcc {*this, "GSFTrackParticles"};
170
171 columnar::EventInfoAccessor<uint32_t> randomRunNumberAcc {*this, "RandomRunNumber"};
172
173 columnar::EgammaAccessor<float> etaAcc{*this,"eta"};
175 columnar::EgammaDecorator<float> sfDec{*this,"sfOut"};
176 columnar::EgammaDecorator<char> validDec{*this,"validOut"};
177
178 columnar::EgammaAccessor<std::vector<columnar::OptClusterId>> caloClusterAcc {*this, "caloClusterLinks"};
179 columnar::ClusterAccessor<float> clusterEAcc {*this, "calE"};
180 columnar::ClusterHelpers::EtaBEAccessor<> clusterEtaBEAcc {*this};
181 };
182 std::unique_ptr<Accessors> m_accessors {std::make_unique<Accessors>(*this)};
183
184
185public:
186
187 void callSingleEvent (columnar::EgammaRange photons, columnar::EventInfoId event) const;
188 void callEvents (columnar::EventContextRange events) const override;
189
190}; // End: class definition
191
192} // namespace ADD_CMODE(CP)
193
194#endif
195
#define ASG_TOOL_CLASS3(CLASSNAME, INT1, INT2, INT3)
Return value from object correction CP tools.
interface for all CP tools supporting systematic variations within a reentrant algorithm
Interface for all CP tools supporting systematic variations.
Class to wrap a set of SystematicVariations.
Base class for the dual-use tool implementation classes.
Definition AsgTool.h:47
the base class for all columnar components
AccessorTemplate< ClusterDef, CT, ColumnAccessMode::input, CM > ClusterAccessor
Definition ClusterDef.h:25
ObjectRange< EgammaDef > EgammaRange
Definition EgammaDef.h:46
AccessorTemplate< EgammaDef, CT, ColumnAccessMode::input, CM > EgammaAccessor
Definition EgammaDef.h:49
ObjectRange< EventContextDef > EventContextRange
AccessorTemplate< VertexDef, CT, ColumnAccessMode::input, CM > VertexAccessor
Definition TrackDef.h:66
AccessorTemplate< EgammaDef, CT, ColumnAccessMode::output, CM > EgammaDecorator
Definition EgammaDef.h:50
AccessorTemplate< TrackDef, CT, ColumnAccessMode::input, CM > TrackAccessor
Definition TrackDef.h:45
ObjectId< EgammaDef > EgammaId
Definition EgammaDef.h:47
ObjectId< EventInfoDef > EventInfoId
AccessorTemplate< EventInfoDef, CT, ColumnAccessMode::input, CM > EventInfoAccessor
Egamma_v1 Egamma
Definition of the current "egamma version".
Definition Egamma.h:17
void initialize()