ATLAS Offline Software
Loading...
Searching...
No Matches
MuonEfficiencyScaleFactors.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#ifndef MUONEFFICIENCYSCALEFACTORS_H_
6#define MUONEFFICIENCYSCALEFACTORS_H_
7
12
13#include "AsgTools/ToolHandle.h"
14#include "AsgTools/AsgTool.h"
17
23
24#include <string>
25#include <memory>
26#include <map>
27#include <unordered_map>
28namespace CP {
30
31 public:
32 MuonEfficiencyScaleFactors(const std::string& name);
33
35 //Proper constructor for Athena
37
38
39 virtual StatusCode initialize() override;
40
42 virtual CorrectionCode getEfficiencyScaleFactor(const xAOD::Muon& mu, float& sf, const xAOD::EventInfo* info = 0) const override;
44 virtual CorrectionCode applyEfficiencyScaleFactor(const xAOD::Muon& mu, const xAOD::EventInfo* info = 0) const override;
46 virtual CorrectionCode getEfficiencyScaleFactorReplicas(const xAOD::Muon& mu, std::vector<float> & sf_err, const xAOD::EventInfo* info = 0) const override;
47 virtual CorrectionCode applyEfficiencyScaleFactorReplicas(const xAOD::Muon& mu, int nreplicas = 50, const xAOD::EventInfo* info = 0) const override;
48
50 virtual bool isAffectedBySystematic(const SystematicVariation& systematic) const override;
51
53 virtual SystematicSet affectingSystematics() const override;
54
56 virtual SystematicSet recommendedSystematics() const override;
57
58 virtual StatusCode applySystematicVariation(const SystematicSet& systConfig) override;
59
61 virtual CorrectionCode getDataEfficiency(const xAOD::Muon& mu, float& eff, const xAOD::EventInfo* info = 0) const override;
62 virtual CorrectionCode applyDataEfficiency(const xAOD::Muon& mu, const xAOD::EventInfo* info = 0) const override;
63
64 virtual CorrectionCode getDataEfficiencyReplicas(const xAOD::Muon& mu, std::vector<float> & sf_err, const xAOD::EventInfo* info = 0) const;
65 virtual CorrectionCode applyDataEfficiencyReplicas(const xAOD::Muon& mu, int nreplicas = 50, const xAOD::EventInfo* info = 0) const;
66
68 virtual CorrectionCode getMCEfficiency(const xAOD::Muon& mu, float& eff, const xAOD::EventInfo* info = 0) const override;
69 virtual CorrectionCode applyMCEfficiency(const xAOD::Muon& mu, const xAOD::EventInfo* info = 0) const override;
70
71 virtual CorrectionCode getMCEfficiencyReplicas(const xAOD::Muon& mu, std::vector<float> & sf_err, const xAOD::EventInfo* info = 0) const;
72 virtual CorrectionCode applyMCEfficiencyReplicas(const xAOD::Muon& mu, int nreplicas = 50, const xAOD::EventInfo* info = 0) const;
73
74 virtual int getUnCorrelatedSystBin(const xAOD::Muon& mu) const override;
75 virtual std::string getUncorrelatedSysBinName(unsigned int Bin) const override;
76 virtual std::string getUncorrelatedSysBinName(const SystematicSet& systConfig) const override;
77
78
79 private:
80 unsigned int getRandomRunNumber(const xAOD::EventInfo* info) const;
81 unsigned int getRandomRunNumber(columnar::EventInfoId info) const;
83 StatusCode LoadInputs();
84
85 SG::ReadHandleKey<xAOD::EventInfo> m_eventInfo{this, "EventInfoContName", "EventInfo", "event info key"};
86
91 std::map<std::string, unsigned int> lookUpSystematics();
92 public:
96
97
102 std::string filename_Central()const;
106 std::string filename_Calo()const;
111 std::string filename_HighEta()const;
112
115 std::string filename_LowPt()const;
116 std::string filename_LowPtCalo()const;
118 std::string filename_LRTCentral() const;
119 std::string filename_LRTLowPt() const;
120
123 float lowPtTransition() const;
124
127
132
134 std::string sf_decoration() const;
135 std::string data_effi_decoration() const;
136 std::string mc_effi_decoration() const;
137
138 std::string sf_replica_decoration() const;
139 std::string data_effi_replica_decoration() const;
140 std::string mc_effi_replica_deocration() const;
141
145 size_t getPosition(const EffiCollection* coll) const;
146
148 size_t getNCollections() const;
150 bool uncorrelate_sys() const;
151
155 const std::string& close_by_jet_decoration() const;
157 bool use_2D_iso_corrections() const;
159 bool use_lrt() const;
160
161
162 private:
164 std::string resolve_file_location(const std::string &filename)const;
165
166
168 std::string m_wp;
169
171 std::vector<std::unique_ptr<EffiCollection>> m_sf_sets;
172
175
176 std::string m_custom_dir;
184
185 // Decorate the data-monteCarlo & scale-factors
186 // to the muon. Decoration names can be set flexile
190
193
194
198 std::string m_iso_jet_dR;
203 std::unordered_map<CP::SystematicSet, EffiCollection*> m_filtered_sys_sets;
204
205 bool m_init;
211
213
214 // a struct holding all columnar accessors, as those interfere
215 // with the root dictionaries.
216 struct Accessors;
217 std::unique_ptr<Accessors> m_accessors;
218
219 public:
220
222 virtual void callEvents (columnar::EventContextRange events) const override;
223 };
224
225} /* namespace CP */
226
227#endif /* MUONEFFICIENCYSCALEFACTORS_H_ */
#define ASG_TOOL_CLASS3(CLASSNAME, INT1, INT2, INT3)
Property holding a SG store/key/clid from which a ReadHandle is made.
Return value from object correction CP tools.
The EffiCollection class handles the 5 different scale-factor maps binned in time.
interface for all CP tools supporting systematic variations within a reentrant algorithm
Interface for all CP tools supporting systematic variations.
std::string filename_LRTCentral() const
LRT muons have their own efficiency maps.
bool uncorrelate_sys() const
Returns a boolean whether the uncorrelation of systematics has been switched on.
std::string filename_HighEta() const
High-eta reconstruction scale-factors are not obtained by the means of are not obtained by the means ...
std::string resolve_file_location(const std::string &filename) const
utility method to 'dress' a filename using the path resolver
virtual SystematicSet recommendedSystematics() const override
returns: the list of all systematics this tool recommends to use
virtual int getUnCorrelatedSystBin(const xAOD::Muon &mu) const override
virtual CorrectionCode getDataEfficiencyReplicas(const xAOD::Muon &mu, std::vector< float > &sf_err, const xAOD::EventInfo *info=0) const
virtual CorrectionCode getMCEfficiency(const xAOD::Muon &mu, float &eff, const xAOD::EventInfo *info=0) const override
Obtain the muon efficiency measured using the MC.
virtual StatusCode applySystematicVariation(const SystematicSet &systConfig) override
effects: configure this tool for the given list of systematic variations.
virtual CorrectionCode getMCEfficiencyReplicas(const xAOD::Muon &mu, std::vector< float > &sf_err, const xAOD::EventInfo *info=0) const
virtual CorrectionCode applyEfficiencyScaleFactorReplicas(const xAOD::Muon &mu, int nreplicas=50, const xAOD::EventInfo *info=0) const override
decorate the muon with a set of SF replica weights.
virtual std::string getUncorrelatedSysBinName(unsigned int Bin) const override
float m_lowpt_threshold
threshold below which low-pt SF (i.e. from JPsi) should be used
virtual CorrectionCode applyMCEfficiency(const xAOD::Muon &mu, const xAOD::EventInfo *info=0) const override
std::string filename_Calo() const
Reconstruction scale-factors have a dedicated map for calo-tag muons around |\eta|<0....
std::map< std::string, unsigned int > lookUpSystematics()
Scale-factor files since Moriond2019 contain the breakdown of systematics into their individual compo...
std::string m_wp
the working point to operate on
std::string sf_decoration() const
The apply<Blah> methods decorate their result directly to the muon.
virtual SystematicSet affectingSystematics() const override
returns: the list of all systematics this tool can be affected by
std::unique_ptr< Accessors > m_accessors
std::unordered_map< CP::SystematicSet, EffiCollection * > m_filtered_sys_sets
It turned out that the code spends a large time in the look up of the systematics.
bool use_2D_iso_corrections() const
option to set if we want to use 1D or 2D isolation SFs
void callSingleEvent(columnar::MuonRange muons, columnar::EventInfoId event) const
virtual CorrectionCode applyDataEfficiency(const xAOD::Muon &mu, const xAOD::EventInfo *info=0) const override
decorate a muon with the efficiency information
virtual CorrectionCode applyEfficiencyScaleFactor(const xAOD::Muon &mu, const xAOD::EventInfo *info=0) const override
decorate the muon with scale factor information
std::vector< std::unique_ptr< EffiCollection > > m_sf_sets
This vector stores all scale-factor maps.
unsigned int getRandomRunNumber(const xAOD::EventInfo *info) const
std::string filename_Central() const
The following methods are meant to propagate information from the central tool to the subtool managin...
virtual CorrectionCode getEfficiencyScaleFactorReplicas(const xAOD::Muon &mu, std::vector< float > &sf_err, const xAOD::EventInfo *info=0) const override
replica generation
virtual StatusCode initialize() override
initialize the tool once all settings are in place!
size_t getNCollections() const
Returns the number of EffiCollections stored in this class.
std::string m_iso_jet_dR
Name of the decoration to catch up the close by jets.
float lowPtTransition() const
If the pt of the muon is below that threshold the J/Psi or Upsilon map is used given that it's availa...
EffiCollection * m_current_sf
Pointer to the current active map in terms of systematics.
virtual bool isAffectedBySystematic(const SystematicVariation &systematic) const override
returns: whether this tool is affected by the given systematis
virtual CorrectionCode applyDataEfficiencyReplicas(const xAOD::Muon &mu, int nreplicas=50, const xAOD::EventInfo *info=0) const
SG::ReadHandleKey< xAOD::EventInfo > m_eventInfo
size_t getPosition(const EffiCollection *coll) const
Returns the position of the collection in the syst set vector.
virtual CorrectionCode getDataEfficiency(const xAOD::Muon &mu, float &eff, const xAOD::EventInfo *info=0) const override
Obtain the muon efficiency measured using the data.
CP::MuonEfficiencyType measurement() const
Returns the type of the measurement to be carried out... E.g. Reco/TTVA/Iso.
virtual void callEvents(columnar::EventContextRange events) const override
virtual CorrectionCode applyMCEfficiencyReplicas(const xAOD::Muon &mu, int nreplicas=50, const xAOD::EventInfo *info=0) const
bool use_lrt() const
option to set if we want to use LRT muons
std::string filename_LowPt() const
Returns the scale-factor maps from a complementary scale-factor measurement using the J/Psi or Upsilo...
virtual CorrectionCode getEfficiencyScaleFactor(const xAOD::Muon &mu, float &sf, const xAOD::EventInfo *info=0) const override
Retrieve the Scale factor and decorate the muon.
std::string m_calibration_version
subfolder to load from the calibration db
const std::string & close_by_jet_decoration() const
Returns the string telling the tool in which float AuxElement the information of the separation to th...
bool m_useLRT
Turn on if using LRT objects.
MuonEfficiencyScaleFactors(const std::string &name)
StatusCode LoadInputs()
load the SF histos
Class to wrap a set of SystematicVariations.
Property holding a SG store/key/clid from which a ReadHandle is made.
Base class for the dual-use tool implementation classes.
Definition AsgTool.h:47
the base class for all columnar components
Select isolated Photons, Electrons and Muons.
ObjectId< ContainerId::muon > MuonId
Definition MuonDef.h:25
ObjectRange< ContainerId::eventContext > EventContextRange
ObjectRange< ContainerId::muon > MuonRange
Definition MuonDef.h:24
ObjectId< ContainerId::eventInfo > EventInfoId
EventInfo_v1 EventInfo
Definition of the latest event info version.
Muon_v1 Muon
Reference the current persistent version: