Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-23 09:21:10

0001 //
0002 // ********************************************************************
0003 // * License and Disclaimer                                           *
0004 // *                                                                  *
0005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
0006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
0007 // * conditions of the Geant4 Software License,  included in the file *
0008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
0009 // * include a list of copyright holders.                             *
0010 // *                                                                  *
0011 // * Neither the authors of this software system, nor their employing *
0012 // * institutes,nor the agencies providing financial support for this *
0013 // * work  make  any representation or  warranty, express or implied, *
0014 // * regarding  this  software system or assume any liability for its *
0015 // * use.  Please see the license in the file  LICENSE  and URL above *
0016 // * for the full disclaimer and the limitation of liability.         *
0017 // *                                                                  *
0018 // * This  code  implementation is the result of  the  scientific and *
0019 // * technical work of the GEANT4 collaboration.                      *
0020 // * By using,  copying,  modifying or  distributing the software (or *
0021 // * any work based  on the software)  you  agree  to acknowledge its *
0022 // * use  in  resulting  scientific  publications,  and indicate your *
0023 // * acceptance of all terms of the Geant4 Software license.          *
0024 // ********************************************************************
0025 //
0026 //
0027 /// \file eventgenerator/pythia/decayer6/src/Pythia6.cc
0028 /// \brief Implementation of the Pythia6 class
0029 
0030 // ----------------------------------------------------------------------------
0031 // According to TPythia6 class from Root:
0032 // (The TPythia6 class is an interface class to F77 routines in Pythia6                //
0033 // CERNLIB event generators, written by T.Sjostrand.)
0034 // http://root.cern.ch/
0035 // see http://root.cern.ch/root/License.html
0036 //
0037 // The complete Pythia6 documentation can be found at:
0038 // http://home.thep.lu.se/~torbjorn/pythiaaux/recent.html
0039 // ----------------------------------------------------------------------------
0040 
0041 // ******************************************************************************
0042 // ******************************************************************************
0043 // **                                                                          **
0044 // **                                                                          **
0045 // **              *......*                  Welcome to the Lund Monte Carlo!  **
0046 // **         *:::!!:::::::::::*                                               **
0047 // **      *::::::!!::::::::::::::*          PPP  Y   Y TTTTT H   H III   A    **
0048 // **    *::::::::!!::::::::::::::::*        P  P  Y Y    T   H   H  I   A A   **
0049 // **   *:::::::::!!:::::::::::::::::*       PPP    Y     T   HHHHH  I  AAAAA  **
0050 // **   *:::::::::!!:::::::::::::::::*       P      Y     T   H   H  I  A   A  **
0051 // **    *::::::::!!::::::::::::::::*!       P      Y     T   H   H III A   A  **
0052 // **      *::::::!!::::::::::::::* !!                                         **
0053 // **      !! *:::!!:::::::::::*    !!       This is PYTHIA version 6.418      **
0054 // **      !!     !* -><- *         !!       Last date of change:  9 Jun 2008  **
0055 // **      !!     !!                !!                                         **
0056 // **      !!     !!                !!       Now is  0 Jan 2000 at  0:00:00    **
0057 // **      !!                       !!                                         **
0058 // **      !!        lh             !!       Disclaimer: this program comes    **
0059 // **      !!                       !!       without any guarantees. Beware    **
0060 // **      !!                 hh    !!       of errors and use common sense    **
0061 // **      !!    ll                 !!       when interpreting results.        **
0062 // **      !!                       !!                                         **
0063 // **      !!                                Copyright T. Sjostrand (2008)     **
0064 // **                                                                          **
0065 // ** An archive of program versions and documentation is found on the web:    **
0066 // ** http://www.thep.lu.se/~torbjorn/Pythia.html                              **
0067 // **                                                                          **
0068 // ** When you cite this program, the official reference is to the 6.4 manual: **
0069 // ** T. Sjostrand, S. Mrenna and P. Skands, JHEP05 (2006) 026                 **
0070 // ** (LU TP 06-13, FERMILAB-PUB-06-052-CD-T) [hep-ph/0603175].                **
0071 // **                                                                          **
0072 // ** Also remember that the program, to a large extent, represents original   **
0073 // ** physics research. Other publications of special relevance to your        **
0074 // ** studies may therefore deserve separate mention.                          **
0075 // **                                                                          **
0076 // ** Main author: Torbjorn Sjostrand; Department of Theoretical Physics,      **
0077 // **   Lund University, Solvegatan 14A, S-223 62 Lund, Sweden;                **
0078 // **   phone: + 46 - 46 - 222 48 16; e-mail: torbjorn@thep.lu.se              **
0079 // ** Author: Stephen Mrenna; Computing Division, GDS Group,                   **
0080 // **   Fermi National Accelerator Laboratory, MS 234, Batavia, IL 60510, USA; **
0081 // **   phone: + 1 - 630 - 840 - 2556; e-mail: mrenna@fnal.gov                 **
0082 // ** Author: Peter Skands; Theoretical Physics Department,                    **
0083 // **   Fermi National Accelerator Laboratory, MS 106, Batavia, IL 60510, USA; **
0084 // **   and CERN/PH, CH-1211 Geneva, Switzerland;                              **
0085 // **   phone: + 41 - 22 - 767 24 59; e-mail: skands@fnal.gov                  **
0086 // **                                                                          **
0087 // **                                                                          **
0088 // ******************************************************************************
0089 
0090 #include "Pythia6.hh"
0091 
0092 #include <cstdlib>
0093 #include <cstring>
0094 #include <iostream>
0095 
0096 #ifndef WIN32
0097 #  define pycomp pycomp_
0098 #  define py1ent py1ent_
0099 #  define type_of_call
0100 #else
0101 #  define pycomp PYCOMP
0102 #  define py1ent PY1ENT
0103 #  define type_of_call _stdcall
0104 #endif
0105 
0106 // pythia6 functions
0107 extern "C"
0108 {
0109   int type_of_call pycomp(int* kf);
0110   void type_of_call py1ent(int&, int&, double&, double&, double&);
0111   void* pythia6_common_address(const char*);
0112 }
0113 
0114 // Direct declaration of pythia6 common blocks
0115 // extern "C" {
0116 //   extern Pyjets_t pyjets_;
0117 //   extern Pydat1_t pydat1_;
0118 //   extern Pydat3_t pydat3_;
0119 // }
0120 
0121 Pythia6* Pythia6::fgInstance = 0;
0122 
0123 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0124 
0125 Pythia6* Pythia6::Instance()
0126 {
0127   /// Static access method
0128 
0129   if (!fgInstance) fgInstance = new Pythia6();
0130 
0131   return fgInstance;
0132 }
0133 
0134 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0135 
0136 Pythia6::Pythia6() : fParticles(0), fPyjets(0), fPydat1(0), fPydat3(0)
0137 {
0138   /// Pythia6 constructor: creates a vector of Pythia6Particle in which it will
0139   /// store all particles. Note that there may be only one functional Pythia6
0140   /// object at a time, so it's not use to create more than one instance of it.
0141 
0142   // Protect against multiple objects.   All access should be via the
0143   // Instance member function.
0144   if (fgInstance) {
0145     std::cerr << "There's already an instance of Pythia6" << std::endl;
0146     exit(1);
0147   }
0148 
0149   fParticles = new ParticleVector();
0150 
0151   // Initialize common-blocks
0152   fPyjets = (Pyjets_t*)pythia6_common_address("PYJETS");
0153   fPydat1 = (Pydat1_t*)pythia6_common_address("PYDAT1");
0154   fPydat3 = (Pydat3_t*)pythia6_common_address("PYDAT3");
0155 
0156   // Alternative way to initialize common-blocks
0157   // usind direct declaration of pythia6 common blocks
0158   // fPyjets = &pyjets_;
0159   // fPydat1 = &pydat1_;
0160   // fPydat3 = &pydat3_;
0161 }
0162 
0163 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0164 
0165 Pythia6::~Pythia6()
0166 {
0167   /// Destroy the object, delete and dispose all Pythia6Particles currently on
0168   /// list.
0169 
0170   if (fParticles) {
0171     ParticleVector::const_iterator it;
0172     for (it = fParticles->begin(); it != fParticles->end(); it++)
0173       delete *it;
0174     delete fParticles;
0175   }
0176 }
0177 
0178 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0179 
0180 int Pythia6::Pycomp(int kf)
0181 {
0182   /// Interface with fortran routine pycomp
0183 
0184   return pycomp(&kf);
0185 }
0186 
0187 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0188 
0189 void Pythia6::Py1ent(int ip, int kf, double pe, double theta, double phi)
0190 {
0191   /// Add one entry to the event record, i.e. either a parton or a
0192   /// particle.
0193   ///
0194   ///  IP:   normally line number for the parton/particle. There are two
0195   ///        exceptions:
0196   ///
0197   ///        If IP = 0: line number 1 is used and PYEXEC is called.
0198   ///        If IP < 0: line -IP is used, with status code K(-IP,2)=2
0199   ///                   rather than 1; thus a parton system may be built
0200   ///                   up by filling all but the last parton of the
0201   ///                   system with IP < 0.
0202   ///  KF:   parton/particle flavour code (PDG code)
0203   ///  PE:   parton/particle energy. If PE is smaller than the mass,
0204   ///        the parton/particle is taken to be at rest.
0205   ///  THETA:
0206   ///  PHI:  polar and azimuthal angle for the momentum vector of the
0207   ///        parton/particle.
0208 
0209   py1ent(ip, kf, pe, theta, phi);
0210 }
0211 
0212 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0213 
0214 int Pythia6::ImportParticles(ParticleVector* particles, const char* option)
0215 {
0216   ///  Default primary creation method. It reads the /HEPEVT/ common block which
0217   ///  has been filled by the GenerateEvent method. If the event generator does
0218   ///  not use the HEPEVT common block, This routine has to be overloaded by
0219   ///  the subclasses.
0220   ///  The function loops on the generated particles and store them in
0221   ///  the TClonesArray pointed by the argument particles.
0222   ///  The default action is to store only the stable particles (ISTHEP = 1)
0223   ///  This can be demanded explicitly by setting the option = "Final"
0224   ///  If the option = "All", all the particles are stored.
0225 
0226   if (particles == 0) return 0;
0227 
0228   ParticleVector::const_iterator it;
0229   for (it = particles->begin(); it != particles->end(); it++)
0230     delete *it;
0231   particles->clear();
0232 
0233   int numpart = fPyjets->N;
0234   int nparts = 0;
0235   if (!strcmp(option, "") || !strcmp(option, "Final")) {
0236     for (int i = 0; i < numpart; i++) {
0237       if (fPyjets->K[0][i] == 1) {
0238         //
0239         //  Use the common block values for the TParticle constructor
0240         //
0241         particles->push_back(new Pythia6Particle(
0242           fPyjets->K[0][i], fPyjets->K[1][i], fPyjets->K[2][i], fPyjets->K[3][i], fPyjets->K[4][i],
0243           fPyjets->P[0][i], fPyjets->P[1][i], fPyjets->P[2][i], fPyjets->P[3][i], fPyjets->P[4][i],
0244           fPyjets->V[0][i], fPyjets->V[1][i], fPyjets->V[2][i], fPyjets->V[3][i],
0245           fPyjets->V[4][i]));
0246 
0247         //     if(gDebug) printf("%d %d %d! ",i,fPyjets->K[1][i],numpart);
0248         nparts++;
0249       }
0250     }
0251   }
0252   else if (!strcmp(option, "All")) {
0253     for (int i = 0; i < numpart; i++) {
0254       particles->push_back(new Pythia6Particle(
0255         fPyjets->K[0][i], fPyjets->K[1][i], fPyjets->K[2][i], fPyjets->K[3][i], fPyjets->K[4][i],
0256         fPyjets->P[0][i], fPyjets->P[1][i], fPyjets->P[2][i], fPyjets->P[3][i], fPyjets->P[4][i],
0257         fPyjets->V[0][i], fPyjets->V[1][i], fPyjets->V[2][i], fPyjets->V[3][i], fPyjets->V[4][i]));
0258     }
0259     nparts = numpart;
0260   }
0261 
0262   return nparts;
0263 }
0264 
0265 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......