10#include "CorrFitPairGeneratorYPtKt.h"
12#include "FemtoCorrFuncKt.h"
13#include "FemtoMiniPair.h"
15#include <RtypesCore.h>
17#include <TClonesArray.h>
18#include <TDatabasePDG.h>
23#include <TParticlePDG.h>
28 CorrFitPairGeneratorYPtKt::CorrFitPairGeneratorYPtKt() : f2Kt2 {0, 1E+9} {}
30 void CorrFitPairGeneratorYPtKt::SetHist(
const TH2D& hist1,
const TH2D& hist2) {
33 fHist1.SetName(
"FirstParticle");
34 fHist2.SetName(
"SecondParticle");
35 fHist1.SetDirectory(
nullptr);
36 fHist2.SetDirectory(
nullptr);
39 Bool_t CorrFitPairGeneratorYPtKt::Init() {
40 bool val = CorrFitPairGenerator::Init();
46 auto ktArr = kt->GetRange();
48 f2Kt2[1] = ktArr[ktArr.GetSize() - 1];
49 f2Kt2[0] = f2Kt2[0] * f2Kt2[0] * 4;
50 f2Kt2[1] = f2Kt2[1] * f2Kt2[1] * 4;
52 if (fHist1.GetEntries() <= 0)
return kFALSE;
53 if (fHist2.GetEntries() <= 0) { fHist2 = fHist1; }
57 CorrFitPairGeneratorYPtKt::~CorrFitPairGeneratorYPtKt() {}
59 void CorrFitPairGeneratorYPtKt::GenerateEvent() {
60 switch (fGroupingFlag) {
61 case EGrouping::kOneDim: {
62 int size = fLimitsN.GetSize() - 1;
63 for (
int i = 0; i < 10000; i++) {
64 int bin = GeneratePairOneDim();
65 if (bin < 1)
continue;
66 if (fLimitsN[bin] > fBinLimit)
continue;
67 auto array = fSignalPairs[bin - 1];
68 auto pair = (FemtoMicroPair*) array->ConstructedAt(array->GetEntriesFast());
69 fLimitsN.IncrementAfter(bin);
73 case EGrouping::kThreeDim: {
74 for (
int i = 0; i < 10000; i++) {
75 auto bin = GeneratePairThreeDim();
76 if (bin.x < 1)
continue;
77 if (bin.y < 1)
continue;
78 if (bin.z < 1)
continue;
79 if (fLimits3D[bin.x][bin.y][bin.z] > fBinLimit)
continue;
80 auto array = fSignalPairs[bin.z - 1];
81 auto pair = (FemtoMicroPair*) array->ConstructedAt(array->GetEntriesFast());
82 fLimits3D.IncrementAfter(bin.x, bin.y, bin.z);
89 Int_t CorrFitPairGeneratorYPtKt::GeneratePairOneDim() {
90 GenerateFreeRandomPair();
93 if (fAbs) {
return fXaxis.GetBin(TMath::Abs(fHbtPair->GetT())); }
94 return fXaxis.GetBin(fHbtPair->GetT());
98 CorrFitPairGeneratorYPtKt::fourVect CorrFitPairGeneratorYPtKt::GeneratePairThreeDim() {
99 GenerateFreeRandomPair();
104 res.t = fXaxis.GetBin(TMath::Abs(fHbtPair->GetT()));
105 res.x = fXaxis.GetBin(TMath::Abs(fHbtPair->GetX()));
106 res.y = fYaxis.GetBin(TMath::Abs(fHbtPair->GetY()));
107 res.z = fZaxis.GetBin(TMath::Abs(fHbtPair->GetZ()));
109 res.t = fXaxis.GetBin(fHbtPair->GetT());
110 res.x = fXaxis.GetBin(fHbtPair->GetX());
111 res.y = fYaxis.GetBin(fHbtPair->GetY());
112 res.z = fZaxis.GetBin(fHbtPair->GetZ());
117 void CorrFitPairGeneratorYPtKt::GenerateFreeRandomPair() {
118 bool bad_pair =
true;
120 Double_t pt1, pt2, y1, y2;
121 fHist1.GetRandom2(y1, pt1);
122 fHist2.GetRandom2(y2, pt2);
123 Double_t phi1 = gRandom->Uniform(-TMath::Pi(), TMath::Pi());
124 Double_t phi2 = gRandom->Uniform(-TMath::Pi(), TMath::Pi());
125 Double_t px1 = pt1 * TMath::Cos(phi1);
126 Double_t px2 = pt2 * TMath::Cos(phi2);
127 Double_t py1 = pt1 * TMath::Sin(phi1);
128 Double_t py2 = pt2 * TMath::Sin(phi2);
129 Double_t et1 = TMath::Sqrt(pt1 * pt1 + fM1 * fM1);
130 Double_t et2 = TMath::Sqrt(pt2 * pt2 + fM2 * fM2);
131 Double_t pz1 = TMath::Sign(et1 * 0.5, y1) * TMath::Exp(-y1) * (TMath::Exp(2.0 * y1) - 1.0);
132 Double_t pz2 = TMath::Sign(et2 * 0.5, y2) * TMath::Exp(-y2) * (TMath::Exp(2.0 * y2) - 1.0);
133 Double_t e1 = TMath::Sqrt(et1 * et1 + pz1 * pz1);
134 Double_t e2 = TMath::Sqrt(et2 * et2 + pz2 * pz2);
135 Double_t Px = px1 + px2;
136 Double_t Py = py1 + py2;
137 Double_t Pz = pz1 + pz2;
138 Double_t tE = e1 + e2;
139 Double_t tPt = Px * Px + Py * Py;
140 if (tPt > f2Kt2[0] && tPt < f2Kt2[1]) {
142 fPair.SetPdg1(fPid1);
143 fPair.SetPdg2(fPid2);
144 fPair.SetTrueMomenta1(px1, py1, pz1, e1);
145 fPair.SetMomenta1(px1, py1, pz1, e1);
146 fPair.SetTrueMomenta2(px2, py2, pz2, e2);
147 fPair.SetMomenta2(px2, py2, pz2, e2);