ATLAS Offline Software
Loading...
Searching...
No Matches
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"
7using namespace MuonCalib;
8
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
20std::string RtLegendre::name() const { return "RtLegendre"; }
21double RtLegendre::tBinWidth() const { return s_tBinWidth; }
22
23double 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 < nDoF(); k++) {
41 rad += par(k+2) * legendrePoly(k, x);
42 }
43 return std::max(rad, 0.);
44}
45
46//*****************************************************************************
47double 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 = dReducedTimeDt();
56 double drdt{0.};
57 for (unsigned int k = 0; k < nDoF(); ++k) {
58 drdt += par(k+2) * legendreDeriv(k, 1, x) * dx_dt;
59 }
60 return drdt;
61}
62double 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(dReducedTimeDt(), 2);
67 for (unsigned int k = 0; k < nDoF(); ++k) {
68 acc += par(k+2) * legendreDeriv(k, 2, x) * dx_dt;
69 }
70 return acc * t;
71}
72double RtLegendre::tLower() const { return par(0); }
73double RtLegendre::tUpper() const { return par(1); }
74unsigned int RtLegendre::nDoF() const { return nPar() -2; }
75
76std::vector<double> RtLegendre::rtParameters() const {
77 return std::vector<double>{parameters().begin() +2, parameters().end()};
78}
std::vector< size_t > vec
#define x
const ParVec & parameters() const
Definition CalibFunc.h:40
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 for a rt-relation
Definition IRtRelation.h:19
static constexpr double s_tBinWidth
Definition IRtRelation.h:60
double dReducedTimeDt() const
Definition IRtRelation.h:53
double getReducedTime(const double t) const
map the in the interval [tLower;tUpper] onto the interval [-1.;1.
Definition IRtRelation.h:49
std::vector< double > rtParameters() const
virtual double driftVelocity(double t) const override final
get the drift acceleration
RtLegendre(const ParVec &vec)
initialization constructor,
Definition RtLegendre.cxx:9
virtual double radius(double t) const override final
get the drift velocity
virtual double tLower() const override final
< get the lower drift-time bound
virtual unsigned nDoF() const override final
Returns the number of degrees of freedom of the relation function.
virtual double tUpper() const override final
Returns the upper time covered by the r-t.
virtual std::string name() const override final
get the class name
virtual double driftAcceleration(double t) const override final
Returns the acceleration of the r-t relation.
virtual double tBinWidth() const override final
get the number of parameters used to describe the r(t) relationship
CscCalcPed - algorithm that finds the Cathode Strip Chamber pedestals from an RDO.
constexpr double legendrePoly(const unsigned l, const double x)
Calculates the legendre polynomial of rank l at x.
constexpr double legendreDeriv(const unsigned l, const unsigned d, const double x)
Evaluates the n-th derivative of the l-th Legendre polynomial.
#define THROW_EXCEPTION(MESSAGE)
Definition throwExcept.h:10