ATLAS Offline Software
RtResolutionChebyshev.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 
8 using namespace MuonCalib;
9 
11  IRtResolution(vec) {
12  // check for consistency //
13  if (nPar() < 3) {
14  THROW_EXCEPTION("Not enough parameters!");
15  }
16  if (tLower() >= tUpper()) {
17  THROW_EXCEPTION("Lower time boundary >= upper time boundary!");
18  }
19 }
20 std::string RtResolutionChebyshev::name() const { return std::string("RtResolutionChebyshev"); }
21 double RtResolutionChebyshev::resolution(double t, double /*bgRate*/) const {
23  // INITIAL TIME CHECK //
25 
26  if (t != tLower() && t != tUpper()) {
27  // get resolution for tmin and tmax to get reasonable boundary conditrions
28  double res_min(resolution(tLower())), res_max(resolution(tUpper()));
29 
30  // if x is out of bounds, return 99999 //
31  if (t < tLower()) return res_min;
32 
33  if (t > tUpper()) return res_max;
34  }
36  // VARIABLES //
38  // argument of the Chebyshev polynomials
39  double x(2 * (t - 0.5 * (tUpper() + tLower())) / (tUpper() - tLower()));
40  double resol(0.0); // auxiliary resolution
41 
43  // CALCULATE r(t) //
45  for (unsigned int k = 0; k < nPar() - 2; k++) { resol = resol + parameters()[k + 2] * chebyshevPoly1st(k, x); }
46 
47  return resol;
48 }
49 double RtResolutionChebyshev::tLower() const { return parameters()[0]; }
50 double RtResolutionChebyshev::tUpper() const { return parameters()[1]; }
51 unsigned int RtResolutionChebyshev::numberOfResParameters() const { return nPar() - 2; }
52 std::vector<double> RtResolutionChebyshev::resParameters() const {
53  std::vector<double> alpha(nPar() - 2);
54  for (unsigned int k = 0; k < alpha.size(); k++) { alpha[k] = parameters()[k + 2]; }
55 
56  return alpha;
57 }
58 inline double RtResolutionChebyshev::get_reduced_time(const double t) const {
59  return 2 * (t - 0.5 * (tUpper() + tLower())) / (tUpper() - tLower());
60 }
MuonCalib::RtResolutionChebyshev::resParameters
std::vector< double > resParameters() const
get the reduced time which is the argument of the Chebyshev polynomial
Definition: RtResolutionChebyshev.cxx:52
MuonCalib::RtResolutionChebyshev::name
std::string name() const
get the class name
Definition: RtResolutionChebyshev.cxx:20
MuonCalib::RtResolutionChebyshev::RtResolutionChebyshev
RtResolutionChebyshev(const ParVec &vec)
initialization constructor,
Definition: RtResolutionChebyshev.cxx:10
MuonCalib::RtResolutionChebyshev::resolution
double resolution(double t, double bgRate=0.0) const
returns resolution for a give time and background rate
Definition: RtResolutionChebyshev.cxx:21
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
MuonCalib::RtResolutionChebyshev::tUpper
double tUpper() const
get the number of parameters used to describe the resolution
Definition: RtResolutionChebyshev.cxx:50
x
#define x
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
MuonCalib::RtResolutionChebyshev::tLower
double tLower() const
< get the lower drift-time bound
Definition: RtResolutionChebyshev.cxx:49
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
RtResolutionChebyshev.h
MuonCalib::IRtResolution
generic interface for a resolution function
Definition: IRtResolution.h:13
MuonCalib::CalibFunc::parameters
const ParVec & parameters() const
Definition: CalibFunc.h:40
MuonCalib::RtResolutionChebyshev::numberOfResParameters
unsigned int numberOfResParameters() const
get the coefficients of the r(t) polynomial
Definition: RtResolutionChebyshev.cxx:51
MuonCalib::CalibFunc::nPar
unsigned int nPar() const
Definition: CalibFunc.h:39
MuonCalib::RtResolutionChebyshev::get_reduced_time
double get_reduced_time(const double t) const
Definition: RtResolutionChebyshev.cxx:58
fitman.k
k
Definition: fitman.py:528