ATLAS Offline Software
Loading...
Searching...
No Matches
RtSpline.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4
5// c- c++
6#include "iostream"
7
8// this
10
11// root
12#include "GeoModelKernel/throwExcept.h"
14#include "GaudiKernel/IMessageSvc.h"
15#include "GaudiKernel/MsgStream.h"
16#include "TSpline.h"
17
18namespace MuonCalib {
19 RtSpline::~RtSpline() = default;
22 // check for minimum number of parameters
23 if (nPar() < 6) {
24 THROW_EXCEPTION("Not enough parameters!" << std::endl<< "Minimum number of parameters is 6!");
25 }
26 // check if the number of parameters is even
27 if ((nPar() % 2) != 0) {
28 THROW_EXCEPTION("RtSpline::_init(): Odd number of parameters!");
29 }
30 // create spline
31 std::vector<double> x(nPar() /2);
32 std::vector<double> y(nPar() /2);
33 for (unsigned int i = 0; i < nPar() / 2; i++) {
34 x[i] = par(2 * i);
35 y[i] = par(2 * i + 1);
36 }
37 m_sp3 = std::make_unique<TSpline3>("Rt Relation", x.data(), y.data(), nPar() / 2, "b2e2", 0, 0);
38 } // end RtSpline::_init
39 double RtSpline::tBinWidth() const {
40 return m_sp3->GetDelta();
41 }
42 unsigned RtSpline::nDoF() const {
43 return m_sp3->GetNp();
44 }
45 double RtSpline::radius(double t) const {
46 // check for t_min and t_max
47 if (t > m_sp3->GetXmax()) return m_sp3->Eval(m_sp3->GetXmax());
48 if (t < m_sp3->GetXmin()) return m_sp3->Eval(m_sp3->GetXmin());
49 double r = m_sp3->Eval(t);
50 return r >= 0 ? r : 0;
51 }
52
53 double RtSpline::driftVelocity(double t) const { return m_sp3->Derivative(t); }
54 double RtSpline::driftAcceleration(double t) const {
55 constexpr double h = 1.e-7;
56 return (driftVelocity(t + h) - driftVelocity(t-h))/ (2.*h);
57 }
58 double RtSpline::tLower() const { return par(0); }
59
60 double RtSpline::tUpper() const { return par(nPar() - 2); }
61
62} // namespace MuonCalib
std::vector< size_t > vec
#define y
#define x
Header file for AthHistogramAlgorithm.
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
virtual unsigned nDoF() const override final
Returns the number of degrees of freedom of the relation function.
Definition RtSpline.cxx:42
std::unique_ptr< TSpline3 > m_sp3
Definition RtSpline.h:37
virtual double tLower() const override final
get the lower drift-time bound
Definition RtSpline.cxx:58
virtual double driftAcceleration(double t) const override final
Returns the acceleration of the r-t relation.
Definition RtSpline.cxx:54
virtual double tUpper() const override final
get the upper drift-time bound
Definition RtSpline.cxx:60
virtual double driftVelocity(double t) const override final
get the drift velocity
Definition RtSpline.cxx:53
RtSpline(const ParVec &vec)
initialization constructor,
Definition RtSpline.cxx:20
virtual double tBinWidth() const override final
Returns the step-size for the sampling.
Definition RtSpline.cxx:39
virtual double radius(double t) const override final
get the radius corresponding to the drift time t; 0 or 14.6 is returned if t is outside the range
Definition RtSpline.cxx:45
singleton-like access to IMessageSvc via open function and helper
int r
Definition globals.cxx:22
CscCalcPed - algorithm that finds the Cathode Strip Chamber pedestals from an RDO.
#define THROW_EXCEPTION(MESSAGE)
Definition throwExcept.h:10