/search.css" rel="stylesheet" type="text/css"/> /search.js">
00001 //-------------------------------------------------------------------------- 00002 #ifndef HEPMC_IO_PDG_PARTICLEDATATABLE_H 00003 #define HEPMC_IO_PDG_PARTICLEDATATABLE_H 00004 00006 // Matt.Dobbs@Cern.CH, November 1999, refer to: 00007 // M. Dobbs and J.B. Hansen, "The HepMC C++ Monte Carlo Event Record for 00008 // High Energy Physics", Computer Physics Communications (to be published). 00009 // 00010 // Reads a particle data table from file supplied in PDG format 00011 // For the most recent table see: http://pdg.lbl.gov/computer_read.html 00013 // 00014 // Example of reading from file PDG98_ParticleDataTable.txt 00015 // 00016 // IO_PDG_ParticleDataTable pdg_io("PDG98_ParticleDataTable.txt"); 00017 // ParticleDataTable pdt = *pdg_io.read_particle_data_table(); 00018 // (note the read_particle_data_table method comes from the IO_Baseclass) 00019 // or 00020 // IO_PDG_ParticleDataTable pdg_io("PDG98_ParticleDataTable.txt"); 00021 // ParticleDataTable* pdt; 00022 // pdg_io >> pdt; 00023 // in both cases IO_PDG_ParticleDataTable creates an instance of the 00024 // ParticleDataTable which the user becomes owner of (i.e. user is 00025 // responsible for deleting) 00026 // 00027 // Note the PDG table does not include antiparticles nor quarks (except top) 00028 // You can make anti-particle entries corresponding to each charged entry with 00029 // the method make_antiparticles_from_particles() and you can make default 00030 // entries for the 6 quarks + anti-quarks with the method add_quarks_to_table() 00031 // Continuing with the above example: 00032 // pdt->make_antiparticles_from_particles(); 00033 // pdg_io.add_quarks_to_table( *pdt ); 00034 // 00035 00036 #include "HepMC/IO_BaseClass.h" 00037 #include <fstream> 00038 00039 namespace HepMC { 00040 00041 class GenEvent; 00042 00044 00049 class IO_PDG_ParticleDataTable : public IO_BaseClass { 00050 public: 00052 IO_PDG_ParticleDataTable( const char* filename 00053 ="PDG98_ParticleDataTable.txt" ); 00054 virtual ~IO_PDG_ParticleDataTable(); 00056 bool fill_particle_data_table( ParticleDataTable* ); 00058 void add_quarks_to_table( ParticleDataTable& ); 00060 void print( std::ostream& ostr = std::cout ) const; 00061 00063 int rdstate() const { return (int)m_file.rdstate(); } 00064 protected: // for internal use only 00066 bool search_for_key_end( std::istream& in, const char* key ); 00068 void read_entry( ParticleDataTable* ); 00069 private: // following are not implemented 00070 void write_event( const GenEvent* ){} 00071 bool fill_next_event( GenEvent* ){ return 0; } 00072 void write_particle_data_table( const ParticleDataTable* ){} 00073 private: // use of copy constructor is not allowed 00074 IO_PDG_ParticleDataTable( const IO_PDG_ParticleDataTable& ) : 00075 IO_BaseClass() {} 00076 private: // member data 00077 std::string m_filename; 00078 std::ifstream m_file; 00079 }; 00080 00082 // Inlines // 00084 00085 inline void IO_PDG_ParticleDataTable::print( std::ostream& ostr ) const { 00086 ostr << "IO_PDG_ParticleDataTable: for computer readable PDG tables.\n" 00087 << " file state: " << m_file.rdstate() 00088 << " bad:" << (m_file.rdstate()&std::ios::badbit) 00089 << " eof:" << (m_file.rdstate()&std::ios::eofbit) 00090 << " fail:" << (m_file.rdstate()&std::ios::failbit) 00091 << " good:" << (m_file.rdstate()&std::ios::goodbit) << std::endl; 00092 } 00093 00094 } // HepMC 00095 00096 #endif // HEPMC_IO_BASECLASS_H 00097 //-------------------------------------------------------------------------- 00098 00099 00100 00101 00102 00103 00104