Geant4  10.03
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 100687 2016-10-31 11:20:33Z 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 // pythia6 functions
108 extern "C" {
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 // Direct declaration of pythia6 common blocks
115 // extern "C" {
116 // extern Pyjets_t pyjets_;
117 // extern Pydat1_t pydat1_;
118 // extern Pydat3_t pydat3_;
119 // }
120 
122 
123 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
124 
126 {
128 
129  if ( ! fgInstance ) fgInstance = new Pythia6();
130 
131  return fgInstance;
132 }
133 
134 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
135 
137  : fParticles(0),
138  fPyjets(0),
139  fPydat1(0),
140  fPydat3(0)
141 {
145 
146  // Protect against multiple objects. All access should be via the
147  // Instance member function.
148  if ( fgInstance ) {
149  std::cerr << "There's already an instance of Pythia6" << std::endl;
150  exit (1);
151  }
152 
153  fParticles = new ParticleVector();
154 
155  // Initialize common-blocks
156  fPyjets = (Pyjets_t*) pythia6_common_address("PYJETS");
157  fPydat1 = (Pydat1_t*) pythia6_common_address("PYDAT1");
158  fPydat3 = (Pydat3_t*) pythia6_common_address("PYDAT3");
159 
160  // Alternative way to initialize common-blocks
161  // usind direct declaration of pythia6 common blocks
162  // fPyjets = &pyjets_;
163  // fPydat1 = &pydat1_;
164  // fPydat3 = &pydat3_;
165 }
166 
167 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
168 
170 {
173 
174  if ( fParticles ) {
175  ParticleVector::const_iterator it;
176  for ( it = fParticles->begin(); it != fParticles->end(); it++ )
177  delete *it;
178  delete fParticles;
179  }
180 }
181 
182 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
183 
184 int Pythia6::Pycomp(int kf)
185 {
187 
188  return pycomp(&kf);
189 }
190 
191 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
192 
193 void Pythia6::Py1ent(int ip, int kf, double pe, double theta, double phi)
194 {
212 
213  py1ent(ip, kf, pe, theta, phi);
214 }
215 
216 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
217 
218 int Pythia6::ImportParticles(ParticleVector* particles, const char* option)
219 {
229 
230  if ( particles == 0 ) return 0;
231 
232  ParticleVector::const_iterator it;
233  for ( it = particles->begin(); it != particles->end(); it++ )
234  delete *it;
235  particles->clear();
236 
237  int numpart = fPyjets->N;
238  int nparts=0;
239  if (!strcmp(option,"") || !strcmp(option,"Final")) {
240  for (int i = 0; i<numpart; i++) {
241 
242  if (fPyjets->K[0][i] == 1) {
243  //
244  // Use the common block values for the TParticle constructor
245  //
246  particles->push_back(
247  new Pythia6Particle(
248  fPyjets->K[0][i] ,
249  fPyjets->K[1][i] ,
250  fPyjets->K[2][i] ,
251  fPyjets->K[3][i] ,
252  fPyjets->K[4][i] ,
253  fPyjets->P[0][i] ,
254  fPyjets->P[1][i] ,
255  fPyjets->P[2][i] ,
256  fPyjets->P[3][i] ,
257  fPyjets->P[4][i] ,
258  fPyjets->V[0][i] ,
259  fPyjets->V[1][i] ,
260  fPyjets->V[2][i] ,
261  fPyjets->V[3][i] ,
262  fPyjets->V[4][i]));
263 
264  // if(gDebug) printf("%d %d %d! ",i,fPyjets->K[1][i],numpart);
265  nparts++;
266  }
267  }
268  }
269  else if (!strcmp(option,"All")) {
270  for (int i = 0; i<numpart; i++) {
271  particles->push_back(
272  new Pythia6Particle(
273  fPyjets->K[0][i] ,
274  fPyjets->K[1][i] ,
275  fPyjets->K[2][i] ,
276  fPyjets->K[3][i] ,
277  fPyjets->K[4][i] ,
278  fPyjets->P[0][i] ,
279  fPyjets->P[1][i] ,
280  fPyjets->P[2][i] ,
281  fPyjets->P[3][i] ,
282  fPyjets->P[4][i] ,
283  fPyjets->V[0][i] ,
284  fPyjets->V[1][i] ,
285  fPyjets->V[2][i] ,
286  fPyjets->V[3][i] ,
287  fPyjets->V[4][i]));
288  }
289  nparts=numpart;
290  }
291 
292  return nparts;
293 }
294 
295 //....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:136
static Pythia6 * Instance()
Definition: Pythia6.cc:125
int Pycomp(int kf)
Definition: Pythia6.cc:184
#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:193
int N
Definition: Pythia6.hh:93
virtual ~Pythia6()
Definition: Pythia6.cc:169
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