Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-06 08:18:52

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 // $Id: Pythia6.cc,v 1.3 2014/11/14 23:26:26 mccumber Exp $
0027 //
0028 /// \file eventgenerator/pythia/decayer6/src/Pythia6.cc
0029 /// \brief Implementation of the Pythia6 class
0030 
0031 // ----------------------------------------------------------------------------
0032 // According to TPythia6 class from Root:
0033 // (The TPythia6 class is an interface class to F77 routines in Pythia6                //
0034 // CERNLIB event generators, written by T.Sjostrand.)
0035 // http://root.cern.ch/
0036 // see http://root.cern.ch/root/License.html
0037 //
0038 // The complete Pythia6 documentation can be found at:
0039 // http://home.thep.lu.se/~torbjorn/pythiaaux/recent.html
0040 // ----------------------------------------------------------------------------
0041 
0042 // ******************************************************************************
0043 // ******************************************************************************
0044 // **                                                                          **
0045 // **                                                                          **
0046 // **              *......*                  Welcome to the Lund Monte Carlo!  **
0047 // **         *:::!!:::::::::::*                                               **
0048 // **      *::::::!!::::::::::::::*          PPP  Y   Y TTTTT H   H III   A    **
0049 // **    *::::::::!!::::::::::::::::*        P  P  Y Y    T   H   H  I   A A   **
0050 // **   *:::::::::!!:::::::::::::::::*       PPP    Y     T   HHHHH  I  AAAAA  **
0051 // **   *:::::::::!!:::::::::::::::::*       P      Y     T   H   H  I  A   A  **
0052 // **    *::::::::!!::::::::::::::::*!       P      Y     T   H   H III A   A  **
0053 // **      *::::::!!::::::::::::::* !!                                         **
0054 // **      !! *:::!!:::::::::::*    !!       This is PYTHIA version 6.418      **
0055 // **      !!     !* -><- *         !!       Last date of change:  9 Jun 2008  **
0056 // **      !!     !!                !!                                         **
0057 // **      !!     !!                !!       Now is  0 Jan 2000 at  0:00:00    **
0058 // **      !!                       !!                                         **
0059 // **      !!        lh             !!       Disclaimer: this program comes    **
0060 // **      !!                       !!       without any guarantees. Beware    **
0061 // **      !!                 hh    !!       of errors and use common sense    **
0062 // **      !!    ll                 !!       when interpreting results.        **
0063 // **      !!                       !!                                         **
0064 // **      !!                                Copyright T. Sjostrand (2008)     **
0065 // **                                                                          **
0066 // ** An archive of program versions and documentation is found on the web:    **
0067 // ** http://www.thep.lu.se/~torbjorn/Pythia.html                              **
0068 // **                                                                          **
0069 // ** When you cite this program, the official reference is to the 6.4 manual: **
0070 // ** T. Sjostrand, S. Mrenna and P. Skands, JHEP05 (2006) 026                 **
0071 // ** (LU TP 06-13, FERMILAB-PUB-06-052-CD-T) [hep-ph/0603175].                **
0072 // **                                                                          **
0073 // ** Also remember that the program, to a large extent, represents original   **
0074 // ** physics research. Other publications of special relevance to your        **
0075 // ** studies may therefore deserve separate mention.                          **
0076 // **                                                                          **
0077 // ** Main author: Torbjorn Sjostrand; Department of Theoretical Physics,      **
0078 // **   Lund University, Solvegatan 14A, S-223 62 Lund, Sweden;                **
0079 // **   phone: + 46 - 46 - 222 48 16; e-mail: torbjorn@thep.lu.se              **
0080 // ** Author: Stephen Mrenna; Computing Division, GDS Group,                   **
0081 // **   Fermi National Accelerator Laboratory, MS 234, Batavia, IL 60510, USA; **
0082 // **   phone: + 1 - 630 - 840 - 2556; e-mail: mrenna@fnal.gov                 **
0083 // ** Author: Peter Skands; Theoretical Physics Department,                    **
0084 // **   Fermi National Accelerator Laboratory, MS 106, Batavia, IL 60510, USA; **
0085 // **   and CERN/PH, CH-1211 Geneva, Switzerland;                              **
0086 // **   phone: + 41 - 22 - 767 24 59; e-mail: skands@fnal.gov                  **
0087 // **                                                                          **
0088 // **                                                                          **
0089 // ******************************************************************************
0090 
0091 #include "Pythia6.hh"
0092 
0093 #include <cstdlib>
0094 #include <cstring>
0095 #include <iostream>
0096 
0097 #ifndef WIN32
0098 #define pycomp pycomp_
0099 #define py1ent py1ent_
0100 #define type_of_call
0101 #else
0102 #define pycomp PYCOMP
0103 #define py1ent PY1ENT
0104 #define type_of_call _stdcall
0105 #endif
0106 
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 Pythia6* Pythia6::fgInstance = nullptr;
0115 
0116 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0117 
0118 Pythia6* Pythia6::Instance()
0119 {
0120   /// Static access method
0121 
0122   if (!fgInstance)
0123   {
0124     fgInstance = new Pythia6();
0125   }
0126 
0127   return fgInstance;
0128 }
0129 
0130 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0131 
0132 Pythia6::Pythia6()
0133   : fParticles(nullptr)
0134   , fPyjets(nullptr)
0135   , fPydat1(nullptr)
0136   , fPydat3(nullptr)
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   {
0146     std::cerr << "There's already an instance of Pythia6" << std::endl;
0147     exit(1);
0148   }
0149 
0150   fParticles = new ParticleVector();
0151 
0152   // initialize common-blocks
0153   fPyjets = static_cast<Pyjets_t*>(pythia6_common_address("PYJETS"));
0154   fPydat1 = static_cast<Pydat1_t*>(pythia6_common_address("PYDAT1"));
0155   fPydat3 = static_cast<Pydat3_t*>(pythia6_common_address("PYDAT3"));
0156 
0157   // turn off Pythia Logo print
0158   fPydat1->MSTU[12 - 1] = 12345;
0159 }
0160 
0161 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0162 
0163 Pythia6::~Pythia6()
0164 {
0165   /// Destroy the object, delete and dispose all Pythia6Particles currently on
0166   /// list.
0167 
0168   if (fParticles)
0169   {
0170     ParticleVector::const_iterator it;
0171     for (it = fParticles->begin(); it != fParticles->end(); ++it)
0172     {
0173       delete *it;
0174     }
0175     delete fParticles;
0176   }
0177 }
0178 
0179 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0180 
0181 int Pythia6::Pycomp(int kf)
0182 {
0183   /// Interface with fortran routine pycomp
0184 
0185   return pycomp(&kf);
0186 }
0187 
0188 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0189 
0190 void Pythia6::Py1ent(int ip, int kf, double pe, double theta, double phi)
0191 {
0192   /// Add one entry to the event record, i.e. either a parton or a
0193   /// particle.
0194   ///
0195   ///  IP:   normally line number for the parton/particle. There are two
0196   ///        exceptions:
0197   ///
0198   ///        If IP = 0: line number 1 is used and PYEXEC is called.
0199   ///        If IP < 0: line -IP is used, with status code K(-IP,2)=2
0200   ///                   rather than 1; thus a parton system may be built
0201   ///                   up by filling all but the last parton of the
0202   ///                   system with IP < 0.
0203   ///  KF:   parton/particle flavour code (PDG code)
0204   ///  PE:   parton/particle energy. If PE is smaller than the mass,
0205   ///        the parton/particle is taken to be at rest.
0206   ///  THETA:
0207   ///  PHI:  polar and azimuthal angle for the momentum vector of the
0208   ///        parton/particle.
0209 
0210   py1ent(ip, kf, pe, theta, phi);
0211 }
0212 
0213 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0214 
0215 int Pythia6::ImportParticles(ParticleVector* particles, const char* option)
0216 {
0217   ///  Default primary creation method. It reads the /HEPEVT/ common block which
0218   ///  has been filled by the GenerateEvent method. If the event generator does
0219   ///  not use the HEPEVT common block, This routine has to be overloaded by
0220   ///  the subclasses.
0221   ///  The function loops on the generated particles and store them in
0222   ///  the TClonesArray pointed by the argument particles.
0223   ///  The default action is to store only the stable particles (ISTHEP = 1)
0224   ///  This can be demanded explicitly by setting the option = "Final"
0225   ///  If the option = "All", all the particles are stored.
0226 
0227   if (particles == nullptr)
0228   {
0229     return 0;
0230   }
0231 
0232   ParticleVector::const_iterator it;
0233   for (it = particles->begin(); it != particles->end(); ++it)
0234   {
0235     delete *it;
0236   }
0237   particles->clear();
0238 
0239   int numpart = fPyjets->N;
0240   int nparts = 0;
0241   if (!strcmp(option, "") || !strcmp(option, "Final"))
0242   {
0243     for (int i = 0; i < numpart; i++)
0244     {
0245       if (fPyjets->K[0][i] == 1)
0246       {
0247         //
0248         //  Use the common block values for the TParticle constructor
0249         //
0250         particles->push_back(
0251             new Pythia6Particle(
0252                 fPyjets->K[0][i],
0253                 fPyjets->K[1][i],
0254                 fPyjets->K[2][i],
0255                 fPyjets->K[3][i],
0256                 fPyjets->K[4][i],
0257                 fPyjets->P[0][i],
0258                 fPyjets->P[1][i],
0259                 fPyjets->P[2][i],
0260                 fPyjets->P[3][i],
0261                 fPyjets->P[4][i],
0262                 fPyjets->V[0][i],
0263                 fPyjets->V[1][i],
0264                 fPyjets->V[2][i],
0265                 fPyjets->V[3][i],
0266                 fPyjets->V[4][i]));
0267 
0268         //     if(gDebug) printf("%d %d %d! ",i,fPyjets->K[1][i],numpart);
0269         nparts++;
0270       }
0271     }
0272   }
0273   else if (!strcmp(option, "All"))
0274   {
0275     for (int i = 0; i < numpart; i++)
0276     {
0277       particles->push_back(
0278           new Pythia6Particle(
0279               fPyjets->K[0][i],
0280               fPyjets->K[1][i],
0281               fPyjets->K[2][i],
0282               fPyjets->K[3][i],
0283               fPyjets->K[4][i],
0284               fPyjets->P[0][i],
0285               fPyjets->P[1][i],
0286               fPyjets->P[2][i],
0287               fPyjets->P[3][i],
0288               fPyjets->P[4][i],
0289               fPyjets->V[0][i],
0290               fPyjets->V[1][i],
0291               fPyjets->V[2][i],
0292               fPyjets->V[3][i],
0293               fPyjets->V[4][i]));
0294     }
0295     nparts = numpart;
0296   }
0297 
0298   return nparts;
0299 }
0300 
0301 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......