HepPDT Reference Documentation

HepPDT

examListHerwig.cc

00001 // -------------------------------------------------------------------
00002 // examListHerwig.cc
00003 //
00004 // ----------------------------------------------------------------------
00013  
00014 #include <fstream>
00015 #include <iostream>
00016 #include <cstdlib>
00017  
00018 #include "HepPID/ParticleIDTranslations.hh"
00019 #include "HepPID/ParticleName.hh"
00020 #include "HepPID/Version.hh"
00021 
00022 extern "C" {
00023 // these functions are defined in examListHerwigInterface.F
00024     void list_herwig_init_ ( int * nevt );
00025     void list_herwig_end_ ( );
00026     void get_list_size_ ( int * );
00027     void get_herwig_name_( int * ihwg, int * id, char *name );
00028 }
00029 
00030 int main()
00031 {
00032     int nevt=20;
00033     int i, j, iend, isize;
00034     int hid, id;
00035     char cname[10];
00036     std::string hname;
00037     std::string pn;
00038     static char outfile[] = "examListHerwig.out";
00039     std::string title = "HepPID listing of Herwig translations";
00040 
00041     // initialize herwig 
00042     list_herwig_init_ ( & nevt );
00043 
00044     // open the output stream
00045     std::ofstream os( outfile );
00046     if( !os ) {
00047         std::cout << "error opening output file"  << std::endl;
00048         exit(1);
00049     }
00050     HepPID::writeVersion(os);
00051 
00052     get_list_size_( & isize );
00053     os << "      " << title << std::endl;
00054     os << " number of Herwig particles: " << isize << std::endl;
00055     
00056     for( i=1, iend=isize+1; i<iend; ++i ) {
00057         // get info from herwig
00058         for( j=0; j<10; ++j) { cname[j] = '\0'; }
00059         get_herwig_name_( & i, & hid, cname );
00060         hname = std::string( cname );
00061         id = HepPID::translateHerwigtoPDT( hid );
00062         pn = HepPID::particleName( id );
00063         os << "Herwig: ";
00064         os.width(7);
00065         os << i ;
00066         os.width(12);
00067         os << hid << " " << hname;
00068         os << "  HepPID: " ;
00069         os.width(12);
00070         os << id << " " << pn << std::endl;
00071     }
00072 
00073     list_herwig_end_();
00074     
00075     return 0;
00076 }
00077 

Generated on Fri Dec 4 14:05:23 2009 for HepPDT by  doxygen 1.4.7