00001 #ifndef HEPMC_COMMON_IO_H
00002 #define HEPMC_COMMON_IO_H
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #include <fstream>
00013 #include <string>
00014
00015 #include "HepMC/GenEvent.h"
00016 #include "HepMC/TempParticleMap.h"
00017 #include "HepMC/ParticleDataTable.h"
00018
00019 namespace HepMC {
00020
00022 enum known_io { gen=1, ascii, extascii, ascii_pdt, extascii_pdt };
00023
00024 class CommonIO {
00025
00026 public:
00027
00028 CommonIO();
00029 ~CommonIO() {;}
00030
00031
00032 std::string IO_GenEvent_Key() const { return m_io_genevent_start; }
00033 std::string IO_GenEvent_End() const { return m_io_genevent_end; }
00034
00035 std::string IO_Ascii_Key() const { return m_io_ascii_start; }
00036 std::string IO_Ascii_End() const { return m_io_ascii_end; }
00037
00038 std::string IO_ExtendedAscii_Key() const { return m_io_extendedascii_start; }
00039 std::string IO_ExtendedAscii_End() const { return m_io_extendedascii_end; }
00041 int io_type() const { return m_io_type; }
00042
00043
00044 void write_IO_GenEvent_Key( std::ostream& );
00045 void write_IO_GenEvent_End( std::ostream& );
00046
00047 void write_IO_Ascii_Key( std::ostream& );
00048 void write_IO_Ascii_End( std::ostream& );
00049 void write_IO_ExtendedAscii_Key( std::ostream& );
00050 void write_IO_ExtendedAscii_End( std::ostream& );
00051
00052 void write_IO_Ascii_PDT_Key( std::ostream& );
00053 void write_IO_Ascii_PDT_End( std::ostream& );
00054 void write_IO_ExtendedAscii_PDT_Key( std::ostream& );
00055 void write_IO_ExtendedAscii_PDT_End( std::ostream& );
00056
00057
00058
00060 int find_file_type( std::istream& );
00061
00063 int find_end_key( std::istream& );
00064
00065 bool read_io_ascii( std::istream* is, GenEvent* evt );
00066
00067 bool read_io_extendedascii( std::istream* is, GenEvent* evt );
00068
00069 bool read_io_genevent( std::istream* is, GenEvent* evt );
00070
00073 bool read_io_particle_data_table( std::istream*, ParticleDataTable* );
00074
00075 protected:
00076
00077 HeavyIon* read_heavy_ion( std::istream* );
00078 PdfInfo* read_pdf_info( std::istream* );
00079 GenParticle* read_particle( std::istream*, TempParticleMap& );
00080 GenVertex* read_vertex( std::istream*, TempParticleMap& );
00083 ParticleData* read_particle_data( std::istream*, ParticleDataTable* );
00084
00085 private:
00086 std::string m_io_genevent_start;
00087 std::string m_io_ascii_start;
00088 std::string m_io_extendedascii_start;
00089 std::string m_io_genevent_end;
00090 std::string m_io_ascii_end;
00091 std::string m_io_extendedascii_end;
00092
00093 std::string m_io_ascii_pdt_start;
00094 std::string m_io_extendedascii_pdt_start;
00095 std::string m_io_ascii_pdt_end;
00096 std::string m_io_extendedascii_pdt_end;
00097 int m_io_type;
00098
00099
00100 };
00101
00102
00103
00104 inline CommonIO::CommonIO()
00105 : m_io_genevent_start("HepMC::IO_GenEvent-START_EVENT_LISTING"),
00106 m_io_ascii_start("HepMC::IO_Ascii-START_EVENT_LISTING"),
00107 m_io_extendedascii_start("HepMC::IO_ExtendedAscii-START_EVENT_LISTING"),
00108 m_io_genevent_end("HepMC::IO_GenEvent-END_EVENT_LISTING"),
00109 m_io_ascii_end("HepMC::IO_Ascii-END_EVENT_LISTING"),
00110 m_io_extendedascii_end("HepMC::IO_ExtendedAscii-END_EVENT_LISTING"),
00111 m_io_ascii_pdt_start("HepMC::IO_Ascii-START_PARTICLE_DATA"),
00112 m_io_extendedascii_pdt_start("HepMC::IO_ExtendedAscii-START_PARTICLE_DATA"),
00113 m_io_ascii_pdt_end("HepMC::IO_Ascii-END_PARTICLE_DATA"),
00114 m_io_extendedascii_pdt_end("HepMC::IO_ExtendedAscii-END_PARTICLE_DATA"),
00115 m_io_type(0)
00116 {}
00117
00118 inline void CommonIO::write_IO_GenEvent_Key( std::ostream& os )
00119 { os << m_io_genevent_start << "\n"; }
00120
00121 inline void CommonIO::write_IO_GenEvent_End( std::ostream& os )
00122 { os << m_io_genevent_end << "\n"; }
00123
00124 inline void CommonIO::write_IO_Ascii_Key( std::ostream& os )
00125 { os << m_io_ascii_start << "\n"; }
00126
00127 inline void CommonIO::write_IO_Ascii_End( std::ostream& os )
00128 { os << m_io_ascii_end << "\n"; }
00129
00130 inline void CommonIO::write_IO_ExtendedAscii_Key( std::ostream& os )
00131 { os << m_io_extendedascii_start << "\n"; }
00132
00133 inline void CommonIO::write_IO_ExtendedAscii_End( std::ostream& os )
00134 { os << m_io_extendedascii_end << "\n"; }
00135
00136 inline void CommonIO::write_IO_Ascii_PDT_Key( std::ostream& os )
00137 { os << m_io_ascii_pdt_start << "\n"; }
00138
00139 inline void CommonIO::write_IO_Ascii_PDT_End( std::ostream& os )
00140 { os << m_io_ascii_pdt_end << "\n"; }
00141
00142 inline void CommonIO::write_IO_ExtendedAscii_PDT_Key( std::ostream& os )
00143 { os << m_io_extendedascii_pdt_start << "\n"; }
00144
00145 inline void CommonIO::write_IO_ExtendedAscii_PDT_End( std::ostream& os )
00146 { os << m_io_extendedascii_pdt_end << "\n"; }
00147
00148
00149 }
00150
00151 #endif // HEPMC_COMMON_IO_H