ATLAS Offline Software
RtResolutionLookUp.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2020 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  m_t_min = 9e9;
30  m_bin_size = 1.0; // will be always out of range
31  } else {
32  m_t_min = par(0);
33  m_bin_size = par(1);
34  }
35  }
36 
37  std::string name() const { return "RtResolutionLookUp"; }
38 
40  double resolution(double t, double) const;
41 
42  private:
43  int getBin(double t) const { return (int)((t - m_t_min) / m_bin_size); }
44 
45  // take offset due to m_t_min and binsize into account
46  int rtBins() const { return nPar() - 2; }
47  double getRadius(int bin) const { return par(bin + 2); }
48  // returns best matching bin within rtRange
49  int binInRtRange(double t) const;
50 
51  double m_t_min;
52  double m_bin_size;
53  };
54 
55  inline double RtResolutionLookUp::resolution(double t, double) const {
56  // get first bin
57  int bin = binInRtRange(t);
58 
59  // shift bin so we are using the last two bins for extrapolation
60  if (bin >= rtBins() - 1) bin = rtBins() - 2;
61 
62  double r1 = getRadius(bin); // get bin value
63  double r2 = getRadius(bin + 1); // get value of next bin
64  double dr = r2 - r1;
65 
66  // scale factor for interpolation
67  double scale = (t - m_t_min) / m_bin_size - (double)bin;
68 
69  double reso = r1 + dr * scale;
70  return reso >= 0 ? reso : 0;
71  }
72 
73  inline int RtResolutionLookUp::binInRtRange(double t) const {
74  // get bin
75  int bin = getBin(t);
76 
77  // if t corresponds to a negative bin return first
78  if (bin < 0) bin = 0;
79 
80  // if t corresponds to a bin outside the range of the lookup table return the last bin
81  if (bin >= rtBins()) bin = rtBins() - 1;
82 
83  return bin;
84  }
85 } // namespace MuonCalib
86 #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:51
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:43
vec
std::vector< size_t > vec
Definition: CombinationsGeneratorTest.cxx:12
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
Athena::getMessageSvc
IMessageSvc * getMessageSvc(bool quiet=false)
Definition: getMessageSvc.cxx:20
MuonCalib::CalibFunc::par
double par(unsigned int index) const
Definition: CalibFunc.h:41
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
MuonCalib::RtResolutionLookUp::rtBins
int rtBins() const
Definition: RtResolutionLookUp.h:46
IRtResolution.h
MuonCalib::RtResolutionLookUp::getRadius
double getRadius(int bin) const
Definition: RtResolutionLookUp.h:47
plotBeamSpotVxVal.bin
int bin
Definition: plotBeamSpotVxVal.py:83
MuonCalib::RtResolutionLookUp::binInRtRange
int binInRtRange(double t) const
Definition: RtResolutionLookUp.h:73
MuonCalib::RtResolutionLookUp::resolution
double resolution(double t, double) const
returns drift radius for a given time
Definition: RtResolutionLookUp.h:55
MuonCalib::IRtResolution
generic interface for a resolution function
Definition: IRtResolution.h:13
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:52
MuonCalib::RtResolutionLookUp::name
std::string name() const
Definition: RtResolutionLookUp.h:37
MuonCalib::RtResolutionLookUp
Equidistant look up table for resolution tables with the time as key.
Definition: RtResolutionLookUp.h:23