ATLAS Offline Software
MuonEfficiencyScaleFactors.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 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 
18 #include <string>
19 #include <memory>
20 #include <map>
21 #include <unordered_map>
22 namespace CP {
24 
25  public:
26  MuonEfficiencyScaleFactors(const std::string& name);
27 
28  virtual ~MuonEfficiencyScaleFactors() = default;
29  //Proper constructor for Athena
31 
32 
33  virtual StatusCode initialize();
34 
36  virtual CorrectionCode getEfficiencyScaleFactor(const xAOD::Muon& mu, float& sf, const xAOD::EventInfo* info = 0) const;
39  virtual CorrectionCode getEfficiencyScaleFactorReplicas(const xAOD::Muon& mu, std::vector<float> & sf_err, const xAOD::EventInfo* info = 0) const;
40  virtual CorrectionCode applyEfficiencyScaleFactorReplicas(const xAOD::Muon& mu, int nreplicas = 50, const xAOD::EventInfo* info = 0) const;
41 
43  virtual bool isAffectedBySystematic(const SystematicVariation& systematic) const;
44 
46  virtual SystematicSet affectingSystematics() const;
47 
49  virtual SystematicSet recommendedSystematics() const;
50 
51  virtual StatusCode applySystematicVariation(const SystematicSet& systConfig);
52 
54  virtual CorrectionCode getDataEfficiency(const xAOD::Muon& mu, float& eff, const xAOD::EventInfo* info = 0) const;
55  virtual CorrectionCode applyDataEfficiency(const xAOD::Muon& mu, const xAOD::EventInfo* info = 0) const;
56 
57  virtual CorrectionCode getDataEfficiencyReplicas(const xAOD::Muon& mu, std::vector<float> & sf_err, const xAOD::EventInfo* info = 0) const;
58  virtual CorrectionCode applyDataEfficiencyReplicas(const xAOD::Muon& mu, int nreplicas = 50, const xAOD::EventInfo* info = 0) const;
59 
61  virtual CorrectionCode getMCEfficiency(const xAOD::Muon& mu, float& eff, const xAOD::EventInfo* info = 0) const;
62  virtual CorrectionCode applyMCEfficiency(const xAOD::Muon& mu, const xAOD::EventInfo* info = 0) const;
63 
64  virtual CorrectionCode getMCEfficiencyReplicas(const xAOD::Muon& mu, std::vector<float> & sf_err, const xAOD::EventInfo* info = 0) const;
65  virtual CorrectionCode applyMCEfficiencyReplicas(const xAOD::Muon& mu, int nreplicas = 50, const xAOD::EventInfo* info = 0) const;
66 
67  virtual int getUnCorrelatedSystBin(const xAOD::Muon& mu) const;
68  virtual std::string getUncorrelatedSysBinName(unsigned int Bin) const;
69  virtual std::string getUncorrelatedSysBinName(const SystematicSet& systConfig) const;
70 
71 
72  private:
73  unsigned int getRandomRunNumber(const xAOD::EventInfo* info) const;
76 
77  SG::ReadHandleKey<xAOD::EventInfo> m_eventInfo{this, "EventInfoContName", "EventInfo", "event info key"};
78 
83  std::map<std::string, unsigned int> lookUpSystematics();
84  public:
88 
89 
94  std::string filename_Central()const;
98  std::string filename_Calo()const;
103  std::string filename_HighEta()const;
104 
107  std::string filename_LowPt()const;
108  std::string filename_LowPtCalo()const;
110  std::string filename_LRTCentral() const;
111  std::string filename_LRTLowPt() const;
112 
115  float lowPtTransition() const;
116 
119 
124 
126  std::string sf_decoration() const;
127  std::string data_effi_decoration() const;
128  std::string mc_effi_decoration() const;
129 
130  std::string sf_replica_decoration() const;
131  std::string data_effi_replica_decoration() const;
132  std::string mc_effi_replica_deocration() const;
133 
137  size_t getPosition(const EffiCollection* coll) const;
138 
140  size_t getNCollections() const;
142  bool uncorrelate_sys() const;
143 
147  const std::string& close_by_jet_decoration() const;
149  bool use_2D_iso_corrections() const;
151  bool use_lrt() const;
152 
153 
154  private:
156  std::string resolve_file_location(const std::string &filename)const;
157 
158 
160  std::string m_wp;
161 
163  std::vector<std::unique_ptr<EffiCollection>> m_sf_sets;
164 
167 
168  std::string m_custom_dir;
170  std::string m_custom_file_Calo;
172  std::string m_custom_file_LowPt;
176 
177  // Decorate the data-monteCarlo & scale-factors
178  // to the muon. Decoration names can be set flexile
181  std::string m_sf_decoration_name;
182 
185 
186 
190  std::string m_iso_jet_dR;
195  std::unordered_map<CP::SystematicSet, EffiCollection*> m_filtered_sys_sets;
196 
197  bool m_init;
202  bool m_useLRT;
203 
205  };
206 
207 } /* namespace CP */
208 
209 #endif /* MUONEFFICIENCYSCALEFACTORS_H_ */
grepfile.info
info
Definition: grepfile.py:38
CP::MuonEfficiencyScaleFactors::filename_Calo
std::string filename_Calo() const
Reconstruction scale-factors have a dedicated map for calo-tag muons around |\eta|<0....
Definition: MuonEfficiencyScaleFactors.cxx:378
CP::MuonEfficiencyScaleFactors::m_custom_file_LowPtCalo
std::string m_custom_file_LowPtCalo
Definition: MuonEfficiencyScaleFactors.h:173
CP::MuonEfficiencyScaleFactors::filename_Central
std::string filename_Central() const
The following methods are meant to propagate information from the central tool to the subtool managin...
Definition: MuonEfficiencyScaleFactors.cxx:347
CP::MuonEfficiencyScaleFactors::filename_LRTLowPt
std::string filename_LRTLowPt() const
Definition: MuonEfficiencyScaleFactors.cxx:400
CP::MuonEfficiencyScaleFactors::m_filtered_sys_sets
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.
Definition: MuonEfficiencyScaleFactors.h:195
CP::MuonEfficiencyScaleFactors::m_custom_file_LRTLowPt
std::string m_custom_file_LRTLowPt
Definition: MuonEfficiencyScaleFactors.h:175
CP::EffiCollection
The EffiCollection class handles the 5 different scale-factor maps binned in time.
Definition: EffiCollection.h:29
CP::MuonEfficiencyScaleFactors::applyMCEfficiency
virtual CorrectionCode applyMCEfficiency(const xAOD::Muon &mu, const xAOD::EventInfo *info=0) const
Definition: MuonEfficiencyScaleFactors.cxx:312
CP::MuonEfficiencyScaleFactors::data_effi_replica_decoration
std::string data_effi_replica_decoration() const
Definition: MuonEfficiencyScaleFactors.cxx:108
asg::AsgTool
Base class for the dual-use tool implementation classes.
Definition: AsgTool.h:47
CP::MuonEfficiencyScaleFactors::m_custom_dir
std::string m_custom_dir
Definition: MuonEfficiencyScaleFactors.h:168
CP::MuonEfficiencyScaleFactors::LoadInputs
StatusCode LoadInputs()
load the SF histos
Definition: MuonEfficiencyScaleFactors.cxx:418
CP::MuonEfficiencyScaleFactors::lowPtTransition
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...
Definition: MuonEfficiencyScaleFactors.cxx:89
CP::MuonEfficiencyScaleFactors::m_useLRT
bool m_useLRT
Turn on if using LRT objects.
Definition: MuonEfficiencyScaleFactors.h:202
CP::MuonEfficiencyScaleFactors::sf_replica_decoration
std::string sf_replica_decoration() const
Definition: MuonEfficiencyScaleFactors.cxx:105
CP::MuonEfficiencyScaleFactors::m_iso_jet_dR
std::string m_iso_jet_dR
Name of the decoration to catch up the close by jets.
Definition: MuonEfficiencyScaleFactors.h:190
CP::MuonEfficiencyScaleFactors::getDataEfficiencyReplicas
virtual CorrectionCode getDataEfficiencyReplicas(const xAOD::Muon &mu, std::vector< float > &sf_err, const xAOD::EventInfo *info=0) const
Definition: MuonEfficiencyScaleFactors.cxx:288
CP::MuonEfficiencyScaleFactors::applyMCEfficiencyReplicas
virtual CorrectionCode applyMCEfficiencyReplicas(const xAOD::Muon &mu, int nreplicas=50, const xAOD::EventInfo *info=0) const
Definition: MuonEfficiencyScaleFactors.cxx:328
CP::MuonEfficiencyScaleFactors::~MuonEfficiencyScaleFactors
virtual ~MuonEfficiencyScaleFactors()=default
CP::MuonEfficiencyScaleFactors::sf_decoration
std::string sf_decoration() const
The apply<Blah> methods decorate their result directly to the muon.
Definition: MuonEfficiencyScaleFactors.cxx:96
CP::MuonEfficiencyScaleFactors::m_eventInfo
SG::ReadHandleKey< xAOD::EventInfo > m_eventInfo
Definition: MuonEfficiencyScaleFactors.h:77
CP::MuonEfficiencyScaleFactors::recommendedSystematics
virtual SystematicSet recommendedSystematics() const
returns: the list of all systematics this tool recommends to use
Definition: MuonEfficiencyScaleFactors.cxx:565
CP::IMuonEfficiencyScaleFactors
Definition: IMuonEfficiencyScaleFactors.h:103
CP::MuonEfficiencyScaleFactors
Definition: MuonEfficiencyScaleFactors.h:23
CP::SystematicSet
Class to wrap a set of SystematicVariations.
Definition: SystematicSet.h:31
CP::MuonEfficiencyScaleFactors::applyEfficiencyScaleFactor
virtual CorrectionCode applyEfficiencyScaleFactor(const xAOD::Muon &mu, const xAOD::EventInfo *info=0) const
decorate the muon with scale factor information
Definition: MuonEfficiencyScaleFactors.cxx:247
CP::MuonEfficiencyScaleFactors::m_custom_file_LRTCombined
std::string m_custom_file_LRTCombined
Definition: MuonEfficiencyScaleFactors.h:174
CP::MuonEfficiencyScaleFactors::getMCEfficiencyReplicas
virtual CorrectionCode getMCEfficiencyReplicas(const xAOD::Muon &mu, std::vector< float > &sf_err, const xAOD::EventInfo *info=0) const
Definition: MuonEfficiencyScaleFactors.cxx:320
MuonEfficiencyType.h
CP::MuonEfficiencyScaleFactors::m_sf_sets
std::vector< std::unique_ptr< EffiCollection > > m_sf_sets
This vector stores all scale-factor maps.
Definition: MuonEfficiencyScaleFactors.h:163
CP::SystematicVariation
Definition: SystematicVariation.h:47
SG::ReadHandleKey< xAOD::EventInfo >
CP::MuonEfficiencyScaleFactors::m_custom_file_Combined
std::string m_custom_file_Combined
Definition: MuonEfficiencyScaleFactors.h:169
CP
Select isolated Photons, Electrons and Muons.
Definition: Control/xAODRootAccess/xAODRootAccess/TEvent.h:48
xAOD::Muon_v1
Class describing a Muon.
Definition: Muon_v1.h:38
CP::MuonEfficiencyScaleFactors::m_use2DIsoCorr
bool m_use2DIsoCorr
Definition: MuonEfficiencyScaleFactors.h:191
CP::MuonEfficiencyScaleFactors::filename_LRTCentral
std::string filename_LRTCentral() const
LRT muons have their own efficiency maps.
Definition: MuonEfficiencyScaleFactors.cxx:361
CP::MuonEfficiencyScaleFactors::m_sf_decoration_name
std::string m_sf_decoration_name
Definition: MuonEfficiencyScaleFactors.h:181
CP::MuonEfficiencyScaleFactors::getPosition
size_t getPosition(const EffiCollection *coll) const
Returns the position of the collection in the syst set vector.
Definition: MuonEfficiencyScaleFactors.cxx:114
IMuonEfficiencyScaleFactors.h
CP::MuonEfficiencyScaleFactors::filename_LowPt
std::string filename_LowPt() const
Returns the scale-factor maps from a complementary scale-factor measurement using the J/Psi or Upsilo...
Definition: MuonEfficiencyScaleFactors.cxx:392
CP::MuonEfficiencyScaleFactors::getDataEfficiency
virtual CorrectionCode getDataEfficiency(const xAOD::Muon &mu, float &eff, const xAOD::EventInfo *info=0) const
Obtain the muon efficiency measured using the data.
Definition: MuonEfficiencyScaleFactors.cxx:272
CP::MuonEfficiencyScaleFactors::MuonEfficiencyScaleFactors
MuonEfficiencyScaleFactors(const std::string &name)
Definition: MuonEfficiencyScaleFactors.cxx:20
CP::MuonEfficiencyScaleFactors::m_init
bool m_init
Definition: MuonEfficiencyScaleFactors.h:197
CP::MuonEfficiencyScaleFactors::m_efficiency_decoration_name_mc
std::string m_efficiency_decoration_name_mc
Definition: MuonEfficiencyScaleFactors.h:180
CP::MuonEfficiencyScaleFactors::applyDataEfficiencyReplicas
virtual CorrectionCode applyDataEfficiencyReplicas(const xAOD::Muon &mu, int nreplicas=50, const xAOD::EventInfo *info=0) const
Definition: MuonEfficiencyScaleFactors.cxx:296
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ReadHandleKey.h
Property holding a SG store/key/clid from which a ReadHandle is made.
CP::MuonEfficiencyScaleFactors::m_efficiency_decoration_name_data
std::string m_efficiency_decoration_name_data
Definition: MuonEfficiencyScaleFactors.h:179
CP::MuonEfficiencyScaleFactors::resolve_file_location
std::string resolve_file_location(const std::string &filename) const
utility method to 'dress' a filename using the path resolver
Definition: MuonEfficiencyScaleFactors.cxx:337
CP::MuonEfficiencyScaleFactors::applySystematicVariation
virtual StatusCode applySystematicVariation(const SystematicSet &systConfig)
effects: configure this tool for the given list of systematic variations.
Definition: MuonEfficiencyScaleFactors.cxx:572
EfficiencyScaleFactor.h
CP::MuonEfficiencyScaleFactors::getUnCorrelatedSystBin
virtual int getUnCorrelatedSystBin(const xAOD::Muon &mu) const
Definition: MuonEfficiencyScaleFactors.cxx:628
CP::MuonEfficiencyScaleFactors::initialize
virtual StatusCode initialize()
initialize the tool once all settings are in place!
Definition: MuonEfficiencyScaleFactors.cxx:128
CP::MuonEfficiencyScaleFactors::m_current_sf
EffiCollection * m_current_sf
Pointer to the current active map in terms of systematics.
Definition: MuonEfficiencyScaleFactors.h:166
CP::MuonEfficiencyScaleFactors::m_affectingSys
CP::SystematicSet m_affectingSys
Definition: MuonEfficiencyScaleFactors.h:192
CP::MuonEfficiencyScaleFactors::filename_HighEta
std::string filename_HighEta() const
High-eta reconstruction scale-factors are not obtained by the means of are not obtained by the means ...
Definition: MuonEfficiencyScaleFactors.cxx:385
CP::MuonEfficiencyScaleFactors::isAffectedBySystematic
virtual bool isAffectedBySystematic(const SystematicVariation &systematic) const
returns: whether this tool is affected by the given systematis
Definition: MuonEfficiencyScaleFactors.cxx:547
CP::MuonEfficiencyScaleFactors::m_breakDownSyst
bool m_breakDownSyst
Definition: MuonEfficiencyScaleFactors.h:199
CP::MuonEfficiencyScaleFactors::m_applyKineDepSys
bool m_applyKineDepSys
Definition: MuonEfficiencyScaleFactors.h:200
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
CP::MuonEfficiencyScaleFactors::m_wp
std::string m_wp
the working point to operate on
Definition: MuonEfficiencyScaleFactors.h:160
CP::MuonEfficiencyScaleFactors::applyDataEfficiency
virtual CorrectionCode applyDataEfficiency(const xAOD::Muon &mu, const xAOD::EventInfo *info=0) const
decorate a muon with the efficiency information
Definition: MuonEfficiencyScaleFactors.cxx:280
CP::MuonEfficiencyScaleFactors::m_custom_file_Calo
std::string m_custom_file_Calo
Definition: MuonEfficiencyScaleFactors.h:170
CP::MuonEfficiencyScaleFactors::getNCollections
size_t getNCollections() const
Returns the number of EffiCollections stored in this class.
Definition: MuonEfficiencyScaleFactors.cxx:122
CP::MuonEfficiencyScaleFactors::getEfficiencyScaleFactorReplicas
virtual CorrectionCode getEfficiencyScaleFactorReplicas(const xAOD::Muon &mu, std::vector< float > &sf_err, const xAOD::EventInfo *info=0) const
replica generation
Definition: MuonEfficiencyScaleFactors.cxx:256
CP::MuonEfficiencyScaleFactors::m_custom_file_HighEta
std::string m_custom_file_HighEta
Definition: MuonEfficiencyScaleFactors.h:171
EventInfo.h
xAOD::EventInfo_v1
Class describing the basic event information.
Definition: EventInfo_v1.h:43
CP::ISystematicsTool
Interface for all CP tools supporting systematic variations.
Definition: ISystematicsTool.h:32
CP::MuonEfficiencyScaleFactors::getEfficiencyScaleFactor
virtual CorrectionCode getEfficiencyScaleFactor(const xAOD::Muon &mu, float &sf, const xAOD::EventInfo *info=0) const
Retrieve the Scale factor and decorate the muon.
Definition: MuonEfficiencyScaleFactors.cxx:239
CP::MuonEfficiencyScaleFactors::getRandomRunNumber
unsigned int getRandomRunNumber(const xAOD::EventInfo *info) const
Definition: MuonEfficiencyScaleFactors.cxx:217
CP::MuonEfficiencyType
MuonEfficiencyType
Definition: MuonEfficiencyType.h:12
mapkey::sf
@ sf
Definition: TElectronEfficiencyCorrectionTool.cxx:38
CP::MuonEfficiencyScaleFactors::mc_effi_decoration
std::string mc_effi_decoration() const
Definition: MuonEfficiencyScaleFactors.cxx:102
CP::MuonEfficiencyScaleFactors::use_lrt
bool use_lrt() const
option to set if we want to use LRT muons
Definition: MuonEfficiencyScaleFactors.cxx:125
CP::MuonEfficiencyScaleFactors::m_custom_file_LowPt
std::string m_custom_file_LowPt
Definition: MuonEfficiencyScaleFactors.h:172
CP::MuonEfficiencyScaleFactors::lookUpSystematics
std::map< std::string, unsigned int > lookUpSystematics()
Scale-factor files since Moriond2019 contain the breakdown of systematics into their individual compo...
Definition: MuonEfficiencyScaleFactors.cxx:462
CP::MuonEfficiencyScaleFactors::applyEfficiencyScaleFactorReplicas
virtual CorrectionCode applyEfficiencyScaleFactorReplicas(const xAOD::Muon &mu, int nreplicas=50, const xAOD::EventInfo *info=0) const
decorate the muon with a set of SF replica weights.
Definition: MuonEfficiencyScaleFactors.cxx:264
CP::MuonEfficiencyScaleFactors::mc_effi_replica_deocration
std::string mc_effi_replica_deocration() const
Definition: MuonEfficiencyScaleFactors.cxx:111
CP::MuonEfficiencyScaleFactors::uncorrelate_sys
bool uncorrelate_sys() const
Returns a boolean whether the uncorrelation of systematics has been switched on.
Definition: MuonEfficiencyScaleFactors.cxx:92
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
CaloCellTimeCorrFiller.filename
filename
Definition: CaloCellTimeCorrFiller.py:24
CP::MuonEfficiencyScaleFactors::close_by_jet_decoration
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...
Definition: MuonEfficiencyScaleFactors.cxx:83
dqt_zlumi_alleff_HIST.eff
int eff
Definition: dqt_zlumi_alleff_HIST.py:113
CP::MuonEfficiencyScaleFactors::filename_LowPtCalo
std::string filename_LowPtCalo() const
Definition: MuonEfficiencyScaleFactors.cxx:408
ToolHandle.h
CP::MuonEfficiencyScaleFactors::m_lowpt_threshold
float m_lowpt_threshold
threshold below which low-pt SF (i.e. from JPsi) should be used
Definition: MuonEfficiencyScaleFactors.h:188
CP::MuonEfficiencyScaleFactors::m_seperateSystBins
bool m_seperateSystBins
Definition: MuonEfficiencyScaleFactors.h:198
AsgTool.h
CP::MuonEfficiencyScaleFactors::use_2D_iso_corrections
bool use_2D_iso_corrections() const
option to set if we want to use 1D or 2D isolation SFs
Definition: MuonEfficiencyScaleFactors.cxx:86
CaloNoise_fillDB.mu
mu
Definition: CaloNoise_fillDB.py:53
CP::MuonEfficiencyScaleFactors::getUncorrelatedSysBinName
virtual std::string getUncorrelatedSysBinName(unsigned int Bin) const
Definition: MuonEfficiencyScaleFactors.cxx:620
CP::MuonEfficiencyScaleFactors::measurement
CP::MuonEfficiencyType measurement() const
Returns the type of the measurement to be carried out... E.g. Reco/TTVA/Iso.
Definition: MuonEfficiencyScaleFactors.cxx:93
CP::MuonEfficiencyScaleFactors::m_Type
CP::MuonEfficiencyType m_Type
Definition: MuonEfficiencyScaleFactors.h:204
CP::MuonEfficiencyScaleFactors::data_effi_decoration
std::string data_effi_decoration() const
Definition: MuonEfficiencyScaleFactors.cxx:99
CP::MuonEfficiencyScaleFactors::getMCEfficiency
virtual CorrectionCode getMCEfficiency(const xAOD::Muon &mu, float &eff, const xAOD::EventInfo *info=0) const
Obtain the muon efficiency measured using the MC.
Definition: MuonEfficiencyScaleFactors.cxx:304
CP::MuonEfficiencyScaleFactors::m_calibration_version
std::string m_calibration_version
subfolder to load from the calibration db
Definition: MuonEfficiencyScaleFactors.h:184
EffiCollection.h
CP::MuonEfficiencyScaleFactors::affectingSystematics
virtual SystematicSet affectingSystematics() const
returns: the list of all systematics this tool can be affected by
Definition: MuonEfficiencyScaleFactors.cxx:551