![]() |
HepMC Reference DocumentationHepMC |
00001 //-------------------------------------------------------------------------- 00002 #ifndef HEPMC_IO_GENEVENT_H 00003 #define HEPMC_IO_GENEVENT_H 00004 00006 // garren@fnal.gov, July 2007 00007 // with input from Gavin Salam, salam@lpthe.jussieu.fr 00008 // 00009 // event input/output in ascii format for machine reading 00010 // This class persists all information found in a GenEvent 00012 00013 #include <fstream> 00014 #include <string> 00015 #include <map> 00016 #include <vector> 00017 #include "HepMC/IO_BaseClass.h" 00018 #include "HepMC/IO_Exception.h" 00019 #include "HepMC/Units.h" 00020 00021 namespace HepMC { 00022 00023 class GenEvent; 00024 class GenVertex; 00025 class GenParticle; 00026 class ParticleData; 00027 class HeavyIon; 00028 class PdfInfo; 00029 00031 00064 class IO_GenEvent : public IO_BaseClass { 00065 public: 00067 IO_GenEvent( const std::string& filename="IO_GenEvent.dat", 00068 std::ios::openmode mode=std::ios::out ); 00070 IO_GenEvent( std::istream & ); 00072 IO_GenEvent( std::ostream & ); 00073 virtual ~IO_GenEvent(); 00074 00076 void write_event( const GenEvent* evt ); 00078 bool fill_next_event( GenEvent* evt ); 00080 void write_particle_data_table(const ParticleDataTable*); 00082 bool fill_particle_data_table( ParticleDataTable* ); 00086 void write_comment( const std::string comment ); 00087 00088 int rdstate() const; 00089 void clear(); 00090 00092 void print( std::ostream& ostr = std::cout ) const; 00093 00098 void use_input_units( Units::MomentumUnit, Units::LengthUnit ); 00099 00102 void precision( int ); 00103 00105 const int error_type() const; 00107 const std::string & error_message() const; 00108 00109 protected: // for internal use only 00110 00114 ParticleData* read_particle_data( std::istream*, ParticleDataTable* ); 00115 bool read_io_particle_data_table( std::istream*, ParticleDataTable* ); 00116 00117 private: // use of copy constructor is not allowed 00118 IO_GenEvent( const IO_GenEvent& ) : IO_BaseClass() {} 00119 00120 private: // data members 00121 std::ios::openmode m_mode; 00122 std::fstream m_file; 00123 std::ostream * m_ostr; 00124 std::istream * m_istr; 00125 std::ios * m_iostr; 00126 bool m_have_file; 00127 IO_Exception::ErrorType m_error_type; 00128 std::string m_error_message; 00129 00130 }; 00131 00133 // Inlines // 00135 00136 inline int IO_GenEvent::rdstate() const { 00137 int state; 00138 if( m_istr ) { 00139 state = (int)m_istr->rdstate(); 00140 } else { 00141 state = (int)m_ostr->rdstate(); 00142 } 00143 return state; 00144 } 00145 00146 inline void IO_GenEvent::clear() { 00147 if( m_istr ) { 00148 m_istr->clear(); 00149 } else { 00150 m_ostr->clear(); 00151 } 00152 } 00153 00154 inline const int IO_GenEvent::error_type() const { 00155 return m_error_type; 00156 } 00157 00158 inline const std::string & IO_GenEvent::error_message() const { 00159 return m_error_message; 00160 } 00161 00162 // these are required by IO_BaseClass, but not used here 00163 inline void IO_GenEvent::write_particle_data_table(const ParticleDataTable*) {;} 00164 inline bool IO_GenEvent::fill_particle_data_table( ParticleDataTable* ) 00165 { return false;} 00166 00167 } // HepMC 00168 00169 #endif // HEPMC_IO_GENEVENT_H 00170 //--------------------------------------------------------------------------