ATLAS Offline Software
Loading...
Searching...
No Matches
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
14namespace MuonCalib {
15
22
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
std::vector< size_t > vec
double par(unsigned int index) const
Definition CalibFunc.h:41
unsigned int nPar() const
Definition CalibFunc.h:39
std::vector< double > ParVec
Definition CalibFunc.h:35
Generic interface to retrieve the resolution on the drift radius as a function of the drift time.
virtual unsigned int nDoF() const override final
Returns the number of degrees of freedom of the relation function.
double getRadius(int bin) const
double resolution(double t, double) const override final
returns drift radius for a given time
virtual std::string name() const override
RtResolutionLookUp(const ParVec &vec)
singleton-like access to IMessageSvc via open function and helper
CscCalcPed - algorithm that finds the Cathode Strip Chamber pedestals from an RDO.