ATLAS Offline Software
Loading...
Searching...
No Matches
CP::BadMuonVetoSystHandler Class Reference

#include <KinematicSystHandler.h>

Inheritance diagram for CP::BadMuonVetoSystHandler:
Collaboration diagram for CP::BadMuonVetoSystHandler:

Public Types

typedef float(IKinematicSystHandler::* KinVariable) (columnar::MuonId mu) const
 Typedef to prepare function pointers to the muon.

Public Member Functions

CorrectionCode GetKineDependent (columnar::MuonId mu, float &Eff) const override
 Add an additional uncertainty to the muon depending on its kinematics.
void SetSystematicWeight (float SystWeight) override
 Set's the absolute scaling of the systematic.
bool initialize () override
 Initialize method to load the inputs and check that everything will work as expected.
 BadMuonVetoSystHandler (TDirectory *InDir_3Stations, TDirectory *InDir_2Stations=nullptr)
virtual ~BadMuonVetoSystHandler ()
KinVariable GetMuonVariableToUse (const std::string &name)
float Eta (columnar::MuonId mu) const
float Pt (columnar::MuonId mu) const
float PtGeV (columnar::MuonId mu) const
float AbsEta (columnar::MuonId mu) const

Public Attributes

columnar::MuonAccessor< columnar::ObjectColumnmuonsHandle {*this, "Muons"}
columnar::MuonAccessor< floatptAcc {*this, "pt"}
columnar::MuonAccessor< floatetaAcc {*this, "eta"}

Private Types

typedef std::pair< float, floatRanges

Private Member Functions

CP::CorrectionCode findAppropiatePolynomial (const xAOD::Muon &mu, TF1 *&Poly) const
std::string getNextProperty (std::string &sstr) const
void fillMap (TDirectory *InDir, std::map< Ranges, std::unique_ptr< TF1 > > &systPolynomials)

Private Attributes

std::map< Ranges, std::unique_ptr< TF1 > > m_syst3Stations
std::map< Ranges, std::unique_ptr< TF1 > > m_syst2Stations
KinVariable m_uncertVar
KinVariable m_polySelVar
float m_SystWeight

Detailed Description

Definition at line 119 of file KinematicSystHandler.h.

Member Typedef Documentation

◆ KinVariable

typedef float(IKinematicSystHandler::* CP::IKinematicSystHandler::KinVariable) (columnar::MuonId mu) const
inherited

Typedef to prepare function pointers to the muon.

Definition at line 50 of file KinematicSystHandler.h.

◆ Ranges

typedef std::pair<float, float> CP::BadMuonVetoSystHandler::Ranges
private

Definition at line 129 of file KinematicSystHandler.h.

Constructor & Destructor Documentation

◆ BadMuonVetoSystHandler()

CP::BadMuonVetoSystHandler::BadMuonVetoSystHandler ( TDirectory * InDir_3Stations,
TDirectory * InDir_2Stations = nullptr )

Definition at line 125 of file KinematicSystHandler.cxx.

125 :
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 }
std::map< Ranges, std::unique_ptr< TF1 > > m_syst2Stations
void fillMap(TDirectory *InDir, std::map< Ranges, std::unique_ptr< TF1 > > &systPolynomials)
std::map< Ranges, std::unique_ptr< TF1 > > m_syst3Stations

◆ ~BadMuonVetoSystHandler()

CP::BadMuonVetoSystHandler::~BadMuonVetoSystHandler ( )
virtual

Definition at line 210 of file KinematicSystHandler.cxx.

210 {
211 }

Member Function Documentation

◆ AbsEta()

float CP::IKinematicSystHandler::AbsEta ( columnar::MuonId mu) const
inherited

Definition at line 17 of file KinematicSystHandler.cxx.

17 {
18 return std::abs(mu(etaAcc));
19 }
columnar::MuonAccessor< float > etaAcc

◆ Eta()

float CP::IKinematicSystHandler::Eta ( columnar::MuonId mu) const
inherited

Definition at line 8 of file KinematicSystHandler.cxx.

8 {
9 return mu(etaAcc);
10 }

◆ fillMap()

void CP::BadMuonVetoSystHandler::fillMap ( TDirectory * InDir,
std::map< Ranges, std::unique_ptr< TF1 > > & systPolynomials )
private

Otherwise we need to get rid of the string

Definition at line 137 of file KinematicSystHandler.cxx.

137 {
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 //Elimnate the TF1_
155 getNextProperty(ObjName);
158 else {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 }
std::pair< float, float > Ranges
std::string getNextProperty(std::string &sstr) const
KinVariable GetMuonVariableToUse(const std::string &name)
double atof(std::string_view str)
Converts a string into a double / float.
Error
The different types of error that can be flagged in the L1TopoRDO.
Definition Error.h:16

◆ findAppropiatePolynomial()

CP::CorrectionCode CP::BadMuonVetoSystHandler::findAppropiatePolynomial ( const xAOD::Muon & mu,
TF1 *& Poly ) const
private

Definition at line 213 of file KinematicSystHandler.cxx.

213 {
214 if (!m_polySelVar) {
215 Error("BadMuonVetoSystHandler()", "Something went wrong with the initialization");
217 }
218 uint8_t nprecisionLayers=0;
219 if (!mu.summaryValue(nprecisionLayers, xAOD::SummaryType::numberOfPrecisionLayers)){
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();
226 return CorrectionCode::Ok;
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();
233 return CorrectionCode::Ok;
234 }
235 }
236 }
238 }
@ Error
Some error happened during the object correction.
@ OutOfValidityRange
Input object is out of validity range.
@ Ok
The correction was done successfully.
@ numberOfPrecisionLayers
layers with at least 3 hits [unit8_t].

