Heavy ion Analysis Libriares
Loading...
Searching...
No Matches
FemtoImaging3D.cxx
1/*
2 * FemtoImaging3D.cxx
3 *
4 * Created on: 21 lut 2016
5 * Author: Daniel Wielanek
6 * E-mail: daniel.wielanek@gmail.com
7 * Warsaw University of Technology, Faculty of Physics
8 */
9
10#include "FemtoImaging3D.h"
11
12#include <TAxis.h>
13#include <TH1.h>
14#include <TH3.h>
15#include <TMath.h>
16#include <TString.h>
17
18#include "Cout.h"
19#include "FemtoConst.h"
20#include "Std.h"
21
22namespace Hal {
23 FemtoImaging3D::FemtoImaging3D() :
24 fQMax {1.0, 1.0, 1.0},
25 fQMin {0, 0, 0},
26 fRMax {20, 20, 20},
27 fRMin {0, 0, 0},
28 fBins {20, 20, 20},
29 fKinematics(Femto::EKinematics::kLCMS),
30 fCF(NULL),
31 fR(NULL),
32 fSource(NULL) {
33 // TODO improve this method
34 }
35
36 void FemtoImaging3D::Init() {
37 TH3* CF = (TH3*) fCF->GetHist(kTRUE);
38 Double_t min_x = CF->GetXaxis()->GetBinLowEdge(1);
39 Double_t max_x = CF->GetXaxis()->GetBinUpEdge(CF->GetNbinsX());
40 Double_t bins_x = CF->GetNbinsX();
41 Double_t min_y = CF->GetYaxis()->GetBinLowEdge(1);
42 Double_t max_y = CF->GetYaxis()->GetBinUpEdge(CF->GetNbinsY());
43 Double_t bins_y = CF->GetNbinsY();
44 Double_t min_z = CF->GetZaxis()->GetBinLowEdge(1);
45 Double_t max_z = CF->GetZaxis()->GetBinUpEdge(CF->GetNbinsZ());
46 Double_t bins_z = CF->GetNbinsZ();
47 fR = new TH3D("R", "R", bins_x, min_x, max_x, bins_y, min_y, max_y, bins_z, min_z, max_z);
48 for (int i = 1; i <= bins_x; i++) {
49 for (int j = 1; j <= bins_y; j++) {
50 for (int k = 1; k <= bins_z; k++) {
51 fR->SetBinContent(i, j, k, CF->GetBinContent(i, j, k) - 1.0);
52 if (CF->GetBinContent(i, j, k) != 0) {
53 fR->SetBinError(i, j, k, CF->GetBinError(i, j, k) * fR->GetBinContent(i, j, k) / CF->GetBinContent(i, j, k));
54 }
55 }
56 }
57 }
58 delete CF;
59 fSource =
60 new TH3D("Source", "Source", fBins[0], fRMin[0], fRMax[0], fBins[1], fRMin[1], fRMax[1], fBins[2], fRMin[2], fRMax[2]);
61 if (fCF->GetFrame() == Femto::EKinematics::kPRF) {
62 fSource->GetXaxis()->SetTitle("r*_{out}");
63 fSource->GetYaxis()->SetTitle("r*_{side}");
64 fSource->GetZaxis()->SetTitle("r*_{long}");
65 fKinematics = Femto::EKinematics::kPRF;
66 } else if (fCF->GetFrame() == Femto::EKinematics::kLCMS) {
67 Cout::PrintInfo("Imaging doesn't work for LCMS ", EInfo::kWarning);
68 return;
69 fSource->GetXaxis()->SetTitle("r_{out}");
70 fSource->GetYaxis()->SetTitle("r_{side}");
71 fSource->GetZaxis()->SetTitle("r_{long}");
72 fKinematics = Femto::EKinematics::kLCMS;
73 }
74 }
75
76 void FemtoImaging3D::InverseTransofrm(Option_t* opt) {
77 TString option = opt;
78 Bool_t fast = kFALSE;
79 if (option.EqualTo("fast")) fast = kTRUE;
80 Int_t zeroX = fSource->GetXaxis()->FindBin(0.0);
81 Int_t zeroY = fSource->GetYaxis()->FindBin(0.0);
82 Int_t zeroZ = fSource->GetZaxis()->FindBin(0.0);
83 Int_t isZeroX, isZeroY, isZeroZ;
84
85 for (int i = 1; i <= fSource->GetNbinsX(); i++) {
86 Double_t rx = fSource->GetXaxis()->GetBinCenter(i) * Femto::FmToGeV();
87 if (i == zeroX) {
88 isZeroX = 1;
89 } else {
90 isZeroX = 0;
91 }
92 for (int j = 1; j <= fSource->GetNbinsY(); j++) {
93 Double_t ry = fSource->GetYaxis()->GetBinCenter(j) * Femto::FmToGeV();
94 if (j == zeroY) {
95 isZeroY = 1;
96 } else {
97 isZeroY = 0;
98 }
99 for (int k = 1; k <= fSource->GetNbinsZ(); k++) {
100 if (fast) {
101 if (k == zeroZ) {
102 isZeroZ = 1;
103 } else {
104 isZeroZ = 0;
105 }
106 if ((isZeroX + isZeroY + isZeroZ) < 2) { continue; }
107 }
108
109 Double_t rz = fSource->GetZaxis()->GetBinCenter(k) * Femto::FmToGeV();
110 // compute SR for signle cell
111 Double_t sum = 0.0;
112 Double_t errors = 0.0;
113 // integral over momentum
114 for (int a = fR->GetXaxis()->FindBin(fQMin[0]); a <= fR->GetXaxis()->FindBin(fQMax[0]); a++) {
115 Double_t qx = fR->GetXaxis()->GetBinCenter(a);
116 Double_t QX = qx * rx;
117 for (int b = fR->GetYaxis()->FindBin(fQMin[1]); b <= fR->GetYaxis()->FindBin(fQMax[1]); b++) {
118 Double_t qy = fR->GetYaxis()->GetBinCenter(b);
119 Double_t QY = qy * ry;
120 for (int c = fR->GetZaxis()->FindBin(fQMin[2]); c <= fR->GetZaxis()->FindBin(fQMax[2]); c++) {
121 Double_t qz = fR->GetZaxis()->GetBinCenter(c);
122 Double_t QZ = qz * rz;
123 Double_t R = fR->GetBinContent(a, b, c);
124 if (R == 0) continue;
125 Double_t dR = fR->GetBinError(a, b, c);
126 Double_t integral = TMath::Cos(2.0 * (QX + QY + QZ));
127 sum += R * integral;
128 errors = dR * integral;
129 }
130 }
131 }
132 //------------- end of integral ------------
133 Double_t ex = rx * fR->GetXaxis()->GetBinWidth(1);
134 Double_t ey = ry * fR->GetYaxis()->GetBinWidth(1);
135 Double_t ez = rz * fR->GetZaxis()->GetBinWidth(1);
136 if (sum < 0) { sum = 0; }
137 Double_t dFourierX = (0.05 + ex * 0.22 + ex * ex + 0.084) * sum;
138 Double_t dFourierY = (0.05 + ey * 0.22 + ey * ey + 0.084) * sum;
139 Double_t dFourierZ = (0.05 + ez * 0.22 + ez * ez + 0.084) * sum;
140 // std::cout<<sum<<std::endl;
141 errors = TMath::Sqrt(errors * errors + dFourierX * dFourierX + dFourierY * dFourierY + dFourierZ * dFourierZ);
142 fSource->SetBinContent(i, j, k, sum);
143 fSource->SetBinError(i, j, k, errors);
144 }
145 }
146 Cout::ProgressBar(i, fSource->GetNbinsX());
147 }
148 delete fR;
149 }
150
151 TH3D* FemtoImaging3D::Inverse(Femto3DCF* cf, Option_t* opt) {
152 fCF = cf;
153 Init();
154 InverseTransofrm(opt);
155 Double_t norm = fSource->Integral(1, fSource->GetNbinsX(), 1, fSource->GetNbinsY(), 1, fSource->GetNbinsZ(), "width");
156 fSource->Scale(1.0 / norm);
157 TH3D* histo = (TH3D*) fSource->Clone();
158 return histo;
159 }
160
161 void FemtoImaging3D::SetRAxis(Int_t bins, Double_t min, Double_t max, Option_t* opt) {
162 Int_t option = 0;
163 if (opt[0] == 'x') {
164 option = 0;
165 } else if (opt[0] == 'y') {
166 option = 1;
167 } else if (opt[0] == 'z') {
168 option = 2;
169 } else {
170 return;
171 }
172 fBins[option] = bins;
173 fRMin[option] = min;
174 fRMax[option] = max;
175 }
176
177 void FemtoImaging3D::SetQMax(Double_t qmax, Option_t* opt) {
178 Int_t option = 0;
179 if (opt[0] == 'x') {
180 option = 0;
181 } else if (opt[0] == 'y') {
182 option = 1;
183 } else if (opt[0] == 'z') {
184 option = 2;
185 } else {
186 return;
187 }
188 fQMax[option] = qmax;
189 }
190
191 void FemtoImaging3D::SetQMin(Double_t qmin, Option_t* opt) {
192 Int_t option = 0;
193 if (opt[0] == 'x') {
194 option = 0;
195 } else if (opt[0] == 'y') {
196 option = 1;
197 } else if (opt[0] == 'z') {
198 option = 2;
199 } else {
200 return;
201 }
202 fQMin[option] = qmin;
203 }
204
205 FemtoImaging3D::~FemtoImaging3D() {
206 // TODO Auto-generated destructor stub
207 }
208} // namespace Hal