ATLAS Offline Software
Loading...
Searching...
No Matches
AsgElectronEfficiencyCorrectionTool.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4
5#ifndef __ASGELECTRONEFFICIENCYCORRECTIONTOOL__
6#define __ASGELECTRONEFFICIENCYCORRECTIONTOOL__
7
15
16// Fwd Declarations
17class TH2F;
20// Interface
22// STL includes
23#include <map>
24#include <string>
25#include <unordered_map>
26#include <vector>
27// PAT includes
32
40
44 , public columnar::ColumnarTool<>
45{
48
49public:
51 AsgElectronEfficiencyCorrectionTool(const std::string& myname);
53 virtual ~AsgElectronEfficiencyCorrectionTool() override final;
55 virtual StatusCode initialize() override final;
56
57 /*
58 * Metadata tool methods
59 */
60 virtual StatusCode beginInputFile() override final;
61 virtual StatusCode beginEvent() override final;
62
63 /*
64 * ISystematic tool methods
65 */
67 virtual CP::SystematicSet affectingSystematics() const override final;
69 virtual CP::SystematicSet recommendedSystematics() const override final;
71 virtual bool isAffectedBySystematic(
72 const CP::SystematicVariation& systematic) const override final;
74 virtual StatusCode applySystematicVariation(
75 const CP::SystematicSet& systConfig) override final;
76
77 /*
78 * IAsgElectronEfficiencyCorrectionTool methods
79 */
81 const xAOD::Electron& inputObject,
82 double& efficiencyScaleFactor) const override final;
84 columnar::ElectronId inputObject,
85 double& efficiencyScaleFactor,
86 columnar::EventInfoId info) const;
87 //
89 const double et, /*in MeV*/
90 const double cluster_eta, /*cluster*/
91 const unsigned int runNumber,
92 double& efficiencyScaleFactor) const override final;
93 //
95 const xAOD::Electron& inputObject) const override final;
96 //
97 virtual int getNumberOfToys() const override final
98 {
99 return m_number_of_toys;
100 };
101
102 virtual void printCorrelationModels() const override final
103 {
105 " Available Correlation Models for the ElectronEfficiencyCorrectionTool");
106 ATH_MSG_INFO("FULL");
107 ATH_MSG_INFO("SIMPLIFIED");
108 ATH_MSG_INFO("MCTOYS");
109 ATH_MSG_INFO("SYST");
110 ATH_MSG_INFO("COMBMCTOYS");
111 ATH_MSG_INFO("TOTAL");
112 };
113
115 virtual const CP::SystematicSet& appliedSystematics() const override final
116 {
117 return *m_appliedSystematics;
118 }
119
120 virtual int systUncorrVariationIndex(
121 const xAOD::Electron& inputObject) const override final;
123 columnar::ElectronId inputObject) const;
124
125private:
126 StatusCode registerSystematics();
127
128 int currentSimplifiedUncorrSystRegion(const double cluster_eta,
129 const double et) const;
130 int currentUncorrSystRegion(const double cluster_eta, const double et) const;
131
133 StatusCode InitSystematics();
134
135 // Gets the correction filename from map
136 virtual StatusCode getFile(const std::string& recokey,
137 const std::string& idkey,
138 const std::string& isokey,
139 const std::string& trigkey);
140 // Get the simulation type from metadata
141 StatusCode get_simType_from_metadata(
143
144 // struct for toys
145 struct SystConf
146 {
147 float m_total;
148 unsigned m_toy_index;
150 };
151
154
156 std::unique_ptr<Root::TElectronEfficiencyCorrectionTool> m_rootTool = nullptr;
157
159 std::unordered_map<CP::SystematicSet, CP::SystematicSet> m_systFilter;
160
163
166
167 // Correlation Model
170
171 // Map-key properties
172 std::string m_mapFile;
173
174 // Four SF key Properties
175 std::string m_recoKey;
176 std::string m_idKey;
177 std::string m_isoKey;
178 std::string m_trigKey;
179
181 std::vector<std::string> m_corrFileNameList;
182
184 std::string m_resultPrefix;
185
187 std::string m_resultName;
188
189 // The prefix for the systematic name
190 std::string m_sysSubstring;
191
194
195 // use RandomRun Number
198
199 // The data type
201
204
205 // Number of toys:
207
208 // seed for toys:
210
211 // scale for toy uncertainty:
213
214 // number of systematic uncertainties
217 std::vector<std::pair<float, std::vector<float>>> m_pteta_bins;
218
219 // custom binning for SIMPLIFIED model
220 std::vector<float> m_uncorrSimplfEtaBinsUser;
221 std::vector<float> m_uncorrSimplfEtBinsUser;
222
223 // simplified uncorrelation regions
226
227 // Caching of variations we know after initialize
228 std::string m_toysBasename;
229 std::vector<CP::SystematicVariation> m_corrVarUp;
230 std::vector<CP::SystematicVariation> m_corrVarDown;
231 std::vector<CP::SystematicVariation> m_uncorrVarUp;
232 std::vector<CP::SystematicVariation> m_uncorrVarDown;
233
234public:
235
256 std::unique_ptr<Accessors> m_accessors;
257
259 void callEvents (columnar::EventContextRange events) const override;
260
261}; // End: class definition
262
263#endif
#define ASG_TOOL_CLASS(CLASSNAME, INT1)
#define ATH_MSG_INFO(x)
void callSingleEvent(columnar::ElectronRange electrons, columnar::EventInfoId event) const
virtual StatusCode beginInputFile() override final
Function called when a new input file is opened.
int currentSimplifiedUncorrSystRegion(const double cluster_eta, const double et) const
std::string m_eventInfoCollectionName
The Event info collection name.
StatusCode InitSystematics()
initialize the systematics
std::vector< std::string > m_corrFileNameList
The list of file names.
virtual StatusCode applySystematicVariation(const CP::SystematicSet &systConfig) override final
Configure this tool for the given systematics.
virtual CP::CorrectionCode applyEfficiencyScaleFactor(const xAOD::Electron &inputObject) const override final
std::vector< CP::SystematicVariation > m_uncorrVarDown
void callEvents(columnar::EventContextRange events) const override
CP::SystematicSet m_affectedSys
Affected systematic, should be done only once.
std::unordered_map< CP::SystematicSet, CP::SystematicSet > m_systFilter
Systematics filter map.
std::vector< CP::SystematicVariation > m_corrVarDown
std::vector< CP::SystematicVariation > m_corrVarUp
std::unique_ptr< Root::TElectronEfficiencyCorrectionTool > m_rootTool
Pointer to the underlying ROOT based tool.
int m_dataTypeOverwrite
Force the data type to a given value.
virtual CP::CorrectionCode getEfficiencyScaleFactor(const xAOD::Electron &inputObject, double &efficiencyScaleFactor) const override final
virtual CP::SystematicSet affectingSystematics() const override final
returns: the list of all systematics this tool can be affected by
std::string m_resultName
The string for the result.
virtual StatusCode beginEvent() override final
Function called when a new events is loaded.
virtual const CP::SystematicSet & appliedSystematics() const override final
returns: the currently applied systematics
std::string m_resultPrefix
The prefix string for the result.
bool m_metadata_retrieved
To check if the metadata can be retrieved.
virtual void printCorrelationModels() const override final
print available/implemented correlation models
virtual StatusCode initialize() override final
Gaudi Service Interface method implementations.
virtual CP::SystematicSet recommendedSystematics() const override final
returns: the list of all systematics this tool recommends to use
virtual StatusCode getFile(const std::string &recokey, const std::string &idkey, const std::string &isokey, const std::string &trigkey)
Gets the correction filename from map.
virtual ASG_TOOL_CLASS(AsgElectronEfficiencyCorrectionTool, IAsgElectronEfficiencyCorrectionTool) public ~AsgElectronEfficiencyCorrectionTool() override final
Standard destructor.
std::vector< std::pair< float, std::vector< float > > > m_pteta_bins
virtual bool isAffectedBySystematic(const CP::SystematicVariation &systematic) const override final
returns: whether this tool is affected by the given systematis
CP::SystematicSet * m_appliedSystematics
Currently applied systematics.
virtual int systUncorrVariationIndex(const xAOD::Electron &inputObject) const override final
StatusCode get_simType_from_metadata(PATCore::ParticleDataType::DataType &result) const
std::vector< CP::SystematicVariation > m_uncorrVarUp
int currentUncorrSystRegion(const double cluster_eta, const double et) const
Return value from object correction CP tools.
Class to wrap a set of SystematicVariations.
Base class for dual-use tools that provide file metadata access.
the base class for all columnar components
AccessorTemplate< ContainerId::electron, CT, ColumnAccessMode::input, CM > ElectronAccessor
Definition EgammaDef.h:40
ObjectId< ContainerId::electron > ElectronId
Definition EgammaDef.h:38
AccessorTemplate< ContainerId::eventInfo, CT, ColumnAccessMode::input, CM > EventInfoAccessor
ObjectRange< ContainerId::eventContext > EventContextRange
AccessorTemplate< ContainerId::electron, CT, ColumnAccessMode::output, CM > ElectronDecorator
Definition EgammaDef.h:41
ObjectRange< ContainerId::electron > ElectronRange
Definition EgammaDef.h:37
AccessorTemplate< ContainerId::cluster, CT, ColumnAccessMode::input, CM > ClusterAccessor
Definition ClusterDef.h:28
ObjectId< ContainerId::eventInfo > EventInfoId
Electron_v1 Electron
Definition of the current "egamma version".
columnar::ClusterAccessor< columnar::ObjectColumn > m_clusterHandle
columnar::EventInfoAccessor< columnar::ObjectColumn > m_eventInfo
columnar::ElectronAccessor< columnar::ObjectColumn > m_electrons
columnar::ElectronAccessor< std::vector< columnar::OptClusterId > > caloClusterAcc
Extra patterns decribing particle interation process.