00001
00002
00003
00004
00013
00014 #include <fstream>
00015 #include <iostream>
00016 #include <cstdlib>
00017 #include <cstring>
00018
00019 #include "HepPID/ParticleIDTranslations.hh"
00020 #include "HepPID/ParticleName.hh"
00021 #include "HepPID/Version.hh"
00022
00023 extern "C" {
00024 void list_isajet_init_ ( );
00025 void flavor_( int *, int *, int *, int *, int *, int * );
00026 void get_label_( int * id, char *name );
00027 }
00028
00029 int main()
00030 {
00031 static char outfile[] = "examListIsajet.out";
00032 std::string title = "HepPID listing of Isajet translations";
00033
00034
00035 list_isajet_init_ ( );
00036
00037
00038 std::ofstream os( outfile );
00039 if( !os ) {
00040 std::cout << "error opening output file" << std::endl;
00041 exit(1);
00042 }
00043 HepPID::writeVersion(os);
00044
00045 os << " " << title << std::endl;
00046
00047 int i, j;
00048 int id, aid, fl1, fl2, fl3, js, indx;
00049 int pid;
00050 char cname[10];
00051 char acname[10];
00052 std::string hname;
00053 std::string pn;
00054 for( i=1; i<100005; ++i ) {
00055
00056 for( j=0; j<10; ++j) { cname[j] = '\0'; }
00057 for( j=0; j<10; ++j) { acname[j] = '\0'; }
00058
00059 id = i;
00060 aid = 0;
00061 flavor_(&id, &fl1, &fl2, &fl3, &js, &indx );
00062
00063
00064 if ( indx > 0 ) {
00065 get_label_(&id,cname);
00066 aid = -id;
00067 get_label_(&aid,acname);
00068 } else {
00069 id = aid = 0;
00070 }
00071
00072
00073 if( id != 0 ) {
00074 pid = HepPID::translateIsajettoPDT( id );
00075 hname = std::string( cname );
00076 if ( pid != 0 ) {
00077 pn = HepPID::particleName( pid );
00078 os << "Isajet: ";
00079 os.width(10);
00080 os << id << " " << hname;
00081 os << " HepPID: " ;
00082 os.width(12);
00083 os << pid << " " << pn << std::endl;
00084 } else if ( strncmp( cname, "ERR", 3 ) != 0 ) {
00085 os << "Isajet: ";
00086 os.width(10);
00087 os << id << " with name \"" << hname;
00088 os << "\" has no HepPID translation " << std::endl;
00089 }
00090 }
00091
00092 if( aid != 0 ) {
00093 hname = std::string( acname );
00094 pid = HepPID::translateIsajettoPDT( aid );
00095 if ( pid != 0 ) {
00096 pn = HepPID::particleName( pid );
00097 os << "Isajet: ";
00098 os.width(10);
00099 os << aid << " " << hname;
00100 os << " HepPID: " ;
00101 os.width(12);
00102 os << pid << " " << pn << std::endl;
00103 } else if ( strncmp( acname, "ERR", 3 ) != 0 ) {
00104 os << "Isajet: ";
00105 os.width(10);
00106 os << aid << " with name \"" << hname;
00107 os << "\" has no HepPID translation " << std::endl;
00108 }
00109 }
00110 }
00111
00112 return 0;
00113 }