6 {
7
10 }
13 }
15 return mu(ptAcc) / 1.e3;
16 }
18 return std::abs(
mu(etaAcc));
19 }
20
21 IKinematicSystHandler::KinVariable IKinematicSystHandler::GetMuonVariableToUse(const std::string &name) {
22 if (name == "pt") return &IKinematicSystHandler::Pt;
23 if (name == "ptGeV") return &IKinematicSystHandler::PtGeV;
24 if (name == "eta") return &IKinematicSystHandler::Eta;
25 if (name == "AbsEta") return &IKinematicSystHandler::AbsEta;
26 return nullptr;
27 }
28
29
30
31
32 PtKinematicSystHandler::PtKinematicSystHandler(std::unique_ptr<HistHandler> pt_flatnesss, std::unique_ptr<HistHandler> energy_loss):
33 m_flatness(),
34 m_loss(),
35 m_SystWeight(0){
36 m_flatness.swap(pt_flatnesss);
37 m_loss.swap(energy_loss);
38 }
39
41 int bin_flat(-1), bin_loss(-1);
42 float syst = 0;
45
46 float eloss_syst = bin_loss < 1 ? 1.e6 : std::abs( m_loss->GetBinContent(bin_loss) *
mu(ptAcc)/1.0e6);
51 syst = eloss_syst;
52 eff *= 1 + m_SystWeight * std::abs(syst);
53 return cc_eloss;
54 } else return cc_flat;
55 } else {
56
57 float abs_error = std::abs( m_flatness->GetBinError(bin_flat));
58 if (cc_eloss ==
CP::CorrectionCode::Ok &&
mu(ptAcc) > 200.e3 && (eloss_syst < abs_error || abs_error == 0 ||
mu(ptAcc) > 500.e3)){
59 syst = eloss_syst;
60
61 } else {
62 syst = m_flatness->GetBinContent(bin_flat);
63 }
64 }
65 eff *= 1 + m_SystWeight * std::abs(syst);
66 return cc_flat;
67 }
68
69 void PtKinematicSystHandler::SetSystematicWeight(float syst_weight) {
70 m_SystWeight = syst_weight;
71 }
72
73 bool PtKinematicSystHandler::initialize(){
74 return m_flatness.get() != nullptr && m_loss.get() != nullptr;
75 }
76
77
78
79 TTVAClosureSysHandler::TTVAClosureSysHandler(std::unique_ptr<HistHandler>
HistHandler):
80 m_Handler(),
81 m_SystWeight(0) {
83 }
84 void TTVAClosureSysHandler::SetSystematicWeight( float SystWeight){m_SystWeight = SystWeight;}
85 bool TTVAClosureSysHandler::initialize() { return m_Handler.get() != nullptr; }
87 int binsys = -1;
91 }
92 Eff *= (1. + m_SystWeight * std::abs(m_Handler->GetBinContent(binsys)));
94 }
95
96
97
98 PrimodialPtSystematic::PrimodialPtSystematic(std::unique_ptr<HistHandler>
Handler) :
99 m_Handler(),
100 m_SystWeight(0) {
102 }
104
105
107
108 int binsys = -1;
112 }
113 Eff *= (1. + m_SystWeight * std::abs(m_Handler->GetBinContent(binsys)) *
mu(ptAcc) / 1.0e6);
115 }
116 void PrimodialPtSystematic::SetSystematicWeight(float SystWeight) {
117 m_SystWeight = SystWeight;
118 }
119 bool PrimodialPtSystematic::initialize() {
120 return m_Handler.get() != nullptr;
121 }
122
123
124
125 BadMuonVetoSystHandler::BadMuonVetoSystHandler(TDirectory* InDir_3Stations, TDirectory* InDir_2Stations) :
126 m_syst3Stations(),
127 m_syst2Stations(),
128 m_uncertVar(nullptr),
129 m_polySelVar(nullptr),
130 m_SystWeight(0.) {
131 fillMap(InDir_3Stations, m_syst3Stations);
132 if (InDir_2Stations && InDir_2Stations!= InDir_3Stations) {
133 fillMap(InDir_2Stations,m_syst2Stations);
134 }
135
136 }
137 void BadMuonVetoSystHandler::fillMap(TDirectory* InDir, std::map<Ranges, std::unique_ptr<TF1>>& systPolynomials){
138 if (!InDir) {
139 Error(
"BadMuonSysVetoHandler()",
"No TDirectory is given");
140 return;
141 }
142 TIter
next(InDir->GetListOfKeys());
143 while (TObject* obj =
next()) {
144 std::string ObjName =
obj->GetName();
145 float lowRange(-1.e20), highRange(1.e20);
146 if (ObjName.find("TF1") == std::string::npos) {
147 continue;
148 }
149 TF1* TF = nullptr;
150 InDir->GetObject(ObjName.c_str(), TF);
151 if (!TF) {
152 continue;
153 }
154
155 getNextProperty(ObjName);
156 if (!m_uncertVar) {m_uncertVar = GetMuonVariableToUse(getNextProperty(ObjName));}
158 else {getNextProperty(ObjName);}
159 if (!m_polySelVar) {m_polySelVar = GetMuonVariableToUse(getNextProperty(ObjName));}
160 else {getNextProperty(ObjName);}
161
162 std::string LowRange_str = getNextProperty(ObjName);
163 std::string HighRange_str = getNextProperty(ObjName);
164 if (!LowRange_str.empty()) {
165 lowRange =
atof(LowRange_str.c_str()) / std::pow(10, LowRange_str.size() -1);
166 }
167 if (!HighRange_str.empty()) {
168 highRange =
atof(HighRange_str.c_str()) / std::pow(10, LowRange_str.size() -1);
169 }
170 systPolynomials.insert(std::pair<Ranges, std::unique_ptr<TF1>>(
Ranges(lowRange, highRange), std::unique_ptr<TF1>(TF)));
171 }
172
173 }
175 if (m_SystWeight == 0.) {
177 }
178 TF1* Poly = nullptr;
179
180 float RelHighPtSys = 0.;
181 if (
mu(ptAcc) >= 100.e3) {
185 }
186 RelHighPtSys = Poly->Eval((this->*m_uncertVar)(
mu.getXAODObject()));
187
188 } else {
189
190 RelHighPtSys = 0.005;
191 }
192 Eff = 1 + m_SystWeight * std::sqrt(std::pow(Eff - 1,2) + RelHighPtSys * RelHighPtSys);
193
195 }
196 void BadMuonVetoSystHandler::SetSystematicWeight(float SystWeight) {
197 m_SystWeight = SystWeight;
198 }
199
200 bool BadMuonVetoSystHandler::initialize() {
201 if (m_syst3Stations.empty()) {
202 Error(
"BadMuonVetoSystHandler::initialize()",
"No polynomials");
203 return false;
204 }
205 if (!m_uncertVar || !m_polySelVar) {
206 return false;
207 }
208 return true;
209 }
210 BadMuonVetoSystHandler::~BadMuonVetoSystHandler() {
211 }
212
214 if (!m_polySelVar) {
215 Error(
"BadMuonVetoSystHandler()",
"Something went wrong with the initialization");
217 }
220 Error(
"BadMuonSysVetoHandler()",
"Precisionlayers unkown");
222 } else if (nprecisionLayers >= 3) {
223 for (const auto& BinnedPoly : m_syst3Stations) {
224 if (BinnedPoly.first.first <= (this->*m_polySelVar)(mu) && (this->*m_polySelVar)(mu) < BinnedPoly.first.second) {
225 Poly = BinnedPoly.second.get();
227 }
228 }
229 } else if (nprecisionLayers == 2) {
230 for (const auto& BinnedPoly : m_syst2Stations) {
231 if (BinnedPoly.first.first <= (this->*m_polySelVar)(mu) && (this->*m_polySelVar)(mu) < BinnedPoly.first.second) {
232 Poly = BinnedPoly.second.get();
234 }
235 }
236 }
238 }
239 std::string BadMuonVetoSystHandler::getNextProperty(std::string &sstr) const {
240
241 while (!sstr.empty() && sstr[0] == '_') {
242 sstr.erase(0, 1);
243 }
244 size_t pos = sstr.find(
"_");
245 std::string
Property =
pos != std::string::npos ? sstr.substr(0, pos) : sstr;
246 if (pos != std::string::npos) {
247 sstr = sstr.substr(
Property.size() + 1, sstr.size());
248 }
250 }
251
252}
Return value from object correction CP tools.
@ Error
Some error happened during the object correction.
@ OutOfValidityRange
Input object is out of validity range.
@ Ok
The correction was done successfully.
Support class for PropertyMgr.
double atof(std::string_view str)
Converts a string into a double / float.
AthROOTErrorHandlerSvc: Replaces ROOT's standard error handler in order to detect Problematic ROOT is...
Error
The different types of error that can be flagged in the L1TopoRDO.
ObjectId< MuonDef > MuonId
Muon_v1 Muon
Reference the current persistent version:
@ numberOfPrecisionLayers
layers with at least 3 hits [unit8_t].