Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer 3 // * License and Disclaimer * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th 5 // * The Geant4 software is copyright of the Copyright Holders of * 6 // * the Geant4 Collaboration. It is provided 6 // * the Geant4 Collaboration. It is provided under the terms and * 7 // * conditions of the Geant4 Software License 7 // * conditions of the Geant4 Software License, included in the file * 8 // * LICENSE and available at http://cern.ch/ 8 // * LICENSE and available at http://cern.ch/geant4/license . These * 9 // * include a list of copyright holders. 9 // * include a list of copyright holders. * 10 // * 10 // * * 11 // * Neither the authors of this software syst 11 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 12 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 13 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 14 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file 15 // * use. Please see the license in the file LICENSE and URL above * 16 // * for the full disclaimer and the limitatio 16 // * for the full disclaimer and the limitation of liability. * 17 // * 17 // * * 18 // * This code implementation is the result 18 // * This code implementation is the result of the scientific and * 19 // * technical work of the GEANT4 collaboratio 19 // * technical work of the GEANT4 collaboration. * 20 // * By using, copying, modifying or distri 20 // * By using, copying, modifying or distributing the software (or * 21 // * any work based on the software) you ag 21 // * any work based on the software) you agree to acknowledge its * 22 // * use in resulting scientific publicati 22 // * use in resulting scientific publications, and indicate your * 23 // * acceptance of all terms of the Geant4 Sof 23 // * acceptance of all terms of the Geant4 Software license. * 24 // ******************************************* 24 // ******************************************************************** 25 // 25 // >> 26 // $Id: Pythia6.cc 72244 2013-07-12 08:49:56Z gcosmo $ 26 // 27 // 27 /// \file eventgenerator/pythia/decayer6/src/P 28 /// \file eventgenerator/pythia/decayer6/src/Pythia6.cc 28 /// \brief Implementation of the Pythia6 class 29 /// \brief Implementation of the Pythia6 class 29 30 30 // ------------------------------------------- 31 // ---------------------------------------------------------------------------- 31 // According to TPythia6 class from Root: 32 // According to TPythia6 class from Root: 32 // (The TPythia6 class is an interface class t 33 // (The TPythia6 class is an interface class to F77 routines in Pythia6 // 33 // CERNLIB event generators, written by T.Sjos << 34 // CERNLIB event generators, written by T.Sjostrand.) 34 // http://root.cern.ch/ 35 // http://root.cern.ch/ 35 // see http://root.cern.ch/root/License.html 36 // see http://root.cern.ch/root/License.html 36 // 37 // 37 // The complete Pythia6 documentation can be f 38 // The complete Pythia6 documentation can be found at: 38 // http://home.thep.lu.se/~torbjorn/pythiaaux/ 39 // http://home.thep.lu.se/~torbjorn/pythiaaux/recent.html 39 // ------------------------------------------- 40 // ---------------------------------------------------------------------------- 40 41 41 // ******************************************* 42 // ****************************************************************************** 42 // ******************************************* 43 // ****************************************************************************** 43 // ** 44 // ** ** 44 // ** 45 // ** ** 45 // ** *......* W 46 // ** *......* Welcome to the Lund Monte Carlo! ** 46 // ** *:::!!:::::::::::* 47 // ** *:::!!:::::::::::* ** 47 // ** *::::::!!::::::::::::::* P 48 // ** *::::::!!::::::::::::::* PPP Y Y TTTTT H H III A ** 48 // ** *::::::::!!::::::::::::::::* P 49 // ** *::::::::!!::::::::::::::::* P P Y Y T H H I A A ** 49 // ** *:::::::::!!:::::::::::::::::* P 50 // ** *:::::::::!!:::::::::::::::::* PPP Y T HHHHH I AAAAA ** 50 // ** *:::::::::!!:::::::::::::::::* P 51 // ** *:::::::::!!:::::::::::::::::* P Y T H H I A A ** 51 // ** *::::::::!!::::::::::::::::*! P 52 // ** *::::::::!!::::::::::::::::*! P Y T H H III A A ** 52 // ** *::::::!!::::::::::::::* !! 53 // ** *::::::!!::::::::::::::* !! ** 53 // ** !! *:::!!:::::::::::* !! T 54 // ** !! *:::!!:::::::::::* !! This is PYTHIA version 6.418 ** 54 // ** !! !* -><- * !! L 55 // ** !! !* -><- * !! Last date of change: 9 Jun 2008 ** 55 // ** !! !! !! 56 // ** !! !! !! ** 56 // ** !! !! !! N 57 // ** !! !! !! Now is 0 Jan 2000 at 0:00:00 ** 57 // ** !! !! 58 // ** !! !! ** 58 // ** !! lh !! D 59 // ** !! lh !! Disclaimer: this program comes ** 59 // ** !! !! w 60 // ** !! !! without any guarantees. Beware ** 60 // ** !! hh !! o 61 // ** !! hh !! of errors and use common sense ** 61 // ** !! ll !! w 62 // ** !! ll !! when interpreting results. ** 62 // ** !! !! 63 // ** !! !! ** 63 // ** !! C 64 // ** !! Copyright T. Sjostrand (2008) ** 64 // ** 65 // ** ** 65 // ** An archive of program versions and docum 66 // ** An archive of program versions and documentation is found on the web: ** 66 // ** http://www.thep.lu.se/~torbjorn/Pythia.h 67 // ** http://www.thep.lu.se/~torbjorn/Pythia.html ** 67 // ** 68 // ** ** 68 // ** When you cite this program, the official 69 // ** When you cite this program, the official reference is to the 6.4 manual: ** 69 // ** T. Sjostrand, S. Mrenna and P. Skands, J 70 // ** T. Sjostrand, S. Mrenna and P. Skands, JHEP05 (2006) 026 ** 70 // ** (LU TP 06-13, FERMILAB-PUB-06-052-CD-T) 71 // ** (LU TP 06-13, FERMILAB-PUB-06-052-CD-T) [hep-ph/0603175]. ** 71 // ** 72 // ** ** 72 // ** Also remember that the program, to a lar 73 // ** Also remember that the program, to a large extent, represents original ** 73 // ** physics research. Other publications of 74 // ** physics research. Other publications of special relevance to your ** 74 // ** studies may therefore deserve separate m 75 // ** studies may therefore deserve separate mention. ** 75 // ** 76 // ** ** 76 // ** Main author: Torbjorn Sjostrand; Departm 77 // ** Main author: Torbjorn Sjostrand; Department of Theoretical Physics, ** 77 // ** Lund University, Solvegatan 14A, S-223 78 // ** Lund University, Solvegatan 14A, S-223 62 Lund, Sweden; ** 78 // ** phone: + 46 - 46 - 222 48 16; e-mail: 79 // ** phone: + 46 - 46 - 222 48 16; e-mail: torbjorn@thep.lu.se ** 79 // ** Author: Stephen Mrenna; Computing Divisi 80 // ** Author: Stephen Mrenna; Computing Division, GDS Group, ** 80 // ** Fermi National Accelerator Laboratory, 81 // ** Fermi National Accelerator Laboratory, MS 234, Batavia, IL 60510, USA; ** 81 // ** phone: + 1 - 630 - 840 - 2556; e-mail: 82 // ** phone: + 1 - 630 - 840 - 2556; e-mail: mrenna@fnal.gov ** 82 // ** Author: Peter Skands; Theoretical Physic 83 // ** Author: Peter Skands; Theoretical Physics Department, ** 83 // ** Fermi National Accelerator Laboratory, 84 // ** Fermi National Accelerator Laboratory, MS 106, Batavia, IL 60510, USA; ** 84 // ** and CERN/PH, CH-1211 Geneva, Switzerla 85 // ** and CERN/PH, CH-1211 Geneva, Switzerland; ** 85 // ** phone: + 41 - 22 - 767 24 59; e-mail: 86 // ** phone: + 41 - 22 - 767 24 59; e-mail: skands@fnal.gov ** 86 // ** 87 // ** ** 87 // ** 88 // ** ** 88 // ******************************************* 89 // ****************************************************************************** 89 90 90 #include "Pythia6.hh" 91 #include "Pythia6.hh" 91 92 >> 93 #include <iostream> 92 #include <cstdlib> 94 #include <cstdlib> 93 #include <cstring> 95 #include <cstring> 94 #include <iostream> << 95 96 96 #ifndef WIN32 97 #ifndef WIN32 97 # define pycomp pycomp_ << 98 # define pycomp pycomp_ 98 # define py1ent py1ent_ << 99 # define py1ent py1ent_ 99 # define type_of_call << 100 # define type_of_call 100 #else 101 #else 101 # define pycomp PYCOMP << 102 # define pycomp PYCOMP 102 # define py1ent PY1ENT << 103 # define py1ent PY1ENT 103 # define type_of_call _stdcall << 104 # define type_of_call _stdcall 104 #endif 105 #endif 105 106 106 // pythia6 functions << 107 extern "C" { 107 extern "C" << 108 int type_of_call pycomp(int *kf); 108 { << 109 int type_of_call pycomp(int* kf); << 110 void type_of_call py1ent(int&, int&, double& 109 void type_of_call py1ent(int&, int&, double&, double&, double&); 111 void* pythia6_common_address(const char*); << 110 void* pythia6_common_address(const char*); 112 } 111 } 113 112 114 // Direct declaration of pythia6 common blocks << 113 Pythia6* Pythia6::fgInstance = 0; 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 114 123 //....oooOO0OOooo........oooOO0OOooo........oo 115 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 124 116 125 Pythia6* Pythia6::Instance() << 117 Pythia6* Pythia6::Instance() 126 { 118 { 127 /// Static access method << 119 /// Static access method 128 120 129 if (!fgInstance) fgInstance = new Pythia6(); << 121 if ( ! fgInstance ) fgInstance = new Pythia6(); 130 122 131 return fgInstance; << 123 return fgInstance; 132 } 124 } 133 125 134 //....oooOO0OOooo........oooOO0OOooo........oo 126 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 135 127 136 Pythia6::Pythia6() : fParticles(0), fPyjets(0) << 128 Pythia6::Pythia6() >> 129 : fParticles(0), >> 130 fPyjets(0), >> 131 fPydat1(0), >> 132 fPydat3(0) 137 { 133 { 138 /// Pythia6 constructor: creates a vector of << 134 /// Pythia6 constructor: creates a vector of Pythia6Particle in which it will 139 /// store all particles. Note that there may << 135 /// store all particles. Note that there may be only one functional Pythia6 140 /// object at a time, so it's not use to cre << 136 /// object at a time, so it's not use to create more than one instance of it. >> 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(); 141 146 142 // Protect against multiple objects. All a << 147 // initialize common-blocks 143 // Instance member function. << 148 fPyjets = (Pyjets_t*) pythia6_common_address("PYJETS"); 144 if (fgInstance) { << 149 fPydat1 = (Pydat1_t*) pythia6_common_address("PYDAT1"); 145 std::cerr << "There's already an instance << 150 fPydat3 = (Pydat3_t*) pythia6_common_address("PYDAT3"); 146 exit(1); << 147 } << 148 << 149 fParticles = new ParticleVector(); << 150 << 151 // Initialize common-blocks << 152 fPyjets = (Pyjets_t*)pythia6_common_address( << 153 fPydat1 = (Pydat1_t*)pythia6_common_address( << 154 fPydat3 = (Pydat3_t*)pythia6_common_address( << 155 << 156 // Alternative way to initialize common-bloc << 157 // usind direct declaration of pythia6 commo << 158 // fPyjets = &pyjets_; << 159 // fPydat1 = &pydat1_; << 160 // fPydat3 = &pydat3_; << 161 } 151 } 162 152 163 //....oooOO0OOooo........oooOO0OOooo........oo 153 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 164 154 165 Pythia6::~Pythia6() 155 Pythia6::~Pythia6() 166 { 156 { 167 /// Destroy the object, delete and dispose a << 157 /// Destroy the object, delete and dispose all Pythia6Particles currently on 168 /// list. << 158 /// list. 169 159 170 if (fParticles) { << 160 if ( fParticles ) { 171 ParticleVector::const_iterator it; << 161 ParticleVector::const_iterator it; 172 for (it = fParticles->begin(); it != fPart << 162 for ( it = fParticles->begin(); it != fParticles->end(); it++ ) 173 delete *it; << 163 delete *it; 174 delete fParticles; << 164 delete fParticles; 175 } << 165 } 176 } 166 } 177 167 178 //....oooOO0OOooo........oooOO0OOooo........oo 168 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 179 169 180 int Pythia6::Pycomp(int kf) << 170 int Pythia6::Pycomp(int kf) 181 { 171 { 182 /// Interface with fortran routine pycomp << 172 /// Interface with fortran routine pycomp 183 173 184 return pycomp(&kf); << 174 return pycomp(&kf); 185 } 175 } 186 176 187 //....oooOO0OOooo........oooOO0OOooo........oo 177 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 188 178 189 void Pythia6::Py1ent(int ip, int kf, double pe 179 void Pythia6::Py1ent(int ip, int kf, double pe, double theta, double phi) 190 { 180 { 191 /// Add one entry to the event record, i.e. << 181 /// Add one entry to the event record, i.e. either a parton or a 192 /// particle. << 182 /// particle. 193 /// << 183 /// 194 /// IP: normally line number for the part << 184 /// IP: normally line number for the parton/particle. There are two 195 /// exceptions: << 185 /// exceptions: 196 /// << 186 /// 197 /// If IP = 0: line number 1 is used << 187 /// If IP = 0: line number 1 is used and PYEXEC is called. 198 /// If IP < 0: line -IP is used, with << 188 /// If IP < 0: line -IP is used, with status code K(-IP,2)=2 199 /// rather than 1; thus a << 189 /// rather than 1; thus a parton system may be built 200 /// up by filling all but << 190 /// up by filling all but the last parton of the 201 /// system with IP < 0. << 191 /// system with IP < 0. 202 /// KF: parton/particle flavour code (PDG << 192 /// KF: parton/particle flavour code (PDG code) 203 /// PE: parton/particle energy. If PE is << 193 /// PE: parton/particle energy. If PE is smaller than the mass, 204 /// the parton/particle is taken to b << 194 /// the parton/particle is taken to be at rest. 205 /// THETA: << 195 /// THETA: 206 /// PHI: polar and azimuthal angle for the << 196 /// PHI: polar and azimuthal angle for the momentum vector of the 207 /// parton/particle. << 197 /// parton/particle. 208 198 209 py1ent(ip, kf, pe, theta, phi); << 199 py1ent(ip, kf, pe, theta, phi); 210 } 200 } 211 201 212 //....oooOO0OOooo........oooOO0OOooo........oo 202 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 213 203 214 int Pythia6::ImportParticles(ParticleVector* p 204 int Pythia6::ImportParticles(ParticleVector* particles, const char* option) 215 { 205 { 216 /// Default primary creation method. It rea << 206 /// Default primary creation method. It reads the /HEPEVT/ common block which 217 /// has been filled by the GenerateEvent me << 207 /// has been filled by the GenerateEvent method. If the event generator does 218 /// not use the HEPEVT common block, This r << 208 /// not use the HEPEVT common block, This routine has to be overloaded by 219 /// the subclasses. << 209 /// the subclasses. 220 /// The function loops on the generated par << 210 /// The function loops on the generated particles and store them in 221 /// the TClonesArray pointed by the argumen << 211 /// the TClonesArray pointed by the argument particles. 222 /// The default action is to store only the << 212 /// The default action is to store only the stable particles (ISTHEP = 1) 223 /// This can be demanded explicitly by sett << 213 /// This can be demanded explicitly by setting the option = "Final" 224 /// If the option = "All", all the particle << 214 /// If the option = "All", all the particles are stored. 225 << 215 226 if (particles == 0) return 0; << 216 if ( particles == 0 ) return 0; 227 << 217 228 ParticleVector::const_iterator it; << 218 ParticleVector::const_iterator it; 229 for (it = particles->begin(); it != particle << 219 for ( it = particles->begin(); it != particles->end(); it++ ) 230 delete *it; << 220 delete *it; 231 particles->clear(); << 221 particles->clear(); 232 << 222 233 int numpart = fPyjets->N; << 223 int numpart = fPyjets->N; 234 int nparts = 0; << 224 int nparts=0; 235 if (!strcmp(option, "") || !strcmp(option, " << 225 if (!strcmp(option,"") || !strcmp(option,"Final")) { 236 for (int i = 0; i < numpart; i++) { << 226 for (int i = 0; i<numpart; i++) { 237 if (fPyjets->K[0][i] == 1) { << 227 238 // << 228 if (fPyjets->K[0][i] == 1) { 239 // Use the common block values for th << 229 // 240 // << 230 // Use the common block values for the TParticle constructor 241 particles->push_back(new Pythia6Partic << 231 // 242 fPyjets->K[0][i], fPyjets->K[1][i], << 232 particles->push_back( 243 fPyjets->P[0][i], fPyjets->P[1][i], << 233 new Pythia6Particle( 244 fPyjets->V[0][i], fPyjets->V[1][i], << 234 fPyjets->K[0][i] , 245 fPyjets->V[4][i])); << 235 fPyjets->K[1][i] , 246 << 236 fPyjets->K[2][i] , 247 // if(gDebug) printf("%d %d %d! ", << 237 fPyjets->K[3][i] , 248 nparts++; << 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])); 249 } 274 } 250 } << 275 nparts=numpart; 251 } << 276 } 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], fP << 256 fPyjets->P[0][i], fPyjets->P[1][i], fP << 257 fPyjets->V[0][i], fPyjets->V[1][i], fP << 258 } << 259 nparts = numpart; << 260 } << 261 277 262 return nparts; << 278 return nparts; 263 } 279 } 264 280 265 //....oooOO0OOooo........oooOO0OOooo........oo 281 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 266 282