Geant4  10.01
Pythia6.cc
Go to the documentation of this file.
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 72244 2013-07-12 08:49:56Z gcosmo $
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 <iostream>
94 #include <cstdlib>
95 #include <cstring>
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  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 
114 
115 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
116 
118 {
120 
121  if ( ! fgInstance ) fgInstance = new Pythia6();
122 
123  return fgInstance;
124 }
125 
126 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
127 
129  : fParticles(0),
130  fPyjets(0),
131  fPydat1(0),
132  fPydat3(0)
133 {
137 
138  // Protect against multiple objects. All access should be via the
139  // Instance member function.
140  if ( fgInstance ) {
141  std::cerr << "There's already an instance of Pythia6" << std::endl;
142  exit (1);
143  }
144 
145  fParticles = new ParticleVector();
146 
147  // initialize common-blocks
148  fPyjets = (Pyjets_t*) pythia6_common_address("PYJETS");
149  fPydat1 = (Pydat1_t*) pythia6_common_address("PYDAT1");
150  fPydat3 = (Pydat3_t*) pythia6_common_address("PYDAT3");
151 }
152 
153 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
154 
156 {
159 
160  if ( fParticles ) {
161  ParticleVector::const_iterator it;
162  for ( it = fParticles->begin(); it != fParticles->end(); it++ )
163  delete *it;
164  delete fParticles;
165  }
166 }
167 
168 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
169 
170 int Pythia6::Pycomp(int kf)
171 {
173 
174  return pycomp(&kf);
175 }
176 
177 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
178 
179 void Pythia6::Py1ent(int ip, int kf, double pe, double theta, double phi)
180 {
198 
199  py1ent(ip, kf, pe, theta, phi);
200 }
201 
202 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
203 
204 int Pythia6::ImportParticles(ParticleVector* particles, const char* option)
205 {
215 
216  if ( particles == 0 ) return 0;
217 
218  ParticleVector::const_iterator it;
219  for ( it = particles->begin(); it != particles->end(); it++ )
220  delete *it;
221  particles->clear();
222 
223  int numpart = fPyjets->N;
224  int nparts=0;
225  if (!strcmp(option,"") || !strcmp(option,"Final")) {
226  for (int i = 0; i<numpart; i++) {
227 
228  if (fPyjets->K[0][i] == 1) {
229  //
230  // Use the common block values for the TParticle constructor
231  //
232  particles->push_back(
233  new Pythia6Particle(
234  fPyjets->K[0][i] ,
235  fPyjets->K[1][i] ,
236  fPyjets->K[2][i] ,
237  fPyjets->K[3][i] ,
238  fPyjets->K[4][i] ,
239  fPyjets->P[0][i] ,
240  fPyjets->P[1][i] ,
241  fPyjets->P[2][i] ,
242  fPyjets->P[3][i] ,
243  fPyjets->P[4][i] ,
244  fPyjets->V[0][i] ,
245  fPyjets->V[1][i] ,
246  fPyjets->V[2][i] ,
247  fPyjets->V[3][i] ,
248  fPyjets->V[4][i]));
249 
250  // if(gDebug) printf("%d %d %d! ",i,fPyjets->K[1][i],numpart);
251  nparts++;
252  }
253  }
254  }
255  else if (!strcmp(option,"All")) {
256  for (int i = 0; i<numpart; i++) {
257  particles->push_back(
258  new Pythia6Particle(
259  fPyjets->K[0][i] ,
260  fPyjets->K[1][i] ,
261  fPyjets->K[2][i] ,
262  fPyjets->K[3][i] ,
263  fPyjets->K[4][i] ,
264  fPyjets->P[0][i] ,
265  fPyjets->P[1][i] ,
266  fPyjets->P[2][i] ,
267  fPyjets->P[3][i] ,
268  fPyjets->P[4][i] ,
269  fPyjets->V[0][i] ,
270  fPyjets->V[1][i] ,
271  fPyjets->V[2][i] ,
272  fPyjets->V[3][i] ,
273  fPyjets->V[4][i]));
274  }
275  nparts=numpart;
276  }
277 
278  return nparts;
279 }
280 
281 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#define pycomp
Definition: Pythia6.cc:98
ParticleVector * fParticles
Definition: Pythia6.hh:194
Pydat1_t * fPydat1
Definition: Pythia6.hh:196
#define type_of_call
Definition: Pythia6.cc:100
static Pythia6 * fgInstance
Definition: Pythia6.hh:192
Pythia6()
Definition: Pythia6.cc:128
static Pythia6 * Instance()
Definition: Pythia6.cc:117
int Pycomp(int kf)
Definition: Pythia6.cc:170
#define py1ent
Definition: Pythia6.cc:99
PYDAT3 common-block.
Definition: Pythia6.hh:110
void * pythia6_common_address(const char *)
Structure for Pythia6 particle properties.
Definition: Pythia6.hh:119
void Py1ent(int line, int kf, double pe, double theta, double phi)
Definition: Pythia6.cc:179
int N
Definition: Pythia6.hh:93
virtual ~Pythia6()
Definition: Pythia6.cc:155
std::vector< Pythia6Particle * > ParticleVector
Definition: Pythia6.hh:149
ParticleVector * ImportParticles()
The C++ interface class to Pythia6.
Definition: Pythia6.hh:163
double P[5][4000]
Definition: Pythia6.hh:96
PYJETS common-block.
Definition: Pythia6.hh:91
Definition of the Pythia6 class.
int K[5][4000]
Definition: Pythia6.hh:95
double V[5][4000]
Definition: Pythia6.hh:97
Pyjets_t * fPyjets
Definition: Pythia6.hh:195
Pydat3_t * fPydat3
Definition: Pythia6.hh:197
PYDAT1 common-block.
Definition: Pythia6.hh:101