9#include "FemtoSourceModelNumerical1D.h"
16 FemtoSourceModelNumerical1D::FemtoSourceModelNumerical1D() : fRawDistribution(nullptr), ff(0) {
17 fDensity =
new FemtoSourceDensityNumerical1D();
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);
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);
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));
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);
47 ((FemtoSourceDensityNumerical1D*) fDensity)->SetRadiusDistribution(*fRawDistribution);
52 void FemtoSourceModelNumerical1D::GenerateCoordinates(
FemtoPair* ) {
53 Double_t randVal = gRandom->Rndm();
55 while (randVal > fRandomDistributionY[i])
57 Double_t R = fRandomDistributionX[i] + ff * (gRandom->Rndm() - 0.5);
58 gRandom->Sphere(fRout, fRside, fRlong, R);
61 Package* FemtoSourceModelNumerical1D::Report()
const {
62 Package* pack = FemtoSourceModel1D::Report();
63 pack->
AddObject(fRawDistribution->Clone());
67 FemtoSourceModelNumerical1D::~FemtoSourceModelNumerical1D() {
68 if (fRawDistribution) {
delete fRawDistribution; }
71 void FemtoSourceDensityNumerical1D::SetRadiusDistribution(
const TH1D& distribution) {
72 if (fRawDistribution)
delete fRawDistribution;
73 fRawDistribution = (TH1D*) distribution.Clone();
74 fRawDistribution->SetDirectory(
nullptr);
77 Double_t FemtoSourceDensityNumerical1D::GetProbDensity1d(
const Double_t r,
const Double_t* )
const {
78 Int_t bin = fRawDistribution->GetXaxis()->FindBin(r);
79 return fRawDistribution->GetBinContent(bin);
82 Double_t FemtoSourceDensityNumerical1D::GetProbDensity3d(
const TVector3& r,
const Double_t* params)
const {
83 return GetProbDensity1d(r.Mag(), params);
void AddObject(TObject *object)