ATLAS Offline Software
Loading...
Searching...
No Matches
MuonTriggerScaleFactors.h File Reference
#include "MuonAnalysisInterfaces/IMuonTriggerScaleFactors.h"
#include "AsgTools/AsgTool.h"
#include "AsgTools/PropertyWrapper.h"
#include "AsgDataHandles/ReadHandleKey.h"
#include "xAODEventInfo/EventInfo.h"
#include "TDirectory.h"
#include <map>
#include <memory>
#include <string>
#include <unordered_map>
#include <ColumnarMode/ColumnarMode.h>
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

namespace ADD_CMODE (CP)

Function Documentation

◆ ADD_CMODE()

namespace ADD_CMODE ( CP )

Returns whether the trigger is supported by the tool or not. The decision depends on the present (random)RunNumber

Definition at line 1 of file MuonTriggerScaleFactors.h.

24 {
25 typedef std::shared_ptr<TH1> TH1_Ptr;
26
27 class MuonTriggerScaleFactors: virtual public CP::IMuonTriggerScaleFactors, public asg::AsgTool {
28 ASG_TOOL_CLASS( MuonTriggerScaleFactors, CP::IMuonTriggerScaleFactors )
29
30 public:
31
32 MuonTriggerScaleFactors(const std::string& name);
33
34 virtual ~MuonTriggerScaleFactors();
35
36 virtual StatusCode initialize(void);
37
38 // for single lepton triggers
39 virtual CP::CorrectionCode getTriggerScaleFactor(const xAOD::MuonContainer& mucont, Double_t& triggersf, const std::string& trigger) const;
40
41 virtual CP::CorrectionCode getTriggerScaleFactor(const xAOD::Muon& muon, Double_t& triggersf, const std::string& trigger) const;
42
43 virtual CP::CorrectionCode getTriggerEfficiency(const xAOD::Muon& mu, Double_t& efficiency, const std::string& trigger, Bool_t dataType) const;
44
45 virtual bool isAffectedBySystematic(const CP::SystematicVariation& systematic) const;
46
47 virtual CP::SystematicSet affectingSystematics() const;
48
49 virtual CP::SystematicSet recommendedSystematics() const;
50
51 virtual StatusCode applySystematicVariation(const CP::SystematicSet& systConfig);
52
53 virtual int getBinNumber(const xAOD::Muon& muon, const std::string& trigger) const;
54
55 virtual int getReplica_index(const std::string& sysBaseName, const std::string& trigStr) const;
56
58 virtual bool isTriggerSupported(const std::string& trigger) const;
59 private:
60
61 virtual CP::CorrectionCode getMuonEfficiency(Double_t& eff, const TrigMuonEff::Configuration& configuration, const xAOD::Muon& muon, const std::string& trigger, const std::string& systematic) const;
62
63 virtual CP::CorrectionCode GetTriggerSF_dimu(Double_t& TriggerSF, TrigMuonEff::Configuration& configuration, const xAOD::MuonContainer& mucont, const std::string& trigger) const;
64
65 virtual CP::CorrectionCode GetTriggerSF(Double_t& TriggerSF, TrigMuonEff::Configuration& configuration, const xAOD::MuonContainer& mucont, const std::string& trigger) const;
66
67 virtual CP::CorrectionCode GetTriggerSF(Double_t& TriggerSF, TrigMuonEff::Configuration& configuration, const xAOD::Muon& muon, const std::string& trigger) const;
68
69 virtual CP::CorrectionCode getDimuonEfficiency(Double_t& eff, const TrigMuonEff::Configuration& configuration, const xAOD::MuonContainer& mucont, const std::string& chain, const std::string& systematic) const;
70
71 const CP::SystematicSet& appliedSystematics() const {
72 return *m_appliedSystematics;
73 }
74
75 StatusCode registerSystematics();
76
77 StatusCode LoadTriggerMap(unsigned int year);
78
79 //This function is needed during initialization to parse the histograms to the cache
80 unsigned int encodeHistoName(const std::string_view period, const std::string& Trigger, bool isData, const std::string& Systematic, bool isBarrel = true) const;
81 //This function is the equivalent during run time to retrieve the histograms from the cache
82 unsigned int encodeHistoName(const std::string& Trigger, const TrigMuonEff::Configuration& configuration, const std::string& Systematic, bool isBarrel = true) const;
83 protected:
84 virtual std::shared_ptr<TH1> getEfficiencyHistogram(unsigned int year, const std::string_view period, const std::string& trigger, bool isData, const std::string& Systematic, bool isBarrel = true) const;
85 virtual std::shared_ptr<TH1> getEfficiencyHistogram(const std::string& trigger, bool isData, const std::string& Systematic, bool isBarrel = true) const;
86 private:
87 typedef std::pair<unsigned int, std::string> YearPeriod;
88 typedef std::pair<YearPeriod, unsigned int> EffiHistoIdent;
89 typedef std::map<EffiHistoIdent, TH1_Ptr> EfficiencyMap;
90
91 CP::CorrectionCode getThreshold(Int_t& threshold, const std::string& trigger) const;
92
93 std::string getTriggerCorrespondingToDimuonTrigger(const std::string& trigger) const;
94 protected:
95
96 const std::string_view getDataPeriod() const;
97 unsigned int getRunNumber() const;
98 unsigned int getYear(unsigned int run) const;
99 const std::string_view getDataPeriod(unsigned int run) const;
100 const std::string_view getDataPeriod(unsigned int runNumber, unsigned int year) const;
101 private:
102 SG::ReadHandleKey<xAOD::EventInfo> m_eventInfo{this, "EventInfoContName", "EventInfo", "event info key"};
103
104 TDirectory* getTemporaryDirectory(void) const;
105
106 //Generate replicas of h for Toys with each bin of h varied with Gaussian distribution
107 //with mean from bin content and sigma from bin error
108 std::vector<TH1_Ptr> generateReplicas(TH1_Ptr h, int nrep, int seed) const;
109
110 std::unordered_map<CP::SystematicSet, CP::SystematicSet> m_systFilter;
111
112 CP::SystematicSet *m_appliedSystematics{};
113 EfficiencyMap m_efficiencyMap;
114 std::map<EffiHistoIdent, std::vector<TH1_Ptr> > m_efficiencyMapReplicaArray;
115
116 Gaudi::Property<std::string> m_muonQuality {this, "MuonQuality", "Medium", "the muon quality to get the scale factors for"};
117 Gaudi::Property<std::string> m_campaign {this, "Campaign", "", "the MC campaign to get the scale factors for"};
118
119 // subfolder to load from the calibration db
120 Gaudi::Property<std::string> m_calibrationVersion {this, "CalibrationVersion", "261003_FallUpdate", "the calibration version to use"};
121 Gaudi::Property<std::string> m_customInputFolder {this, "CustomInputFolder", "", "the custom input folder to use (debugging only)"};
122 Gaudi::Property<std::map<unsigned int, std::string>> m_customInputFilePerYear {this, "CustomInputFilePerYear", {}, "the custom input file to use per year (debugging only)"};
123 Gaudi::Property<std::string> m_binning {this, "Binning", "fine", "the binning to use"};
124
125 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"};
126 Gaudi::Property<bool> m_experimental {this, "UseExperimental", false, "enable experimental features like single muon SF"};
127 Gaudi::Property<int> m_forceYear {this, "ForceYear", -1, "Only for developers. Never use this in any analysis!!!!!!"};
128 Gaudi::Property<std::string> m_forcePeriod {this, "ForcePeriod", "", "Only for developers. Never use this in any analysis!!!!!!"};
129
130 // Variables for toy replicas setup
131 Gaudi::Property<std::vector<std::string>> m_replicaTriggerList {this, "ReplicaTriggerList", {}, "List of triggers on which we want to generate stat. uncertainty toy replicas."};
132 std::set<std::string> m_replicaSet; // set of triggers for replicas, for fast searching
133 Gaudi::Property<int> m_nReplicas {this, "NReplicas", 100, "Number of generated toy replicas, if replicas are required."};
134 Gaudi::Property<int> m_ReplicaRandomSeed {this, "ReplicaRandomSeed", 12345, "Random seed for toy replica generation."};
135
136 // Map connecting run and year:
137 static const std::map<unsigned short int, std::vector< std::tuple<unsigned int,unsigned int,std::string_view> > > m_year_periods;
138 };
139
140}
#define ASG_TOOL_CLASS(CLASSNAME, INT1)
CP::CorrectionCode getThreshold(Int_t &threshold, const std::string &trigger)
virtual CorrectionCode getTriggerEfficiency(const xAOD::Muon &mu, Double_t &efficiency, const std::string &trigger, Bool_t dataType) const =0
virtual int getBinNumber(const xAOD::Muon &muon, const std::string &trigger) const =0
virtual bool isTriggerSupported(const std::string &trigger) const =0
Returns whether the trigger is supported in the current data-period.
virtual StatusCode initialize(void)=0
virtual CorrectionCode getTriggerScaleFactor(const xAOD::MuonContainer &mucont, Double_t &triggersf, const std::string &trigger) const =0
virtual SystematicSet affectingSystematics() const =0
the list of all systematics this tool can be affected by
virtual SystematicSet recommendedSystematics() const =0
the list of all systematics this tool recommends to use
virtual StatusCode applySystematicVariation(const SystematicSet &systConfig)=0
effects: configure this tool for the given list of systematic variations.
virtual bool isAffectedBySystematic(const SystematicVariation &systematic) const =0
Declare the interface that this class provides.
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="")
::StatusCode StatusCode
StatusCode definition for legacy code.
Muon_v1 Muon
Reference the current persistent version:
Definition Muon.h:13
MuonContainer_v1 MuonContainer
Definition of the current "Muon container version".
int run(int argc, char *argv[])