14#include "FemtoSerializationInterface3D.h"
21#include <TCollection.h>
33#include "CorrFit3DCF.h"
34#include "Femto3DCFPainter.h"
40 AddLabel(Femto::KinematicsToLabel(fFrame));
63 Femto3DCF::~Femto3DCF() {}
66 TString path = Form(
"%s/divided_%i", dir.Data(), counter);
67 gSystem->MakeDirectory(path);
68 Bool_t batch = gROOT->IsBatch();
69 gROOT->SetBatch(kTRUE);
71 Int_t middle_x =
fNum->GetXaxis()->FindBin(0.0);
72 Int_t middle_y =
fNum->GetYaxis()->FindBin(0.0);
73 Int_t middle_z =
fNum->GetZaxis()->FindBin(0.0);
74 TString names[] = {
"out",
"side",
"long"};
75 TString dirs[] = {
"x",
"y",
"z"};
76 TString titles[] = {
"cf",
"num",
"den"};
77 Color_t colz[] = {kRed, kGreen, kBlue};
78 Int_t mxx[] = {middle_y, middle_x, middle_x};
79 Int_t myy[] = {middle_z, middle_z, middle_y};
80 TCanvas* c1 =
new TCanvas(
"canvas",
"canvas", 0, 0, 1000, 1500);
82 TH1D** histos =
new TH1D*[9];
83 for (
int padId = 0; padId < 9; padId++) {
85 int optId = padId % 3;
86 int flagDir = (padId - optId) / 3;
87 TString opt = titles[optId] +
"+" + dirs[flagDir] +
"+scale+bins";
88 histos[padId] =
GetProjection1D(mxx[flagDir], mxx[flagDir], myy[flagDir], myy[flagDir], opt);
89 histos[padId]->SetLineColor(colz[flagDir]);
90 histos[padId]->SetTitle(Form(
"%s %s", names[flagDir].Data(), titles[optId].Data()));
91 histos[padId]->SetMinimum(0);
92 histos[padId]->Draw();
95 c1->SaveAs(Form(
"%s/divided.root", path.Data()));
96 gROOT->SetBatch(batch);
99 for (
int i = 0; i < 9; i++) {
108 h->GetXaxis()->SetTitle(Femto::KinematicsToAxisLabel(fFrame, 0, 3));
109 h->GetYaxis()->SetTitle(Femto::KinematicsToAxisLabel(fFrame, 1, 3));
110 h->GetZaxis()->SetTitle(Femto::KinematicsToAxisLabel(fFrame, 2, 3));
111 SetAxisName(Femto::KinematicsToAxisLabel(fFrame, 3, 3));
116 h->GetXaxis()->SetTitle(Femto::KinematicsToAxisLabel(fFrame, 0, 3));
117 h->GetYaxis()->SetTitle(Femto::KinematicsToAxisLabel(fFrame, 1, 3));
118 h->GetZaxis()->SetTitle(Femto::KinematicsToAxisLabel(fFrame, 2, 3));
119 SetAxisName(Femto::KinematicsToAxisLabel(fFrame, 3, 3));
128 TVirtualPad* c1 = gPad;
129 if (gPad ==
nullptr) {
new TCanvas(); }
138 TString options = opt;
150 TString option = opt;
151 TString name =
"Divided 1D";
155 middle_x[0] = middle_x[1] =
fNum->GetXaxis()->FindBin(0.0);
156 middle_y[0] = middle_y[1] =
fNum->GetYaxis()->FindBin(0.0);
157 middle_z[0] = middle_z[1] =
fNum->GetZaxis()->FindBin(0.0);
158 if (fFrame == Femto::EKinematics::kSH_LCMS || fFrame == Femto::EKinematics::kSH_PRF) {
159 middle_x[0] = middle_y[0] = middle_z[0] = 1;
160 middle_x[1] =
fNum->GetXaxis()->GetNbins();
161 middle_y[1] =
fNum->GetYaxis()->GetNbins();
162 middle_z[1] =
fNum->GetZaxis()->GetNbins();
164 if (
fNum->GetXaxis()->GetBinLowEdge(middle_x[0]) == 0.0 && middle_x[0] > 1) --middle_x[0];
165 if (
fNum->GetYaxis()->GetBinLowEdge(middle_y[0]) == 0.0 && middle_y[0] > 1) --middle_y[0];
166 if (
fNum->GetZaxis()->GetBinLowEdge(middle_z[0]) == 0.0 && middle_z[0] > 1) --middle_z[0];
167 TVirtualPad* c1 = gPad;
168 if (c1->GetListOfPrimitives()->GetEntries() < 4) c1->Divide(2, 2);
170 TH1D* out_func =
GetProjection1D(middle_y[0], middle_y[1], middle_z[0], middle_z[1],
"x+scale+bins+autoname");
171 out_func->SetLineColor(kRed);
172 out_func->SetTitle(
"out function");
173 out_func->SetMinimum(0);
174 out_func->Draw(option);
176 TH1D* side_func =
GetProjection1D(middle_x[0], middle_x[1], middle_z[0], middle_z[1],
"y+scale+bins+autoname");
177 side_func->SetLineColor(kBlue);
178 side_func->SetTitle(
"side function");
179 side_func->SetMinimum(0);
180 side_func->Draw(option);
182 TH1D* long_func =
GetProjection1D(middle_x[0], middle_x[1], middle_y[0], middle_y[1],
"z+scale+bins+autoname");
183 long_func->SetMinimum(0);
184 long_func->SetLineColor(kGreen);
185 long_func->SetTitle(
"long function");
186 long_func->Draw(option);
201 Femto::EKinematics frame) :
202 DividedHisto3D(name, binsX, minX, maxX, binsY, minY, maxY, binsZ, minZ, maxZ,
'D'), fFrame(frame) {
205 if (fFrame == Femto::EKinematics::kSH_PRF || fFrame == Femto::EKinematics::kSH_LCMS) {
206 TH3* old_num = (TH3*)
fNum;
207 TH3* old_den = (TH3*)
fDen;
208 TString old_name = old_num->GetName();
209 name = old_name(0, old_name.Length() - 4);
210 fNum =
new TH3D(name +
"_Num",
221 fDen =
new TH3D(name +
"_Den",
237 AddLabel(Femto::KinematicsToLabel(fFrame));
240 Femto3DCF::Femto3DCF(TString name, Int_t binsX, Double_t minX, Double_t maxX, Femto::EKinematics frame) :
241 Femto3DCF(name, binsX, minX, maxX, binsX, minX, maxX, binsX, minX, maxX, frame) {}
243 void Femto3DCF::SetAxisNames(TH1* h) {
244 if (h == NULL)
return;
245 h->GetXaxis()->SetTitle(Femto::KinematicsToAxisLabel(fFrame, 0, 3));
246 h->GetYaxis()->SetTitle(Femto::KinematicsToAxisLabel(fFrame, 1, 3));
247 h->GetZaxis()->SetTitle(Femto::KinematicsToAxisLabel(fFrame, 2, 3));
248 SetAxisName(Femto::KinematicsToAxisLabel(fFrame, 3, 3));
251 void Femto3DCF::Print(Option_t* opt)
const {
252 DividedHisto1D::Print(opt);
253 TString text = Form(
"Frame : %s", Femto::KinematicsToLabel(fFrame).Data());
257 TH1D** Femto3DCF::GetDiagProj(Option_t* opt, Bool_t normalized)
const {
258 TString option = opt;
259 if (Hal::Std::FindParam(option,
"cf", kTRUE)) {
260 TH3D* h = (TH3D*)
GetHist(normalized);
261 TString options[3] = {
"x",
"y",
"z"};
262 TString titles[3] = {
"out",
"side",
"long"};
263 TH1D** array =
new TH1D*[3];
265 Color_t colors[3] = {kRed, kBlue, kGreen};
266 if (Hal::Std::FindParam(option,
"rgb", kTRUE)) rgb = kTRUE;
267 for (
int i = 0; i < 3; i++) {
268 array[i] = Hal::Std::GetDiagonalProjection1D(h, options[i], 0, 0);
269 array[i]->SetTitle(titles[i]);
270 array[i]->SetStats(0);
271 TString xTitle = array[i]->GetXaxis()->GetTitle();
272 xTitle = xTitle.ReplaceAll(
"[GeV/c]",
"");
273 array[i]->SetYTitle(Form(
"C(%s)", xTitle.Data()));
274 array[i]->SetXTitle(Form(
"%s [GeV/c]", xTitle.Data()));
276 array[i]->SetMarkerColor(colors[i]);
277 array[i]->SetLineColor(colors[i]);
282 }
else if (option.EqualTo(
"diag1")) {
283 TH3D* h = (TH3D*)
GetHist(normalized);
284 TString options[7] = {
"x",
"y",
"z",
"xy++",
"yz++",
"xz++",
"xyz+++"};
285 TString titles[7] = {
294 TH1D** array =
new TH1D*[7];
295 for (
int i = 0; i < 7; i++) {
296 array[i] = Hal::Std::GetDiagonalProjection1D(h, options[i], 0, 0);
297 array[i]->SetTitle(titles[i]);
298 array[i]->SetStats(0);
299 TString xTitle = array[i]->GetXaxis()->GetTitle();
300 xTitle = xTitle.ReplaceAll(
"[GeV/c]",
"");
301 array[i]->SetYTitle(Form(
"C(%s)", xTitle.Data()));
302 array[i]->SetXTitle(Form(
"%s [GeV/c]", xTitle.Data()));
307 }
else if (option.EqualTo(
"diag2")) {
308 TString drawOpt = option;
309 TH3D* h = (TH3D*)
GetHist(normalized);
310 TString options[13] = {
311 "x",
"y",
"z",
"xy++",
"xy+-",
"yz++",
"yz+-",
"xz++",
"xz+-",
"xyz+++",
"xyz+-+",
"xyz+--",
"xyz++-"};
312 TString titles[13] = {
"out",
325 TH1D** array =
new TH1D*[13];
326 for (
int i = 0; i < 13; i++) {
327 array[i] = Hal::Std::GetDiagonalProjection1D(h, options[i], 0, 0);
328 array[i]->SetTitle(titles[i]);
329 array[i]->SetStats(0);
330 TString xTitle = array[i]->GetXaxis()->GetTitle();
331 xTitle = xTitle.ReplaceAll(
"[GeV/c]",
"");
332 array[i]->SetYTitle(Form(
"C(%s)", xTitle.Data()));
333 array[i]->SetXTitle(Form(
"%s [GeV/c]", xTitle.Data()));
343 if (opt ==
"painter")
return fPainter;
virtual void FitDummy(TObject *histo)
virtual void Fit(TObject *histo)
static void Text(TString text, TString option="L", Color_t color=-1)
void SetAxisName(TString name)
virtual TString CommonExtract(Int_t counter, TString dir) const
virtual void AddNum(TH1 *num, Option_t *opt="")
void AddLabel(TString label)
TH1 * GetHist(Bool_t normalized=kTRUE) const
virtual void AddDen(TH1 *den, Option_t *opt="")
TH1D * GetProjection1D(Double_t min1, Double_t max1, Double_t min2, Double_t max2, Option_t *opt) const
virtual void FillNumObj(TObject *ob)
virtual void FillDenObj(TObject *obj)
virtual TString HTMLExtract(Int_t counter=0, TString dir=" ") const
virtual void Browse(TBrowser *b)
virtual void AddDen(TH1 *h, Option_t *opt="")
virtual void AddNum(TH1 *h, Option_t *opt="")
virtual void DrawScaled(Double_t scale, Option_t *opt)
virtual void Draw(Option_t *opt="cf+rgb+norm")
void Fit(CorrFit3DCF *fit)
virtual TObject * GetSpecial(TString opt) const
void FitDummy(CorrFit3DCF *fit)
Double_t GetWeight() const
virtual void SetOption(TString option)