10#include "CorrFitPairGenerator.h"
13#include "DividedHisto.h"
14#include "FemtoCorrFunc.h"
19#include <RtypesCore.h>
20#include <TClonesArray.h>
21#include <TDatabasePDG.h>
25#include <TParticlePDG.h>
31 CorrFitPairGenerator::CorrFitPairGenerator() {}
33 Bool_t CorrFitPairGenerator::Init() {
34 if (!fCF)
return kFALSE;
35 DividedHisto1D* dummy = fCF->
GetCF(0);
39 if (dummy->GetNum()->InheritsFrom(
"TH3")) {
40 fGrouping.SetGroupByKLong();
41 Std::GetAxisPar(*dummy->GetNum(), bins, min, max,
"z");
42 fXaxis.Recalc(*dummy->GetNum()->GetXaxis());
43 fYaxis.Recalc(*dummy->GetNum()->GetYaxis());
44 fZaxis.Recalc(*dummy->GetNum()->GetZaxis());
45 if (fDebug) fDebugHisto =
new TH1D(
"debug",
"debug", bins, min, max);
46 auto d3 = (TH3*) dummy->GetNum();
47 fOutCut[0] = d3->GetXaxis()->GetBinLowEdge(1);
48 fOutCut[1] = d3->GetXaxis()->GetBinUpEdge(d3->GetNbinsX());
49 fSideCut[0] = d3->GetYaxis()->GetBinLowEdge(1);
50 fSideCut[1] = d3->GetYaxis()->GetBinUpEdge(d3->GetNbinsY());
51 fGroupingFlag = EGrouping::kThreeDim;
52 Int_t bins1, bins2, bins3;
53 Std::GetAxisPar(*dummy->GetNum(), bins2, min, max,
"y");
54 Std::GetAxisPar(*dummy->GetNum(), bins1, min, max,
"x");
55 Std::GetAxisPar(*dummy->GetNum(), bins3, min, max,
"z");
56 fLimits3D.
MakeBigger(bins1 + 1, bins2 + 1, bins3 + 1);
59 Std::GetAxisPar(*dummy->GetNum(), bins, min, max,
"x");
61 fXaxis.Recalc(*dummy->GetNum()->GetXaxis());
62 fGrouping.GroupByKStar();
63 fGroupingFlag = EGrouping::kOneDim;
64 if (fDebug) fDebugHisto =
new TH1D(
"debug",
"debug", bins, min, max);
66 fXaxis.RoundToMinusOne();
67 fYaxis.RoundToMinusOne();
68 fZaxis.RoundToMinusOne();
71 fOverStep = (max - min) / ((
double) bins);
72 fOverStep = 1.0 / fOverStep;
73 if (fLow == 0) fAbs = kTRUE;
74 if (dummy->GetLabelsNo() > 0) {
75 TString label = dummy->GetLabel(0);
76 fFrame = Femto::LabelToKinematics(label);
78 fHbtPair = Hal::Femto::MakePair(fFrame,
true);
80 TDatabasePDG* pid = TDatabasePDG::Instance();
81 TParticlePDG* pid1 = pid->GetParticle(fPid1);
82 TParticlePDG* pid2 = pid->GetParticle(fPid2);
86 if (!pid1)
return kFALSE;
87 if (!pid2)
return kFALSE;
90 fGrouping.SetFrame(fFrame);
91 fGrouping.SetAxis(bins, min, max);
94 fOutFile =
new TFile(fFileName,
"recreate");
95 fOutTree =
new TTree(
"HalTree",
"Tree");
96 fOutFile->mkdir(
"HalInfo");
97 fOutFile->cd(
"HalInfo");
101 auto FillCenters = [&](Array_1<Double_t>& array, Int_t binsx, Double_t minx, Double_t maxx) {
102 Double_t step = (maxx - minx) /
double(binsx);
103 array.MakeBigger(binsx);
104 for (
int i = 0; i < binsx; i++) {
105 Double_t val = step * i + step * 0.5;
111 if (dummy->GetNum()->InheritsFrom(
"TH3")) {
112 Std::GetAxisPar(*dummy->GetNum(), bins, min, max,
"x");
113 FillCenters(fCentersX, bins, min, max);
114 Std::GetAxisPar(*dummy->GetNum(), bins, min, max,
"y");
115 FillCenters(fCentersY, bins, min, max);
116 Std::GetAxisPar(*dummy->GetNum(), bins, min, max,
"z");
117 FillCenters(fCentersZ, bins, min, max);
119 Std::GetAxisPar(*dummy->GetNum(), bins, min, max,
"x");
120 FillCenters(fCentersX, bins, min, max);
123 auto vec = fGrouping.GetBranchesByValue(0, 0, kTRUE);
125 for (
auto branchName : vec) {
126 fSignalPairs.push_back(
new TClonesArray(
"Hal::FemtoMicroPair", 100));
127 fOutTree->Branch(branchName, &*fSignalPairs[idx]);
136 void CorrFitPairGenerator::Run(Int_t entries) {
137 if (!fInited || !fOutFile)
return;
138 int percent = entries / 100;
139 if (percent == 0) percent = 1;
140 for (
int i = 0; i < entries; i++) {
143 unsigned int count = 1;
144 for (
auto data : fSignalPairs) {
145 fDebugHisto->SetBinContent(count, fDebugHisto->GetBinContent(count) + data->GetEntriesFast());
149 for (
auto data : fSignalPairs)
160 TFile* f =
new TFile(Form(
"%s_debug.root", ClassName()),
"recreate");
161 fDebugHisto->Write();
163 fDebugHisto =
nullptr;
169 Int_t CorrFitPairGenerator::GetBin(Double_t val)
const {
172 bin = TMath::Abs(val) * fOverStep;
174 bin = (val - fLow) * fOverStep;
177 if (bin >= fNBins)
return -1;
181 CorrFitPairGenerator::~CorrFitPairGenerator() {
182 if (fOutFile) { fOutFile->Close(); }
void MakeBigger(Int_t new_dim)
void MakeBigger(Int_t sizeA, Int_t sizeB, Int_t sizeC)
void SetCorrFctn(const FemtoCorrFunc &cf)
static void ProgressBar(Double_t acutal, Double_t total)
DividedHisto1D * GetCF(Int_t i) const