8#include "Femto3DCFPainter.h"
17#include <TVirtualPad.h>
20 const int Femto3DCFPainter::kRgbBit = 16;
21 const int Femto3DCFPainter::kRawBit = 17;
22 const int Femto3DCFPainter::kDiag1Bit = 18;
23 const int Femto3DCFPainter::kDiag2Bit = 19;
24 const int Femto3DCFPainter::kTwoDimBit = 20;
25 const int Femto3DCFPainter::kTwoDimPlusBit = 21;
26 const int Femto3DCFPainter::kAngles = 22;
29 auto cleanFlags = [&](
int setbit) {
ResetFewBits(newFlags, {kDiag1Bit, kDiag2Bit, kTwoDimBit, kTwoDimPlusBit}, setbit); };
30 if (Hal::Std::FindParam(opt,
"diag1")) {
31 cleanFlags(kDiag1Bit);
32 fDefDrawFlag =
"SAME+P";
34 if (Hal::Std::FindParam(opt,
"diag2")) {
35 cleanFlags(kDiag2Bit);
36 fDefDrawFlag =
"SAME+P";
38 if (Hal::Std::FindParam(opt,
"2d")) {
39 cleanFlags(kTwoDimBit);
40 fDefDrawFlag =
"SAME+colz";
42 if (Hal::Std::FindParam(opt,
"3d")) {
43 cleanFlags(kTwoDimPlusBit);
44 fDefDrawFlag =
"SAME+surf1";
45 auto bra = Hal::Std::FindBrackets(opt, kTRUE, kTRUE);
46 for (
auto pat : bra) {
47 std::vector<Double_t> vals;
49 SETBIT(newFlags, kAngles);
50 if (vals.size() == 2) {
62 void Femto3DCFPainter::MakeHistograms() {
66 h = (TH3*) fCF->
GetNum()->Clone();
68 h = (TH3*) fCF->
GetDen()->Clone();
70 h = (TH3*) fCF->
GetHist(kFALSE);
92 Int_t req = GetPadsRequired();
94 if (padsNo < req)
return kFALSE;
98 Femto3DCFPainter::Femto3DCFPainter(
Femto3DCF* cf) : fCF(cf) {}
100 void Femto3DCFPainter::Prepare3DFull(TH1* h) {
104 middle_x[0] = middle_x[1] = h->GetXaxis()->FindBin(0.0);
105 middle_y[0] = middle_y[1] = h->GetYaxis()->FindBin(0.0);
106 middle_z[0] = middle_z[1] = h->GetZaxis()->FindBin(0.0);
108 if (frame == Femto::EKinematics::kSH_LCMS || frame == Femto::EKinematics::kSH_PRF) {
109 middle_x[0] = middle_y[0] = middle_z[0] = 1;
110 middle_x[1] = h->GetXaxis()->GetNbins();
111 middle_y[1] = h->GetYaxis()->GetNbins();
112 middle_z[1] = h->GetZaxis()->GetNbins();
114 if (h->GetXaxis()->GetBinLowEdge(middle_x[0]) == 0.0 && middle_x[0] > 1) --middle_x[0];
115 if (h->GetYaxis()->GetBinLowEdge(middle_y[0]) == 0.0 && middle_y[0] > 1) --middle_y[0];
116 if (h->GetZaxis()->GetBinLowEdge(middle_z[0]) == 0.0 && middle_z[0] > 1) --middle_z[0];
118 TString names[] = {
"out",
"side",
"long"};
119 TString dirs[] = {
"x",
"y",
"z"};
120 TString titles[] = {
"cf",
"num",
"den"};
121 Int_t mxxLow[] = {middle_y[0], middle_x[0], middle_x[0]};
122 Int_t myyLow[] = {middle_z[0], middle_z[0], middle_y[0]};
123 Int_t mxxHi[] = {middle_y[1], middle_x[1], middle_x[1]};
124 Int_t myyHi[] = {middle_z[1], middle_z[1], middle_y[1]};
125 for (
int padId = 0; padId < 9; padId++) {
126 int optId = padId % 3;
127 int flagDir = (padId - optId) / 3;
128 TString optLoc = titles[optId] +
"+" + dirs[flagDir] +
"+scale+bins";
131 case 0: hx = h;
break;
132 case 1: hx = fCF->
GetNum();
break;
133 case 2: hx = fCF->
GetDen();
break;
136 auto histo = GetProjection1D(h, mxxLow[flagDir], mxxHi[flagDir], myyLow[flagDir], myyHi[flagDir], optLoc);
137 histo->SetTitle(Form(
"%s %s", names[flagDir].Data(), titles[optId].Data()));
138 histo->SetMinimum(0);
139 if (fRangeY[0] != fRangeY[1]) {
140 histo->SetMaximum(fRangeY[1]);
141 histo->SetMinimum(fRangeY[0]);
143 if (fRangeX[0] != fRangeX[1]) { histo->GetXaxis()->SetRangeUser(fRangeX[0], fRangeX[1]); }
144 std::vector<TH1*> histVec;
145 histVec.push_back(histo);
146 fHistograms.push_back(histVec);
151 Femto3DCFPainter::GetProjection1D(TH1* h, Double_t min1, Double_t max1, Double_t min2, Double_t max2, Option_t* opt)
const {
152 TString option = opt;
153 TH1D* num1d = Hal::Std::GetProjection1D((TH3*) h, min1, max1, min2, max2, option);
157 void Femto3DCFPainter::Prepare3D(TH1* h) {
161 middle_x[0] = middle_x[1] = h->GetXaxis()->FindBin(0.0);
162 middle_y[0] = middle_y[1] = h->GetYaxis()->FindBin(0.0);
163 middle_z[0] = middle_z[1] = h->GetZaxis()->FindBin(0.0);
165 if (frame == Femto::EKinematics::kSH_LCMS || frame == Femto::EKinematics::kSH_PRF) {
166 middle_x[0] = middle_y[0] = middle_z[0] = 1;
167 middle_x[1] = h->GetXaxis()->GetNbins();
168 middle_y[1] = h->GetYaxis()->GetNbins();
169 middle_z[1] = h->GetZaxis()->GetNbins();
171 if (h->GetXaxis()->GetBinLowEdge(middle_x[0]) == 0.0 && middle_x[0] > 1) --middle_x[0];
172 if (h->GetYaxis()->GetBinLowEdge(middle_y[0]) == 0.0 && middle_y[0] > 1) --middle_y[0];
173 if (h->GetZaxis()->GetBinLowEdge(middle_z[0]) == 0.0 && middle_z[0] > 1) --middle_z[0];
175 TString names[] = {
"out",
"side",
"long"};
176 TString dirs[] = {
"x",
"y",
"z"};
177 Int_t mxxLow[] = {middle_y[0], middle_x[0], middle_x[0]};
178 Int_t myyLow[] = {middle_z[0], middle_z[0], middle_y[0]};
179 Int_t mxxHi[] = {middle_y[1], middle_x[1], middle_x[1]};
180 Int_t myyHi[] = {middle_z[1], middle_z[1], middle_y[1]};
181 for (
int i = 0; i < 3; i++) {
182 auto histo = GetProjection1D(h, mxxLow[i], mxxHi[i], myyLow[i], myyHi[i], dirs[i] +
"+scale+bins");
183 histo->SetTitle(names[i]);
184 if (fRangeY[0] != fRangeY[1]) {
185 histo->SetMaximum(fRangeY[1]);
186 histo->SetMinimum(fRangeY[0]);
190 titleY =
"dN_{pairs}/d%s";
194 TString axisTitle = Femto::KinematicsToAxisLabel(fCF->
GetFrame(), i, 3);
195 axisTitle = Hal::Std::RemoveUnits(axisTitle);
196 axisTitle.ReplaceAll(
" ",
"");
197 titleY = Form(titleY.Data(), axisTitle.Data());
198 histo->GetYaxis()->SetTitle(titleY);
199 std::vector<TH1*> histVec;
200 histVec.push_back(histo);
201 fHistograms.push_back(histVec);
205 void Femto3DCFPainter::PrepareDiagonal1(TH1* h) {
206 TString options[7] = {
"x",
"y",
"z",
"xy++",
"yz++",
"xz++",
"xyz+++"};
207 TString titles[7] = {
216 for (
int i = 0; i < 7; i++) {
217 auto hist = Hal::Std::GetDiagonalProjection1D((TH3*) h, options[i], 0, 0);
218 hist->SetTitle(titles[i]);
220 TString xTitle = hist->GetXaxis()->GetTitle();
221 xTitle = xTitle.ReplaceAll(
"[GeV/c]",
"");
222 hist->SetYTitle(Form(
"C(%s)", xTitle.Data()));
223 hist->SetXTitle(Form(
"%s [GeV/c]", xTitle.Data()));
224 std::vector<TH1*> histVec;
225 histVec.push_back(hist);
226 if (fRangeY[0] != fRangeY[1]) {
227 hist->SetMaximum(fRangeY[1]);
228 hist->SetMinimum(fRangeY[0]);
230 if (fRangeX[0] != fRangeX[1]) { hist->GetXaxis()->SetRangeUser(fRangeX[0], fRangeX[1]); }
231 fHistograms.push_back(histVec);
235 void Femto3DCFPainter::PrepareDiagonal2(TH1* h) {
236 TString options[16] = {
237 "x",
"y",
"z",
"",
"xy++",
"xy+-",
"yz++",
"",
"yz+-",
"xz++",
"xz+-",
"",
"xyz+++",
"xyz+-+",
"xyz+--",
"xyz++-"};
238 TString titles[16] = {
"out",
255 for (
int i = 0; i < 16; i++) {
256 std::vector<TH1*> histVec;
257 if (options[i] ==
"") {
258 histVec.push_back(
nullptr);
260 auto histo = Hal::Std::GetDiagonalProjection1D((TH3*) h, options[i], 0, 0);
261 histo->SetTitle(titles[i]);
263 TString xTitle = histo->GetXaxis()->GetTitle();
264 xTitle = xTitle.ReplaceAll(
"[GeV/c]",
"");
265 histo->SetYTitle(Form(
"C(%s)", xTitle.Data()));
266 histo->SetXTitle(Form(
"%s [GeV/c]", xTitle.Data()));
267 if (fRangeY[0] != fRangeY[1]) {
268 histo->SetMaximum(fRangeY[1]);
269 histo->SetMinimum(fRangeY[0]);
271 if (fRangeX[0] != fRangeX[1]) { histo->GetXaxis()->SetRangeUser(fRangeX[0], fRangeX[1]); }
272 histVec.push_back(histo);
274 fHistograms.push_back(histVec);
278 void Femto3DCFPainter::PrepareTwoDim(TH1* h) {
280 TString opts[] = {
"xy",
"xz",
"yz"};
281 for (
int i = 0; i < 3; i++) {
282 auto out_side = Hal::Std::GetProjection2D((TH3*) h, 0, 0, opts[i]);
283 if (fRangeY[0] != fRangeY[1]) {
284 out_side->SetMaximum(fRangeY[1]);
285 out_side->SetMinimum(fRangeY[0]);
287 std::vector<TH1*> histVec;
288 histVec.push_back(out_side);
289 fHistograms.push_back(histVec);
293 Int_t Femto3DCFPainter::GetPadsRequired()
const {
312 void Femto3DCFPainter::PrepareHtml(TH1* h) {
316 middle_x[0] = middle_x[1] = h->GetXaxis()->FindBin(0.0);
317 middle_y[0] = middle_y[1] = h->GetYaxis()->FindBin(0.0);
318 middle_z[0] = middle_z[1] = h->GetZaxis()->FindBin(0.0);
320 if (frame == Femto::EKinematics::kSH_LCMS || frame == Femto::EKinematics::kSH_PRF) {
321 middle_x[0] = middle_y[0] = middle_z[0] = 1;
322 middle_x[1] = h->GetXaxis()->GetNbins();
323 middle_y[1] = h->GetYaxis()->GetNbins();
324 middle_z[1] = h->GetZaxis()->GetNbins();
326 if (h->GetXaxis()->GetBinLowEdge(middle_x[0]) == 0.0 && middle_x[0] > 1) --middle_x[0];
327 if (h->GetYaxis()->GetBinLowEdge(middle_y[0]) == 0.0 && middle_y[0] > 1) --middle_y[0];
328 if (h->GetZaxis()->GetBinLowEdge(middle_z[0]) == 0.0 && middle_z[0] > 1) --middle_z[0];
330 TString names[] = {
"out",
"side",
"long"};
331 TString dirs[] = {
"x",
"y",
"z"};
332 Int_t mxxLow[] = {middle_y[0], middle_x[0], middle_x[0]};
333 Int_t myyLow[] = {middle_z[0], middle_z[0], middle_y[0]};
334 Int_t mxxHi[] = {middle_y[1], middle_x[1], middle_x[1]};
335 Int_t myyHi[] = {middle_z[1], middle_z[1], middle_y[1]};
336 for (
int i = 0; i < 3; i++) {
337 auto histo = GetProjection1D(h, mxxLow[i], mxxHi[i], myyLow[i], myyHi[i], dirs[i] +
"+scale+bins");
338 histo->SetTitle(names[i]);
339 if (fRangeY[0] != fRangeY[1]) {
340 histo->SetMaximum(fRangeY[1]);
341 histo->SetMinimum(fRangeY[0]);
343 auto histoNum = GetProjection1D(fCF->
GetNum(), mxxLow[i], mxxHi[i], myyLow[i], myyHi[i], dirs[i]);
344 histoNum->SetTitle(
"Numerator" + names[i]);
345 auto histoDen = GetProjection1D(fCF->
GetDen(), mxxLow[i], mxxHi[i], myyLow[i], myyHi[i], dirs[i]);
346 histoDen->SetTitle(
"Numerator" + names[i]);
347 Hal::Std::SetColor(*histoNum, kGreen);
348 Hal::Std::SetColor(*histoDen, kRed);
349 Hal::Std::SetColor(*histo, kBlue);
350 std::vector<TH1*> histVec1;
351 histVec1.push_back(histo);
352 std::vector<TH1*> histVec2;
353 histVec2.push_back(histoNum);
354 std::vector<TH1*> histVec3;
355 histVec3.push_back(histoDen);
356 fHistograms.push_back(histVec1);
357 fHistograms.push_back(histVec2);
358 fHistograms.push_back(histVec3);
364 HalCoutDebug(
"Diag1");
368 HalCoutDebug(
"Diag2");
371 if (
CheckOpt(kTwoDimBit))
return "fit4";
372 if (
CheckOpt(kTwoDimPlusBit))
return "fit5";
376 void Femto3DCFPainter::ScaleHistograms() {
377 FemtoCFPainter::ScaleHistograms();
378 if (fRangeY[0] != fRangeY[1])
379 for (
auto& x : fHistograms) {
382 y->SetMinimum(fRangeY[0]);
383 y->SetMaximum(fRangeY[1]);
389 Femto3DCFPainter::~Femto3DCFPainter() {}
392 Int_t req = TMath::Sqrt(GetPadsRequired());
396 void Femto3DCFPainter::DrawHistograms() {
397 FemtoCFPainter::DrawHistograms();
401 for (
auto i : fHistograms) {
403 gPad->SetTheta(fThetaPad);
404 gPad->SetPhi(fPhiPad);
TH1 * GetHist(Bool_t normalized=kTRUE) const
virtual Bool_t CheckPads() const
virtual TString GetOptionForCorrFit() const
virtual void MakePadsAndCanvases()
virtual ULong64_t SetOptionInternal(TString opt, ULong64_t prev=0)
Femto::EKinematics GetFrame() const
Bool_t AreSimiliar(ULong64_t current, ULong64_t pattern) const
virtual ULong64_t SetOptionInternal(TString opt, ULong64_t prev=0)
ULong64_t GetDrawFlags() const
Bool_t CheckOpt(Int_t opt) const
void ResetFewBits(ULong64_t &flag, std::initializer_list< Int_t > bits, Int_t set=-1) const
void MakeCanvasPads(Int_t x=1, Int_t y=1, Int_t canvasNo=0)
Int_t GetPadsNo(Int_t canvasNo=0) const
void ContitionalPattern(TString &option, TString pattern, ULong64_t &drawOpt, Int_t bit, Bool_t remove=kTRUE) const
void GotoPad(Int_t no, Int_t canvasNo=0)
Bool_t GetPatterns(TString opt, TString flag, std::vector< double > &vals) const