ATLAS Offline Software
Loading...
Searching...
No Matches
MuonTriggerScaleFactors.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3 */
4
5#ifndef MUONTRIGGERSCALEFACTORS_H_
6#define MUONTRIGGERSCALEFACTORS_H_
7
9#include "AsgTools/AsgTool.h"
13
14#include "TDirectory.h"
15
16#include <map>
17#include <memory>
18#include <string>
19#include <unordered_map>
20
21class TH1;
22
23namespace CP {
24 typedef std::shared_ptr<TH1> TH1_Ptr;
25
28
29 public:
30
31 MuonTriggerScaleFactors(const std::string& name);
32
34
35 virtual StatusCode initialize(void);
36
37 // for single lepton triggers
38 virtual CorrectionCode getTriggerScaleFactor(const xAOD::MuonContainer& mucont, Double_t& triggersf, const std::string& trigger) const;
39
40 virtual CorrectionCode getTriggerScaleFactor(const xAOD::Muon& muon, Double_t& triggersf, const std::string& trigger) const;
41
42 virtual CorrectionCode getTriggerEfficiency(const xAOD::Muon& mu, Double_t& efficiency, const std::string& trigger, Bool_t dataType) const;
43
44 virtual bool isAffectedBySystematic(const CP::SystematicVariation& systematic) const;
45
47
49
50 virtual StatusCode applySystematicVariation(const CP::SystematicSet& systConfig);
51
52 virtual int getBinNumber(const xAOD::Muon& muon, const std::string& trigger) const;
53
54 virtual int getReplica_index(const std::string& sysBaseName, const std::string& trigStr) const;
55
57 virtual bool isTriggerSupported(const std::string& trigger) const;
58 private:
59
60 virtual CorrectionCode getMuonEfficiency(Double_t& eff, const TrigMuonEff::Configuration& configuration, const xAOD::Muon& muon, const std::string& trigger, const std::string& systematic) const;
61
62 virtual CorrectionCode GetTriggerSF_dimu(Double_t& TriggerSF, TrigMuonEff::Configuration& configuration, const xAOD::MuonContainer& mucont, const std::string& trigger) const;
63
64 virtual CorrectionCode GetTriggerSF(Double_t& TriggerSF, TrigMuonEff::Configuration& configuration, const xAOD::MuonContainer& mucont, const std::string& trigger) const;
65
66 virtual CorrectionCode GetTriggerSF(Double_t& TriggerSF, TrigMuonEff::Configuration& configuration, const xAOD::Muon& muon, const std::string& trigger) const;
67
68 virtual CorrectionCode getDimuonEfficiency(Double_t& eff, const TrigMuonEff::Configuration& configuration, const xAOD::MuonContainer& mucont, const std::string& chain, const std::string& systematic) const;
69
73
74 StatusCode registerSystematics();
75
76 StatusCode LoadTriggerMap(unsigned int year);
77
78 //This function is needed during initialization to parse the histograms to the cache
79 unsigned int encodeHistoName(const std::string &period, const std::string& Trigger, bool isData, const std::string& Systematic, bool isBarrel = true) const;
80 //This function is the equivalent during run time to retrieve the histograms from the cache
81 unsigned int encodeHistoName(const std::string& Trigger, const TrigMuonEff::Configuration& configuration, const std::string& Systematic, bool isBarrel = true) const;
82 protected:
83 virtual std::shared_ptr<TH1> getEfficiencyHistogram(unsigned int year, const std::string& period, const std::string& trigger, bool isData, const std::string& Systematic, bool isBarrel = true) const;
84 virtual std::shared_ptr<TH1> getEfficiencyHistogram(const std::string& trigger, bool isData, const std::string& Systematic, bool isBarrel = true) const;
85 private:
86 typedef std::pair<unsigned int, std::string> YearPeriod;
87 typedef std::pair<YearPeriod, unsigned int> EffiHistoIdent;
88 typedef std::map<EffiHistoIdent, TH1_Ptr> EfficiencyMap;
89
90 CorrectionCode getThreshold(Int_t& threshold, const std::string& trigger) const;
91
92 std::string getTriggerCorrespondingToDimuonTrigger(const std::string& trigger) const;
93 protected:
94
95 std::string getDataPeriod() const;
96 unsigned int getRunNumber() const;
97 unsigned int getYear(unsigned int run) const;
98 std::string getDataPeriod(unsigned int run) const;
99 std::string getDataPeriod(unsigned int runNumber, unsigned int year) const;
100 private:
101 SG::ReadHandleKey<xAOD::EventInfo> m_eventInfo{this, "EventInfoContName", "EventInfo", "event info key"};
102
103 TDirectory* getTemporaryDirectory(void) const;
104
105 //Generate replicas of h for Toys with each bin of h varied with Gaussian distribution
106 //with mean from bin content and sigma from bin error
107 std::vector<TH1_Ptr> generateReplicas(TH1_Ptr h, int nrep, int seed) const;
108
109 std::unordered_map<CP::SystematicSet, CP::SystematicSet> m_systFilter;
110
113 std::map<EffiHistoIdent, std::vector<TH1_Ptr> > m_efficiencyMapReplicaArray;
114
115 Gaudi::Property<std::string> m_muonQuality {this, "MuonQuality", "Medium", "the muon quality to get the scale factors for"};
116 Gaudi::Property<std::string> m_campaign {this, "Campaign", "", "the MC campaign to get the scale factors for"};
117
118 // subfolder to load from the calibration db
119 Gaudi::Property<std::string> m_calibrationVersion {this, "CalibrationVersion", "250731_SummerUpdate", "the calibration version to use"};
120 Gaudi::Property<std::string> m_customInputFolder {this, "CustomInputFolder", "", "the custom input folder to use (debugging only)"};
121 Gaudi::Property<std::map<unsigned int, std::string>> m_customInputFilePerYear {this, "CustomInputFilePerYear", {}, "the custom input file to use per year (debugging only)"};
122 Gaudi::Property<std::string> m_binning {this, "Binning", "fine", "the binning to use"};
123
124 Gaudi::Property<bool> m_allowZeroSF {this, "AllowZeroSF", false, "if a trigger is not available will return 0 instead of throwing an error. More difficult to spot configuration issues. Use at own risk"};
125 Gaudi::Property<bool> m_experimental {this, "UseExperimental", false, "enable experimental features like single muon SF"};
126 Gaudi::Property<int> m_forceYear {this, "ForceYear", -1, "Only for developers. Never use this in any analysis!!!!!!"};
127 Gaudi::Property<std::string> m_forcePeriod {this, "ForcePeriod", "", "Only for developers. Never use this in any analysis!!!!!!"};
128
129 // Variables for toy replicas setup
130 Gaudi::Property<std::vector<std::string>> m_replicaTriggerList {this, "ReplicaTriggerList", {}, "List of triggers on which we want to generate stat. uncertainty toy replicas."};
131 std::set<std::string> m_replicaSet; // set of triggers for replicas, for fast searching
132 Gaudi::Property<int> m_nReplicas {this, "NReplicas", 100, "Number of generated toy replicas, if replicas are required."};
133 Gaudi::Property<int> m_ReplicaRandomSeed {this, "ReplicaRandomSeed", 12345, "Random seed for toy replica generation."};
134
135 // Map connecting run and year:
136 static const std::map<unsigned int, int> m_runNumber_year;
137 };
138
139}
140
141#endif
#define ASG_TOOL_CLASS(CLASSNAME, INT1)
Property holding a SG store/key/clid from which a ReadHandle is made.
Header file for AthHistogramAlgorithm.
Return value from object correction CP tools.
unsigned int getYear(unsigned int run) const
Gaudi::Property< int > m_ReplicaRandomSeed
static const std::map< unsigned int, int > m_runNumber_year
Gaudi::Property< std::string > m_forcePeriod
virtual CorrectionCode GetTriggerSF_dimu(Double_t &TriggerSF, TrigMuonEff::Configuration &configuration, const xAOD::MuonContainer &mucont, const std::string &trigger) const
StatusCode LoadTriggerMap(unsigned int year)
std::set< std::string > m_replicaSet
SG::ReadHandleKey< xAOD::EventInfo > m_eventInfo
Gaudi::Property< std::vector< std::string > > m_replicaTriggerList
Gaudi::Property< std::string > m_campaign
std::map< EffiHistoIdent, std::vector< TH1_Ptr > > m_efficiencyMapReplicaArray
TDirectory * getTemporaryDirectory(void) const
Gaudi::Property< std::string > m_calibrationVersion
virtual CorrectionCode getMuonEfficiency(Double_t &eff, const TrigMuonEff::Configuration &configuration, const xAOD::Muon &muon, const std::string &trigger, const std::string &systematic) const
Gaudi::Property< std::string > m_binning
virtual std::shared_ptr< TH1 > getEfficiencyHistogram(unsigned int year, const std::string &period, const std::string &trigger, bool isData, const std::string &Systematic, bool isBarrel=true) const
std::map< EffiHistoIdent, TH1_Ptr > EfficiencyMap
virtual int getReplica_index(const std::string &sysBaseName, const std::string &trigStr) const
std::pair< YearPeriod, unsigned int > EffiHistoIdent
std::string getDataPeriod(unsigned int runNumber, unsigned int year) const
virtual StatusCode applySystematicVariation(const CP::SystematicSet &systConfig)
effects: configure this tool for the given list of systematic variations.
MuonTriggerScaleFactors(const std::string &name)
std::vector< TH1_Ptr > generateReplicas(TH1_Ptr h, int nrep, int seed) const
virtual CorrectionCode getDimuonEfficiency(Double_t &eff, const TrigMuonEff::Configuration &configuration, const xAOD::MuonContainer &mucont, const std::string &chain, const std::string &systematic) const
unsigned int encodeHistoName(const std::string &period, const std::string &Trigger, bool isData, const std::string &Systematic, bool isBarrel=true) const
Gaudi::Property< bool > m_allowZeroSF
virtual CorrectionCode GetTriggerSF(Double_t &TriggerSF, TrigMuonEff::Configuration &configuration, const xAOD::MuonContainer &mucont, const std::string &trigger) const
virtual int getBinNumber(const xAOD::Muon &muon, const std::string &trigger) const
Gaudi::Property< std::string > m_customInputFolder
std::string getTriggerCorrespondingToDimuonTrigger(const std::string &trigger) const
Gaudi::Property< bool > m_experimental
Gaudi::Property< std::map< unsigned int, std::string > > m_customInputFilePerYear
CorrectionCode getThreshold(Int_t &threshold, const std::string &trigger) const
std::unordered_map< CP::SystematicSet, CP::SystematicSet > m_systFilter
Gaudi::Property< std::string > m_muonQuality
const CP::SystematicSet & appliedSystematics() const
virtual bool isAffectedBySystematic(const CP::SystematicVariation &systematic) const
Declare the interface that this class provides.
virtual CorrectionCode getTriggerScaleFactor(const xAOD::MuonContainer &mucont, Double_t &triggersf, const std::string &trigger) const
virtual CP::SystematicSet affectingSystematics() const
returns: the list of all systematics this tool can be affected by
virtual CP::SystematicSet recommendedSystematics() const
returns: the list of all systematics this tool recommends to use
virtual bool isTriggerSupported(const std::string &trigger) const
Returns whether the trigger is supported by the tool or not. The decision depends on the present (ran...
virtual CorrectionCode getTriggerEfficiency(const xAOD::Muon &mu, Double_t &efficiency, const std::string &trigger, Bool_t dataType) const
std::pair< unsigned int, std::string > YearPeriod
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
void efficiency(std::vector< double > &bins, std::vector< double > &values, const std::vector< std::string > &files, const std::string &histname, const std::string &tplotname, const std::string &label="")
Select isolated Photons, Electrons and Muons.
std::shared_ptr< TH1 > TH1_Ptr
Muon_v1 Muon
Reference the current persistent version:
MuonContainer_v1 MuonContainer
Definition of the current "Muon container version".
structure to hold variables to configure behaviour of the tool
int run(int argc, char *argv[])