Fork me on GitHub

source: svn/trunk/Utilities/HepMC/interface/IO_PDG_ParticleDataTable.h@ 509

Last change on this file since 509 was 349, checked in by severine ovyn, 16 years ago

first test

File size: 3.7 KB
Line 
1//--------------------------------------------------------------------------
2#ifndef HEPMC_IO_PDG_PARTICLEDATATABLE_H
3#define HEPMC_IO_PDG_PARTICLEDATATABLE_H
4
5//////////////////////////////////////////////////////////////////////////
6// Matt.Dobbs@Cern.CH, November 1999, refer to:
7// M. Dobbs and J.B. Hansen, "The HepMC C++ Monte Carlo Event Record for
8// High Energy Physics", Computer Physics Communications (to be published).
9//
10// Reads a particle data table from file supplied in PDG format
11// For the most recent table see: http://pdg.lbl.gov/computer_read.html
12//////////////////////////////////////////////////////////////////////////
13//
14// Example of reading from file PDG98_ParticleDataTable.txt
15//
16// IO_PDG_ParticleDataTable pdg_io("PDG98_ParticleDataTable.txt");
17// ParticleDataTable pdt = *pdg_io.read_particle_data_table();
18// (note the read_particle_data_table method comes from the IO_Baseclass)
19// or
20// IO_PDG_ParticleDataTable pdg_io("PDG98_ParticleDataTable.txt");
21// ParticleDataTable* pdt;
22// pdg_io >> pdt;
23// in both cases IO_PDG_ParticleDataTable creates an instance of the
24// ParticleDataTable which the user becomes owner of (i.e. user is
25// responsible for deleting)
26//
27// Note the PDG table does not include antiparticles nor quarks (except top)
28// You can make anti-particle entries corresponding to each charged entry with
29// the method make_antiparticles_from_particles() and you can make default
30// entries for the 6 quarks + anti-quarks with the method add_quarks_to_table()
31// Continuing with the above example:
32// pdt->make_antiparticles_from_particles();
33// pdg_io.add_quarks_to_table( *pdt );
34//
35
36#include "IO_BaseClass.h"
37#include <fstream>
38
39namespace HepMC {
40
41 class GenEvent;
42
43 //! an example ParticleDataTable IO method
44
45 ///
46 /// \class IO_PDG_ParticleDataTable
47 /// Example of reading from file PDG98_ParticleDataTable.txt
48 ///
49 class IO_PDG_ParticleDataTable : public IO_BaseClass {
50 public:
51 /// constructor using filename
52 IO_PDG_ParticleDataTable( const char* filename
53 ="PDG98_ParticleDataTable.txt" );
54 virtual ~IO_PDG_ParticleDataTable();
55 /// read the input and fill the table
56 bool fill_particle_data_table( ParticleDataTable* );
57 /// add u, d, s, c, b, and t
58 void add_quarks_to_table( ParticleDataTable& );
59 /// write to ostr
60 void print( std::ostream& ostr = std::cout ) const;
61
62 /// check the IO state
63 int rdstate() const { return (int)m_file.rdstate(); }
64 protected: // for internal use only
65 /// for internal use
66 bool search_for_key_end( std::istream& in, const char* key );
67 /// read a line
68 void read_entry( ParticleDataTable* );
69 private: // following are not implemented
70 void write_event( const GenEvent* ){}
71 bool fill_next_event( GenEvent* ){ return false; }
72 void write_particle_data_table( const ParticleDataTable* ){}
73 private: // use of copy constructor is not allowed
74 IO_PDG_ParticleDataTable( const IO_PDG_ParticleDataTable& ) :
75 IO_BaseClass() {}
76 private: // member data
77 std::string m_filename;
78 std::ifstream m_file;
79 };
80
81 //////////////
82 // Inlines //
83 //////////////
84
85 inline void IO_PDG_ParticleDataTable::print( std::ostream& ostr ) const {
86 ostr << "IO_PDG_ParticleDataTable: for computer readable PDG tables.\n"
87 << " file state: " << m_file.rdstate()
88 << " bad:" << (m_file.rdstate()&std::ios::badbit)
89 << " eof:" << (m_file.rdstate()&std::ios::eofbit)
90 << " fail:" << (m_file.rdstate()&std::ios::failbit)
91 << " good:" << (m_file.rdstate()&std::ios::goodbit) << std::endl;
92 }
93
94} // HepMC
95
96#endif // HEPMC_IO_BASECLASS_H
97//--------------------------------------------------------------------------
98
99
100
101
102
103
104
Note: See TracBrowser for help on using the repository browser.