ATLAS Offline Software
RtRelationLookUp.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
5 
7 #include <GaudiKernel/MsgStream.h>
8 namespace MuonCalib{
9 
11  IRtRelation(vec) {
12  if (vec.size() < 4) {
13  m_t_min = 9e9;
14  m_bin_size = 1.0; // will be always out of range
15  MsgStream log(Athena::getMessageSvc(), "RtRelationLookUp");
16  log << MSG::WARNING << "<to few parameters>" << endmsg;
17  } else {
18  m_t_min = par(0);
19  m_bin_size = par(1);
20  if (m_bin_size == 0) {
21  MsgStream log(Athena::getMessageSvc(), "RtRelationLookUp");
22  log << MSG::WARNING << "<bin size=0>" << endmsg;
23  }
24  }
25  }
26  inline int RtRelationLookUp::getBin(double t) const {
27  double t_minus_tmin{t - m_t_min};
28  double rel = t_minus_tmin / m_bin_size;
29  if (rel < static_cast<double>(INT_MIN)) return INT_MIN;
30  if (rel > static_cast<double>(INT_MAX)) return INT_MAX;
31  return static_cast<int>(rel);
32  }
33 
34  double RtRelationLookUp::radius(double t) const {
35  // get best matching bin in rt range
36  int bin = binInRtRange(t);
37 
38  // shift bin so we are using the last two bins for extrapolation
39  if (bin >= rtBins() - 1) bin = rtBins() - 2;
40 
41  double r1 = getRadius(bin); // get bin value
42  double r2 = getRadius(bin + 1); // get value of next bin
43  double dr = r2 - r1;
44 
45  // scale factor for interpolation
46  double scale = (t - m_t_min) / m_bin_size - (double)bin;
47 
48  double r = r1 + dr * scale;
49 
50  return r >= 0 ? r : 0;
51  }
52 
53  double RtRelationLookUp::driftVelocity(double t) const {
54  // get best matching bin in rt range
55  int bin = binInRtRange(t);
56 
57  // shift bin so we are using the last two bins for extrapolation
58  if (bin >= rtBins() - 1) bin = rtBins() - 2;
59 
60  double r1 = getRadius(bin); // get bin value
61  double r2 = getRadius(bin + 1); // get value of next bin
62  double dr = r2 - r1;
63 
64  double v = dr / m_bin_size;
65 
66  return v;
67  }
68  double RtRelationLookUp::driftAcceleration(double t) const {
69  return (driftVelocity(t+1) - driftVelocity(t-1)) / 2.;
70  }
71 
72  inline int RtRelationLookUp::binInRtRange(double t) const {
73  // get bin
74  int bin = getBin(t);
75 
76  // if t corresponds to a negativ bin return first
77  if (bin < 0) bin = 0;
78 
79  // if t corresponds to a bin outside the range of the lookup table return the last bin
80  if (bin >= rtBins()) bin = rtBins() - 1;
81 
82  return bin;
83  }
84 
85  double RtRelationLookUp::tLower() const { return m_t_min; }
86  double RtRelationLookUp::tUpper() const { return m_t_min + m_bin_size * rtBins(); }
87  double RtRelationLookUp::tBinWidth() const {return m_bin_size; }
88 }
89 
beamspotman.r
def r
Definition: beamspotman.py:676
MuonCalib::RtRelationLookUp::binInRtRange
int binInRtRange(double t) const
Definition: RtRelationLookUp.cxx:72
skel.rel
rel
Announce start of JO checkingrelease nimber checking.
Definition: skel.GENtoEVGEN.py:182
getMessageSvc.h
singleton-like access to IMessageSvc via open function and helper
MuonCalib::RtRelationLookUp::getBin
int getBin(double t) const
Definition: RtRelationLookUp.cxx:26
MuonCalib::RtRelationLookUp::RtRelationLookUp
RtRelationLookUp(const ParVec &vec)
Definition: RtRelationLookUp.cxx:10
RtRelationLookUp.h
bin
Definition: BinsDiffFromStripMedian.h:43
MuonCalib::RtRelationLookUp::tUpper
virtual double tUpper() const override final
Returns the upper time covered by the r-t.
Definition: RtRelationLookUp.cxx:86
vec
std::vector< size_t > vec
Definition: CombinationsGeneratorTest.cxx:12
MuonCalib::RtRelationLookUp::getRadius
double getRadius(int bin) const
Definition: RtRelationLookUp.h:46
python.TurnDataReader.dr
dr
Definition: TurnDataReader.py:112
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
yodamerge_tmp.scale
scale
Definition: yodamerge_tmp.py:138
MuonCalib::RtRelationLookUp::radius
virtual double radius(double t) const override final
returns drift radius for a given time
Definition: RtRelationLookUp.cxx:34
MuonCalib::RtRelationLookUp::m_bin_size
double m_bin_size
Definition: RtRelationLookUp.h:51
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::RtRelationLookUp::tLower
virtual double tLower() const override final
return rt range
Definition: RtRelationLookUp.cxx:85
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
MuonCalib::RtRelationLookUp::driftVelocity
virtual double driftVelocity(double t) const override final
returns drift velocity for a given time
Definition: RtRelationLookUp.cxx:53
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
MuonCalib::RtRelationLookUp::m_t_min
double m_t_min
Definition: RtRelationLookUp.h:50
MuonCalib::RtRelationLookUp::driftAcceleration
virtual double driftAcceleration(double t) const override final
returns the acceleration for a given time
Definition: RtRelationLookUp.cxx:68
plotBeamSpotVxVal.bin
int bin
Definition: plotBeamSpotVxVal.py:83
python.PyAthena.v
v
Definition: PyAthena.py:154
MuonCalib::RtRelationLookUp::tBinWidth
virtual double tBinWidth() const override final
Returns the step-size for the sampling.
Definition: RtRelationLookUp.cxx:87
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
MuonCalib::RtRelationLookUp::rtBins
int rtBins() const
Definition: RtRelationLookUp.h:45
MuonCalib::IRtRelation
generic interface for a rt-relation
Definition: IRtRelation.h:15