ATLAS Offline Software
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 
16 // Fwd Declarations
17 class TH2F;
19 #include "xAODEgamma/ElectronFwd.h"
20 // Interface
22 // STL includes
23 #include <map>
24 #include <string>
25 #include <unordered_map>
26 #include <vector>
27 // PAT includes
29 #include "PATCore/PATCoreEnums.h"
32 
35  , public asg::AsgMetadataTool
36 {
39 
40 public:
42  AsgElectronEfficiencyCorrectionTool(const std::string& myname);
44  virtual ~AsgElectronEfficiencyCorrectionTool() override final;
46  virtual StatusCode initialize() override final;
47 
48  /*
49  * Metadata tool methods
50  */
51  virtual StatusCode beginInputFile() override final;
52  virtual StatusCode beginEvent() override final;
53 
54  /*
55  * ISystematic tool methods
56  */
58  virtual CP::SystematicSet affectingSystematics() const override final;
60  virtual CP::SystematicSet recommendedSystematics() const override final;
62  virtual bool isAffectedBySystematic(
63  const CP::SystematicVariation& systematic) const override final;
66  const CP::SystematicSet& systConfig) override final;
67 
68  /*
69  * IAsgElectronEfficiencyCorrectionTool methods
70  */
72  const xAOD::Electron& inputObject,
73  double& efficiencyScaleFactor) const override final;
74  //
76  const double et, /*in MeV*/
77  const double cluster_eta, /*cluster*/
78  const unsigned int runNumber,
79  double& efficiencyScaleFactor) const override final;
80  //
82  const xAOD::Electron& inputObject) const override final;
83  //
84  virtual int getNumberOfToys() const override final
85  {
86  return m_number_of_toys;
87  };
89  virtual void printCorrelationModels() const override final
90  {
92  " Available Correlation Models for the ElectronEfficiencyCorrectionTool");
93  ATH_MSG_INFO("FULL");
94  ATH_MSG_INFO("SIMPLIFIED");
95  ATH_MSG_INFO("MCTOYS");
96  ATH_MSG_INFO("SYST");
97  ATH_MSG_INFO("COMBMCTOYS");
98  ATH_MSG_INFO("TOTAL");
99  };
100 
102  virtual const CP::SystematicSet& appliedSystematics() const override final
103  {
104  return *m_appliedSystematics;
105  }
106 
107  virtual int systUncorrVariationIndex(
108  const xAOD::Electron& inputObject) const override final;
109 
110 private:
112 
113  int currentSimplifiedUncorrSystRegion(const double cluster_eta,
114  const double et) const;
115  int currentUncorrSystRegion(const double cluster_eta, const double et) const;
116 
119 
120  // Gets the correction filename from map
121  virtual StatusCode getFile(const std::string& recokey,
122  const std::string& idkey,
123  const std::string& isokey,
124  const std::string& trigkey);
125  // Get the simulation type from metadata
128 
129  // struct for toys
130  struct SystConf
131  {
132  float m_total;
133  unsigned m_toy_index;
134  float m_toy_scale;
135  };
136 
138  bool m_metadata_retrieved = false;
139 
141  std::unique_ptr<Root::TElectronEfficiencyCorrectionTool> m_rootTool = nullptr;
142 
144  std::unordered_map<CP::SystematicSet, CP::SystematicSet> m_systFilter;
145 
148 
151 
152  // Correlation Model
155 
156  // Map-key properties
157  std::string m_mapFile;
158 
159  // Four SF key Properties
160  std::string m_recoKey;
161  std::string m_idKey;
162  std::string m_isoKey;
163  std::string m_trigKey;
164 
166  std::vector<std::string> m_corrFileNameList;
167 
169  std::string m_resultPrefix;
170 
172  std::string m_resultName;
173 
174  // The prefix for the systematic name
175  std::string m_sysSubstring;
176 
179 
180  // use RandomRun Number
183 
184  // The data type
186 
189 
190  // Number of toys:
192 
193  // seed for toys:
195 
196  // scale for toy uncertainty:
197  double m_scale_toys;
198 
199  // number of systematic uncertainties
202  std::vector<std::pair<float, std::vector<float>>> m_pteta_bins;
203 
204  // custom binning for SIMPLIFIED model
205  std::vector<float> m_uncorrSimplfEtaBinsUser;
206  std::vector<float> m_uncorrSimplfEtBinsUser;
207 
208  // simplified uncorrelation regions
211 
212  // Caching of variations we know after initialize
213  std::string m_toysBasename;
214  std::vector<CP::SystematicVariation> m_corrVarUp;
215  std::vector<CP::SystematicVariation> m_corrVarDown;
216  std::vector<CP::SystematicVariation> m_uncorrVarUp;
217  std::vector<CP::SystematicVariation> m_uncorrVarDown;
218 
219 }; // End: class definition
220 
221 #endif
AsgElectronEfficiencyCorrectionTool::getFile
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.
Definition: AsgElectronEfficiencyCorrectionTool.cxx:834
AsgElectronEfficiencyCorrectionTool::m_correlation_model
int m_correlation_model
Definition: AsgElectronEfficiencyCorrectionTool.h:154
AsgElectronEfficiencyCorrectionTool::applySystematicVariation
virtual StatusCode applySystematicVariation(const CP::SystematicSet &systConfig) override final
Configure this tool for the given systematics.
Definition: AsgElectronEfficiencyCorrectionTool.cxx:591
AsgElectronEfficiencyCorrectionTool
Definition: AsgElectronEfficiencyCorrectionTool.h:36
et
Extra patterns decribing particle interation process.
AsgElectronEfficiencyCorrectionTool::m_corrFileNameList
std::vector< std::string > m_corrFileNameList
The list of file names.
Definition: AsgElectronEfficiencyCorrectionTool.h:166
AsgElectronEfficiencyCorrectionTool::recommendedSystematics
virtual CP::SystematicSet recommendedSystematics() const override final
returns: the list of all systematics this tool recommends to use
Definition: AsgElectronEfficiencyCorrectionTool.cxx:585
get_generator_info.result
result
Definition: get_generator_info.py:21
AsgElectronEfficiencyCorrectionTool::m_idKey
std::string m_idKey
Definition: AsgElectronEfficiencyCorrectionTool.h:161
AsgElectronEfficiencyCorrectionTool::m_appliedSystematics
CP::SystematicSet * m_appliedSystematics
Currently applied systematics.
Definition: AsgElectronEfficiencyCorrectionTool.h:150
AsgElectronEfficiencyCorrectionTool::m_rootTool
std::unique_ptr< Root::TElectronEfficiencyCorrectionTool > m_rootTool
Pointer to the underlying ROOT based tool.
Definition: AsgElectronEfficiencyCorrectionTool.h:141
AsgElectronEfficiencyCorrectionTool::m_mapFile
std::string m_mapFile
Definition: AsgElectronEfficiencyCorrectionTool.h:157
AsgElectronEfficiencyCorrectionTool::InitSystematics
StatusCode InitSystematics()
initialize the systematics
Definition: AsgElectronEfficiencyCorrectionTool.cxx:639
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
AsgElectronEfficiencyCorrectionTool::m_uncorrSimplfEtaBinsUser
std::vector< float > m_uncorrSimplfEtaBinsUser
Definition: AsgElectronEfficiencyCorrectionTool.h:205
IAsgElectronEfficiencyCorrectionTool.h
AsgElectronEfficiencyCorrectionTool::SystConf::m_toy_scale
float m_toy_scale
Definition: AsgElectronEfficiencyCorrectionTool.h:134
AsgElectronEfficiencyCorrectionTool::m_useRandomRunNumber
bool m_useRandomRunNumber
Definition: AsgElectronEfficiencyCorrectionTool.h:181
CP::SystematicSet
Class to wrap a set of SystematicVariations.
Definition: SystematicSet.h:31
AsgElectronEfficiencyCorrectionTool::currentUncorrSystRegion
int currentUncorrSystRegion(const double cluster_eta, const double et) const
Definition: AsgElectronEfficiencyCorrectionTool.cxx:748
AsgElectronEfficiencyCorrectionTool::SystConf
Definition: AsgElectronEfficiencyCorrectionTool.h:131
AsgElectronEfficiencyCorrectionTool::initialize
virtual StatusCode initialize() override final
Gaudi Service Interface method implementations.
Definition: AsgElectronEfficiencyCorrectionTool.cxx:150
AsgElectronEfficiencyCorrectionTool::registerSystematics
StatusCode registerSystematics()
Definition: AsgElectronEfficiencyCorrectionTool.cxx:572
AsgElectronEfficiencyCorrectionTool::m_resultName
std::string m_resultName
The string for the result.
Definition: AsgElectronEfficiencyCorrectionTool.h:172
AsgElectronEfficiencyCorrectionTool::m_correlation_model_name
std::string m_correlation_model_name
Definition: AsgElectronEfficiencyCorrectionTool.h:153
const
bool const RAWDATA *ch2 const
Definition: LArRodBlockPhysicsV0.cxx:560
CP::SystematicVariation
Definition: SystematicVariation.h:47
python.TrigEgammaMonitorHelper.TH2F
def TH2F(name, title, nxbins, bins_par2, bins_par3, bins_par4, bins_par5=None, bins_par6=None, path='', **kwargs)
Definition: TrigEgammaMonitorHelper.py:45
AsgElectronEfficiencyCorrectionTool::m_defaultRandomRunNumber
int m_defaultRandomRunNumber
Definition: AsgElectronEfficiencyCorrectionTool.h:182
AsgElectronEfficiencyCorrectionTool::beginInputFile
virtual StatusCode beginInputFile() override final
Function called when a new input file is opened.
Definition: AsgElectronEfficiencyCorrectionTool.cxx:887
AsgElectronEfficiencyCorrectionTool::m_dataType
PATCore::ParticleDataType::DataType m_dataType
Definition: AsgElectronEfficiencyCorrectionTool.h:185
PATCore::ParticleDataType::DataType
DataType
Definition: PATCoreEnums.h:22
AsgElectronEfficiencyCorrectionTool::m_isoKey
std::string m_isoKey
Definition: AsgElectronEfficiencyCorrectionTool.h:162
AsgElectronEfficiencyCorrectionTool::SystConf::m_toy_index
unsigned m_toy_index
Definition: AsgElectronEfficiencyCorrectionTool.h:133
AsgElectronEfficiencyCorrectionTool::m_uncorrSimplfEtBinsUser
std::vector< float > m_uncorrSimplfEtBinsUser
Definition: AsgElectronEfficiencyCorrectionTool.h:206
AsgElectronEfficiencyCorrectionTool::m_toysBasename
std::string m_toysBasename
Definition: AsgElectronEfficiencyCorrectionTool.h:213
AsgElectronEfficiencyCorrectionTool::getNumberOfToys
virtual int getNumberOfToys() const override final
Definition: AsgElectronEfficiencyCorrectionTool.h:84
SystematicRegistry.h
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
AsgElectronEfficiencyCorrectionTool::m_uncorrVarDown
std::vector< CP::SystematicVariation > m_uncorrVarDown
Definition: AsgElectronEfficiencyCorrectionTool.h:217
PATCoreEnums.h
AsgElectronEfficiencyCorrectionTool::m_nCorrSyst
int m_nCorrSyst
Definition: AsgElectronEfficiencyCorrectionTool.h:200
AsgElectronEfficiencyCorrectionTool::m_recoKey
std::string m_recoKey
Definition: AsgElectronEfficiencyCorrectionTool.h:160
AsgElectronEfficiencyCorrectionTool::appliedSystematics
virtual const CP::SystematicSet & appliedSystematics() const override final
returns: the currently applied systematics
Definition: AsgElectronEfficiencyCorrectionTool.h:102
AsgElectronEfficiencyCorrectionTool::m_number_of_toys
int m_number_of_toys
Definition: AsgElectronEfficiencyCorrectionTool.h:191
AsgElectronEfficiencyCorrectionTool::m_resultPrefix
std::string m_resultPrefix
The prefix string for the result.
Definition: AsgElectronEfficiencyCorrectionTool.h:169
ElectronFwd.h
AsgElectronEfficiencyCorrectionTool::systUncorrVariationIndex
virtual int systUncorrVariationIndex(const xAOD::Electron &inputObject) const override final
Definition: AsgElectronEfficiencyCorrectionTool.cxx:801
AsgElectronEfficiencyCorrectionTool::m_seed_toys
int m_seed_toys
Definition: AsgElectronEfficiencyCorrectionTool.h:194
AsgElectronEfficiencyCorrectionTool::applyEfficiencyScaleFactor
virtual CP::CorrectionCode applyEfficiencyScaleFactor(const xAOD::Electron &inputObject) const override final
Definition: AsgElectronEfficiencyCorrectionTool.cxx:532
AsgElectronEfficiencyCorrectionTool::m_nUncorrSyst
int m_nUncorrSyst
Definition: AsgElectronEfficiencyCorrectionTool.h:201
AsgElectronEfficiencyCorrectionTool::m_scale_toys
double m_scale_toys
Definition: AsgElectronEfficiencyCorrectionTool.h:197
AsgElectronEfficiencyCorrectionTool::m_dataTypeOverwrite
int m_dataTypeOverwrite
Force the data type to a given value.
Definition: AsgElectronEfficiencyCorrectionTool.h:188
AsgElectronEfficiencyCorrectionTool::m_corrVarDown
std::vector< CP::SystematicVariation > m_corrVarDown
Definition: AsgElectronEfficiencyCorrectionTool.h:215
AsgElectronEfficiencyCorrectionTool::~AsgElectronEfficiencyCorrectionTool
virtual ASG_TOOL_CLASS(AsgElectronEfficiencyCorrectionTool, IAsgElectronEfficiencyCorrectionTool) public ~AsgElectronEfficiencyCorrectionTool() override final
Standard destructor.
Definition: AsgElectronEfficiencyCorrectionTool.cxx:142
AsgElectronEfficiencyCorrectionTool::printCorrelationModels
virtual void printCorrelationModels() const override final
print available/implemented correlation models
Definition: AsgElectronEfficiencyCorrectionTool.h:89
AsgElectronEfficiencyCorrectionTool::getEfficiencyScaleFactor
virtual CP::CorrectionCode getEfficiencyScaleFactor(const xAOD::Electron &inputObject, double &efficiencyScaleFactor) const override final
Definition: AsgElectronEfficiencyCorrectionTool.cxx:329
AsgElectronEfficiencyCorrectionTool::m_systFilter
std::unordered_map< CP::SystematicSet, CP::SystematicSet > m_systFilter
Systematics filter map.
Definition: AsgElectronEfficiencyCorrectionTool.h:144
AsgElectronEfficiencyCorrectionTool::m_eventInfoCollectionName
std::string m_eventInfoCollectionName
The Event info collection name.
Definition: AsgElectronEfficiencyCorrectionTool.h:178
AsgElectronEfficiencyCorrectionTool::get_simType_from_metadata
StatusCode get_simType_from_metadata(PATCore::ParticleDataType::DataType &result) const
Definition: AsgElectronEfficiencyCorrectionTool.cxx:935
AsgElectronEfficiencyCorrectionTool::m_trigKey
std::string m_trigKey
Definition: AsgElectronEfficiencyCorrectionTool.h:163
AsgElectronEfficiencyCorrectionTool::affectingSystematics
virtual CP::SystematicSet affectingSystematics() const override final
returns: the list of all systematics this tool can be affected by
Definition: AsgElectronEfficiencyCorrectionTool.cxx:565
xAOD::Electron_v1
Definition: Electron_v1.h:34
AsgElectronEfficiencyCorrectionTool::isAffectedBySystematic
virtual bool isAffectedBySystematic(const CP::SystematicVariation &systematic) const override final
returns: whether this tool is affected by the given systematis
Definition: AsgElectronEfficiencyCorrectionTool.cxx:549
AsgElectronEfficiencyCorrectionTool::m_uncorrVarUp
std::vector< CP::SystematicVariation > m_uncorrVarUp
Definition: AsgElectronEfficiencyCorrectionTool.h:216
DeMoAtlasDataLoss.runNumber
string runNumber
Definition: DeMoAtlasDataLoss.py:64
AsgElectronEfficiencyCorrectionTool::beginEvent
virtual StatusCode beginEvent() override final
Function called when a new events is loaded.
Definition: AsgElectronEfficiencyCorrectionTool.cxx:922
asg::AsgMetadataTool
Base class for dual-use tools that provide file metadata access.
Definition: AsgMetadataTool.h:48
AsgElectronEfficiencyCorrectionTool::m_nSimpleUncorrSyst
int m_nSimpleUncorrSyst
Definition: AsgElectronEfficiencyCorrectionTool.h:210
AsgElectronEfficiencyCorrectionTool::m_affectedSys
CP::SystematicSet m_affectedSys
Affected systematic, should be done only once.
Definition: AsgElectronEfficiencyCorrectionTool.h:147
ASG_TOOL_CLASS
#define ASG_TOOL_CLASS(CLASSNAME, INT1)
Definition: AsgToolMacros.h:68
AsgElectronEfficiencyCorrectionTool::m_corrVarUp
std::vector< CP::SystematicVariation > m_corrVarUp
Definition: AsgElectronEfficiencyCorrectionTool.h:214
AsgElectronEfficiencyCorrectionTool::m_UncorrRegions
TH2F * m_UncorrRegions
Definition: AsgElectronEfficiencyCorrectionTool.h:209
AsgMetadataTool.h
CP::CorrectionCode
Return value from object correction CP tools.
Definition: CorrectionCode.h:31
AsgElectronEfficiencyCorrectionTool::m_pteta_bins
std::vector< std::pair< float, std::vector< float > > > m_pteta_bins
Definition: AsgElectronEfficiencyCorrectionTool.h:202
CorrectionCode.h
AsgElectronEfficiencyCorrectionTool::m_sysSubstring
std::string m_sysSubstring
Definition: AsgElectronEfficiencyCorrectionTool.h:175
AsgElectronEfficiencyCorrectionTool::SystConf::m_total
float m_total
Definition: AsgElectronEfficiencyCorrectionTool.h:132
AsgElectronEfficiencyCorrectionTool::m_metadata_retrieved
bool m_metadata_retrieved
To check if the metadata can be retrieved.
Definition: AsgElectronEfficiencyCorrectionTool.h:138
TElectronEfficiencyCorrectionTool.h
IAsgElectronEfficiencyCorrectionTool
Definition: IAsgElectronEfficiencyCorrectionTool.h:18
AsgElectronEfficiencyCorrectionTool::currentSimplifiedUncorrSystRegion
int currentSimplifiedUncorrSystRegion(const double cluster_eta, const double et) const
Definition: AsgElectronEfficiencyCorrectionTool.cxx:709