ATLAS Offline Software
RtLegendre.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 "GeoModelKernel/throwExcept.h"
7 using namespace MuonCalib;
8 
10  IRtRelation(vec) {
11  // check for consistency //
12  if (nPar() < 3) {
13  THROW_EXCEPTION("RtLegendre::_init() - Not enough parameters!");
14  }
15  if (tLower() >= tUpper()) {
16  THROW_EXCEPTION("Lower time boundary >= upper time boundary!");
17  }
18 } // end RtLegendre::_init
19 
20 std::string RtLegendre::name() const { return "RtLegendre"; }
21 double RtLegendre::tBinWidth() const { return s_tBinWidth; }
22 
23 double RtLegendre::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 Legendre 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) * legendrePoly(k, x);
42  }
43  return std::max(rad, 0.);
44 }
45 
46 //*****************************************************************************
47 double RtLegendre::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 Legendre 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 = 0; k < nPar() - 2; ++k) {
58  drdt += par(k+2) * legendreDeriv(k, x, 1) * dx_dt;
59  }
60  return drdt;
61 }
62 double RtLegendre::driftAcceleration(double t) const {
63  double acc{0.};
64  // Argument of the Legendre polynomials
65  const double x = getReducedTime(t);
66  const double dx_dt = std::pow(2. / (tUpper() - tLower()), 2);
67  for (unsigned int k = 0; k < nPar() - 2; ++k) {
68  acc += par(k+2) * legendreDeriv(k, x, 2) * dx_dt;
69  }
70  return acc * t;
71 }
72 double RtLegendre::tLower() const { return par(0); }
73 double RtLegendre::tUpper() const { return par(1); }
74 unsigned int RtLegendre::numberOfRtParameters() const { return nPar() - 2; }
75 
76 std::vector<double> RtLegendre::rtParameters() const {
77  return std::vector<double>{parameters().begin() +2, parameters().end()};
78 }
79 double RtLegendre::getReducedTime(const double t) const {
80  return 2. * (t - 0.5 * (tUpper() + tLower())) / (tUpper() - tLower());
81 }
MuonCalib::RtLegendre::radius
virtual double radius(double t) const override final
get the drift velocity
Definition: RtLegendre.cxx:23
max
constexpr double max()
Definition: ap_fixedTest.cxx:33
LegendrePoly.h
MuonCalib::legendreDeriv
constexpr double legendreDeriv(const unsigned int l, const double x, const unsigned int derivOrder)
Definition: LegendrePoly.h:150
vec
std::vector< size_t > vec
Definition: CombinationsGeneratorTest.cxx:12
MuonCalib::RtLegendre::rtParameters
std::vector< double > rtParameters() const
get the reduced time which is the argument of the Legendre polynomial
Definition: RtLegendre.cxx:76
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
THROW_EXCEPTION
#define THROW_EXCEPTION(MSG)
Definition: MMReadoutElement.cxx:48
MuonCalib::RtLegendre::driftAcceleration
virtual double driftAcceleration(double t) const override final
Returns the acceleration of the r-t relation.
Definition: RtLegendre.cxx:62
x
#define x
MuonCalib::RtLegendre::getReducedTime
double getReducedTime(const double t) const
Definition: RtLegendre.cxx:79
MuonCalib::CalibFunc::par
double par(unsigned int index) const
Definition: CalibFunc.h:41
MuonCalib::RtLegendre::numberOfRtParameters
unsigned int numberOfRtParameters() const
get the coefficients of the r(t) polynomial
Definition: RtLegendre.cxx:74
MuonCalib::RtLegendre::tBinWidth
virtual double tBinWidth() const override final
get the number of parameters used to describe the r(t) relationship
Definition: RtLegendre.cxx:21
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
AthenaPoolTestRead.acc
acc
Definition: AthenaPoolTestRead.py:16
MuonCalib::IRtRelation::s_tBinWidth
static constexpr double s_tBinWidth
Definition: IRtRelation.h:43
MuonCalib::RtLegendre::driftVelocity
virtual double driftVelocity(double t) const override final
get the drift acceleration
Definition: RtLegendre.cxx:47
MuonCalib::legendrePoly
constexpr double legendrePoly(const unsigned int l, const double x)
Definition: LegendrePoly.h:125
MuonCalib::CalibFunc::parameters
const ParVec & parameters() const
Definition: CalibFunc.h:40
MuonCalib::RtLegendre::tUpper
virtual double tUpper() const override final
Returns the upper time covered by the r-t.
Definition: RtLegendre.cxx:73
MuonCalib::RtLegendre::RtLegendre
RtLegendre(const ParVec &vec)
initialization constructor,
Definition: RtLegendre.cxx:9
MuonCalib::CalibFunc::nPar
unsigned int nPar() const
Definition: CalibFunc.h:39
MuonCalib::RtLegendre::tLower
virtual double tLower() const override final
< get the lower drift-time bound
Definition: RtLegendre.cxx:72
pow
constexpr int pow(int base, int exp) noexcept
Definition: ap_fixedTest.cxx:15
RtLegendre.h
MuonCalib::RtLegendre::name
virtual std::string name() const override final
get the class name
Definition: RtLegendre.cxx:20
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