KaliVeda
Toolkit for HIC analysis
Loading...
Searching...
No Matches
rogly_fitting_function.h
1#ifndef ROGLY_FITTING_FUNCTION_H
2#define ROGLY_FITTING_FUNCTION_H
3
4#include "ipde_fit_parameter.h"
5#include <TH1.h>
6#include <vector>
7#include "TRandom.h"
8
9namespace KVImpactParameters {
26 template<unsigned int PolyDegree>
28 ipde_fit_parameter theta_p;
29 ipde_fit_parameter kmax;
30 std::vector<ipde_fit_parameter> poly_param;
31
32 public:
34 : poly_param(PolyDegree)
35 {}
37 : theta_p(prev_fit.theta_p), kmax(prev_fit.kmax), poly_param(PolyDegree)
38 {
39 poly_param = prev_fit.poly_param;
40 }
41 rogly_fitting_function(std::initializer_list<double> params)
42 : poly_param(PolyDegree)
43 {
50 int i = 0;
51 for (auto param : params) {
52 switch (i) {
53 case 0:
54 theta_p.value = param;
55 break;
56 case 1:
57 kmax.value = param;
58 break;
59 default:
60 poly_param[i - 2].value = param;
61 }
62 ++i;
63 }
64 }
65 constexpr int npar() const
66 {
68 return PolyDegree + 2;
69 }
70
71 double k_cb(double cb) const
72 {
75 double kcb = 0;
76 for (int j = 1; j <= PolyDegree; ++j) kcb += poly_param[j - 1].value * pow(cb, j);
77 return kmax.value * TMath::Exp(-kcb);
78 }
79 void fill_params_from_array(double* p)
80 {
88 theta_p.value = p[0];
89 kmax.value = p[1];
90 for (int j = 1; j <= PolyDegree; ++j) poly_param[j - 1].value = p[j + 1];
91 }
92 void fill_array_from_params(double* p) const
93 {
101 p[0] = theta_p.value;
102 p[1] = kmax.value;
103 for (int j = 1; j <= PolyDegree; ++j) p[j + 1] = poly_param[j - 1].value ;
104 }
110 void set_par_names(TF1& f) const
111 {
114 f.SetParName(0, "#theta");
115 f.SetParName(1, "k_{max}");
116 for (int j = 1; j <= PolyDegree; ++j) f.SetParName(j + 1, Form("a_{%d}", j));
117 }
119 {
123 f.SetParameter(0, theta_p.value = 0.5);
124 f.SetParLimits(0, 0.1, 5);
125 double xmax = h->GetXaxis()->GetBinUpEdge(h->GetNbinsX());
126 double xmin = xmax / 7.;
127 f.SetParameter(1, kmax.value = (xmin * 2) / theta_p.value);
128 f.SetParLimits(1, xmin / theta_p.value, xmax / theta_p.value);
129 for (int j = 1; j <= PolyDegree; ++j) {
130 f.SetParameter(j + 1, gRandom->Uniform(-1, 1));
131 f.SetParLimits(j + 1, -5, 5);
132 }
133 }
134 void print_fit_params() const
135 {
136 std::cout << "Theta = ";
137 theta_p.print();
138 std::cout << "\n";
139 std::cout << "kmax = ";
140 kmax.print();
141 std::cout << "(Xmax = " << theta_p.value* kmax.value << ")";
142 std::cout << "\n";
143 for (int j = 1; j <= PolyDegree; ++j) {
144 std::cout << "a" << j << " = ";
145 poly_param[j - 1].print();
146 std::cout << " ";
147 }
148 std::cout << "\n";
149 }
151 {
153 theta_p.backup();
154 kmax.backup();
155 std::for_each(poly_param.begin(), poly_param.end(), [](ipde_fit_parameter & p) {
156 p.backup();
157 });
158 }
160 {
162 theta_p.restore();
163 kmax.restore();
164 std::for_each(poly_param.begin(), poly_param.end(), [](ipde_fit_parameter & p) {
165 p.restore();
166 });
167 }
169 {
173 kmax.value = 1;
174 }
175 double meanX(double cb) const
176 {
177 return theta_p.value * k_cb(cb);
178 }
179 double redVar(double) const
180 {
181 return theta_p.value;
182 }
183
184 ClassDef(rogly_fitting_function, 0) //fit using exponential polynomial
185 };
186}
187
188#endif // ROGLY_FITTING_FUNCTION_H
#define f(i)
#define ClassDef(name, id)
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
float xmin
float xmax
R__EXTERN TRandom * gRandom
char * Form(const char *fmt,...)
Exponential function relating mean value of observable to centrality.
ipde_fit_parameter theta_p
fluctuation parameter
rogly_fitting_function(const rogly_fitting_function &prev_fit)
ipde_fit_parameter kmax
maximum of mean value for
rogly_fitting_function(std::initializer_list< double > params)
std::vector< ipde_fit_parameter > poly_param
polynomial coefficients
virtual Double_t GetBinUpEdge(Int_t bin) const
TAxis * GetXaxis()
virtual Int_t GetNbinsX() const
virtual Double_t Uniform(Double_t x1, Double_t x2)
RVec< PromoteTypes< T0, T1 > > pow(const RVec< T0 > &v, const T1 &y)
TH1 * h
Double_t Exp(Double_t x)