elegent is hosted by Hepforge, IPPP Durham
Elegent
InterpolationModel.h
1 /********************************************************************************
2 
3  Copyright 2013 Jan Kašpar
4 
5  This file is part of Elegent (http://elegent.hepforge.org/).
6 
7  Elegent is free software: you can redistribute it and/or modify
8  it under the terms of the GNU General Public License as published by
9  the Free Software Foundation, either version 3 of the License, or
10  (at your option) any later version.
11 
12  Elegent is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with Elegent. If not, see <http://www.gnu.org/licenses/>.
19 
20 ********************************************************************************/
21 
22 #ifndef _elegent_interpolation_model_
23 #define _elegent_interpolation_model_
24 
25 #include "Model.h"
26 
27 #include <vector>
28 
29 class TGraph;
30 
31 namespace Elegent
32 {
33 
37 class InterpolationModel : public Model
38 {
39  public:
41  unsigned int N;
42 
44  double t_min;
45 
47  double t_max;
48 
50  double dt;
51 
53  std::vector<TComplex> amp_data;
54 
55  public:
56  InterpolationModel(unsigned int _N, double _t_min, double _t_max);
57 
58  virtual ~InterpolationModel();
59 
60  void Configure();
61 
62  virtual void Init() {}
63 
64  virtual void Print() const;
65 
67  virtual TComplex Amp(double t) const
68  {
69  double f = (t - t_min) / dt;
70  unsigned int idx = (unsigned int) f;
71 
72  if (idx + 1 > N - 1)
73  {
74  if (fabs(t - t_max) < 1E-10)
75  return amp_data[N-1];
76  return TComplex(0, 0);
77  }
78 
79  f -= idx;
80 
81  return amp_data[idx] + (amp_data[idx+1] - amp_data[idx]) * f;
82  }
83 
84  virtual TComplex Prf(double b) const;
85 
87  inline double GetT(unsigned int idx) const
88  {
89  return t_min + dt * idx;
90  }
91 
92  inline void SetPoint(unsigned int idx, const TComplex &v)
93  {
94  amp_data[idx] = v;
95  }
96 };
97 
98 } // namespace
99 
100 #endif
double GetT(unsigned int idx) const
returns the value of t corresponding to the point with index `idx' (between 0 and N-1 inclusively) ...
Definition: InterpolationModel.h:87
Definition: BHModel.h:28
double dt
the t interval between two adjacent (equidistant) points
Definition: InterpolationModel.h:50
virtual TComplex Amp(double t) const
amplitude, t in GeV^-2, t < 0
Definition: InterpolationModel.h:67
virtual TComplex Prf(double b) const
Profile function (amplitude in b-space).
Definition: InterpolationModel.cc:61
virtual void Init()
sets up model parameters and data members
Definition: InterpolationModel.h:62
double t_min
the lower boundary
Definition: InterpolationModel.h:44
double t_max
the upper boundary
Definition: InterpolationModel.h:47
std::vector< TComplex > amp_data
amplitude samples
Definition: InterpolationModel.h:53
The base class for hadronic models of (anti)proton-proton elastic scattering.
Definition: Model.h:35
unsigned int N
number of points (samples)
Definition: InterpolationModel.h:41
Model that interpolates stored amplitude points.
Definition: InterpolationModel.h:37
virtual void Print() const
prints model info
Definition: InterpolationModel.cc:53