Heavy ion Analysis Libriares
Loading...
Searching...
No Matches
FemtoSourceModelNumericalPseudo3d.cxx
1/*
2 * FemtoSourceModelPseudo3d.cxx
3 *
4 * Created on: 3 sty 2024
5 * Author: Daniel Wielanek
6 * E-mail: daniel.wielanek@gmail.com
7 * Warsaw University of Technology, Faculty of Physics
8 */
9#include "FemtoSourceModelNumericalPseudo3d.h"
10#include "Cout.h"
11
12#include <TH1D.h>
13#include <iostream>
14
15namespace Hal {
16 FemtoSourceModelNumericalPseudo3d::FemtoSourceModelNumericalPseudo3d() { fDensity = new FemtoSourceDensityNumericalPseudo3d(); }
17
18 FemtoSourceModelNumericalPseudo3d::FemtoSourceModelNumericalPseudo3d(const FemtoSourceModelNumericalPseudo3d& other) :
19 FemtoSourceModel3D(other) {
20 if (other.fRawDistribution) this->fRawDistribution = (TH1D*) other.fRawDistribution->Clone();
21 }
22
23 void FemtoSourceModelNumericalPseudo3d::SetRadiusDistribution(const TH1D& distribution) {
24 if (fRawDistribution) delete fRawDistribution;
25 fRawDistribution = (TH1D*) distribution.Clone();
26 fRawDistribution->SetDirectory(nullptr);
27 Double_t scale = 0;
28 fRawDistribution->SetBinContent(0, 0);
29 ((FemtoSourceDensityNumericalPseudo3d*) fDensity)->SetRadiusDistribution(*fRawDistribution);
30 }
31
32 void FemtoSourceModelNumericalPseudo3d::GenerateCoordinates(FemtoPair* Pair) {
33 fRout = fRawDistribution->GetRandom();
34 fRside = fRawDistribution->GetRandom();
35 fRlong = fRawDistribution->GetRandom();
36 int swap = gRandom->Integer(8);
37 switch (swap) {
38 case 0: {
39 // do nothing
40 } break;
41 case 1: {
42 fRout = -fRout;
43 } break;
44 case 2: {
45 fRside = -fRside;
46 } break;
47 case 3: {
48 fRout = -fRout;
49 fRside = -fRside;
50 } break;
51 case 4: {
52 fRlong = -fRlong;
53 } break;
54 case 5: {
55 fRout = -fRout;
56 fRlong = -fRlong;
57 } break;
58 case 6: {
59 fRside = -fRside;
60 fRlong = -fRlong;
61 } break;
62 case 7: {
63 fRout = -fRout;
64 fRside = -fRside;
65 fRlong = -fRlong;
66 } break;
67 }
68 }
69
70 FemtoSourceModelNumericalPseudo3d::~FemtoSourceModelNumericalPseudo3d() {
71 if (fRawDistribution) delete fRawDistribution;
72 }
73
74 Double_t FemtoSourceDensityNumericalPseudo3d::GetProbDensity3d(const TVector3& r, const Double_t* params) const {
75 auto findDens = [&](Double_t v) { return int((TMath::Abs(v) - fMin) * fDx + 1); };
76 double rho = fRawDistribution->GetBinContent(findDens(r.X()));
77 rho *= fRawDistribution->GetBinContent(findDens(r.Y()));
78 rho *= fRawDistribution->GetBinContent(findDens(r.Z()));
79 return rho;
80 }
81
82 void FemtoSourceDensityNumericalPseudo3d::SetRadiusDistribution(const TH1D& distribution) {
83 if (fRawDistribution) delete fRawDistribution;
84
85 fRawDistribution = (TH1D*) distribution.Clone();
86 fRawDistribution->SetDirectory(nullptr);
87 fRawDistribution->SetBinContent(0, 0);
88 fDx = 1.0 / fRawDistribution->GetBinWidth(1);
89 fMin = fRawDistribution->GetBinLowEdge(1);
90 double integral = fRawDistribution->Integral("width");
91 fRawDistribution->Scale(1.0 / integral);
92 }
93
94 FemtoSourceDensityNumericalPseudo3d::FemtoSourceDensityNumericalPseudo3d(const FemtoSourceDensityNumericalPseudo3d& other) :
95 FemtoSourceDensity(other) {
96 if (other.fRawDistribution) fRawDistribution = (TH1D*) other.fRawDistribution;
97 fMin = other.fMin;
98 fDx = other.fDx;
99 }
100
101 FemtoSourceDensityNumericalPseudo3d::~FemtoSourceDensityNumericalPseudo3d() {
102 if (fRawDistribution) delete fRawDistribution;
103 }
104} // namespace Hal
FemtoSourceDensity * fDensity