Heavy ion Analysis Libriares
Loading...
Searching...
No Matches
CorrFitWielanek.cxx
1/*
2 * CorrFitWielanek.cxx
3 *
4 * Created on: 28 sty 2016
5 * Author: Daniel Wielanek
6 * E-mail: daniel.wielanek@gmail.com
7 * Warsaw University of Technology, Faculty of Physics
8 */
9
10#include "CorrFitWielanek.h"
11#include "CorrFit1DCF.h"
12#include "CorrFitMapKstarRstar.h"
13#include "Cout.h"
14#include "Splines.h"
15#include "Std.h"
16
17#include <TAxis.h>
18#include <TF1.h>
19#include <TFile.h>
20#include <TH1.h>
21#include <TH2.h>
22
23
24namespace Hal {
25 CorrFitWielanek::CorrFitWielanek() : fExtrapolationsSteps(40), fFSIMap(NULL), fSource(NULL) {}
26
27 void CorrFitWielanek::LoadMapFromFile(TString name, Int_t /*kt_bin*/) {
28 TFile* file = new TFile(name);
29 TH2D* map = (TH2D*) file->Get("map");
30 fFSIMap = (TH2D*) map->Clone();
31 fFSIMap->SetDirectory(0);
32 file->Close();
33 }
34
35 void CorrFitWielanek::Check() {
36 CorrFit1DCF::Check();
37 if (fMaps.size() == 0) { CreateMap(); }
38 CorrFitKisiel::Check();
39 }
40
41 void CorrFitWielanek::CreateMap() {
42 if (fSource == NULL) { Cout::PrintInfo("No source emission funciont", EInfo::kCriticalError); }
43 if (fMaps.size() > 0) return;
44 Double_t r_min = fParameters[RadiusID()].GetMin();
45 Double_t r_max = fParameters[RadiusID()].GetMax();
46 Double_t d_r = r_max - r_min;
47 d_r = d_r / ((Double_t) fExtrapolationsSteps * 2.0);
48 r_min = r_min - d_r;
49 r_max = r_max + d_r;
50 TH2D* MAP = new TH2D("new_map",
51 "new_map",
52 fFSIMap->GetNbinsX(),
53 fFSIMap->GetXaxis()->GetBinLowEdge(1),
54 fFSIMap->GetXaxis()->GetBinUpEdge(fFSIMap->GetNbinsX()),
55 fExtrapolationsSteps + 1,
56 r_min,
57 r_max);
58 Int_t R_Map = fFSIMap->GetNbinsY();
59 TAxis* R_Ax = fFSIMap->GetYaxis();
60 Double_t* prob = new Double_t[R_Map];
61 for (int j = 1; j <= MAP->GetNbinsY(); j++) { // loop over R
62 Double_t R = MAP->GetYaxis()->GetBinCenter(j);
63 Double_t infs = 0;
64 fSource->FixParameter(0, R);
65 if (fSource->GetNpar() == 2) { fSource->FixParameter(1, 1); }
66 Double_t sum = 0;
67 for (int a = 0; a < R_Map; a++) { // calculate density probability for given R
68 // prob[a] = fSource->Eval(R_Ax->GetBinCenter(a+1));
69 prob[a] = fSource->Integral(R_Ax->GetBinLowEdge(a + 1), R_Ax->GetBinUpEdge(a + 1));
70 sum += prob[a];
71 }
72
73 infs += fSource->Integral(-1000, R_Ax->GetBinLowEdge(1));
74 infs += fSource->Integral(R_Ax->GetBinUpEdge(R_Ax->GetNbins()), 1000);
75 sum += infs;
76 for (int a = 0; a < R_Map; a++) { // calculate density probability for given R
77 prob[a] = prob[a] / sum;
78 }
79 for (int i = 1; i <= MAP->GetNbinsX(); i++) {
80 Double_t val = 0;
81 for (int k = 0; k < R_Map; k++) {
82 val += prob[k] * fFSIMap->GetBinContent(i, k + 1);
83 }
84 MAP->SetBinContent(i, j, val + infs);
85 }
86 }
87
88 CorrFitMapKstarRstar* map = new CorrFitMapKstarRstar(*MAP, Femto::EKinematics::kPRF);
89 map->Recalc();
90 fMaps.push_back(map);
91 delete[] prob;
92 delete MAP;
93 }
94
95 void CorrFitWielanek::SetSourceEmissionFunction(TF1* func) {
96 if (fSource) {
97 Cout::PrintInfo("cannot set more source emission functions", EInfo::kWarning);
98 return;
99 }
100 fSource = func;
101 }
102
103 void CorrFitWielanek::SetSourceEmissionFunstion(Option_t* opt) {
104 if (fSource) {
105 Cout::PrintInfo("cannot set more source emission functions", EInfo::kLowWarning);
106 return;
107 } else {
108 TString option = opt;
109 if (option == "gaus") {
110 fSource = new TF1("gaus", "[1]*x*x*exp(-x*x/[0]/[0]/4)", 2);
111 } else {
112 Cout::PrintInfo(Form("Unkonw option in %s", this->ClassName()), EInfo::kLowWarning);
113 }
114 }
115 }
116
117 void CorrFitWielanek::SetExtrapolationsSteps(Int_t /*step*/) {}
118
119 CorrFitWielanek::~CorrFitWielanek() {
120 if (fFSIMap) delete fFSIMap;
121 if (fSource) delete fSource;
122 }
123} // namespace Hal