9#include "FemtoImaging1D.h"
15#include <gsl/gsl_sf_bessel.h>
19 FemtoImaging1D::FemtoImaging1D() :
25 fKinematics(Femto::EKinematics::kLCMS),
30 void FemtoImaging1D::Init() {
31 TH1* CF = fCF->GetHist(kTRUE);
32 Double_t min = CF->GetXaxis()->GetBinLowEdge(1);
33 Double_t max = CF->GetXaxis()->GetBinUpEdge(CF->GetNbinsX());
34 Double_t bins = CF->GetNbinsX();
35 fR =
new TH1D(
"R",
"R", bins, min, max);
36 for (
int i = 1; i <= bins; i++) {
37 fR->SetBinContent(i, (CF->GetBinContent(i) - 1.0));
38 if (CF->GetBinContent(i) != 0) fR->SetBinError(i, CF->GetBinError(i) * fR->GetBinContent(i) / CF->GetBinContent(i));
42 fSource =
new TH1D(
"Source",
"Source", fBins, fRMin, fRMax);
43 if (fCF->GetFrame() == Femto::EKinematics::kPRF) {
44 fSource->GetYaxis()->SetTitle(
"S(r*)");
45 fSource->GetXaxis()->SetTitle(
"r*");
46 fKinematics = Femto::EKinematics::kPRF;
47 }
else if (fCF->GetFrame() == Femto::EKinematics::kLCMS) {
48 fSource->GetYaxis()->SetTitle(
"S(r)");
49 fSource->GetXaxis()->SetTitle(
"r");
50 fKinematics = Femto::EKinematics::kLCMS;
58 Double_t norm = fSource->Integral(1, fSource->GetNbinsX(),
"width");
60 fSource->Scale(1.0 / norm);
61 TH1D* histo = (TH1D*) fSource->Clone();
68 void FemtoImaging1D::SetRAxis(Int_t bins, Double_t min, Double_t max) {
74 TH1D* FemtoImaging1D::Inverse(TH1D* CF, Bool_t normalize) {
75 Double_t min = CF->GetXaxis()->GetBinLowEdge(1);
76 Double_t max = CF->GetXaxis()->GetBinUpEdge(CF->GetNbinsX());
77 Double_t bins = CF->GetNbinsX();
79 fR =
new TH1D(
"R",
"R", bins, min, max);
80 for (
int i = 1; i <= bins; i++) {
81 fR->SetBinContent(i, (CF->GetBinContent(i) - 1.0));
82 if (CF->GetBinContent(i) != 0) fR->SetBinError(i, CF->GetBinError(i) * fR->GetBinContent(i) / CF->GetBinContent(i));
85 fSource =
new TH1D(
"Source",
"Source", fBins, fRMin, fRMax);
87 Double_t norm = fSource->Integral(1, fSource->GetNbinsX(),
"width");
89 if (normalize) fSource->Scale(1.0 / norm);
90 TH1D* histo = (TH1D*) fSource->Clone();
98 TH1D* FemtoImaging1D::MagicInverse(TH1D* CF, Double_t l, Bool_t ) {
99 Double_t min = CF->GetXaxis()->GetBinLowEdge(1);
100 Double_t max = CF->GetXaxis()->GetBinUpEdge(CF->GetNbinsX());
101 Double_t bins = CF->GetNbinsX();
103 fR =
new TH1D(
"R",
"R", bins, min, max);
104 for (
int i = 1; i <= bins; i++) {
105 fR->SetBinContent(i, (CF->GetBinContent(i)));
106 if (CF->GetBinContent(i) != 0) fR->SetBinError(i, CF->GetBinError(i) * fR->GetBinContent(i) / CF->GetBinContent(i));
109 fSource =
new TH1D(
"Source",
"Source", fBins, fRMin, fRMax);
110 MagicInverseTransform(l);
111 TH1D* histo = (TH1D*) fSource->Clone();
119 void FemtoImaging1D::MagicInverseTransform(Int_t l) {
120 Double_t power = TMath::Power(-1, l / 2) * TMath::Power(TMath::Pi(), 3);
121 for (
double i = 1; i <= fSource->GetNbinsX(); i++) {
122 if (l % 2 == 1)
continue;
123 Double_t r = fSource->GetBinCenter(i) * Femto::FmToGeV();
125 Double_t errors = 0.0;
126 for (
int j = fR->GetXaxis()->FindBin(fQMin); j < fR->GetXaxis()->FindBin(fQMax); j++) {
127 Double_t q = fR->GetBinCenter(j);
128 if (fKinematics == Femto::EKinematics::kPRF) q += q;
129 Double_t R = fR->GetBinContent(j);
131 Double_t dR = fR->GetBinError(j);
132 Double_t integral = q * q * BesselJn(l, 2 * q * r) / Femto::FmToGeV() / Femto::FmToGeV();
134 errors += dR * integral;
145 if (sum < 0) { sum = 0; }
149 fSource->SetBinContent(i, sum * power);
150 fSource->SetBinError(i, errors);
157 Double_t FemtoImaging1D::BesselJ0(
double x)
const {
159 return gsl_sf_bessel_j0(x);
161 std::cout <<
"GSL NOT SUPPORTED" << std::endl;
166 Double_t FemtoImaging1D::BesselJn(
int n,
double x)
const {
173 std::cout <<
"GSL NOT SUPPORTED" << std::endl;
178 double FemtoImaging1D::BesselJ1(
double x)
const {
180 return gsl_sf_bessel_j1(x);
182 std::cout <<
"GSL NOT SUPPORTED" << std::endl;
187 FemtoImaging1D::~FemtoImaging1D() {}
189 void FemtoImaging1D::InverseTransofrm() {
190 for (
double i = 1; i <= fSource->GetNbinsX(); i++) {
191 Double_t r = fSource->GetBinCenter(i) * Femto::FmToGeV();
193 Double_t errors = 0.0;
194 for (
int j = fR->GetXaxis()->FindBin(fQMin); j < fR->GetXaxis()->FindBin(fQMax); j++) {
195 Double_t q = fR->GetBinCenter(j);
196 if (fKinematics == Femto::EKinematics::kPRF) q += q;
197 Double_t R = fR->GetBinContent(j);
198 if (R == 0)
continue;
199 Double_t dR = fR->GetBinError(j);
200 Double_t integral = q * TMath::Sin(q * r * 2);
202 errors += dR * integral;
211 Double_t ep = r * fR->GetBinWidth(1);
213 if (sum < 0) { sum = 0; }
214 Double_t dFourierError = (0.05 + ep * 0.22 + ep * ep * 0.084) * sum;
215 errors = TMath::Sqrt(errors * errors + dFourierError * dFourierError);
217 fSource->SetBinContent(i, sum / r);
218 fSource->SetBinError(i, errors / r);