ATLAS Offline Software
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 
18 namespace MuonCalib {
19  RtSpline::~RtSpline() = default;
21  IRtRelation(vec) {
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  double RtSpline::radius(double t) const {
43  // check for t_min and t_max
44  if (t > m_sp3->GetXmax()) return m_sp3->Eval(m_sp3->GetXmax());
45  if (t < m_sp3->GetXmin()) return m_sp3->Eval(m_sp3->GetXmin());
46  double r = m_sp3->Eval(t);
47  return r >= 0 ? r : 0;
48  }
49 
50  double RtSpline::driftVelocity(double t) const { return m_sp3->Derivative(t); }
51  double RtSpline::driftAcceleration(double t) const {
52  constexpr double h = 1.e-7;
53  return (driftVelocity(t + h) - driftVelocity(t-h))/ (2.*h);
54  }
55  double RtSpline::tLower() const { return par(0); }
56 
57  double RtSpline::tUpper() const { return par(nPar() - 2); }
58 
59 } // namespace MuonCalib
MuonCalib::RtSpline::~RtSpline
virtual ~RtSpline()
beamspotman.r
def r
Definition: beamspotman.py:676
getMessageSvc.h
singleton-like access to IMessageSvc via open function and helper
RtSpline.h
vec
std::vector< size_t > vec
Definition: CombinationsGeneratorTest.cxx:12
MuonCalib::RtSpline::tLower
virtual double tLower() const override final
get the lower drift-time bound
Definition: RtSpline.cxx:55
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
THROW_EXCEPTION
#define THROW_EXCEPTION(MSG)
Definition: MMReadoutElement.cxx:48
x
#define x
MuonCalib::CalibFunc::par
double par(unsigned int index) const
Definition: CalibFunc.h:41
MuonCalib::RtSpline::driftAcceleration
virtual double driftAcceleration(double t) const override final
Returns the acceleration of the r-t relation.
Definition: RtSpline.cxx:51
MuonCalib::RtSpline::driftVelocity
virtual double driftVelocity(double t) const override final
get the drift velocity
Definition: RtSpline.cxx:50
lumiFormat.i
int i
Definition: lumiFormat.py:85
extractSporadic.h
list h
Definition: extractSporadic.py:97
MuonCalib::RtSpline::tUpper
virtual double tUpper() const override final
get the upper drift-time bound
Definition: RtSpline.cxx:57
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::RtSpline::m_sp3
std::unique_ptr< TSpline3 > m_sp3
Definition: RtSpline.h:48
MuonCalib::RtSpline::tBinWidth
virtual double tBinWidth() const override final
Returns the step-size for the sampling.
Definition: RtSpline.cxx:39
y
#define y
h
MuonCalib::CalibFunc::nPar
unsigned int nPar() const
Definition: CalibFunc.h:39
MuonCalib::RtSpline::RtSpline
RtSpline(const ParVec &vec)
initialization constructor,
Definition: RtSpline.cxx:20
MuonCalib::IRtRelation
generic interface for a rt-relation
Definition: IRtRelation.h:15
MuonCalib::RtSpline::radius
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:42