ATLAS Offline Software
RtChebyshev.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
6 #include "GeoModelHelpers/throwExcept.h"
7 using namespace MuonCalib;
8 
10  IRtRelation(vec) {
11  // check for consistency //
12  if (nPar() < 3) {
13  THROW_EXCEPTION("RtChebyshev::_init() - Not enough parameters!");
14  }
15  if (tLower() >= tUpper()) {
16  THROW_EXCEPTION("Lower time boundary >= upper time boundary!");
17  }
18 } // end RtChebyshev::_init
19 
20 std::string RtChebyshev::name() const { return "RtChebyshev"; }
21 double RtChebyshev::tBinWidth() const { return s_tBinWidth; }
22 
23 double RtChebyshev::radius(double t) const {
25  // INITIAL TIME CHECK //
27  if (t < tLower()) return 0.0;
28  if (t > tUpper()) return 14.6;
29 
31  // VARIABLES //
33  // argument of the Chebyshev polynomials
34  double x = getReducedTime(t);
35  double rad{0.0}; // auxiliary radius
36 
38  // CALCULATE r(t) //
40  for (unsigned int k = 0; k < nPar() - 2; k++) {
41  rad += par(k+2) * chebyshevPoly1st(k, x);
42  }
43  return std::max(rad, 0.);
44 }
45 
46 //*****************************************************************************
47 double RtChebyshev::driftVelocity(double t) const {
48  return (radius(t + 1.0) - radius(t));
49  // Set derivative to 0 outside of the bounds
50  if (t < tLower() || t > tUpper()) return 0.0;
51 
52  // Argument of the Chebyshev polynomials
53  const double x = getReducedTime(t);
54  // Chain rule
55  const double dx_dt = 2. / (tUpper() - tLower());
56  double drdt{0.};
57  for (unsigned int k = 1; k < nPar() - 2; ++k) {
58  // Calculate the contribution to dr/dt using k * U_{k-1}(x) * dx/dt
59  drdt += par(k+2) * chebyshevPoly1stPrime(k, x) * dx_dt;
60  }
61  return drdt;
62 }
63 double RtChebyshev::driftAcceleration(double t) const {
64  double acc{0.};
65  // Argument of the Chebyshev polynomials
66  const double x = getReducedTime(t);
67  const double dx_dt = std::pow(2. / (tUpper() - tLower()), 2);
68  for (unsigned int k = 2; k < nPar() - 2; ++k) {
69  acc += par(k+2) * chebyshevPoly1st2Prime(k, x) * dx_dt;
70  }
71  return acc * t;
72 }
73 double RtChebyshev::tLower() const { return par(0); }
74 double RtChebyshev::tUpper() const { return par(1); }
75 unsigned int RtChebyshev::numberOfRtParameters() const { return nPar() - 2; }
76 
77 std::vector<double> RtChebyshev::rtParameters() const {
78  return std::vector<double>{parameters().begin() +2, parameters().end()};
79 }
80 double RtChebyshev::getReducedTime(const double t) const {
81  return 2. * (t - 0.5 * (tUpper() + tLower())) / (tUpper() - tLower());
82 }
max
#define max(a, b)
Definition: cfImp.cxx:41
MuonCalib::RtChebyshev::numberOfRtParameters
unsigned int numberOfRtParameters() const
get the coefficients of the r(t) polynomial
Definition: RtChebyshev.cxx:75
conifer::pow
constexpr int pow(int x)
Definition: conifer.h:20
vec
std::vector< size_t > vec
Definition: CombinationsGeneratorTest.cxx:12
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
THROW_EXCEPTION
#define THROW_EXCEPTION(MSG)
Definition: MMReadoutElement.cxx:48
x
#define x
MuonCalib::RtChebyshev::driftVelocity
virtual double driftVelocity(double t) const override final
get the drift acceleration
Definition: RtChebyshev.cxx:47
MuonCalib::CalibFunc::par
double par(unsigned int index) const
Definition: CalibFunc.h:41
MuonCalib::chebyshevPoly1st2Prime
constexpr double chebyshevPoly1st2Prime(const unsigned int order, const double x)
Returns the second derivative of the n-th Chebycheb polynomial of the first kind.
Definition: ChebychevPoly.h:81
MuonCalib::RtChebyshev::tUpper
virtual double tUpper() const override final
Returns the upper time covered by the r-t.
Definition: RtChebyshev.cxx:74
MuonCalib::RtChebyshev::radius
virtual double radius(double t) const override final
get the drift velocity
Definition: RtChebyshev.cxx:23
MuonCalib
CscCalcPed - algorithm that finds the Cathode Strip Chamber pedestals from an RDO.
Definition: CscCalcPed.cxx:22
MuonCalib::RtChebyshev::getReducedTime
double getReducedTime(const double t) const
Definition: RtChebyshev.cxx:80
MuonCalib::CalibFunc::ParVec
std::vector< double > ParVec
Definition: CalibFunc.h:35
AthenaPoolTestRead.acc
acc
Definition: AthenaPoolTestRead.py:16
MuonCalib::RtChebyshev::name
virtual std::string name() const override final
get the class name
Definition: RtChebyshev.cxx:20
ChebychevPoly.h
MuonCalib::chebyshevPoly1st
constexpr double chebyshevPoly1st(const unsigned int order, const double x)
Returns the n-th Chebyshev polynomial of first kind evaluated at x (c.f.
Definition: ChebychevPoly.h:13
MuonCalib::IRtRelation::s_tBinWidth
static constexpr double s_tBinWidth
Definition: IRtRelation.h:43
MuonCalib::RtChebyshev::tBinWidth
virtual double tBinWidth() const override final
get the number of parameters used to describe the r(t) relationship
Definition: RtChebyshev.cxx:21
MuonCalib::CalibFunc::parameters
const ParVec & parameters() const
Definition: CalibFunc.h:40
RtChebyshev.h
MuonCalib::RtChebyshev::RtChebyshev
RtChebyshev(const ParVec &vec)
initialization constructor,
Definition: RtChebyshev.cxx:9
MuonCalib::RtChebyshev::driftAcceleration
virtual double driftAcceleration(double t) const override final
Returns the acceleration of the r-t relation.
Definition: RtChebyshev.cxx:63
MuonCalib::CalibFunc::nPar
unsigned int nPar() const
Definition: CalibFunc.h:39
MuonCalib::chebyshevPoly1stPrime
constexpr double chebyshevPoly1stPrime(const unsigned int order, const double x)
Returns the first derivative of the n-th Chebycheb polynomial of the first kind.
Definition: ChebychevPoly.h:49
MuonCalib::IRtRelation
generic interface for a rt-relation
Definition: IRtRelation.h:15
python.SystemOfUnits.rad
int rad
Definition: SystemOfUnits.py:111
fitman.k
k
Definition: fitman.py:528
MuonCalib::RtChebyshev::rtParameters
std::vector< double > rtParameters() const
get the reduced time which is the argument of the Chebyshev polynomial
Definition: RtChebyshev.cxx:77
MuonCalib::RtChebyshev::tLower
virtual double tLower() const override final
< get the lower drift-time bound
Definition: RtChebyshev.cxx:73