ECCE @ 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 //
29 
30 // ----------------------------------------------------------------------------
31 // According to TPythia6 class from Root:
32 // (The TPythia6 class is an interface class to F77 routines in Pythia6 //
33 // CERNLIB event generators, written by T.Sjostrand.)
34 // http://root.cern.ch/
35 // see http://root.cern.ch/root/License.html
36 //
37 // The complete Pythia6 documentation can be found at:
38 // http://home.thep.lu.se/~torbjorn/pythiaaux/recent.html
39 // ----------------------------------------------------------------------------
40 
41 // ******************************************************************************
42 // ******************************************************************************
43 // ** **
44 // ** **
45 // ** *......* Welcome to the Lund Monte Carlo! **
46 // ** *:::!!:::::::::::* **
47 // ** *::::::!!::::::::::::::* PPP Y Y TTTTT H H III A **
48 // ** *::::::::!!::::::::::::::::* P P Y Y T H H I A A **
49 // ** *:::::::::!!:::::::::::::::::* PPP Y T HHHHH I AAAAA **
50 // ** *:::::::::!!:::::::::::::::::* P Y T H H I A A **
51 // ** *::::::::!!::::::::::::::::*! P Y T H H III A A **
52 // ** *::::::!!::::::::::::::* !! **
53 // ** !! *:::!!:::::::::::* !! This is PYTHIA version 6.418 **
54 // ** !! !* -><- * !! Last date of change: 9 Jun 2008 **
55 // ** !! !! !! **
56 // ** !! !! !! Now is 0 Jan 2000 at 0:00:00 **
57 // ** !! !! **
58 // ** !! lh !! Disclaimer: this program comes **
59 // ** !! !! without any guarantees. Beware **
60 // ** !! hh !! of errors and use common sense **
61 // ** !! ll !! when interpreting results. **
62 // ** !! !! **
63 // ** !! Copyright T. Sjostrand (2008) **
64 // ** **
65 // ** An archive of program versions and documentation is found on the web: **
66 // ** http://www.thep.lu.se/~torbjorn/Pythia.html **
67 // ** **
68 // ** When you cite this program, the official reference is to the 6.4 manual: **
69 // ** T. Sjostrand, S. Mrenna and P. Skands, JHEP05 (2006) 026 **
70 // ** (LU TP 06-13, FERMILAB-PUB-06-052-CD-T) [hep-ph/0603175]. **
71 // ** **
72 // ** Also remember that the program, to a large extent, represents original **
73 // ** physics research. Other publications of special relevance to your **
74 // ** studies may therefore deserve separate mention. **
75 // ** **
76 // ** Main author: Torbjorn Sjostrand; Department of Theoretical Physics, **
77 // ** Lund University, Solvegatan 14A, S-223 62 Lund, Sweden; **
78 // ** phone: + 46 - 46 - 222 48 16; e-mail: torbjorn@thep.lu.se **
79 // ** Author: Stephen Mrenna; Computing Division, GDS Group, **
80 // ** Fermi National Accelerator Laboratory, MS 234, Batavia, IL 60510, USA; **
81 // ** phone: + 1 - 630 - 840 - 2556; e-mail: mrenna@fnal.gov **
82 // ** Author: Peter Skands; Theoretical Physics Department, **
83 // ** Fermi National Accelerator Laboratory, MS 106, Batavia, IL 60510, USA; **
84 // ** and CERN/PH, CH-1211 Geneva, Switzerland; **
85 // ** phone: + 41 - 22 - 767 24 59; e-mail: skands@fnal.gov **
86 // ** **
87 // ** **
88 // ******************************************************************************
89 
90 #include "Pythia6.hh"
91 
92 #include <iostream>
93 #include <cstdlib>
94 #include <cstring>
95 
96 #ifndef WIN32
97 # define pycomp pycomp_
98 # define py1ent py1ent_
99 # define type_of_call
100 #else
101 # define pycomp PYCOMP
102 # define py1ent PY1ENT
103 # define type_of_call _stdcall
104 #endif
105 
106 // pythia6 functions
107 extern "C" {
108  int type_of_call pycomp(int *kf);
109  void type_of_call py1ent(int&, int&, double&, double&, double&);
110  void* pythia6_common_address(const char*);
111 }
112 
113 // Direct declaration of pythia6 common blocks
114 // extern "C" {
115 // extern Pyjets_t pyjets_;
116 // extern Pydat1_t pydat1_;
117 // extern Pydat3_t pydat3_;
118 // }
119 
121 
122 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
123 
125 {
127 
128  if ( ! fgInstance ) fgInstance = new Pythia6();
129 
130  return fgInstance;
131 }
132 
133 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
134 
136  : fParticles(0),
137  fPyjets(0),
138  fPydat1(0),
139  fPydat3(0)
140 {
144 
145  // Protect against multiple objects. All access should be via the
146  // Instance member function.
147  if ( fgInstance ) {
148  std::cerr << "There's already an instance of Pythia6" << std::endl;
149  exit (1);
150  }
151 
152  fParticles = new ParticleVector();
153 
154  // Initialize common-blocks
155  fPyjets = (Pyjets_t*) pythia6_common_address("PYJETS");
156  fPydat1 = (Pydat1_t*) pythia6_common_address("PYDAT1");
157  fPydat3 = (Pydat3_t*) pythia6_common_address("PYDAT3");
158 
159  // Alternative way to initialize common-blocks
160  // usind direct declaration of pythia6 common blocks
161  // fPyjets = &pyjets_;
162  // fPydat1 = &pydat1_;
163  // fPydat3 = &pydat3_;
164 }
165 
166 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
167 
169 {
172 
173  if ( fParticles ) {
174  ParticleVector::const_iterator it;
175  for ( it = fParticles->begin(); it != fParticles->end(); it++ )
176  delete *it;
177  delete fParticles;
178  }
179 }
180 
181 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
182 
183 int Pythia6::Pycomp(int kf)
184 {
186 
187  return pycomp(&kf);
188 }
189 
190 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
191 
192 void Pythia6::Py1ent(int ip, int kf, double pe, double theta, double phi)
193 {
211 
212  py1ent(ip, kf, pe, theta, phi);
213 }
214 
215 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
216 
217 int Pythia6::ImportParticles(ParticleVector* particles, const char* option)
218 {
228 
229  if ( particles == 0 ) return 0;
230 
231  ParticleVector::const_iterator it;
232  for ( it = particles->begin(); it != particles->end(); it++ )
233  delete *it;
234  particles->clear();
235 
236  int numpart = fPyjets->N;
237  int nparts=0;
238  if (!strcmp(option,"") || !strcmp(option,"Final")) {
239  for (int i = 0; i<numpart; i++) {
240 
241  if (fPyjets->K[0][i] == 1) {
242  //
243  // Use the common block values for the TParticle constructor
244  //
245  particles->push_back(
246  new Pythia6Particle(
247  fPyjets->K[0][i] ,
248  fPyjets->K[1][i] ,
249  fPyjets->K[2][i] ,
250  fPyjets->K[3][i] ,
251  fPyjets->K[4][i] ,
252  fPyjets->P[0][i] ,
253  fPyjets->P[1][i] ,
254  fPyjets->P[2][i] ,
255  fPyjets->P[3][i] ,
256  fPyjets->P[4][i] ,
257  fPyjets->V[0][i] ,
258  fPyjets->V[1][i] ,
259  fPyjets->V[2][i] ,
260  fPyjets->V[3][i] ,
261  fPyjets->V[4][i]));
262 
263  // if(gDebug) printf("%d %d %d! ",i,fPyjets->K[1][i],numpart);
264  nparts++;
265  }
266  }
267  }
268  else if (!strcmp(option,"All")) {
269  for (int i = 0; i<numpart; i++) {
270  particles->push_back(
271  new Pythia6Particle(
272  fPyjets->K[0][i] ,
273  fPyjets->K[1][i] ,
274  fPyjets->K[2][i] ,
275  fPyjets->K[3][i] ,
276  fPyjets->K[4][i] ,
277  fPyjets->P[0][i] ,
278  fPyjets->P[1][i] ,
279  fPyjets->P[2][i] ,
280  fPyjets->P[3][i] ,
281  fPyjets->P[4][i] ,
282  fPyjets->V[0][i] ,
283  fPyjets->V[1][i] ,
284  fPyjets->V[2][i] ,
285  fPyjets->V[3][i] ,
286  fPyjets->V[4][i]));
287  }
288  nparts=numpart;
289  }
290 
291  return nparts;
292 }
293 
294 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......