-
Notifications
You must be signed in to change notification settings - Fork 0
/
TGenThermalParticles.cxx
186 lines (151 loc) · 4.61 KB
/
TGenThermalParticles.cxx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
#include <TClass.h>
#include <TString.h>
#include <TError.h>
#include <TMath.h>
#include <TRandom3.h>
#include <TLorentzVector.h>
#include <TF1.h>
#include <TParticle.h>
#include <TClonesArray.h>
#include "TGenThermalParticles.h"
ClassImp(TGenThermalParticles)
//_____________________________________________________________________________
TGenThermalParticles::TGenThermalParticles() :
TNamed(),
fMult(0),
fPtMin(0.),
fPtMax(0.),
fPtMean(0.),
fEtaMin(0.),
fEtaMax(0.),
fPhiMin(0.),
fPhiMax(0.),
fIsInitBoltzmann(kFALSE),
fFxnBoltzmann(0)
{
//
// TGenThermalParticles::TGenThermalParticles
//
}
//_____________________________________________________________________________
TGenThermalParticles::TGenThermalParticles(const char *name, const char *title) :
TNamed(name,title),
fMult(2000),
fPtMin(0.15),
fPtMax(200.),
fPtMean(0.7),
fEtaMin(-0.9),
fEtaMax(0.9),
fPhiMin(0.),
fPhiMax(TMath::TwoPi()),
fIsInitBoltzmann(kFALSE),
fFxnBoltzmann(0)
{
//
// TGenThermalParticles::TGenThermalParticles
//
}
//_____________________________________________________________________________
TGenThermalParticles::~TGenThermalParticles()
{
//
// TGenThermalParticles::~TGenThermalParticles
//
if (fFxnBoltzmann) { delete fFxnBoltzmann; fFxnBoltzmann = 0; }
}
//_____________________________________________________________________________
Int_t TGenThermalParticles::ImportParticles(TClonesArray *pClArr, const TString sOpt)
{
Int_t ncs = CheckClArr(pClArr);
if (ncs<0) {
Error("ImportParticles", "No particle will be filled!");
return ncs;
}
//=============================================================================
if (sOpt.IsNull()) {
Error("ImportParticles", "Particle type is not defined!");
return pClArr->GetEntriesFast();
}
//=============================================================================
if (sOpt=="Boltzmann") {
InitBoltzmann();
FillBoltzmann(pClArr);
}
//=============================================================================
return pClArr->GetEntriesFast();
}
//_____________________________________________________________________________
void TGenThermalParticles::FillBoltzmann(TClonesArray *pClArr)
{
//
// TGenThermalParticles::FillBoltzmann
//
TRandom3 r3(0);
TLorentzVector vPseudo;
TParticle *particle = 0;
Int_t ncs = pClArr->GetEntriesFast();
//=============================================================================
for (Int_t i=0; i<fMult; i++) {
double dPt = fFxnBoltzmann->GetRandom(0., fPtMax);
if (dPt<fPtMin) continue;
vPseudo.SetPtEtaPhiM(dPt, r3.Uniform(fEtaMin,fEtaMax),
r3.Uniform(fPhiMin,fPhiMax), 0.);
particle = new TParticle();
particle->SetStatusCode(-1);
particle->SetMomentum(vPseudo);
new ((*pClArr)[ncs++]) TParticle(*particle);
particle = 0;
}
return;
}
//_____________________________________________________________________________
void TGenThermalParticles::InitBoltzmann()
{
//
// TGenThermalParticles::InitBoltzmann
//
if (fIsInitBoltzmann) return;
//=============================================================================
if (fFxnBoltzmann) { delete fFxnBoltzmann; fFxnBoltzmann = 0; }
fFxnBoltzmann = new TF1("fxnBoltzmann", this, &TGenThermalParticles::Boltzmann,
0., fPtMax, 1, "TGenThermalParticles", "Boltzmann");
fFxnBoltzmann->SetParameter(0, fPtMean);
fFxnBoltzmann->SetNpx(2000);
//=============================================================================
fIsInitBoltzmann = kTRUE;
//=============================================================================
return;
}
//_____________________________________________________________________________
Double_t TGenThermalParticles::Boltzmann(Double_t const *x, Double_t const *par)
{
//
// TGenThermalParticles::Boltzmann
//
Double_t dKernel = 2. * x[0] / par[0];
return (dKernel * TMath::Exp(-1.*dKernel));
}
//_____________________________________________________________________________
Int_t TGenThermalParticles::CheckClArr(TClonesArray *pClArr)
{
//
// TGenThermalParticles::CheckClArr
//
if (pClArr) {
TClass *cls = pClArr->GetClass();
if (cls) {
return pClArr->GetEntriesFast();
} else {
Warning("CheckClArr", "Redefine input TClonesArray to collect TParticle object!");
pClArr->Delete("C");
delete pClArr; pClArr = 0;
pClArr = new TClonesArray("TParticle");
return pClArr->GetEntriesFast();
}
} else {
Warning("CheckClArr", "Init input TClonesArray to collect TParticle object!");
pClArr = new TClonesArray("TParticle");
return pClArr->GetEntriesFast();
}
return pClArr->GetEntriesFast();
}