EIC 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 
115 
116 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
117 
119 {
121 
122  if (!fgInstance) fgInstance = new Pythia6();
123 
124  return fgInstance;
125 }
126 
127 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
128 
130  : fParticles(0)
131  , fPyjets(0)
132  , fPydat1(0)
133  , fPydat3(0)
134 {
138 
139  // Protect against multiple objects. All access should be via the
140  // Instance member function.
141  if (fgInstance)
142  {
143  std::cerr << "There's already an instance of Pythia6" << std::endl;
144  exit(1);
145  }
146 
147  fParticles = new ParticleVector();
148 
149  // initialize common-blocks
150  fPyjets = static_cast<Pyjets_t*>(pythia6_common_address("PYJETS"));
151  fPydat1 = static_cast<Pydat1_t*>(pythia6_common_address("PYDAT1"));
152  fPydat3 = static_cast<Pydat3_t*>(pythia6_common_address("PYDAT3"));
153 
154  // turn off Pythia Logo print
155  fPydat1->MSTU[12 - 1] = 12345;
156 }
157 
158 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
159 
161 {
164 
165  if (fParticles)
166  {
167  ParticleVector::const_iterator it;
168  for (it = fParticles->begin(); it != fParticles->end(); ++it)
169  delete *it;
170  delete fParticles;
171  }
172 }
173 
174 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
175 
176 int Pythia6::Pycomp(int kf)
177 {
179 
180  return pycomp(&kf);
181 }
182 
183 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
184 
185 void Pythia6::Py1ent(int ip, int kf, double pe, double theta, double phi)
186 {
204 
205  py1ent(ip, kf, pe, theta, phi);
206 }
207 
208 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
209 
210 int Pythia6::ImportParticles(ParticleVector* particles, const char* option)
211 {
221 
222  if (particles == 0) return 0;
223 
224  ParticleVector::const_iterator it;
225  for (it = particles->begin(); it != particles->end(); ++it)
226  delete *it;
227  particles->clear();
228 
229  int numpart = fPyjets->N;
230  int nparts = 0;
231  if (!strcmp(option, "") || !strcmp(option, "Final"))
232  {
233  for (int i = 0; i < numpart; i++)
234  {
235  if (fPyjets->K[0][i] == 1)
236  {
237  //
238  // Use the common block values for the TParticle constructor
239  //
240  particles->push_back(
241  new Pythia6Particle(
242  fPyjets->K[0][i],
243  fPyjets->K[1][i],
244  fPyjets->K[2][i],
245  fPyjets->K[3][i],
246  fPyjets->K[4][i],
247  fPyjets->P[0][i],
248  fPyjets->P[1][i],
249  fPyjets->P[2][i],
250  fPyjets->P[3][i],
251  fPyjets->P[4][i],
252  fPyjets->V[0][i],
253  fPyjets->V[1][i],
254  fPyjets->V[2][i],
255  fPyjets->V[3][i],
256  fPyjets->V[4][i]));
257 
258  // if(gDebug) printf("%d %d %d! ",i,fPyjets->K[1][i],numpart);
259  nparts++;
260  }
261  }
262  }
263  else if (!strcmp(option, "All"))
264  {
265  for (int i = 0; i < numpart; i++)
266  {
267  particles->push_back(
268  new Pythia6Particle(
269  fPyjets->K[0][i],
270  fPyjets->K[1][i],
271  fPyjets->K[2][i],
272  fPyjets->K[3][i],
273  fPyjets->K[4][i],
274  fPyjets->P[0][i],
275  fPyjets->P[1][i],
276  fPyjets->P[2][i],
277  fPyjets->P[3][i],
278  fPyjets->P[4][i],
279  fPyjets->V[0][i],
280  fPyjets->V[1][i],
281  fPyjets->V[2][i],
282  fPyjets->V[3][i],
283  fPyjets->V[4][i]));
284  }
285  nparts = numpart;
286  }
287 
288  return nparts;
289 }
290 
291 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......