Heavy ion Analysis Libriares
Loading...
Searching...
No Matches
CorrFit3DCFBowlerSinyukov.cxx
1/*
2 * CorrFit3DCFBowlerSinyukov.cxx
3 *
4 * Created on: 22 sty 2018
5 * Author: Daniel Wielanek
6 * E-mail: daniel.wielanek@gmail.com
7 * Warsaw University of Technology, Faculty of Physics
8 */
9
10#include "CorrFit3DCFBowlerSinyukov.h"
11
12
13#include <TAxis.h>
14#include <TFile.h>
15#include <TH1.h>
16#include <TH2.h>
17#include <TH3.h>
18#include <TMath.h>
19#include <TMathBase.h>
20#include <TString.h>
21#include <iostream>
22
23#include "Array.h"
24#include "CorrFit.h"
25#include "Cout.h"
26#include "Femto3DCF.h"
27#include "Femto3DCFQinv.h"
28#include "StdHist.h"
29#include "StdString.h"
30
31
32namespace Hal {
33 Double_t CorrFit3DCFBowlerSinyukov::CalculateCF(const Double_t* x, const Double_t* params) const {
34 Double_t cf_free = 0;
35 Double_t kq = 0;
36
37 switch (fFrame) {
38 case Femto::EKinematics::kLCMS: {
39 Double_t k_star = 0;
40 k_star = 0.5 * fQinvMap->Eval(x[0], x[1], x[2]);
41 kq = fCFs->Eval(k_star, fRinv);
42 cf_free = 1.
43 + fQSMode
44 * TMath::Exp(-25.76578
45 * (x[0] * x[0] * params[RoutID()] * params[RoutID()]
46 + x[1] * x[1] * params[RsideID()] * params[RsideID()]
47 + x[2] * x[2] * params[RlongID()] * params[RlongID()]));
48 } break;
49 case Femto::EKinematics::kPRF: {
50 Double_t k_star = TMath::Sqrt(x[0] * x[0] + x[1] * x[1] + x[2] * x[2]);
51 cf_free = 1.
52 + fQSMode
53 * TMath::Exp(-25.76578 * 4.0
54 * (x[0] * x[0] * params[RoutID()] * params[RoutID()]
55 + x[1] * x[1] * params[RsideID()] * params[RsideID()]
56 + x[2] * x[2] * params[RlongID()] * params[RlongID()])); // x4 cause PRF
57 kq = fCFs->Eval(k_star, fRinv);
58 } break;
59 default:
60 // r_out = params[Rout()];
61 break;
62 }
63 if (kq < 0 || TMath::IsNaN(kq)) kq = 0;
64 return params[NormID()] * (1.0 - params[LambdaID()] + params[LambdaID()] * kq * cf_free);
65 }
66
67 CorrFit3DCFBowlerSinyukov::CorrFit3DCFBowlerSinyukov() :
68 CorrFit3DCF(6),
69 fCFs(NULL),
70 fQinvMap(NULL),
71 fTStarZero(kFALSE),
72 fRinv(0),
73 fAverageBeta(0),
74 fQSMode(0),
75 fSqrt3(1.0 / TMath::Sqrt(3.0)),
76 fFrame(Femto::EKinematics::kLCMS) {
77 SetParameterName(Tau(), "#tau");
78 FixParameter(Tau(), 0);
79 }
80 CorrFit3DCFBowlerSinyukov::CorrFit3DCFBowlerSinyukov(Int_t extra_params) :
81 CorrFit3DCF(6 + extra_params),
82 fCFs(NULL),
83 fQinvMap(NULL),
84 fTStarZero(kFALSE),
85 fRinv(0),
86 fAverageBeta(0),
87 fQSMode(0),
88 fSqrt3(1.0 / TMath::Sqrt(3.0)),
89 fFrame(Femto::EKinematics::kLCMS) {
90 SetParameterName(Tau(), "#tau");
91 FixParameter(Tau(), 0);
92 }
93 void CorrFit3DCFBowlerSinyukov::LoadMap(TH2D* h, Option_t* opt) {
94 TString option = opt;
95 if (fCFs) delete fCFs;
96 if (Hal::Std::FindParam(option, "krmap")) {
97 fCFs = new Spline2D(h);
98 // h->RebinY(4);
99 // h->RebinX(2);
100 Cout::Text(Form("Safe range of k* is %4.2f", h->GetXaxis()->GetBinUpEdge(h->GetNbinsX())), "M", kWhite);
101 Cout::Text(Form("Safe range of r* is %4.2f", 0.125 * TMath::Abs(h->GetYaxis()->GetBinUpEdge(h->GetNbinsY()))), "M", kWhite);
102 // make integration over R from 0.5 to 0.2 r* map with step 0.1 fm
103 Double_t map_step = 0.5;
104 // Double_t r_Min = h->GetYaxis()->GetBinLowEdge(1);
105 // Double_t r_Max = h->GetYaxis()->GetBinUpEdge(h->GetNbinsY());
106 Double_t r_max = h->GetYaxis()->GetBinUpEdge(h->GetNbinsY()) * 0.125;
107 Int_t r_bins = r_max / map_step;
108 TH2D* cf_map = new TH2D("cf_map",
109 "cf_map",
110 h->GetNbinsX(),
111 h->GetXaxis()->GetBinLowEdge(1),
112 h->GetXaxis()->GetBinUpEdge(h->GetNbinsX()),
113 r_bins,
114 0,
115 r_max);
116 Cout::Text("calculating integrals", "M", kWhite);
117 Double_t dr2 = fCFs->GetYaxis()->GetBinWidth(1) * 0.5; // 0.5 dR
118 Double_t r_steps = fCFs->GetYaxis()->GetNbins();
119
120 Double_t sqrtpi = TMath::Sqrt(TMath::Pi());
121 for (int r_bin = 0; r_bin <= r_bins; r_bin++) {
122 Double_t R = cf_map->GetYaxis()->GetBinCenter(r_bin);
123 Double_t norm = 1.0 / (sqrtpi * TMath::Power(R, 3) * 4.0);
124
125 // Double_t exp_min =
126 // TMath::Exp(r_Min*r_Min/(4.0*R*R))*sqrtpi*R; Double_t exp_max =
127 // TMath::Exp(r_Max*r_Max/(4.0*R*R))*sqrtpi*R; Double_t min_int =
128 // 0.5*( 1.0-r_Min/exp_min +TMath::Erf(r_Min/(2*R)) ); Double_t max_int =
129 // 0.5*(r_Max/exp_max +TMath::Erfc(r_Max/(2.*R)));
130 for (int i = 1; i <= cf_map->GetNbinsX(); i++) {
131 Double_t k = cf_map->GetXaxis()->GetBinCenter(i);
132 Double_t integ = 0;
133 for (int j = 1; j <= r_steps; j++) {
134 Double_t r_temp = fCFs->GetYaxis()->GetBinCenter(j);
135 Double_t m_dr = fCFs->Eval(k, r_temp - dr2) * norm * Gaus(r_temp - dr2, R);
136 Double_t dr = fCFs->Eval(k, r_temp) * norm * Gaus(r_temp, R);
137 Double_t p_dr = fCFs->Eval(k, r_temp + dr2) * norm * Gaus(r_temp + dr2, R);
138 /*
139 Double_t m_dr =1*norm*Gaus(r_temp-dr2, R);
140 Double_t dr = 1*norm*Gaus(r_temp,R);
141 Double_t p_dr = 1*norm*Gaus(r_temp+dr2,R);
142 */
143 integ += (m_dr + 2.0 * dr + p_dr) * dr2 * 0.5;
144 // integ +=2.0*dr*dr2;
145 }
146 // Double_t min_r =
147 // fCFs->GetYaxis()->GetBinCenter(1); Double_t max_r =
148 // fCFs->GetYaxis()->GetBinCenter(fCFs->GetYaxis()->GetNbins());
149
150 // Double_t dif =
151 // integ-(TMath::Exp(-4*R*R*25.76578*k*k)+1);
152 /* std::cout<<"m\t"<<min_int<<std::endl;
153 std::cout<<"M\t"<<max_int<<std::endl;
154 integ+=min_int*fCFs->Eval(min_r, k);
155 integ+=max_int*fCFs->Eval(max_r, k);
156 */
157 cf_map->SetBinContent(i, r_bin, integ);
158 }
159 Cout::ProgressBar(r_bin, r_bins);
160 }
161 if (cf_map->GetXaxis()->GetBinUpEdge(0) == 1)
162 for (int r_bin = 0; r_bin <= r_bins; r_bin++) {
163 cf_map->SetBinContent(0, r_bin, 0); // zero at q ==0
164 }
165 Cout::Text("Integrals done", "M", kWhite);
166 delete fCFs;
167 fCFs = new Spline2D(cf_map, "linear");
168 fCFs->Refit();
169 if (Hal::Std::FindParam(option, "dump")) {
170 TFile* dump = new TFile("dump.root", "recreate");
171 cf_map->Write();
172 dump->Close();
173 } else {
174 delete cf_map;
175 }
176 } else {
177 if (Hal::Std::FindParam(option, "lcms")) {
178 TH2D* h2 = new TH2D("kstarMap",
179 "kstarMap",
180 h->GetNbinsX(),
181 h->GetXaxis()->GetBinLowEdge(1) * 0.5,
182 h->GetXaxis()->GetBinUpEdge(h->GetNbinsX()) * 0.5,
183 h->GetNbinsY(),
184 h->GetYaxis()->GetBinLowEdge(1),
185 h->GetYaxis()->GetBinUpEdge(h->GetNbinsY()));
186 h2->GetYaxis()->SetTitle("R*");
187 h2->GetXaxis()->SetTitle("k*");
188 for (int i = 0; i <= h->GetNbinsX() + 1; i++) {
189 for (int j = 0; j <= h->GetNbinsY() + 1; j++) {
190 h2->SetBinContent(i, j, h->GetBinContent(i, j));
191 h2->SetBinError(i, j, h->GetBinError(i, j));
192 }
193 }
194 fCFs = new Spline2D(h2);
195 delete h2;
196 } else {
197 TH2D* temp = (TH2D*) h->Clone();
198 Hal::Std::HistogramEdges(temp, "x+uv", 0);
199 Hal::Std::HistogramEdges(temp, "y+uv", 0);
200 Hal::Std::HistogramEdges(temp, "z+uv", 0);
201 fCFs = new Spline2D(temp);
202 delete temp;
203 }
204 fCFs->Refit();
205 Cout::Text(Form("Safe range of k* is %4.2f", h->GetXaxis()->GetBinUpEdge(h->GetNbinsX())), "M", kWhite);
206 Cout::Text(Form("Safe range of r* is %4.2f", TMath::Abs(h->GetYaxis()->GetBinUpEdge(h->GetNbinsY()))), "M", kWhite);
207 }
208 }
209
211 switch (fFrame) {
212 case Femto::EKinematics::kPRF: {
213 fRinv = TMath::Sqrt(fTempParamsEval[RoutID()] * fTempParamsEval[RoutID()]
216 * fSqrt3;
217 } break;
218 case Femto::EKinematics::kLCMS: {
219 Double_t t = fTempParamsEval[Tau()];
220 if (fTStarZero) { t = fTempParamsEval[RoutID()] * fAverageBeta; }
221 Double_t r_out = GetRoutPRF(fTempParamsEval[RoutID()], t);
222 fRinv = TMath::Sqrt(r_out * r_out + fTempParamsEval[RsideID()] * fTempParamsEval[RsideID()]
224 * fSqrt3;
225 } break;
226 default: fRinv = 0; break;
227 }
228 }
229
230 CorrFit3DCFBowlerSinyukov::~CorrFit3DCFBowlerSinyukov() {
231 if (fCFs) delete fCFs;
232 if (fQinvMap) delete fQinvMap;
233 }
234
235 void CorrFit3DCFBowlerSinyukov::Fit(TObject* histo) {
236 Femto3DCF* cf = (Femto3DCF*) histo;
237 fFrame = cf->GetFrame();
238 switch (fFrame) {
239 case Femto::EKinematics::kPRF: break;
240 case Femto::EKinematics::kLCMS: {
241 Femto3DCFQinv* cfq = dynamic_cast<Femto3DCFQinv*>(cf);
242 if (cfq == NULL) {
243 if (fQinvMap) delete fQinvMap;
244 fQinvMap = NULL;
245 Cout::Text("No Qinv Map in LCMS !", "M", kOrange);
246 } else {
247 TH3D* temp = (TH3D*) cfq->GetQinvHist()->Clone();
248 fQinvMap = new Spline3D(temp, "yes+mid");
249 delete temp;
250 }
251 } break;
252 default: break;
253 }
254 CorrFit3DCF::Fit(histo);
255 if (fTStarZero && fFrame == Femto::EKinematics::kLCMS) {
256 Double_t t = GetParameter(RoutID()) * fAverageBeta;
257 fParameters[Tau()].SetFittedValue(t);
258 fTempParamsEval[Tau()] = t;
259 FixParameter(Tau(), t);
260 }
261 }
262
263 void CorrFit3DCFBowlerSinyukov::SetAveragePairBeta(Double_t m1, Double_t m2, Double_t avkt) {
264 Double_t mpair = m1 + m2;
265 avkt = avkt * 2.0;
266 Double_t epair = TMath::Sqrt(avkt * avkt + mpair * mpair);
267 fAverageBeta = avkt / epair;
268 fGamma = 1.0 / (TMath::Sqrt(1 - fAverageBeta * fAverageBeta));
269 }
270
272 fAverageBeta = beta;
273 fGamma = 1.0 / (TMath::Sqrt(1 - fAverageBeta * fAverageBeta));
274 }
275
276 Double_t CorrFit3DCFBowlerSinyukov::GetRoutPRF(Double_t r_out, Double_t tau) const {
277 return fGamma * (r_out - fAverageBeta * tau);
278 }
279
281 if (fCF == NULL) return NULL;
282 Femto3DCF* unbowler = new Femto3DCF(*(Femto3DCF*) fCF);
284 Double_t x[3];
285 Double_t* params = new Double_t[GetParametersNo()];
286 for (int i = 0; i < GetParametersNo(); i++) {
287 params[i] = GetParameter(i);
288 }
289 params[NormID()] = 1;
290 TH3* num = (TH3*) unbowler->GetNum();
291 for (fBinX = 1; fBinX <= unbowler->GetNum()->GetXaxis()->GetNbins(); fBinX++) {
292 x[0] = num->GetXaxis()->GetBinCenter(fBinX);
293 for (fBinY = 1; fBinY <= unbowler->GetNum()->GetYaxis()->GetNbins(); fBinY++) {
294 x[1] = num->GetYaxis()->GetBinCenter(fBinY);
295 for (fBinZ = 1; fBinZ <= unbowler->GetNum()->GetZaxis()->GetNbins(); fBinZ++) {
296 x[2] = num->GetZaxis()->GetBinCenter(fBinZ);
297 Double_t val = num->GetBinContent(fBinX, fBinY, fBinZ);
298 Double_t cf = EvalCF(x, params);
299 if (cf < 0) continue;
300 val = val / cf;
301 num->SetBinContent(fBinX, fBinY, fBinZ, val);
302 }
303 }
304 }
305 delete[] params;
306 return unbowler;
307 }
308
310 Femto3DCF* cf = (Femto3DCF*) histo;
311 fFrame = cf->GetFrame();
312 switch (fFrame) {
313 case Femto::EKinematics::kPRF: break;
314 case Femto::EKinematics::kLCMS: {
315 Femto3DCFQinv* cfq = dynamic_cast<Femto3DCFQinv*>(cf);
316 if (cfq == NULL) {
317 if (fQinvMap) delete fQinvMap;
318 fQinvMap = NULL;
319 Cout::Text("No Qinv Map in LCMS !", "M", kOrange);
320 } else {
321 TH3D* temp = (TH3D*) cfq->GetQinvHist()->Clone();
322 fQinvMap = new Spline3D(temp, "yes+mid");
323 delete temp;
324 }
325 } break;
326 default: break;
327 }
329 if (fTStarZero && fFrame == Femto::EKinematics::kLCMS) {
330 Double_t t = GetParameter(RoutID()) * fAverageBeta;
331 fParameters[Tau()].SetFittedValue(t);
332 fTempParamsEval[Tau()] = t;
333 FixParameter(Tau(), t);
334 }
335 }
336} // namespace Hal
virtual Double_t CalculateCF(const Double_t *x, const Double_t *params) const
void LoadMap(TH2D *h, Option_t *opt="")
virtual Double_t EvalCF(const Double_t *x, const Double_t *params) const
Int_t RsideID() const
Int_t LambdaID() const
Int_t RoutID() const
Int_t RlongID() const
void ParametersChanged() const
Int_t NormID() const
virtual void FitDummy(TObject *histo)
virtual void Fit(TObject *histo)
Int_t GetParametersNo() const
Definition CorrFit.h:269
Double_t GetParameter(Int_t par) const
Definition CorrFit.cxx:141
Double_t * fTempParamsEval
Definition CorrFit.h:109
void FixParameter(Int_t par, Double_t val)
Definition CorrFit.cxx:106
void SetParameterName(Int_t par, TString name)
Definition CorrFit.cxx:110
std::vector< FitParam > fParameters
Definition CorrFit.h:103
static void Text(TString text, TString option="L", Color_t color=-1)
Definition Cout.cxx:92
static void ProgressBar(Double_t acutal, Double_t total)
Definition Cout.cxx:229
TH3D * GetQinvHist(TString opt="av") const
Femto::EKinematics GetFrame() const
Definition Femto3DCF.h:67
Double_t Eval(Double_t x, Double_t y) const
Definition Splines.cxx:327
TAxis * GetYaxis() const
Definition Splines.h:209
Double_t Eval(Double_t x, Double_t y, Double_t z) const
Definition Splines.cxx:645