forked from aiola/alice-fast-simulation
-
Notifications
You must be signed in to change notification settings - Fork 2
/
AliPythia6_dev.cxx
360 lines (310 loc) · 10.1 KB
/
AliPythia6_dev.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
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
/**************************************************************************
* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
* *
* Author: The ALICE Off-line Project. *
* Contributors are mentioned in the code where appropriate. *
* *
* Permission to use, copy, modify and distribute this software and its *
* documentation strictly for non-commercial purposes is hereby granted *
* without fee, provided that the above copyright notice appears in all *
* copies and that both the copyright notice and this permission notice *
* appear in the supporting documentation. The authors make no claims *
* about the suitability of this software for any purpose. It is *
* provided "as is" without express or implied warranty. *
**************************************************************************/
#include <iostream>
#include <TParticle.h>
#include <TClonesArray.h>
#include <AliPythiaRndm.h>
#include <AliLog.h>
#include <AliStructFuncType.h>
#include "AliPythia6_dev.h"
ClassImp(AliPythia6_dev)
#ifndef WIN32
# define pyclus pyclus_
# define pycell pycell_
# define pyshow pyshow_
# define pyrobo pyrobo_
# define pyquen pyquen_
# define pyevnw pyevnw_
# define pyshowq pyshowq_
# define qpygin0 qpygin0_
# define pytune pytune_
# define py2ent py2ent_
# define setpowwght setpowwght_
# define type_of_call
#else
# define pyclus PYCLUS
# define pycell PYCELL
# define pyrobo PYROBO
# define pyquen PYQUEN
# define pyevnw PYEVNW
# define pyshowq PYSHOWQ
# define qpygin0 QPYGIN0
# define pytune PYTUNE
# define py2ent PY2ENT
# define setpowwght SETPOWWGHT
# define type_of_call _stdcall
#endif
extern "C" void type_of_call pyclus(Int_t & );
extern "C" void type_of_call pycell(Int_t & );
extern "C" void type_of_call pyshow(Int_t &, Int_t &, Double_t &);
extern "C" void type_of_call pyrobo(Int_t &, Int_t &, Double_t &, Double_t &, Double_t &, Double_t &, Double_t &);
extern "C" void type_of_call pyquen(Double_t &, Int_t &, Double_t &);
extern "C" void type_of_call pyevnw();
extern "C" void type_of_call pyshowq(Int_t &, Int_t &, Double_t &);
extern "C" void type_of_call pytune(Int_t &);
extern "C" void type_of_call py2ent(Int_t &, Int_t&, Int_t&, Double_t&);
extern "C" void type_of_call qpygin0();
extern "C" void type_of_call setpowwght(Double_t &);
AliPythia6_dev::AliPythia6_dev():
fProcess(kPyMbDefault),
fItune(-1),
fEcms(0.),
fStrucFunc(-1),
fLHEFile(),
fNewMIS(kTRUE),
fEndOfLHEFile(kFALSE)
{
// Default Constructor
//
// Set random number
if (!AliPythiaRndm::GetPythiaRandom()) AliPythiaRndm::SetPythiaRandom(GetRandom());
}
void AliPythia6_dev::SetPtHardRange(Float_t ptmin, Float_t ptmax)
{
SetCKIN(3, ptmin);
SetCKIN(4, ptmax);
}
void AliPythia6_dev::SetYHardRange(Float_t ymin, Float_t ymax)
{
SetCKIN(7, ymin);
SetCKIN(8, ymax);
}
void AliPythia6_dev::SetInitialAndFinalStateRadiation(Int_t flag1, Int_t flag2)
{
// initial state radiation
SetMSTP(61, flag1);
// final state radiation
SetMSTP(71, flag2);
}
void AliPythia6_dev::Pytune(int itune)
{
//interface with fortran routine pytune
pytune(itune);
}
void AliPythia6_dev::ProcInit(Process_t process, Float_t energy, Int_t strucfunc, Int_t itune)
{
// Initialise the process to generate
if (!AliPythiaRndm::GetPythiaRandom()) AliPythiaRndm::SetPythiaRandom(GetRandom());
fProcess = process;
fEcms = energy;
fStrucFunc = strucfunc;
fItune = itune;
// Select the tune
if (itune > -1) Pytune(itune);
// Pythia initialisation for selected processes
// Make MSEL clean
for (Int_t i = 1; i <= 200; i++) SetMSUB(i,0);
// select charm production
switch (process) {
case kPyMbDefault:
// All soft QCD processes
SetMSEL(0);
SetMSUB(92, 1); // single diffraction AB-->XB
SetMSUB(93, 1); // single diffraction AB-->AX
SetMSUB(94, 1); // double diffraction
SetMSUB(95, 1); // low pt production
break;
case kPyMbNonDiffr:
// Inelastic non-diffractive collisions -> should correspond to experimental minimum-bias
SetMSEL(0);
SetMSUB(95, 1); // low pt production
break;
case kPyJets:
// QCD Jets
SetMSEL(1);
break;
case kPyCharm:
SetMSEL(4);
// heavy quark mass
SetPMAS(4, 1, 1.5);
break;
case kPyBeauty:
SetMSEL(5);
// heavy quark mass
SetPMAS(5, 1, 4.75);
break;
case kPyJetsPWHG:
// N.B.
// ====
// For the case of jet production the following parameter setting
// limits the transverse momentum of secondary scatterings, due
// to multiple parton interactions, to be less than that of the
// primary interaction (see POWHEG Dijet paper arXiv:1012.3380
// [hep-ph] sec. 4.1 and also the PYTHIA Manual).
SetMSTP(86,1);
// maximum number of errors before pythia aborts (def=10)
SetMSTU(22,10);
// number of warnings printed on the shell
SetMSTU(26,20);
break;
case kPyCharmPWHG:
case kPyBeautyPWHG:
// number of warnings printed on the shell
SetMSTU(26,20);
break;
default:
AliWarningStream() << "Process '" << process << "' not implemented!!" << std::endl;
break;
}
if (AliLog::GetDebugLevel("","AliPythia6_dev") >= 1 ) {
Pystat(4);
Pystat(5);
}
// Particles produced in string fragmentation point directly to either of the two endpoints
// of the string (depending in the side they were generated from).
SetMSTU(16,2);
// Select structure function
if (strucfunc >= 0) {
AliWarningStream() << "Structure function for tune " << itune << " set to " << AliStructFuncType::PDFsetName((StrucFunc_t)strucfunc).Data() << std::endl;
SetMSTP(52,2);
SetMSTP(51, AliStructFuncType::PDFsetIndex((StrucFunc_t)strucfunc));
}
// Initialize PYTHIA
if (!fLHEFile.IsNull() && (process == kPyJetsPWHG || process == kPyCharmPWHG || process == kPyBeautyPWHG)) {
char* fname = new char[fLHEFile.Length() + 1];
strcpy(fname, fLHEFile.Data());
AliInfoStream() << "Opening LHE file '" << fname << "'" << std::endl;
OpenFortranFile(97, fname);
delete[] fname;
Initialize("USER","","",0.);
}
else {
Initialize("CMS", "p", "p", fEcms);
}
}
void AliPythia6_dev::SetDecayOff(const std::set<int>& pdg_codes)
{
for (auto pdg : pdg_codes) SetMDCY(Pycomp(pdg), 1, 0);
}
Int_t AliPythia6_dev::CheckedLuComp(Int_t kf)
{
// Check Lund particle code (for debugging)
Int_t kc = Pycomp(kf);
AliInfoStream() << "Lucomp kf = " << kf << ", kc = " << kc << std::endl;
return kc;
}
void AliPythia6_dev::SetNuclei(Int_t a1, Int_t a2, Int_t pdf)
{
// Treat protons as inside nuclei with mass numbers a1 and a2
// The MSTP array in the PYPARS common block is used to enable and
// select the nuclear structure functions.
// MSTP(52) : (D=1) choice of proton and nuclear structure-function library
// =1: internal PYTHIA acording to MSTP(51)
// =2: PDFLIB proton s.f., with MSTP(51) = 1000xNGROUP+NSET
// If the following mass number both not equal zero, nuclear corrections of the stf are used.
// MSTP(192) : Mass number of nucleus side 1
// MSTP(193) : Mass number of nucleus side 2
// MSTP(194) : Nuclear structure function: 0: EKS98 8:EPS08 9:EPS09LO 19:EPS09NLO
SetMSTP(52,2);
SetMSTP(192, a1);
SetMSTP(193, a2);
SetMSTP(194, pdf);
}
void AliPythia6_dev::GenerateEvent()
{
if (EndOfLHEFileReached()) return;
if (fNewMIS) {
Pyevnw();
}
else {
Pyevnt();
}
// See page 320 of the PYTHIA manual
if (!fLHEFile.IsNull() && GetN() == 0 && GetMSTI(51) > 0) {
fEndOfLHEFile = kTRUE;
AliInfoStream() << "The end of the LHE file was reached. Stopping event generation." << std::endl;
}
}
void AliPythia6_dev::EventListing()
{
return Pylist(2);
}
void AliPythia6_dev::PrintParticles()
{
// Print list of particl properties
Int_t np = 0;
char* name = new char[16];
for (Int_t kf=0; kf<1000000; kf++) {
for (Int_t c = 1; c > -2; c-=2) {
Int_t kc = Pycomp(c*kf);
if (kc) {
Float_t mass = GetPMAS(kc,1);
Float_t width = GetPMAS(kc,2);
Float_t tau = GetPMAS(kc,4);
Pyname(kf,name);
np++;
AliInfoStream() << c*kf << " " << name << ", mass " << mass << ", width " << width << ", tau " << tau << std::endl;
}
}
}
AliInfoStream() << "Number of particles " << np << std::endl;
}
void AliPythia6_dev::Pyshow(Int_t ip1, Int_t ip2, Double_t qmax)
{
// Call Pythia jet reconstruction algorithm
//
pyshow(ip1, ip2, qmax);
}
Float_t AliPythia6_dev::GetXSection()
{
AliDebugStream(2) << "GetPARI(1) = " << GetPARI(1) << std::endl;
return GetPARI(1);
}
Int_t AliPythia6_dev::ProcessCode()
{
return GetMSTI(1);
}
void AliPythia6_dev::PrintStatistics()
{
Pystat(1);
}
Float_t AliPythia6_dev::GetEventWeight()
{
AliDebugStream(2) << "GetPARI(7) = " << GetPARI(7) << ", GetPARI(10) = " << GetPARI(10) << std::endl;
return GetPARI(7) * GetPARI(10);
// PARI(7) is the weight coming from the user process, e.g. POWHEG
// GetVINT(97) is the same as GetPARI(7);
// PARI(10) is a weight coming from PYTHIA when SetMSTP(142, 1) was set
}
void AliPythia6_dev::SetWeightPower(Double_t pow)
{
setpowwght(pow);
SetMSTP(142, 1); // Tell Pythia to use pyevwt to calculate event wghts
if (GetCKIN(3) <= 0) AliWarningStream() << "Need to set minimum p_T,hard to nonzero value for weighted event generation" << std::endl;
}
Float_t AliPythia6_dev::GetPtHard()
{
return GetVINT(47);
}
void AliPythia6_dev::Pyevnw()
{
// New multiple interaction scenario
pyevnw();
}
Int_t AliPythia6_dev::GetNMPI()
{
// returns the number of parton-parton interactions
return (GetMSTI(31));
}
Int_t AliPythia6_dev::GetParticles(TClonesArray *particles)
{
Int_t n = ImportParticles(particles, "All");
for (auto obj : *particles) {
TParticle* p = static_cast<TParticle*>(obj);
p->SetFirstMother(p->GetFirstMother() - 1);
p->SetLastMother(p->GetSecondMother() - 1);
}
return n;
}