◆ GetKineDependent()

CorrectionCode CP::BadMuonVetoSystHandler::GetKineDependent ( columnar::MuonId mu,
float & Eff ) const
overridevirtual

Add an additional uncertainty to the muon depending on its kinematics.

Implements CP::IKinematicSystHandler.

Definition at line 174 of file KinematicSystHandler.cxx.

174 {
175 if (m_SystWeight == 0.) {
176 return CorrectionCode::Ok;
177 }
178 TF1* Poly = nullptr;
179 // we know that Eff=(1+relative sys error), since SF==1
180 float RelHighPtSys = 0.;
181 if (mu(ptAcc) >= 100.e3) {
182 CorrectionCode cc = findAppropiatePolynomial(mu.getXAODObject(), Poly);
183 if (cc != CorrectionCode::Ok) {
184 return cc;
185 }
186 RelHighPtSys = Poly->Eval((this->*m_uncertVar)(mu.getXAODObject()));
187
188 } else {
189 //Apply flat 0.5% systematic
190 RelHighPtSys = 0.005;
191 }
192 Eff = 1 + m_SystWeight * std::sqrt(std::pow(Eff - 1,2) + RelHighPtSys * RelHighPtSys);
193
194 return CorrectionCode::Ok;
195 }
CP::CorrectionCode findAppropiatePolynomial(const xAOD::Muon &mu, TF1 *&Poly) const
columnar::MuonAccessor< float > ptAcc

◆ GetMuonVariableToUse()

IKinematicSystHandler::KinVariable CP::IKinematicSystHandler::GetMuonVariableToUse ( const std::string & name)
inherited

Definition at line 21 of file KinematicSystHandler.cxx.

21 {
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 }
float PtGeV(columnar::MuonId mu) const
float Pt(columnar::MuonId mu) const
float AbsEta(columnar::MuonId mu) const
float Eta(columnar::MuonId mu) const

◆ getNextProperty()

std::string CP::BadMuonVetoSystHandler::getNextProperty ( std::string & sstr) const
private

Definition at line 239 of file KinematicSystHandler.cxx.

239 {
240 //Eliminate the beginning underscores
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 }
249 return Property;
250 }

◆ initialize()

bool CP::BadMuonVetoSystHandler::initialize ( )
overridevirtual

Initialize method to load the inputs and check that everything will work as expected.

Implements CP::IKinematicSystHandler.

Definition at line 200 of file KinematicSystHandler.cxx.

200 {
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 }

◆ Pt()

float CP::IKinematicSystHandler::Pt ( columnar::MuonId mu) const
inherited

Definition at line 11 of file KinematicSystHandler.cxx.

11 {
12 return mu(ptAcc);
13 }

◆ PtGeV()

float CP::IKinematicSystHandler::PtGeV ( columnar::MuonId mu) const
inherited

Definition at line 14 of file KinematicSystHandler.cxx.

14 {
15 return mu(ptAcc) / 1.e3;
16 }

◆ SetSystematicWeight()

void CP::BadMuonVetoSystHandler::SetSystematicWeight ( float SystWeight)
overridevirtual

Set's the absolute scaling of the systematic.

For daily puposes it's usually either 1 or -1 indicating if the instance is an upwards or downwards variation.

Implements CP::IKinematicSystHandler.

Definition at line 196 of file KinematicSystHandler.cxx.

196 {
197 m_SystWeight = SystWeight;
198 }

Member Data Documentation

◆ etaAcc

columnar::MuonAccessor<float> CP::IKinematicSystHandler::etaAcc {*this, "eta"}
inherited

Definition at line 60 of file KinematicSystHandler.h.

60{*this, "eta"};

◆ m_polySelVar

KinVariable CP::BadMuonVetoSystHandler::m_polySelVar
private

Definition at line 140 of file KinematicSystHandler.h.

◆ m_syst2Stations

std::map<Ranges, std::unique_ptr<TF1> > CP::BadMuonVetoSystHandler::m_syst2Stations
private

Definition at line 137 of file KinematicSystHandler.h.

◆ m_syst3Stations

std::map<Ranges, std::unique_ptr<TF1> > CP::BadMuonVetoSystHandler::m_syst3Stations
private

Definition at line 136 of file KinematicSystHandler.h.

◆ m_SystWeight

float CP::BadMuonVetoSystHandler::m_SystWeight
private

Definition at line 141 of file KinematicSystHandler.h.

◆ m_uncertVar

KinVariable CP::BadMuonVetoSystHandler::m_uncertVar
private

Definition at line 139 of file KinematicSystHandler.h.

◆ muonsHandle

columnar::MuonAccessor<columnar::ObjectColumn> CP::IKinematicSystHandler::muonsHandle {*this, "Muons"}
inherited

Definition at line 58 of file KinematicSystHandler.h.

58{*this, "Muons"};

◆ ptAcc

columnar::MuonAccessor<float> CP::IKinematicSystHandler::ptAcc {*this, "pt"}
inherited

Definition at line 59 of file KinematicSystHandler.h.

59{*this, "pt"};

The documentation for this class was generated from the following files: