10#include "FemtoCorrFunc2D.h"
17#include "ObjectMatrix.h"
20#include <RtypesCore.h>
28 FemtoCorrFunc2D::FemtoCorrFunc2D(
const DividedHisto1D* h, TString labelX, TString labelY, Int_t sizeX, Int_t sizeY) :
29 FemtoCorrFunc(h, sizeX * sizeY), fLabelX(labelX), fLabelY(labelY) {
30 fRangeX.MakeBigger(sizeX + 1);
31 fRangeY.MakeBigger(sizeY + 1);
34 FemtoCorrFunc2D::FemtoCorrFunc2D(
const DividedHisto1D& h, TString labelX, TString labelY, Int_t sizeX, Int_t sizeY) :
35 FemtoCorrFunc(h, sizeX * sizeY), fLabelX(labelX), fLabelY(labelY) {
36 fRangeX.MakeBigger(sizeX + 1);
37 fRangeY.MakeBigger(sizeY + 1);
40 TString FemtoCorrFunc2D::HTMLExtract(Int_t counter, TString dir)
const {
41 TString path = Form(
"%s/corrfunc_%i", dir.Data(), counter);
42 gSystem->MakeDirectory(path);
43 TString filename = Form(
"%s/corrfunc.html", path.Data());
49 row1.
SetClass(HtmlTableRowClass::DarkBlue());
50 auto GetStringContent = [&](Double_t a, Double_t b, Char_t flag) {
53 res = ((Form(
"%4.2f - %4.2f° ", a * TMath::RadToDeg(), b * TMath::RadToDeg())));
55 res = ((Form(
"%4.2f - %4.2f ", a, b)));
59 for (
int i = 0; i < fRangeX.GetSize() - 1; i++) {
61 cell.SetStringContent(GetStringContent(fRangeX.Get(i), fRangeX.Get(i + 1),
'x'));
62 cell.
SetClass(Hal::HtmlTableRowClass::DarkBlue());
66 const Int_t y_size = fRangeY.GetSize() - 1;
67 const Int_t x_size = fRangeX.GetSize() - 1;
68 for (
int i = 0; i < y_size; i++) {
71 celltmp.SetStringContent(GetStringContent(fRangeY.Get(i), fRangeY.Get(i + 1),
'y'));
72 celltmp.
SetClass(HtmlTableRowClass::DarkBlue());
74 for (
int j = 0; j < x_size; j++) {
75 Int_t pos = i * x_size + j;
82 HtmlRow row2(
"",
"light_blue",
"");
86 file.AddContent(table);
90 row3.
SetClass(HtmlTableRowClass::DarkBlue());
91 row3.AddSimpleCells({
"Numerator",
"Denominator"});
94 row4.
SetClass(HtmlTableRowClass::LightBlue());
96 cell1.SetStringContent(HtmlCore::GetJsDiv(
"num.root",
"Cnum;1",
"colz",
"dd1"));
97 cell2.SetStringContent(HtmlCore::GetJsDiv(
"den.root",
"Cden;1",
"colz",
"dd2"));
98 Bool_t batch = gROOT->IsBatch();
99 gStyle->SetOptStat(0);
101 TCanvas* cnum =
new TCanvas(
"Cnum");
102 fNumProp->DrawClone(
"colz");
103 cnum->SaveAs(Form(
"%s/num.root", path.Data()));
104 TCanvas* cden =
new TCanvas(
"Cden");
105 fDenProp->DrawClone(
"colz");
106 cden->SaveAs(Form(
"%s/den.root", path.Data()));
109 gROOT->SetBatch(batch);
113 file.AddContent(table2);
115 return HtmlCore::GetUrl(Form(
"corrfunc_%i/corrfunc.html", counter), this->ClassName());
118 Bool_t FemtoCorrFunc2D::Check() {
119 for (
int i = 1; i < fRangeX.GetSize(); i++) {
120 if (fRangeX[i] < fRangeX[i - 1]) {
121 Cout::PrintInfo(Form(
"Wrong order in X-axis in %s", this->ClassName()), EInfo::kCriticalError);
125 for (
int i = 1; i < fRangeY.GetSize(); i++) {
126 if (fRangeY[i] < fRangeY[i - 1]) {
127 Cout::PrintInfo(Form(
"Wrong order in Y-axis in %s", this->ClassName()), EInfo::kCriticalError);
131 Int_t x_bins = fRangeX.GetSize() - 1;
132 for (
int i = 0; i < x_bins; i++) {
133 for (
int j = 0; j < fRangeY.GetSize() - 1; j++) {
135 TString histname = h->GetName();
136 histname.ReplaceAll(Form(
"[%i]", i + j * x_bins), Form(
"[%i][%i]", i, j));
139 return InitPropMon();
142 FemtoCorrFunc2D::~FemtoCorrFunc2D() {
149 DividedHisto1D* FemtoCorrFunc2D::GetCF(Int_t i, Int_t j)
const {
150 Int_t pos = i + j * (fRangeX.GetSize() - 1);
151 {
return (DividedHisto1D*) fArray->At(pos); };
154 FemtoCorrFunc::FemtoCorrFunc() : Object(), fArray(nullptr) {}
157 auto par = GetPairValNum(pair);
158 Int_t bin = ConvertVal(par);
160 fNumProp->Fill(par.first, par.second);
164 void FemtoCorrFunc2D::FillDenMixed(
FemtoPair* pair) {
165 auto par = GetPairValDenMix(pair);
166 Int_t bin = ConvertVal(par);
168 fDenProp->Fill(par.first, par.second);
172 void FemtoCorrFunc2D::FillDenRotated(FemtoPair* pair) {
173 auto par = GetPairValDenMix(pair);
174 Int_t bin = ConvertVal(par);
176 fDenProp->Fill(par.first, par.second);
177 ((DividedHisto1D*) fArray->
At(bin))->FillDenObj(pair);
180 void FemtoCorrFunc2D::FillDenHemisphere(FemtoPair* pair) {
181 auto par = GetPairValDenHemi(pair);
182 Int_t bin = ConvertVal(par);
184 fDenProp->Fill(par.first, par.second);
185 ((DividedHisto1D*) fArray->
At(bin))->FillDenObj(pair);
189 auto par = GetPairValDenChar(pair);
190 Int_t bin = ConvertVal(par);
192 fDenProp->Fill(par.first, par.second);
193 ((DividedHisto1D*) fArray->
At(bin))->FillDenObj(pair);
197 auto par = GetPairValDenPerf(pair);
198 Int_t bin = ConvertVal(par);
200 fDenProp->Fill(par.first, par.second);
201 ((DividedHisto1D*) fArray->
At(bin))->FillDenObj(pair);
204 Int_t FemtoCorrFunc2D::ConvertVal(std::pair<Double_t, Double_t> vals)
const {
205 const Int_t sizeX = fRangeX.
GetSize();
207 if (vals.first < fRangeX.
Get(0))
return -1;
208 for (
int i = 1; i < sizeX; i++) {
209 if (vals.first < fRangeX.
Get(i)) {
215 const Int_t sizeY = fRangeY.
GetSize();
216 if (vals.second < fRangeY.
Get(0))
return -1;
217 for (
int i = 1; i < sizeY; i++) {
218 if (vals.second < fRangeY.
Get(i)) {
223 return xbin + ybin * (fRangeX.
GetSize() - 1);
226 FemtoCorrFunc2D::FemtoCorrFunc2D(
const FemtoCorrFunc2D& other) :
227 Hal::FemtoCorrFunc(other),
228 fLabelX(other.fLabelX),
229 fLabelY(other.fLabelY),
230 fRangeX(other.fRangeX),
231 fRangeY(other.fRangeY),
234 if (other.fNumProp) {
235 fNumProp = (TH2D*) other.fNumProp;
236 fDenProp = (TH2D*) other.fDenProp;
240 Bool_t FemtoCorrFunc2D::InitPropMon() {
241 Double_t mins[2] = {fRangeX[0], fRangeY[0]};
242 Double_t maxs[2] = {fRangeX[fRangeX.
GetSize() - 1], fRangeY[fRangeY.
GetSize() - 1]};
243 fNumProp =
new TH2D(
"NumProp",
"NumProp", fBinsX, mins[0], maxs[0], fBinsY, mins[1], maxs[1]);
244 fDenProp =
new TH2D(
"DenProp",
"DenProp", fBinsX, mins[0], maxs[0], fBinsY, mins[1], maxs[1]);
245 fNumProp->SetXTitle(fLabelX);
246 fDenProp->SetYTitle(fLabelY);
virtual TString HTMLExtract(Int_t counter=0, TString dir=" ") const
void FillNum(FemtoPair *pair)
void SetClass(TString className)
virtual void AddContent(const HtmlObject &obj)
virtual void AddContent(const HtmlObject &obj)
TObject * At(Int_t i) const