Heavy ion Analysis Libriares
Loading...
Searching...
No Matches
FemtoSourceModelNumerical1D.cxx
1/*
2 * FemtoSourceModelNumerical1D.cxx
3 *
4 * Created on: 23 sie 2021
5 * Author: Daniel Wielanek
6 * E-mail: daniel.wielanek@gmail.com
7 * Warsaw University of Technology, Faculty of Physics
8 */
9#include "FemtoSourceModelNumerical1D.h"
10
11#include "Package.h"
12
13#include <TH1D.h>
14#include <iostream>
15namespace Hal {
16 FemtoSourceModelNumerical1D::FemtoSourceModelNumerical1D() : fRawDistribution(nullptr), ff(0) {
17 fDensity = new FemtoSourceDensityNumerical1D();
18 }
19
20 FemtoSourceModelNumerical1D::FemtoSourceModelNumerical1D(const FemtoSourceModelNumerical1D& other) :
21 FemtoSourceModel1D(other), fRawDistribution(nullptr), ff(other.ff) {
22 if (other.fRawDistribution) fRawDistribution = (TH1D*) other.fRawDistribution->Clone();
23 fRandomDistributionX = other.fRandomDistributionX;
24 fRandomDistributionY = other.fRandomDistributionY;
25 if (fRawDistribution) fRawDistribution->SetDirectory(nullptr);
26 }
27
28 void FemtoSourceModelNumerical1D::SetRadiusDistribution(const TH1D& distribution) {
29 if (fRawDistribution) delete fRawDistribution;
30 fRandomDistributionX.clear();
31 fRandomDistributionY.clear();
32 fRawDistribution = (TH1D*) distribution.Clone();
33 fRawDistribution->SetDirectory(nullptr);
34 Double_t scale = 0;
35 fRawDistribution->SetBinContent(0, 0);
36 ff = fRawDistribution->GetXaxis()->GetBinWidth(1);
37 for (int i = 1; i <= fRawDistribution->GetNbinsX(); i++) {
38 scale += fRawDistribution->GetBinContent(i);
39 fRandomDistributionX.push_back(fRawDistribution->GetXaxis()->GetBinCenter(i));
40 }
41 fRawDistribution->Scale(1.0 / (scale * ff));
42 for (int i = 1; i <= fRawDistribution->GetNbinsX(); i++) {
43 Double_t val = fRawDistribution->GetBinContent(i) * ff;
44 if (i > 1) val += fRandomDistributionY[i - 2];
45 fRandomDistributionY.push_back(val);
46 }
47 ((FemtoSourceDensityNumerical1D*) fDensity)->SetRadiusDistribution(*fRawDistribution);
48 }
49
50 FemtoSourceModel* FemtoSourceModelNumerical1D::MakeCopy() const { return new FemtoSourceModelNumerical1D(*this); }
51
52 void FemtoSourceModelNumerical1D::GenerateCoordinates(FemtoPair* /*Pair*/) {
53 Double_t randVal = gRandom->Rndm();
54 Int_t i = 0;
55 while (randVal > fRandomDistributionY[i])
56 i++;
57 Double_t R = fRandomDistributionX[i] + ff * (gRandom->Rndm() - 0.5);
58 gRandom->Sphere(fRout, fRside, fRlong, R);
59 }
60
61 Package* FemtoSourceModelNumerical1D::Report() const {
62 Package* pack = FemtoSourceModel1D::Report();
63 pack->AddObject(fRawDistribution->Clone());
64 return pack;
65 }
66
67 FemtoSourceModelNumerical1D::~FemtoSourceModelNumerical1D() {
68 if (fRawDistribution) { delete fRawDistribution; }
69 }
70
71 void FemtoSourceDensityNumerical1D::SetRadiusDistribution(const TH1D& distribution) {
72 if (fRawDistribution) delete fRawDistribution;
73 fRawDistribution = (TH1D*) distribution.Clone();
74 fRawDistribution->SetDirectory(nullptr);
75 }
76
77 Double_t FemtoSourceDensityNumerical1D::GetProbDensity1d(const Double_t r, const Double_t* /*params*/) const {
78 Int_t bin = fRawDistribution->GetXaxis()->FindBin(r);
79 return fRawDistribution->GetBinContent(bin);
80 }
81
82 Double_t FemtoSourceDensityNumerical1D::GetProbDensity3d(const TVector3& r, const Double_t* params) const {
83 return GetProbDensity1d(r.Mag(), params);
84 }
85
86} // namespace Hal
void AddObject(TObject *object)
Definition Package.cxx:209