![]() |
HepPDT Reference DocumentationHepPDT |
00001 // ---------------------------------------------------------------------- 00002 // examListPythia.cc 00003 // 00004 // ---------------------------------------------------------------------- 00013 00014 #include <fstream> 00015 #include <string> 00016 #include <cstdlib> 00017 00018 #include "HepPID/ParticleIDTranslations.hh" 00019 #include "HepPID/ParticleIDMethods.hh" 00020 #include "HepPID/ParticleName.hh" 00021 #include "HepPID/Version.hh" 00022 00023 extern "C" { 00024 void list_pythia_ ( ); 00025 void getkf_( int *, int * ); 00026 void getpyname_( int * , int *, char *name ); 00027 } 00028 00029 void writeLine( int & i, int & kf, int & id, 00030 std::string & name, std::string & pn, std::ofstream & os ); 00031 00032 int main() 00033 { 00034 int kf,akf,pid,apid,iok; 00035 char cname[17],caname[17]; 00036 std::string name, aname, pn, apn; 00037 const char outfile[] = "examListPythia.out"; 00038 std::string title = "HepPID listing of Pythia translations"; 00039 // open the output file 00040 std::ofstream os( outfile ); 00041 if( !os ) { 00042 std::cerr << "cannot open " << outfile << std::endl; 00043 exit(-1); 00044 } 00045 HepPID::writeVersion(os); 00046 // get Pythia listing using the fortran pylist function 00047 // write the output of pylist to examListPythia.lpt 00048 list_pythia_(); 00049 00050 os << " " << title << std::endl; 00051 00052 for(int i=1; i<501; ++i) { 00053 getkf_( &i, &kf); 00054 if( kf != 0 ) { 00055 getpyname_(&kf, &iok, cname); 00056 if( iok == 1 ) { 00057 cname[16]='\0'; 00058 name = std::string( cname ); 00059 pid = HepPID::translatePythiatoPDT( kf ); 00060 pn = HepPID::particleName( pid ); 00061 writeLine( i, kf, pid, name, pn, os ); 00062 if( HepPID::isValid( -pid ) ) { 00063 akf=-kf; 00064 getpyname_(&akf, &iok, caname); 00065 if( iok == 1 ) { 00066 apid = HepPID::translatePythiatoPDT( akf ); 00067 apn = HepPID::particleName( apid ); 00068 caname[16]='\0'; 00069 aname = std::string( caname ); 00070 writeLine( i, akf, apid, aname, apn, os ); 00071 } 00072 } 00073 } 00074 } 00075 } 00076 return 0; 00077 } 00078 00079 void writeLine( int & i, int & kf, int & id, 00080 std::string & name, std::string & pn, std::ofstream & os ) 00081 { 00082 os << "Pythia: "; 00083 os.width(7); 00084 os << i ; 00085 os.width(12); 00086 os << kf << " " << name; 00087 os << " HepPID: " ; 00088 os.width(12); 00089 os << id << " " << pn << std::endl; 00090 }