ATLAS Offline Software
RtSpline.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 // c- c++
6 #include "iostream"
7 
8 // this
10 
11 // root
13 #include "GaudiKernel/IMessageSvc.h"
14 #include "GaudiKernel/MsgStream.h"
15 #include "TSpline.h"
16 
17 namespace MuonCalib {
18 
20  // as long as there is no default constructor, we can delete the TSpline3 without a check
21  delete p_sp3;
22  }
23 
24  void RtSpline::_init() {
25  MsgStream log(Athena::getMessageSvc(), "RtSpline");
26  // check for minimum number of parameters
27  if (nPar() < 6) {
28  log << MSG::ERROR << "Not enough parameters!" << endmsg;
29  log << MSG::ERROR << "Minimum number of parameters is 6!" << endmsg;
30  throw 1;
31  }
32  // check if the number of parameters is even
33  if ((nPar() % 2) != 0) {
34  log << MSG::ERROR << "RtSpline::_init(): Odd number of parameters!" << endmsg;
35  throw 2;
36  }
37  // create spline
38  Double_t *x = new Double_t[nPar() / 2];
39  Double_t *y = new Double_t[nPar() / 2];
40  for (unsigned int i = 0; i < nPar() / 2; i++) {
41  x[i] = par(2 * i);
42  y[i] = par(2 * i + 1);
43  }
44  p_sp3 = new TSpline3("Rt Relation", x, y, nPar() / 2, "b2e2", 0, 0);
45  delete[] x;
46  delete[] y;
47  } // end RtSpline::_init
48 
49  double RtSpline::radius(double t) const {
50  // check for t_min and t_max
51  if (t > p_sp3->GetXmax()) return p_sp3->Eval(p_sp3->GetXmax());
52  if (t < p_sp3->GetXmin()) return p_sp3->Eval(p_sp3->GetXmin());
53  double r = p_sp3->Eval(t);
54  return r >= 0 ? r : 0;
55  }
56 
57  double RtSpline::driftvelocity(double t) const { return p_sp3->Derivative(t); }
58 
59  double RtSpline::tLower(void) const { return par(0); }
60 
61  double RtSpline::tUpper(void) const { return par(nPar() - 2); }
62 
63 } // namespace MuonCalib
MuonCalib::RtSpline::~RtSpline
~RtSpline()
Definition: RtSpline.cxx:19
beamspotman.r
def r
Definition: beamspotman.py:676
getMessageSvc.h
singleton-like access to IMessageSvc via open function and helper
RtSpline.h
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
x
#define x
Athena::getMessageSvc
IMessageSvc * getMessageSvc(bool quiet=false)
Definition: getMessageSvc.cxx:20
MuonCalib::CalibFunc::par
double par(unsigned int index) const
Definition: CalibFunc.h:41
MuonCalib::RtSpline::radius
double radius(double t) const
get the radius corresponding to the drift time t; 0 or 14.6 is returned if t is outside the range
Definition: RtSpline.cxx:49
lumiFormat.i
int i
Definition: lumiFormat.py:92
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
MuonCalib
CscCalcPed - algorithm that finds the Cathode Strip Chamber pedestals from an RDO.
Definition: CscCalcPed.cxx:22
MuonCalib::RtSpline::tLower
double tLower(void) const
get the lower drift-time bound
Definition: RtSpline.cxx:59
MuonCalib::RtSpline::driftvelocity
double driftvelocity(double t) const
get the drift velocity
Definition: RtSpline.cxx:57
MuonCalib::RtSpline::_init
void _init(void)
initialization method
Definition: RtSpline.cxx:24
y
#define y
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
MuonCalib::CalibFunc::nPar
unsigned int nPar() const
Definition: CalibFunc.h:39
MuonCalib::RtSpline::tUpper
double tUpper(void) const
get the upper drift-time bound
Definition: RtSpline.cxx:61
MuonCalib::RtSpline::p_sp3
TSpline3 * p_sp3
Definition: RtSpline.h:48