ATLAS Offline Software
Public Types | Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
CP::BadMuonVetoSystHandler Class Reference

#include <KinematicSystHandler.h>

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

Public Types

typedef float(IKinematicSystHandler::* KinVariable) (const xAOD::Muon &mu) const
 Typedef to prepare function pointers to the muon. More...
 

Public Member Functions

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

Private Types

typedef std::pair< float, float > Ranges
 

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 111 of file KinematicSystHandler.h.

Member Typedef Documentation

◆ KinVariable

typedef float(IKinematicSystHandler::* CP::IKinematicSystHandler::KinVariable) (const xAOD::Muon &mu) const
inherited

Typedef to prepare function pointers to the muon.

Definition at line 45 of file KinematicSystHandler.h.

◆ Ranges

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

Definition at line 121 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  :
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  }

◆ ~BadMuonVetoSystHandler()

CP::BadMuonVetoSystHandler::~BadMuonVetoSystHandler ( )
virtual

Definition at line 210 of file KinematicSystHandler.cxx.

210  {
211  }

Member Function Documentation

◆ AbsEta()

float CP::IKinematicSystHandler::AbsEta ( const xAOD::Muon mu) const
inherited

Definition at line 17 of file KinematicSystHandler.cxx.

17  {
18  return std::abs(mu.eta());
19  }

◆ Eta()

float CP::IKinematicSystHandler::Eta ( const xAOD::Muon mu) const
inherited

Definition at line 8 of file KinematicSystHandler.cxx.

8  {
9  return mu.eta();
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  }

◆ 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");
216  return CorrectionCode::Error;
217  }
218  uint8_t nprecisionLayers=0;
219  if (!mu.summaryValue(nprecisionLayers, xAOD::SummaryType::numberOfPrecisionLayers)){
220  Error("BadMuonSysVetoHandler()", "Precisionlayers unkown");
221  return CorrectionCode::Error;
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  }

◆ GetKineDependent()

CorrectionCode CP::BadMuonVetoSystHandler::GetKineDependent ( const xAOD::Muon 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.pt() >= 100.e3) {
182  CorrectionCode cc = findAppropiatePolynomial(mu, Poly);
183  if (cc != CorrectionCode::Ok) {
184  return cc;
185  }
186  RelHighPtSys = Poly->Eval((this->*m_uncertVar)(mu));
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  }

◆ 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  }

◆ 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 ( const xAOD::Muon mu) const
inherited

Definition at line 11 of file KinematicSystHandler.cxx.

11  {
12  return mu.pt();
13  }

◆ PtGeV()

float CP::IKinematicSystHandler::PtGeV ( const xAOD::Muon mu) const
inherited

Definition at line 14 of file KinematicSystHandler.cxx.

14  {
15  return mu.pt() / 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

◆ m_polySelVar

KinVariable CP::BadMuonVetoSystHandler::m_polySelVar
private

Definition at line 132 of file KinematicSystHandler.h.

◆ m_syst2Stations

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

Definition at line 129 of file KinematicSystHandler.h.

◆ m_syst3Stations

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

Definition at line 128 of file KinematicSystHandler.h.

◆ m_SystWeight

float CP::BadMuonVetoSystHandler::m_SystWeight
private

Definition at line 133 of file KinematicSystHandler.h.

◆ m_uncertVar

KinVariable CP::BadMuonVetoSystHandler::m_uncertVar
private

Definition at line 131 of file KinematicSystHandler.h.


The documentation for this class was generated from the following files:
CP::IKinematicSystHandler::GetMuonVariableToUse
KinVariable GetMuonVariableToUse(const std::string &name)
Definition: KinematicSystHandler.cxx:21
CP::BadMuonVetoSystHandler::fillMap
void fillMap(TDirectory *InDir, std::map< Ranges, std::unique_ptr< TF1 >> &systPolynomials)
Definition: KinematicSystHandler.cxx:137
CP::BadMuonVetoSystHandler::Ranges
std::pair< float, float > Ranges
Definition: KinematicSystHandler.h:121
xAOD::uint8_t
uint8_t
Definition: Muon_v1.cxx:557
CP::BadMuonVetoSystHandler::m_syst2Stations
std::map< Ranges, std::unique_ptr< TF1 > > m_syst2Stations
Definition: KinematicSystHandler.h:129
CP::BadMuonVetoSystHandler::getNextProperty
std::string getNextProperty(std::string &sstr) const
Definition: KinematicSystHandler.cxx:239
conifer::pow
constexpr int pow(int x)
Definition: conifer.h:20
CP::IKinematicSystHandler::Pt
float Pt(const xAOD::Muon &mu) const
Definition: KinematicSystHandler.cxx:11
Property
Support class for PropertyMgr.
Definition: Property.h:23
CP::BadMuonVetoSystHandler::findAppropiatePolynomial
CP::CorrectionCode findAppropiatePolynomial(const xAOD::Muon &mu, TF1 *&Poly) const
Definition: KinematicSystHandler.cxx:213
CP::CorrectionCode::OutOfValidityRange
@ OutOfValidityRange
Input object is out of validity range.
Definition: CorrectionCode.h:37
CP::CorrectionCode::Error
@ Error
Some error happened during the object correction.
Definition: CorrectionCode.h:36
fillPileUpNoiseLumi.next
next
Definition: fillPileUpNoiseLumi.py:52
CP::BadMuonVetoSystHandler::m_uncertVar
KinVariable m_uncertVar
Definition: KinematicSystHandler.h:131
CP::IKinematicSystHandler::AbsEta
float AbsEta(const xAOD::Muon &mu) const
Definition: KinematicSystHandler.cxx:17
CxxUtils::atof
double atof(std::string_view str)
Converts a string into a double / float.
Definition: Control/CxxUtils/Root/StringUtils.cxx:91
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
CP::BadMuonVetoSystHandler::m_SystWeight
float m_SystWeight
Definition: KinematicSystHandler.h:133
python.LumiBlobConversion.pos
pos
Definition: LumiBlobConversion.py:18
CP::IKinematicSystHandler::PtGeV
float PtGeV(const xAOD::Muon &mu) const
Definition: KinematicSystHandler.cxx:14
CP::CorrectionCode::Ok
@ Ok
The correction was done successfully.
Definition: CorrectionCode.h:38
CP::IKinematicSystHandler::Eta
float Eta(const xAOD::Muon &mu) const
Definition: KinematicSystHandler.cxx:8
L1Topo::Error
Error
The different types of error that can be flagged in the L1TopoRDO.
Definition: Error.h:16
CP::BadMuonVetoSystHandler::m_polySelVar
KinVariable m_polySelVar
Definition: KinematicSystHandler.h:132
CP::BadMuonVetoSystHandler::m_syst3Stations
std::map< Ranges, std::unique_ptr< TF1 > > m_syst3Stations
Definition: KinematicSystHandler.h:128
python.PyAthena.obj
obj
Definition: PyAthena.py:132
CaloNoise_fillDB.mu
mu
Definition: CaloNoise_fillDB.py:53
python.handimod.cc
int cc
Definition: handimod.py:523
xAOD::numberOfPrecisionLayers
@ numberOfPrecisionLayers
layers with at least 3 hits [unit8_t].
Definition: TrackingPrimitives.h:288