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 ] [ 10.5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

  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 //
 27 /// \file eventgenerator/pythia/decayer6/src/Pythia6.cc
 28 /// \brief Implementation of the Pythia6 class
 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 <cstdlib>
 93 #include <cstring>
 94 #include <iostream>
 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 {
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 
121 Pythia6* Pythia6::fgInstance = 0;
122 
123 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
124 
125 Pythia6* Pythia6::Instance()
126 {
127   /// Static access method
128 
129   if (!fgInstance) fgInstance = new Pythia6();
130 
131   return fgInstance;
132 }
133 
134 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
135 
136 Pythia6::Pythia6() : fParticles(0), fPyjets(0), fPydat1(0), fPydat3(0)
137 {
138   /// Pythia6 constructor: creates a vector of Pythia6Particle in which it will
139   /// store all particles. Note that there may be only one functional Pythia6
140   /// object at a time, so it's not use to create more than one instance of it.
141 
142   // Protect against multiple objects.   All access should be via the
143   // Instance member function.
144   if (fgInstance) {
145     std::cerr << "There's already an instance of Pythia6" << std::endl;
146     exit(1);
147   }
148 
149   fParticles = new ParticleVector();
150 
151   // Initialize common-blocks
152   fPyjets = (Pyjets_t*)pythia6_common_address("PYJETS");
153   fPydat1 = (Pydat1_t*)pythia6_common_address("PYDAT1");
154   fPydat3 = (Pydat3_t*)pythia6_common_address("PYDAT3");
155 
156   // Alternative way to initialize common-blocks
157   // usind direct declaration of pythia6 common blocks
158   // fPyjets = &pyjets_;
159   // fPydat1 = &pydat1_;
160   // fPydat3 = &pydat3_;
161 }
162 
163 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
164 
165 Pythia6::~Pythia6()
166 {
167   /// Destroy the object, delete and dispose all Pythia6Particles currently on
168   /// list.
169 
170   if (fParticles) {
171     ParticleVector::const_iterator it;
172     for (it = fParticles->begin(); it != fParticles->end(); it++)
173       delete *it;
174     delete fParticles;
175   }
176 }
177 
178 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
179 
180 int Pythia6::Pycomp(int kf)
181 {
182   /// Interface with fortran routine pycomp
183 
184   return pycomp(&kf);
185 }
186 
187 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
188 
189 void Pythia6::Py1ent(int ip, int kf, double pe, double theta, double phi)
190 {
191   /// Add one entry to the event record, i.e. either a parton or a
192   /// particle.
193   ///
194   ///  IP:   normally line number for the parton/particle. There are two
195   ///        exceptions:
196   ///
197   ///        If IP = 0: line number 1 is used and PYEXEC is called.
198   ///        If IP < 0: line -IP is used, with status code K(-IP,2)=2
199   ///                   rather than 1; thus a parton system may be built
200   ///                   up by filling all but the last parton of the
201   ///                   system with IP < 0.
202   ///  KF:   parton/particle flavour code (PDG code)
203   ///  PE:   parton/particle energy. If PE is smaller than the mass,
204   ///        the parton/particle is taken to be at rest.
205   ///  THETA:
206   ///  PHI:  polar and azimuthal angle for the momentum vector of the
207   ///        parton/particle.
208 
209   py1ent(ip, kf, pe, theta, phi);
210 }
211 
212 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
213 
214 int Pythia6::ImportParticles(ParticleVector* particles, const char* option)
215 {
216   ///  Default primary creation method. It reads the /HEPEVT/ common block which
217   ///  has been filled by the GenerateEvent method. If the event generator does
218   ///  not use the HEPEVT common block, This routine has to be overloaded by
219   ///  the subclasses.
220   ///  The function loops on the generated particles and store them in
221   ///  the TClonesArray pointed by the argument particles.
222   ///  The default action is to store only the stable particles (ISTHEP = 1)
223   ///  This can be demanded explicitly by setting the option = "Final"
224   ///  If the option = "All", all the particles are stored.
225 
226   if (particles == 0) return 0;
227 
228   ParticleVector::const_iterator it;
229   for (it = particles->begin(); it != particles->end(); it++)
230     delete *it;
231   particles->clear();
232 
233   int numpart = fPyjets->N;
234   int nparts = 0;
235   if (!strcmp(option, "") || !strcmp(option, "Final")) {
236     for (int i = 0; i < numpart; i++) {
237       if (fPyjets->K[0][i] == 1) {
238         //
239         //  Use the common block values for the TParticle constructor
240         //
241         particles->push_back(new Pythia6Particle(
242           fPyjets->K[0][i], fPyjets->K[1][i], fPyjets->K[2][i], fPyjets->K[3][i], fPyjets->K[4][i],
243           fPyjets->P[0][i], fPyjets->P[1][i], fPyjets->P[2][i], fPyjets->P[3][i], fPyjets->P[4][i],
244           fPyjets->V[0][i], fPyjets->V[1][i], fPyjets->V[2][i], fPyjets->V[3][i],
245           fPyjets->V[4][i]));
246 
247         //     if(gDebug) printf("%d %d %d! ",i,fPyjets->K[1][i],numpart);
248         nparts++;
249       }
250     }
251   }
252   else if (!strcmp(option, "All")) {
253     for (int i = 0; i < numpart; i++) {
254       particles->push_back(new Pythia6Particle(
255         fPyjets->K[0][i], fPyjets->K[1][i], fPyjets->K[2][i], fPyjets->K[3][i], fPyjets->K[4][i],
256         fPyjets->P[0][i], fPyjets->P[1][i], fPyjets->P[2][i], fPyjets->P[3][i], fPyjets->P[4][i],
257         fPyjets->V[0][i], fPyjets->V[1][i], fPyjets->V[2][i], fPyjets->V[3][i], fPyjets->V[4][i]));
258     }
259     nparts = numpart;
260   }
261 
262   return nparts;
263 }
264 
265 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
266