Heavy ion Analysis Libriares
Loading...
Searching...
No Matches
FemtoFastCut.cxx
1/*
2 * FemtoFastCut.cxx
3 *
4 * Created on: 25-07-2014
5 * Author: Daniel Wielanek
6 * E-mail: daniel.wielanek@gmail.com
7 * Warsaw University of Technology, Faculty of Physics
8 */
9
10#include "FemtoFastCut.h"
11
12#include "Cout.h"
13#include "FemtoPair.h"
14#include "Std.h"
15#include "Package.h"
16#include "Parameter.h"
17
18#include <TCollection.h>
19#include <TList.h>
20#include <TMath.h>
21#include <TMathBase.h>
22#include <TString.h>
23
24
25namespace Hal {
26 FemtoFastCut::FemtoFastCut() : fBins(0), fMin(NULL), fMax(NULL), fMinTrue(NULL), fMaxTrue(NULL), fPair(NULL) {}
27
29 if (fBins == 0) {
30 Cout::PrintInfo("No default value in FemtoFastCuts, put some default values", EInfo::kLowWarning);
31 fBins = 1;
32 fMin = new Double_t[1];
33 fMax = new Double_t[1];
34 fMin[0] = -1E+9;
35 fMax[0] = 1E+9;
36 }
37 for (int i = 1; i < fBins; i++) {
38 if (fMax[i - 1] > fMin[i]) {
39 Cout::PrintInfo("Overlaping bins in FemtoFastCuts, this lead to loosing pairs", EInfo::kLowWarning);
40 }
41 if (fMin[i - 1] != fMax[i]) {
42 Cout::PrintInfo("Hole in FemtoFastCut, this might lead to loosing pairs", EInfo::kLowWarning);
43 }
44 }
45 }
46
48 if (fBins == 0) {
49 Cout::PrintInfo("Empty femto fast cut, adding large values", EInfo::kLowWarning);
50 AddCutBin(-1E+9, 1E+9);
51 }
52 fMinTrue = new Double_t[fBins];
53 fMaxTrue = new Double_t[fBins];
54 for (int i = 0; i < fBins; i++) {
55 fMinTrue[i] = fMin[i];
56 fMaxTrue[i] = fMax[i];
57 }
58 fPair = pair;
59 if (fPair == NULL) { Cout::PrintInfo(Form("No FemtoPair in %s", this->ClassName()), EInfo::kCriticalError); }
60 }
61
62 void FemtoFastCut::AddCutBin(Double_t min, Double_t max, Option_t* /*opt*/) {
63 Double_t* old_min = fMin;
64 Double_t* old_max = fMax;
65 fMin = new Double_t[fBins + 1];
66 fMax = new Double_t[fBins + 1];
67 for (int i = 0; i < fBins; i++) {
68 fMin[i] = old_min[i];
69 fMax[i] = old_max[i];
70 }
71 fMin[fBins] = min;
72 fMax[fBins] = max;
73 fBins++;
74 if (old_min) {
75 delete[] old_min;
76 delete[] old_max;
77 }
78 }
79
80 FemtoFastCut::FemtoFastCut(const FemtoFastCut& copy) : TObject(copy) {
81 if (copy.fPair) Cout::PrintInfo("FemtoFastCut already initialized", EInfo::kCriticalError);
82 fPair = NULL;
83 fBins = copy.fBins;
84 fMin = new Double_t[fBins];
85 fMax = new Double_t[fBins];
86 if (fMinTrue) {
87 fMinTrue = new Double_t[fBins];
88 fMaxTrue = new Double_t[fBins];
89 }
90 for (int i = 0; i < fBins; i++) {
91 fMin[i] = copy.fMin[i];
92 fMax[i] = copy.fMax[i];
93 }
94 if (copy.fMinTrue) {
95 for (int i = 0; i < fBins; i++) {
96 fMinTrue[i] = copy.fMinTrue[i];
97 fMaxTrue[i] = copy.fMaxTrue[i];
98 }
99 }
100 }
101
102 FemtoFastCut::~FemtoFastCut() {
103 delete[] fMin;
104 delete[] fMax;
105 delete[] fMinTrue;
106 delete[] fMaxTrue;
107 }
109 FemtoFastCutKt::FemtoFastCutKt() : FemtoFastCut() {}
110
112 Double_t px = fPair->GetPx1() + fPair->GetPx2();
113 Double_t py = fPair->GetPy1() + fPair->GetPy2();
114 Double_t val = TMath::Sqrt(px * px + py * py) * 0.5;
115 for (int i = 0; i < fBins; i++) {
116 if (val >= fMinTrue[i] && val < fMaxTrue[i]) { return i; }
117 }
118 return -1;
119 }
120
122 Double_t px = fPair->GetPx1() - fPair->GetPx2();
123 Double_t py = fPair->GetPy1() - fPair->GetPy2();
124 Double_t val = TMath::Sqrt(px * px + py * py) * 0.5;
125 for (int i = 0; i < fBins; i++) {
126 if (val >= fMinTrue[i] && val < fMaxTrue[i]) { return i; }
127 }
128 return -1;
129 }
130
132
133 FemtoFastCutKt::~FemtoFastCutKt() {}
134
135 FemtoFastCutPtSum::FemtoFastCutPtSum() : FemtoFastCut() {}
136
138 Double_t pt1 = TMath::Power(fPair->GetPx1(), 2) + TMath::Power(fPair->GetPy1(), 2);
139 Double_t pt2 = TMath::Power(fPair->GetPx2(), 2) + TMath::Power(fPair->GetPy2(), 2);
140 Double_t val = TMath::Sqrt(pt1) + TMath::Sqrt(pt2);
141 for (int i = 0; i < fBins; i++) {
142 if (val >= fMinTrue[i] && val < fMaxTrue[i]) { return i; }
143 }
144 return -1;
145 }
146
148 Double_t pt1 = TMath::Power(fPair->GetPx1(), 2) + TMath::Power(fPair->GetPy1(), 2);
149 Double_t pt2 = TMath::Power(fPair->GetPx2(), 2) + TMath::Power(fPair->GetPy2(), 2);
150 Double_t val = TMath::Sqrt(pt1) + TMath::Sqrt(pt2);
151 for (int i = 0; i < fBins; i++) {
152 if (val >= fMinTrue[i] && val < fMaxTrue[i]) { return i; }
153 }
154 return -1;
155 }
156
158
159 FemtoFastCutPtSum::~FemtoFastCutPtSum() {}
160
162 Package* pack = new Package(this);
163 TList* list = new TList();
164 TList* listF = new TList();
165 list->SetName("NumericValues");
166 listF->SetName("FormatedNames");
167 list->Add(new ParameterString("Mode", this->ClassName()));
168 list->Add(new ParameterInt("Bins", fBins));
169 for (int i = 0; i < fBins; i++) {
170 list->Add(new ParameterFloat("Min", fMin[i]));
171 list->Add(new ParameterFloat("Max", fMax[i]));
172 listF->Add(new ParameterString(Form("%s_%i", this->ClassName(), i), Form("%.2f %.2f", fMin[i], fMax[i])));
173 }
174 pack->AddObject(list);
175 pack->AddObject(listF);
176 return pack;
177 }
178
179 FemtoFastCutPhi::FemtoFastCutPhi() {
180 fEventPhi = 0;
181 fGlobalMin = 0;
182 fPhiCorrection = 0;
183 }
184
186 Double_t px_sum = fPair->GetPx1() + fPair->GetPx2();
187 Double_t py_sum = fPair->GetPy1() + fPair->GetPy2();
188 Double_t val = RoundPhi(TMath::ATan2(py_sum, px_sum) - fPhiCorrection);
189 for (int i = 0; i < fBins; i++) {
190 if (val >= fMinTrue[i] && val < fMaxTrue[i]) { return i; }
191 }
192 return -1;
193 }
194
196 Double_t px_sum = fPair->GetPx1() - fPair->GetPx2();
197 Double_t py_sum = fPair->GetPy1() - fPair->GetPy2();
198 Double_t val = TMath::ATan2(py_sum, px_sum) - fPhiCorrection;
199 val = RoundPhi(val - TMath::Pi());
200 for (int i = 0; i < fBins; i++) {
201 if (val >= fMinTrue[i] && val < fMaxTrue[i]) { return i; }
202 }
203 return -1;
204 }
205
207
209 FemtoFastCut::Init(pair);
210 for (int i = 0; i < fBins; i++) {
211 fMin[i] = RoundPhi(fMin[i]);
212 fMax[i] = RoundPhi(fMax[i]);
213 }
214 fGlobalMin = TMath::Pi();
215 for (int i = 0; i < fBins; i++) {
216 if (fMin[i] < fGlobalMin) { fGlobalMin = fMin[i]; }
217 }
218 for (int i = 0; i < fBins; i++) {
219 fMinTrue[i] -= fGlobalMin;
220 fMaxTrue[i] -= fGlobalMin;
221 fMinTrue[i] = RoundPhi(fMinTrue[i]);
222 fMaxTrue[i] = RoundPhi(fMaxTrue[i]);
223 TryRoundRange(i);
224 }
225 for (int i = 0; i < fBins; i++) {
226 fMin[i] = fMin[i] * TMath::RadToDeg(); // round to degrees to be
227 // human-readable in HTML-report
228 fMax[i] = fMax[i] * TMath::RadToDeg();
229 }
230 }
231
232 Double_t FemtoFastCutPhi::RoundPhi(Double_t val) const {
233 while (val < -TMath::Pi()) {
234 val += TMath::Pi() * 2.0;
235 }
236 while (val >= TMath::Pi()) {
237 val -= TMath::Pi() * 2.0;
238 }
239 return val;
240 }
241
242 void FemtoFastCutPhi::SetEventPhi(const Double_t phi) {
243 fEventPhi = phi;
244 fPhiCorrection = fEventPhi + fGlobalMin;
245 fPhiCorrection = RoundPhi(fPhiCorrection);
246 }
247
249
250 void FemtoFastCutPhi::TryRoundRange(Int_t i) {
251 if (fMinTrue[i] > fMaxTrue[i]) {
252 Double_t MinMod = TMath::Abs(fMinTrue[i]);
253 Double_t MaxMod = TMath::Abs(fMaxTrue[i]);
254 Double_t dMax = TMath::Abs(TMath::Pi() - MaxMod);
255 Double_t dMin = TMath::Abs(MinMod - TMath::Pi());
256 if (dMax < dMin) {
257 fMaxTrue[i] = -fMaxTrue[i];
258 } else if (dMin < dMax) {
259 fMinTrue[i] = -fMinTrue[i];
260 } else {
261 Cout::PrintInfo(Form("Something is wrong with %s cut", this->ClassName()), EInfo::kWarning);
262 }
263 }
264 }
265
266 FemtoFastCutPhi::~FemtoFastCutPhi() {}
267
268 FemtoFastCutEta::FemtoFastCutEta() {
269 // TODO Auto-generated constructor stub
270 }
271
273 Double_t px = fPair->GetPx1() + fPair->GetPx2();
274 Double_t py = fPair->GetPy1() + fPair->GetPy2();
275 Double_t pz = fPair->GetPz1() + fPair->GetPz2();
276 Double_t p = TMath::Sqrt(px * px + py * py + pz * pz);
277 Double_t eta = 0.5 * TMath::Log((p + pz) / (p - pz));
278 for (int i = 0; i < fBins; i++) {
279 if (eta >= fMinTrue[i] && eta < fMaxTrue[i]) { return i; }
280 }
281 return -1;
282 }
283
285 Double_t px = fPair->GetPx1() - fPair->GetPx2();
286 Double_t py = fPair->GetPy1() - fPair->GetPy2();
287 Double_t pz = fPair->GetPz1() + fPair->GetPz2();
288 Double_t p = TMath::Sqrt(px * px + py * py + pz * pz);
289 Double_t eta = 0.5 * TMath::Log((p + pz) / (p - pz));
290 for (int i = 0; i < fBins; i++) {
291 if (eta >= fMinTrue[i] && eta < fMaxTrue[i]) { return i; }
292 }
293 return -1;
294 }
295
297 Double_t px = fPair->GetPx1() - fPair->GetPx2();
298 Double_t py = fPair->GetPy1() - fPair->GetPy2();
299 Double_t pz = fPair->GetPz1() - fPair->GetPz2();
300 Double_t p = TMath::Sqrt(px * px + py * py + pz * pz);
301 Double_t eta = 0.5 * TMath::Log((p + pz) / (p - pz));
302 for (int i = 0; i < fBins; i++) {
303 if (eta >= fMinTrue[i] && eta < fMaxTrue[i]) { return i; }
304 }
305 return -1;
306 }
307
308 FemtoFastCutEta::~FemtoFastCutEta() {}
309
310 FemtoFastCutVirtual::FemtoFastCutVirtual(const FemtoFastCutVirtual& /*fast*/) : FemtoFastCut() {}
311
312 FemtoFastCutKt::FemtoFastCutKt(const FemtoFastCutKt& fast) : FemtoFastCut(fast) {}
313
314 FemtoFastCutPtSum::FemtoFastCutPtSum(const FemtoFastCutPtSum& fast) : FemtoFastCut(fast) {}
315
316 FemtoFastCutPhi::FemtoFastCutPhi(const FemtoFastCutPhi& fast) :
317 FemtoFastCut(fast), fEventPhi(0), fGlobalMin(0), fPhiCorrection(0) {}
318
319 FemtoFastCutEta::FemtoFastCutEta(const FemtoFastCutEta& fast) : FemtoFastCut(fast) {}
320} // namespace Hal
static void PrintInfo(TString text, Hal::EInfo status)
Definition Cout.cxx:370
Int_t GetBinHemisphere() const
Int_t GetBinRotated() const
Int_t GetBinRotated() const
Int_t GetBinHemisphere() const
void SetEventPhi(const Double_t phi)
Int_t GetBinRotated() const
Int_t GetBinHemisphere() const
virtual Package * Report() const
void Init(FemtoPair *pair)
Int_t GetBinHemisphere() const
Int_t GetBinRotated() const
FemtoPair * fPair
Double_t * fMaxTrue
virtual void Init(FemtoPair *pair)
virtual void AddCutBin(Double_t min, Double_t max, Option_t *opt=" ")
virtual Package * Report() const
Double_t * fMinTrue
Double_t GetPy1() const
Definition FemtoPair.h:237
Double_t GetPy2() const
Definition FemtoPair.h:262
Double_t GetPz1() const
Definition FemtoPair.h:242
Double_t GetPx2() const
Definition FemtoPair.h:257
Double_t GetPx1() const
Definition FemtoPair.h:232
Double_t GetPz2() const
Definition FemtoPair.h:267
void AddObject(TObject *object)
Definition Package.cxx:209