Class Reference for E1039 Core & Analysis Software
RTCurve.cc
Go to the documentation of this file.
1 #include <cassert>
2 #include <TSpline.h>
3 #include <TGraph.h>
4 #include "RTCurve.h"
5 using namespace std;
6 
7 RTCurve::RTCurve(const int n_pt)
8  : m_n_pt(n_pt)
9  , m_array_r(new double[n_pt])
10  , m_array_t(new double[n_pt])
11  , m_t2r_changed(true)
12  , m_t2dr_changed(true)
13  , m_spl_t2r(0)
14  , m_gr_t2dr(0)
15 {
16  ;
17 }
18 
20 {
21  delete m_array_t;
22  delete m_array_r;
23  if (m_spl_t2r) delete m_spl_t2r;
24  if (m_gr_t2dr) delete m_gr_t2dr;
25 }
26 
27 void RTCurve::SetPoint(const int i_pt, const double r, const double t)
28 {
29  assert(0 <= i_pt && i_pt < m_n_pt);
30  m_array_r[i_pt] = r;
31  m_array_t[i_pt] = t;
32  m_t2r_changed = true;
33 }
34 
35 void RTCurve::GetPoint(const int i_pt, double& r, double& t) const
36 {
37  assert(0 <= i_pt && i_pt < m_n_pt);
38  r = m_array_r[i_pt];
39  t = m_array_t[i_pt];
40 }
41 
42 void RTCurve::SetRWidth(const double dr)
43 {
44  m_dr = dr;
45  m_t2dr_changed = true;
46 }
47 
48 double RTCurve::GetRWidth() const
49 {
50  return m_dr;
51 }
52 
53 double RTCurve::EvalR(const double t)
54 {
55  if (t < GetTMin()) return GetRMax();
56  if (t > GetTMax()) return 0;
57  double r = GetT2RSpline()->Eval(t);
58  if (r > GetRMax()) return GetRMax();
59  if (r < 0 ) return 0;
60  return r;
61 }
62 
64 {
65  if (m_t2r_changed) {
66  if (m_spl_t2r) delete m_spl_t2r;
67  m_spl_t2r = CreateT2RSpline();
68  m_t2r_changed = false;
69  }
70  return m_spl_t2r;
71 }
72 
74 {
75  if (m_t2dr_changed) {
76  if (m_gr_t2dr) delete m_gr_t2dr;
77  m_gr_t2dr = CreateT2DRGraph();
78  m_t2dr_changed = false;
79  }
80  return m_gr_t2dr;
81 }
82 
83 TSpline3* RTCurve::CreateT2RSpline() const
84 {
85  return new TSpline3("spl", m_array_t, m_array_r, m_n_pt, "b1e1", 0, 0);
86 }
87 
88 TGraph* RTCurve::CreateT2DRGraph() const
89 {
90  TGraph* gr = new TGraph();
91  gr->SetPoint(0, GetTMin(), m_dr);
92  return gr;
93 }
double GetRWidth() const
Definition: RTCurve.cc:48
virtual ~RTCurve()
Definition: RTCurve.cc:19
double GetRMax() const
Definition: RTCurve.h:31
double GetTMax() const
Definition: RTCurve.h:30
double EvalR(const double t)
Definition: RTCurve.cc:53
RTCurve(const int n_pt)
Definition: RTCurve.cc:7
void SetPoint(const int i_pt, const double r, const double t)
Definition: RTCurve.cc:27
TSpline3 * GetT2RSpline()
Definition: RTCurve.cc:63
void SetRWidth(const double dr)
Definition: RTCurve.cc:42
void GetPoint(const int i_pt, double &r, double &t) const
Definition: RTCurve.cc:35
double GetTMin() const
Definition: RTCurve.h:29
TGraph * GetT2DRGraph()
Definition: RTCurve.cc:73