ATLAS Offline Software
Loading...
Searching...
No Matches
EfficiencyScaleFactor.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4#ifndef MUONEFFICIENCYCORRECITONS_EFFICIENCYSCALEFACTOR_H_
5#define MUONEFFICIENCYCORRECITONS_EFFICIENCYSCALEFACTOR_H_
6
7// EDM include(s):
8#include "xAODMuon/Muon.h"
11
17
22
23// further ROOT includes
24#include <TFile.h>
25#include <TDirectory.h>
26
27// STL includes
28#include <string>
29#include <iostream>
30#include <exception>
31#include <map>
32#include <cmath>
33#include <memory>
34
35namespace CP {
36 class SystematicSet;
37}
38
39namespace ADD_CMODE(CP) {
40
41 class MuonEfficiencyScaleFactors;
42 class EfficiencyScaleFactor : public columnar::ColumnarTool<> {
43
50 public:
53 EfficiencyScaleFactor(const MuonEfficiencyScaleFactors& ref_tool,
54 const std::string &file,
55 const std::string &time_unit);
56
63 EfficiencyScaleFactor(std::shared_ptr<EfficiencyScaleFactor> nominal,
64 const MuonEfficiencyScaleFactors& ref_tool,
65 const std::string& file,
66 const std::string& time_unit,
67 const std::string& syst_name,
68 int syst_type_bitmap);
72
73
76 bool CheckConsistency();
77
80 int nBins() const;
81
83 std::string GetBinName(int bin) const;
84
86 int nOverFlowBins() const;
88 bool isOverFlowBin(int b) const;
89
90
92 int FindBinSF(const xAOD::Muon & mu) const;
93
96 bool SetSystematicBin(int bin);
97
98 bool separateBinSyst() const;
99 bool IsUpVariation() const;
100
101
103
105 CP::CorrectionCode ScaleFactor(const xAOD::Muon& mu, float & SF) const;
106 CP::CorrectionCode ScaleFactor(columnar::MuonId mu, float & SF) const;
107 CP::CorrectionCode ScaleFactorReplicas(const xAOD::Muon& mu, std::vector<float> & SF);
108
110 CP::CorrectionCode ApplyScaleFactor(const xAOD::Muon& mu) const;
111 CP::CorrectionCode ApplyScaleFactorReplicas(const xAOD::Muon& mu, int n_replicas);
112
114 CP::CorrectionCode DataEfficiency(const xAOD::Muon& mu, float & Eff) const;
115 CP::CorrectionCode DataEfficiencyReplicas(const xAOD::Muon& mu, std::vector<float> & eff);
117 CP::CorrectionCode ApplyDataEfficiency(const xAOD::Muon& mu) const;
118 CP::CorrectionCode ApplyDataEfficiencyReplicas(const xAOD::Muon& mu, int n_replicas);
119
121 CP::CorrectionCode MCEfficiency(const xAOD::Muon& mu, float & Eff) const;
122 CP::CorrectionCode MCEfficiencyReplicas(const xAOD::Muon& mu, std::vector<float> & eff);
124 CP::CorrectionCode ApplyMCEfficiency(const xAOD::Muon& mu) const;
125 CP::CorrectionCode ApplyMCEfficiencyReplicas(const xAOD::Muon& mu, int n_replicas);
126
128 void DebugPrint() const;
129
130
134 std::string sysname(bool with_direction = true) const;
135
138 unsigned int firstRun() const;
140 unsigned int lastRun() const;
141
143 bool coversRunNumber(unsigned int run) const;
144
146 void setFirstLastRun(unsigned int first, unsigned int last);
147 private:
148
149 typedef std::vector<std::unique_ptr<HistHandler>> SFReplicaVec;
150
152 bool ReadFromFile(const std::string &file, const std::string& time_unit);
153 std::unique_ptr<HistHandler> ReadHistFromFile(columnar::ColumnarTool<>* parent, const std::string& name, TFile* f, const std::string& time_unit);
154
155 // use some maps for easy histo loading / arithmetics by name
156
158 CP::CorrectionCode GetContentFromHist(const HistHandler* Hist, const xAOD::Muon& mu, float & SF, bool add_kine_syst) const;
159 CP::CorrectionCode GetContentFromHist(const HistHandler* Hist, columnar::MuonId mu, float & SF, bool add_kine_syst) const;
161 CP::CorrectionCode GetContentReplicasFromHist(EfficiencyScaleFactor::SFReplicaVec &replicas, const xAOD::Muon& mu, std::vector<float> & SF, bool add_kine_syst);
162
163
164 // package a TH1 in a HistHandler
165 std::unique_ptr<HistHandler> package_histo(columnar::ColumnarTool<>* parent, TH1* h);
166
167
168 // replica generation
169 void GenerateReplicas(int nrep, int seed);
170 void GenerateReplicasFromHist(HistHandler* h, int nrep, int seed, EfficiencyScaleFactor::SFReplicaVec &repVector);
171
175 MuonEfficiencyType m_measurement;
176 std::string m_syst_name;
177
180 bool m_is_up;
182 bool m_is_lowpt;
184 bool m_respond_to_kineDepSyst;
186 bool m_separateBinSyst;
188 std::unique_ptr<HistHandler> m_sf;
189 std::unique_ptr<HistHandler> m_eff;
190 std::unique_ptr<HistHandler> m_mc_eff;
191
193 typedef SG::Decorator<float> FloatDecorator;
194 typedef SG::Decorator<std::vector<float>> FloatVectorDecorator;
195
196 std::unique_ptr<FloatDecorator> m_sf_decor;
197 std::unique_ptr<FloatDecorator> m_eff_decor;
198 std::unique_ptr<FloatDecorator> m_mc_eff_decor;
199
200 std::unique_ptr<FloatVectorDecorator> m_sf_rep_decor;
201 std::unique_ptr<FloatVectorDecorator> m_eff_rep_decor;
202 std::unique_ptr<FloatVectorDecorator> m_mc_eff_rep_decor;
203
204
205 // these are for the continuous pt dependent systematic if we have one
206 std::unique_ptr<IKinematicSystHandler> m_sf_KineDepsys;
207
208
210 SFReplicaVec m_sf_replicas;
211 SFReplicaVec m_eff_replicas;
212 SFReplicaVec m_mc_eff_replicas;
213
215 std::shared_ptr<EfficiencyScaleFactor> m_NominalFallBack;
216 int m_SystematicBin;
217
218
220 float m_default_eff;
222 float m_default_eff_ttva;
223
224 mutable std::atomic<unsigned int> m_warnsPrinted;
225 static const unsigned int m_warningLimit;
226
227 unsigned int m_firstRun;
228 unsigned int m_lastRun;
229
230 public:
231
232 columnar::MuonAccessor<columnar::ObjectColumn> m_muons {*this, "Muons"};
237 };
238} /* namespace ADD_CMODE(CP) */
239
240#endif /* EFFICIENCYSCALEFACTOR_H_ */
Header file for AthHistogramAlgorithm.
Return value from object correction CP tools.
Class to wrap a set of SystematicVariations.
Select isolated Photons, Electrons and Muons.
SG::Decorator< T, ALLOC > Decorator
Helper class to provide type-safe access to aux data, specialized for JaggedVecElt.
Definition AuxElement.h:576
ObjectId< MuonDef > MuonId
Definition MuonDef.h:22
AccessorTemplate< MuonDef, CT, ColumnAccessMode::input, CM > MuonAccessor
Definition MuonDef.h:24
Muon_v1 Muon
Reference the current persistent version:
Definition Muon.h:13
TFile * file
int run(int argc, char *argv[])