00001 //-------------------------------------------------------------------------- 00002 00003 #ifndef PYTHIA_WRAPPER_H 00004 #define PYTHIA_WRAPPER_H 00005 00007 // Matt.Dobbs@Cern.CH, December 1999 00008 // Wrapper for FORTRAN version 5.720 of Pythia 00009 // This wrapper is NOT intended as a part of HepMC - it is only supplied 00010 // for your convenience. 00011 // Most everything was written by Silvia Resconi (thanks!) 00013 // 00014 // A simple example of calling Pythia from C++ using this header file is given 00015 // at the bottom of this file. 00016 // 00017 // Note the luhepc routine in Jetset 7.4 which is used by Pythia 5.720 to fill 00018 // the HEPEVT common block uses double precision and 2000 entries. 00019 // 00020 00021 #include <ctype.h> 00022 00023 //-------------------------------------------------------------------------- 00024 // Initialization routine 00025 00026 #define initpydata initpydata_ 00027 extern "C" { 00028 void initpydata(void); 00029 } 00030 00031 //-------------------------------------------------------------------------- 00032 // PYTHIA Common Block Declarations 00033 00034 const int pyjets_maxn =4000; 00035 extern struct { 00036 int n, k[5][pyjets_maxn]; 00037 float p[5][pyjets_maxn], v[5][pyjets_maxn]; 00038 } lujets_; 00039 #define lujets lujets_ 00040 00041 extern struct { 00042 int mstu[200]; 00043 float paru[200]; 00044 int mstj[200]; 00045 float parj[200]; 00046 } ludat1_; 00047 #define ludat1 ludat1_ 00048 00049 extern struct { 00050 int kchg[3][500]; 00051 float pmas[4][500], parf[2000], vckm[4][4]; 00052 } ludat2_; 00053 #define ludat2 ludat2_ 00054 00055 extern struct { 00056 int mdcy[3][500], mdme[2][2000]; 00057 float brat[2000]; 00058 int kfdp[5][2000]; 00059 } ludat3_; 00060 #define ludat3 ludat3_ 00061 00062 extern struct { 00063 int mrlu[6]; 00064 float rrlu[100]; 00065 } ludatr_; 00066 #define ludatr ludatr_ 00067 00068 extern struct { 00069 int msel, msub[200], kfin[81][2]; 00070 float ckin[200]; 00071 } pysubs_; 00072 #define pysubs pysubs_ 00073 00074 extern struct { 00075 int mstp[200]; 00076 float parp[200]; 00077 int msti[200]; 00078 float pari[200]; 00079 } pypars_; 00080 #define pypars pypars_ 00081 00082 extern struct { 00083 int mint[400]; 00084 float vint[400]; 00085 } pyint1_; 00086 #define pyint1 pyint1_ 00087 00088 extern struct { 00089 int iset[200], kfpr[2][200]; 00090 float coef[20][200]; 00091 int icol[2][4][40]; 00092 } pyint2_; 00093 #define pyint2 pyint2_ 00094 00095 extern struct { 00096 int ngen[3][201][3]; 00097 float xsec[3][201]; 00098 } pyint5_; 00099 #define pyint5 pyint5_ 00100 00101 //-------------------------------------------------------------------------- 00102 // PYTHIA routines declaration 00103 00104 #define luhepc luhepc_ 00105 #define pyinit pyinit_ 00106 #define lulist lulist_ 00107 #define pystat pystat_ 00108 #define pyevnt pyevnt_ 00109 #define ludata ludata_ 00110 extern "C" { 00111 void luhepc(int*); 00112 void pyinit(const char*,const char*,const char*,float*,int,int,int); 00113 void lulist(int*); 00114 void pystat(int*); 00115 void pyevnt(); 00116 void ludata(void); 00117 } 00118 00119 //-------------------------------------------------------------------------- 00120 // PYTHIA block data 00121 // ( with gcc it works to initialize the block data by calling 00122 // "pydata();" at beginning, but this fails for f77, so the fortran routine 00123 // initpydata.f is supplied ... call it instead for platform independent 00124 // behaviour ) 00125 00126 #define pydata pydata_ 00127 extern "C" { 00128 void pydata(void); 00129 } 00130 00131 #endif // PYTHIA_WRAPPER_H 00132 //-------------------------------------------------------------------------- 00133 00134 //-------------------------------------------------------------------------- 00135 // A simple example of calling Pythia from C++ using this header file: 00136 // (compiling instructions are given after the example) 00137 //-------------------------------------------------------------------------- 00138 // #include "HepMC/PythiaWrapper5_720.h" 00139 // main() { 00140 // // init the PYDATA block data as external by calling 00141 // initpydata(); 00142 // // 00143 // // Turn on process number 20 to generate W+gamma 00144 // pysubs.msel=0; 00145 // pysubs.msub[20-1] = 1; // -1 because arrays in C start at 0, F77 at 1 00146 // // set random number seed (mandatory) 00147 // ludatr.mrlu[0]=55122 ; 00148 // // 00149 // // call pythia initialization for 14 TeV p+ p+ collisions 00150 // float r_1 = (float)14000.; 00151 // const char* cms="CMS"; 00152 // const char* collision_particle="p"; 00153 // pyinit(cms, collision_particle, collision_particle, &r_1, 3, 1, 1); 00154 // // 00155 // // EVENT LOOP for 100 events 00156 // for ( int i = 1; i <= 100; i++ ) { 00157 // pyevnt(); 00158 // int c_p1 = 1; // necessary for C interface to pass by value 00159 // if ( i <= 5 ) lulist(&c_p1); // print first 5 events 00160 // // pythia luhepc routine convert common LUJETS in common HEPEVT 00161 // luhepc(&c_p1); 00162 // } 00163 // // print out the statistics 00164 // int c_p1 = 1; // necessary for C interface to pass by value 00165 // pystat(&c_p1); 00166 // } 00167 // 00168 //-------------------------------------------------------------------------- 00169 // In order to compile the above example you must link with the CERN library 00170 // (in the order given below), with the g2c library, and with a compiled 00171 // initpydata.f Fortran routine. Assuming the HepMC include files are 00172 // in ./HepMC/ and the cern library is in /cern/pro/lib/, you would 00173 // compile as follows using g++: 00174 // g77 -c initpydata.f 00175 // g++ -c -I. filename.cxx 00176 // g++ *.o -L/cern/pro/lib/ -lpawlib -lgraflib -lgrafX11 -lmathlib \ 00177 // -lkernlib -lpacklib -ljetset74 -lg2c 00178 // 00179 //-------------------------------------------------------------------------- 00180 00181