Heavy ion Analysis Libriares
Loading...
Searching...
No Matches
CorrFitPairGeneratorYPtKt.cxx
1/*
2 * CorrFitPairGeneratorYPtKt.cpp
3 *
4 * Created on: 10 kwi 2020
5 * Author: Daniel Wielanek
6 * E-mail: daniel.wielanek@gmail.com
7 * Warsaw University of Technology, Faculty of Physics
8 */
9
10#include "CorrFitPairGeneratorYPtKt.h"
11
12#include "FemtoCorrFuncKt.h"
13#include "FemtoMiniPair.h"
14
15#include <RtypesCore.h>
16#include <TAxis.h>
17#include <TClonesArray.h>
18#include <TDatabasePDG.h>
19#include <TFile.h>
20#include <TMath.h>
21#include <TMathBase.h>
22#include <TObjArray.h>
23#include <TParticlePDG.h>
24#include <TRandom.h>
25#include <TTree.h>
26
27namespace Hal {
28 CorrFitPairGeneratorYPtKt::CorrFitPairGeneratorYPtKt() : f2Kt2 {0, 1E+9} {}
29
30 void CorrFitPairGeneratorYPtKt::SetHist(const TH2D& hist1, const TH2D& hist2) {
31 hist1.Copy(fHist1);
32 hist2.Copy(fHist2);
33 fHist1.SetName("FirstParticle");
34 fHist2.SetName("SecondParticle");
35 fHist1.SetDirectory(nullptr);
36 fHist2.SetDirectory(nullptr);
37 }
38
39 Bool_t CorrFitPairGeneratorYPtKt::Init() {
40 bool val = CorrFitPairGenerator::Init();
41 if (!val) return val;
42 fHist1.ResetStats();
43 fHist2.ResetStats();
44 auto kt = dynamic_cast<Hal::FemtoCorrFuncKt*>(fCF);
45 if (kt) {
46 auto ktArr = kt->GetRange();
47 f2Kt2[0] = ktArr[0];
48 f2Kt2[1] = ktArr[ktArr.GetSize() - 1];
49 f2Kt2[0] = f2Kt2[0] * f2Kt2[0] * 4;
50 f2Kt2[1] = f2Kt2[1] * f2Kt2[1] * 4;
51 }
52 if (fHist1.GetEntries() <= 0) return kFALSE;
53 if (fHist2.GetEntries() <= 0) { fHist2 = fHist1; }
54 return kTRUE;
55 }
56
57 CorrFitPairGeneratorYPtKt::~CorrFitPairGeneratorYPtKt() {}
58
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);
70 *pair = fPair;
71 }
72 } break;
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);
83 *pair = fPair;
84 }
85 } break;
86 }
87 }
88
89 Int_t CorrFitPairGeneratorYPtKt::GeneratePairOneDim() {
90 GenerateFreeRandomPair();
91 *fHbtPair = fPair;
92 fHbtPair->Compute();
93 if (fAbs) { return fXaxis.GetBin(TMath::Abs(fHbtPair->GetT())); }
94 return fXaxis.GetBin(fHbtPair->GetT());
95 }
96
97
98 CorrFitPairGeneratorYPtKt::fourVect CorrFitPairGeneratorYPtKt::GeneratePairThreeDim() {
99 GenerateFreeRandomPair();
100 *fHbtPair = fPair;
101 fHbtPair->Compute();
102 fourVect res;
103 if (fAbs) {
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()));
108 } else {
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());
113 }
114 return res;
115 }
116
117 void CorrFitPairGeneratorYPtKt::GenerateFreeRandomPair() {
118 bool bad_pair = true;
119 do { // generate pairs until match kT bins
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]) {
141 bad_pair = false;
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);
148 }
149 } while (bad_pair);
150 }
151
152} // namespace Hal