Loading [MathJax]/extensions/tex2jax.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
RtResolutionLookUp.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef MUONCALIB_RTRESOLUTIONLOOKUP_H
6 #define MUONCALIB_RTRESOLUTIONLOOKUP_H
7 
8 #include <iostream>
9 
11 #include "GaudiKernel/MsgStream.h"
13 
14 namespace MuonCalib {
15 
24  public:
26  if (vec.size() < 4) {
27  MsgStream log(Athena::getMessageSvc(), "RtResolutionLookUp");
28  log << MSG::WARNING << "<to few parameters>" << endmsg;
29  } else {
30  m_t_min = par(0);
31  m_bin_size = par(1);
32  }
33  }
34 
35  virtual std::string name() const override { return "RtResolutionLookUp"; }
36 
38  double resolution(double t, double) const override final;
39  virtual unsigned int nDoF() const override final{
40  return nPar() -2;
41  }
42 
43  double tLower() const {
44  return m_t_min;
45  }
46 
47  double tUpper() const {
48  return m_t_min + m_bin_size * nDoF();
49  }
50 
51  private:
52  int getBin(double t) const { return static_cast<int>((t - m_t_min) / m_bin_size); }
53 
54  double getRadius(int bin) const { return par(bin + 2); }
55  // returns best matching bin within rtRange
56  int binInRtRange(double t) const;
57 
58  double m_t_min{9e9};
59  double m_bin_size{1.};
60  };
61 
62  inline double RtResolutionLookUp::resolution(double t, double) const {
63  // get first bin
64  int bin = binInRtRange(t);
65 
66  // shift bin so we are using the last two bins for extrapolation
67  if (static_cast<unsigned>(bin) >= nDoF() - 1) bin = nDoF() - 2;
68 
69  double r1 = getRadius(bin); // get bin value
70  double r2 = getRadius(bin + 1); // get value of next bin
71  double dr = r2 - r1;
72 
73  // scale factor for interpolation
74  double scale = (t - m_t_min) / m_bin_size - (double)bin;
75 
76  double reso = r1 + dr * scale;
77  return reso >= 0 ? reso : 0;
78  }
79 
80  inline int RtResolutionLookUp::binInRtRange(double t) const {
81  // get bin
82  int bin = getBin(t);
83 
84  // if t corresponds to a negative bin return first
85  if (bin < 0) bin = 0;
86 
87  // if t corresponds to a bin outside the range of the lookup table return the last bin
88  if (static_cast<unsigned>(bin) >= nDoF()) bin = nDoF() - 1;
89 
90  return bin;
91  }
92 } // namespace MuonCalib
93 #endif
getMessageSvc.h
singleton-like access to IMessageSvc via open function and helper
MuonCalib::RtResolutionLookUp::m_t_min
double m_t_min
Definition: RtResolutionLookUp.h:58
MuonCalib::RtResolutionLookUp::RtResolutionLookUp
RtResolutionLookUp(const ParVec &vec)
Definition: RtResolutionLookUp.h:25
bin
Definition: BinsDiffFromStripMedian.h:43
MuonCalib::RtResolutionLookUp::getBin
int getBin(double t) const
Definition: RtResolutionLookUp.h:52
vec
std::vector< size_t > vec
Definition: CombinationsGeneratorTest.cxx:9
python.TurnDataReader.dr
dr
Definition: TurnDataReader.py:112
MuonCalib::RtResolutionLookUp::tLower
double tLower() const
Definition: RtResolutionLookUp.h:43
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
const
bool const RAWDATA *ch2 const
Definition: LArRodBlockPhysicsV0.cxx:560
yodamerge_tmp.scale
scale
Definition: yodamerge_tmp.py:138
Athena::getMessageSvc
IMessageSvc * getMessageSvc(bool quiet=false)
Definition: getMessageSvc.cxx:20
MuonCalib::CalibFunc::par
double par(unsigned int index) const
Definition: CalibFunc.h:41
MuonCalib::RtResolutionLookUp::name
virtual std::string name() const override
Definition: RtResolutionLookUp.h:35
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
MuonCalib
CscCalcPed - algorithm that finds the Cathode Strip Chamber pedestals from an RDO.
Definition: CscCalcPed.cxx:22
MuonCalib::CalibFunc::ParVec
std::vector< double > ParVec
Definition: CalibFunc.h:35
IRtResolution.h
MuonCalib::RtResolutionLookUp::getRadius
double getRadius(int bin) const
Definition: RtResolutionLookUp.h:54
plotBeamSpotVxVal.bin
int bin
Definition: plotBeamSpotVxVal.py:83
MuonCalib::RtResolutionLookUp::binInRtRange
int binInRtRange(double t) const
Definition: RtResolutionLookUp.h:80
MuonCalib::RtResolutionLookUp::tUpper
double tUpper() const
Definition: RtResolutionLookUp.h:47
MuonCalib::IRtResolution
Generic interface to retrieve the resolution on the drift radius as a function of the drift time.
Definition: IRtResolution.h:20
MuonCalib::RtResolutionLookUp::resolution
double resolution(double t, double) const override final
returns drift radius for a given time
Definition: RtResolutionLookUp.h:62
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
MuonCalib::CalibFunc::nPar
unsigned int nPar() const
Definition: CalibFunc.h:39
MuonCalib::RtResolutionLookUp::m_bin_size
double m_bin_size
Definition: RtResolutionLookUp.h:59
MuonCalib::RtResolutionLookUp::nDoF
virtual unsigned int nDoF() const override final
Returns the number of degrees of freedom of the relation function
Definition: RtResolutionLookUp.h:39
MuonCalib::RtResolutionLookUp
Equidistant look up table for resolution tables with the time as key.
Definition: RtResolutionLookUp.h:23