Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Pythia6.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file Pythia6.cc
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
26 // $Id: Pythia6.cc,v 1.3 2014/11/14 23:26:26 mccumber Exp $
27 //
30 
31 // ----------------------------------------------------------------------------
32 // According to TPythia6 class from Root:
33 // (The TPythia6 class is an interface class to F77 routines in Pythia6 //
34 // CERNLIB event generators, written by T.Sjostrand.)
35 // http://root.cern.ch/
36 // see http://root.cern.ch/root/License.html
37 //
38 // The complete Pythia6 documentation can be found at:
39 // http://home.thep.lu.se/~torbjorn/pythiaaux/recent.html
40 // ----------------------------------------------------------------------------
41 
42 // ******************************************************************************
43 // ******************************************************************************
44 // ** **
45 // ** **
46 // ** *......* Welcome to the Lund Monte Carlo! **
47 // ** *:::!!:::::::::::* **
48 // ** *::::::!!::::::::::::::* PPP Y Y TTTTT H H III A **
49 // ** *::::::::!!::::::::::::::::* P P Y Y T H H I A A **
50 // ** *:::::::::!!:::::::::::::::::* PPP Y T HHHHH I AAAAA **
51 // ** *:::::::::!!:::::::::::::::::* P Y T H H I A A **
52 // ** *::::::::!!::::::::::::::::*! P Y T H H III A A **
53 // ** *::::::!!::::::::::::::* !! **
54 // ** !! *:::!!:::::::::::* !! This is PYTHIA version 6.418 **
55 // ** !! !* -><- * !! Last date of change: 9 Jun 2008 **
56 // ** !! !! !! **
57 // ** !! !! !! Now is 0 Jan 2000 at 0:00:00 **
58 // ** !! !! **
59 // ** !! lh !! Disclaimer: this program comes **
60 // ** !! !! without any guarantees. Beware **
61 // ** !! hh !! of errors and use common sense **
62 // ** !! ll !! when interpreting results. **
63 // ** !! !! **
64 // ** !! Copyright T. Sjostrand (2008) **
65 // ** **
66 // ** An archive of program versions and documentation is found on the web: **
67 // ** http://www.thep.lu.se/~torbjorn/Pythia.html **
68 // ** **
69 // ** When you cite this program, the official reference is to the 6.4 manual: **
70 // ** T. Sjostrand, S. Mrenna and P. Skands, JHEP05 (2006) 026 **
71 // ** (LU TP 06-13, FERMILAB-PUB-06-052-CD-T) [hep-ph/0603175]. **
72 // ** **
73 // ** Also remember that the program, to a large extent, represents original **
74 // ** physics research. Other publications of special relevance to your **
75 // ** studies may therefore deserve separate mention. **
76 // ** **
77 // ** Main author: Torbjorn Sjostrand; Department of Theoretical Physics, **
78 // ** Lund University, Solvegatan 14A, S-223 62 Lund, Sweden; **
79 // ** phone: + 46 - 46 - 222 48 16; e-mail: torbjorn@thep.lu.se **
80 // ** Author: Stephen Mrenna; Computing Division, GDS Group, **
81 // ** Fermi National Accelerator Laboratory, MS 234, Batavia, IL 60510, USA; **
82 // ** phone: + 1 - 630 - 840 - 2556; e-mail: mrenna@fnal.gov **
83 // ** Author: Peter Skands; Theoretical Physics Department, **
84 // ** Fermi National Accelerator Laboratory, MS 106, Batavia, IL 60510, USA; **
85 // ** and CERN/PH, CH-1211 Geneva, Switzerland; **
86 // ** phone: + 41 - 22 - 767 24 59; e-mail: skands@fnal.gov **
87 // ** **
88 // ** **
89 // ******************************************************************************
90 
91 #include "Pythia6.hh"
92 
93 #include <cstdlib>
94 #include <cstring>
95 #include <iostream>
96 
97 #ifndef WIN32
98 #define pycomp pycomp_
99 #define py1ent py1ent_
100 #define type_of_call
101 #else
102 #define pycomp PYCOMP
103 #define py1ent PY1ENT
104 #define type_of_call _stdcall
105 #endif
106 
107 extern "C"
108 {
109  int type_of_call pycomp(int* kf);
110  void type_of_call py1ent(int&, int&, double&, double&, double&);
111  void* pythia6_common_address(const char*);
112 }
113 
114 Pythia6* Pythia6::fgInstance = nullptr;
115 
116 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
117 
119 {
121 
122  if (!fgInstance)
123  {
124  fgInstance = new Pythia6();
125  }
126 
127  return fgInstance;
128 }
129 
130 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
131 
133  : fParticles(nullptr)
134  , fPyjets(nullptr)
135  , fPydat1(nullptr)
136  , fPydat3(nullptr)
137 {
141 
142  // Protect against multiple objects. All access should be via the
143  // Instance member function.
144  if (fgInstance)
145  {
146  std::cerr << "There's already an instance of Pythia6" << std::endl;
147  exit(1);
148  }
149 
150  fParticles = new ParticleVector();
151 
152  // initialize common-blocks
153  fPyjets = static_cast<Pyjets_t*>(pythia6_common_address("PYJETS"));
154  fPydat1 = static_cast<Pydat1_t*>(pythia6_common_address("PYDAT1"));
155  fPydat3 = static_cast<Pydat3_t*>(pythia6_common_address("PYDAT3"));
156 
157  // turn off Pythia Logo print
158  fPydat1->MSTU[12 - 1] = 12345;
159 }
160 
161 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
162 
164 {
167 
168  if (fParticles)
169  {
170  ParticleVector::const_iterator it;
171  for (it = fParticles->begin(); it != fParticles->end(); ++it)
172  {
173  delete *it;
174  }
175  delete fParticles;
176  }
177 }
178 
179 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
180 
181 int Pythia6::Pycomp(int kf)
182 {
184 
185  return pycomp(&kf);
186 }
187 
188 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
189 
190 void Pythia6::Py1ent(int ip, int kf, double pe, double theta, double phi)
191 {
209 
210  py1ent(ip, kf, pe, theta, phi);
211 }
212 
213 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
214 
216 {
226 
227  if (particles == nullptr)
228  {
229  return 0;
230  }
231 
232  ParticleVector::const_iterator it;
233  for (it = particles->begin(); it != particles->end(); ++it)
234  {
235  delete *it;
236  }
237  particles->clear();
238 
239  int numpart = fPyjets->N;
240  int nparts = 0;
241  if (!strcmp(option, "") || !strcmp(option, "Final"))
242  {
243  for (int i = 0; i < numpart; i++)
244  {
245  if (fPyjets->K[0][i] == 1)
246  {
247  //
248  // Use the common block values for the TParticle constructor
249  //
250  particles->push_back(
251  new Pythia6Particle(
252  fPyjets->K[0][i],
253  fPyjets->K[1][i],
254  fPyjets->K[2][i],
255  fPyjets->K[3][i],
256  fPyjets->K[4][i],
257  fPyjets->P[0][i],
258  fPyjets->P[1][i],
259  fPyjets->P[2][i],
260  fPyjets->P[3][i],
261  fPyjets->P[4][i],
262  fPyjets->V[0][i],
263  fPyjets->V[1][i],
264  fPyjets->V[2][i],
265  fPyjets->V[3][i],
266  fPyjets->V[4][i]));
267 
268  // if(gDebug) printf("%d %d %d! ",i,fPyjets->K[1][i],numpart);
269  nparts++;
270  }
271  }
272  }
273  else if (!strcmp(option, "All"))
274  {
275  for (int i = 0; i < numpart; i++)
276  {
277  particles->push_back(
278  new Pythia6Particle(
279  fPyjets->K[0][i],
280  fPyjets->K[1][i],
281  fPyjets->K[2][i],
282  fPyjets->K[3][i],
283  fPyjets->K[4][i],
284  fPyjets->P[0][i],
285  fPyjets->P[1][i],
286  fPyjets->P[2][i],
287  fPyjets->P[3][i],
288  fPyjets->P[4][i],
289  fPyjets->V[0][i],
290  fPyjets->V[1][i],
291  fPyjets->V[2][i],
292  fPyjets->V[3][i],
293  fPyjets->V[4][i]));
294  }
295  nparts = numpart;
296  }
297 
298  return nparts;
299 }
300 
301 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......