ATLAS Offline Software
Functions
MuonCalib::Legendre Namespace Reference

Functions

constexpr double coeff (unsigned int l, unsigned int k)
 Calculates the n-th coefficient of the legendre polynomial series. More...
 
template<unsigned int l, unsigned int k>
constexpr double polySum (const double x)
 Assembles the sum of the legendre monomials. More...
 
template<unsigned int l, unsigned int k, unsigned int d>
constexpr double derivativeSum (const double x)
 Assembles the n-th derivative of the legendre polynomial. More...
 
template<unsigned int l>
constexpr double poly (const double x)
 
template<unsigned int l, unsigned d>
constexpr double derivative (const double x)
 

Function Documentation

◆ coeff()

constexpr double MuonCalib::Legendre::coeff ( unsigned int  l,
unsigned int  k 
)
constexpr

Calculates the n-th coefficient of the legendre polynomial series.

Parameters
lOrder of the legendre polynomial
kCoefficient of the polynomial representation

Definition at line 73 of file LegendrePoly.h.

73  {
74  if (k %2 != l %2) {
75  return 0.;
76  } else if (k > 1) {
77  const double a_k = -(1.*(l- k +2)*(l+ k-1)) / (1.*(k * (k-1))) * coeff(l, k-2);
78  return a_k;
79  } else {
80  unsigned fl = (l - l %2) /2;
81  unsigned long binom = binomial(l,fl) * binomial(2*l - 2*fl,l);
82  return (fl % 2 ? -1. : 1.) * std::pow(0.5, l) * (1.*binom);
83  }
84  }

◆ derivative()

template<unsigned int l, unsigned d>
constexpr double MuonCalib::Legendre::derivative ( const double  x)
constexpr

Definition at line 120 of file LegendrePoly.h.

120  {
121  return derivativeSum<l,l,d>(x);
122  }

◆ derivativeSum()

template<unsigned int l, unsigned int k, unsigned int d>
constexpr double MuonCalib::Legendre::derivativeSum ( const double  x)
constexpr

Assembles the n-th derivative of the legendre polynomial.

Parameters
lOrder of the legendre polynomial
kTerm in the polynomial to add to the sum
kOrder of the derivative
xDependency of the polynomial

Definition at line 104 of file LegendrePoly.h.

104  {
105  static_assert(d> 0);
106  if constexpr(k <= l && k>=d) {
107  constexpr unsigned long powFac = factorial(k) / factorial(k-d);
108  const double a_n = coeff(l,k) * powFac;
109  return a_n *std::pow(x,k-d) + derivativeSum<l, k-2, d>(x);
110  } else {
111  return 0.;
112  }
113  }

◆ poly()

template<unsigned int l>
constexpr double MuonCalib::Legendre::poly ( const double  x)
constexpr

Definition at line 116 of file LegendrePoly.h.

116  {
117  return polySum<l,l>(x);
118  }

◆ polySum()

template<unsigned int l, unsigned int k>
constexpr double MuonCalib::Legendre::polySum ( const double  x)
constexpr

Assembles the sum of the legendre monomials.

Parameters
lOrder of the legendre polynomial
kTerm in the polynomial to add to the sum
xDependency of the polynomial

Definition at line 90 of file LegendrePoly.h.

90  {
91  const double a_n = coeff(l,k);
92  if constexpr (k > 1) {
93  return a_n* std::pow(x,k) + polySum<l, k-2>(x);
94  } else{
95  return a_n*std::pow(x,k);
96  }
97  }
MuonCalib::Legendre::derivativeSum
constexpr double derivativeSum(const double x)
Assembles the n-th derivative of the legendre polynomial.
Definition: LegendrePoly.h:104
CLHEP::binom
double binom(int n, int k)
Definition: RandBinomialFixedP.cxx:19
MuonCalib::Legendre::polySum
constexpr double polySum(const double x)
Assembles the sum of the legendre monomials.
Definition: LegendrePoly.h:90
hist_file_dump.d
d
Definition: hist_file_dump.py:137
conifer::pow
constexpr int pow(int x)
Definition: conifer.h:20
UploadAMITag.l
list l
Definition: UploadAMITag.larcaf.py:158
x
#define x
MuonCalib::binomial
constexpr unsigned long binomial(unsigned int n, unsigned k)
Calculates the binomial coefficient at compile time.
Definition: LegendrePoly.h:63
MuonCalib::Legendre::coeff
constexpr double coeff(unsigned int l, unsigned int k)
Calculates the n-th coefficient of the legendre polynomial series.
Definition: LegendrePoly.h:73
fitman.k
k
Definition: fitman.py:528
MuonCalib::factorial
constexpr unsigned long factorial(int n)
Evaluated the n-th factorial at compile time.
Definition: LegendrePoly.h:54