hepmc - Blame information for rev 193
Subversion Repositories:
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 188 | garren | 1 | #ifndef HEPMC_COMMON_IO_H |
| 2 | #define HEPMC_COMMON_IO_H | ||
| 3 | // ---------------------------------------------------------------------- | ||
| 4 | // | ||
| 5 | // CommonIO.h | ||
| 6 | // Author: Lynn Garren | ||
| 7 | // | ||
| 8 | // Allowed keys used at the beginning and end of HepMC data dumps | ||
| 9 | // | ||
| 10 | // ---------------------------------------------------------------------- | ||
| 11 | |||
| 12 | #include <fstream> | ||
| 13 | #include <string> | ||
| 14 | |||
| 15 | #include "HepMC/GenEvent.h" | ||
| 16 | #include "HepMC/TempParticleMap.h" | ||
| 193 | garren | 17 | #include "HepMC/ParticleDataTable.h" |
| 188 | garren | 18 | |
| 19 | namespace HepMC { | ||
| 20 | |||
| 21 | /// The known_io enum is used to track which type of input is being read | ||
| 193 | garren | 22 | enum known_io { gen=1, ascii, extascii, ascii_pdt, extascii_pdt }; |
| 188 | garren | 23 | |
| 24 | class CommonIO { | ||
| 25 | |||
| 26 | public: | ||
| 27 | |||
| 28 | CommonIO(); | ||
| 29 | ~CommonIO() {;} | ||
| 30 | |||
| 31 | // input keys - IO_GenEvent is strongly recommended | ||
| 32 | std::string IO_GenEvent_Key() const { return m_io_genevent_start; } | ||
| 33 | std::string IO_GenEvent_End() const { return m_io_genevent_end; } | ||
| 34 | // IO_Ascii is deprecated, but we want to be able to read these files | ||
| 35 | std::string IO_Ascii_Key() const { return m_io_ascii_start; } | ||
| 36 | std::string IO_Ascii_End() const { return m_io_ascii_end; } | ||
| 37 | // IO_ExtendedAscii is deprecated, but we want to be able to read these files | ||
| 38 | std::string IO_ExtendedAscii_Key() const { return m_io_extendedascii_start; } | ||
| 39 | std::string IO_ExtendedAscii_End() const { return m_io_extendedascii_end; } | ||
| 40 | |||
| 41 | // write keys | ||
| 42 | void write_IO_GenEvent_Key( std::ostream& ); | ||
| 43 | void write_IO_GenEvent_End( std::ostream& ); | ||
| 193 | garren | 44 | // write keys for deprecated IO methods |
| 188 | garren | 45 | void write_IO_Ascii_Key( std::ostream& ); |
| 46 | void write_IO_Ascii_End( std::ostream& ); | ||
| 47 | void write_IO_ExtendedAscii_Key( std::ostream& ); | ||
| 48 | void write_IO_ExtendedAscii_End( std::ostream& ); | ||
| 193 | garren | 49 | // write keys for deprecated particle data IO methods |
| 50 | void write_IO_Ascii_PDT_Key( std::ostream& ); | ||
| 51 | void write_IO_Ascii_PDT_End( std::ostream& ); | ||
| 52 | void write_IO_ExtendedAscii_PDT_Key( std::ostream& ); | ||
| 53 | void write_IO_ExtendedAscii_PDT_End( std::ostream& ); | ||
| 188 | garren | 54 | |
| 55 | // methods to read input | ||
| 193 | garren | 56 | |
| 57 | /// look for line type (key) | ||
| 188 | garren | 58 | int find_file_type( std::istream& ); |
| 59 | |||
| 193 | garren | 60 | /// look for line type (key) |
| 188 | garren | 61 | int find_end_key( std::istream& ); |
| 62 | |||
| 193 | garren | 63 | bool read_io_ascii( std::istream* is, GenEvent* evt ); |
| 188 | garren | 64 | |
| 193 | garren | 65 | bool read_io_extendedascii( std::istream* is, GenEvent* evt ); |
| 188 | garren | 66 | |
| 67 | bool read_io_genevent_event( std::istream* is, GenEvent* evt ); | ||
| 193 | garren | 68 | |
| 69 | /// ParticleDataTable is deprecated. | ||
| 70 | /// We include this method for reading old files which may have ParticleData information. | ||
| 71 | ParticleData* read_particle_data( std::istream*, ParticleDataTable* ); | ||
| 72 | |||
| 188 | garren | 73 | protected: |
| 74 | // methods used by the read_io* methods | ||
| 193 | garren | 75 | HeavyIon* read_heavy_ion( std::istream* ); |
| 76 | PdfInfo* read_pdf_info( std::istream* ); | ||
| 77 | GenParticle* read_particle( std::istream*, TempParticleMap& ); | ||
| 78 | GenVertex* read_vertex( std::istream*, TempParticleMap& ); | ||
| 188 | garren | 79 | |
| 80 | private: | ||
| 81 | std::string m_io_genevent_start; | ||
| 82 | std::string m_io_ascii_start; | ||
| 83 | std::string m_io_extendedascii_start; | ||
| 84 | std::string m_io_genevent_end; | ||
| 85 | std::string m_io_ascii_end; | ||
| 86 | std::string m_io_extendedascii_end; | ||
| 193 | garren | 87 | // particle data method keys |
| 88 | std::string m_io_ascii_pdt_start; | ||
| 89 | std::string m_io_extendedascii_pdt_start; | ||
| 90 | std::string m_io_ascii_pdt_end; | ||
| 91 | std::string m_io_extendedascii_pdt_end; | ||
| 92 | int m_io_type; | ||
| 93 | |||
| 188 | garren | 94 | |
| 95 | }; | ||
| 96 | |||
| 97 | // inline methods | ||
| 98 | |||
| 99 | inline CommonIO::CommonIO() | ||
| 100 | : m_io_genevent_start("HepMC::IO_GenEvent-START_EVENT_LISTING"), | ||
| 101 | m_io_ascii_start("HepMC::IO_Ascii-START_EVENT_LISTING"), | ||
| 102 | m_io_extendedascii_start("HepMC::IO_ExtendedAscii-START_EVENT_LISTING"), | ||
| 103 | m_io_genevent_end("HepMC::IO_GenEvent-END_EVENT_LISTING"), | ||
| 104 | m_io_ascii_end("HepMC::IO_Ascii-END_EVENT_LISTING"), | ||
| 193 | garren | 105 | m_io_extendedascii_end("HepMC::IO_ExtendedAscii-END_EVENT_LISTING"), |
| 106 | m_io_ascii_pdt_start("HepMC::IO_Ascii-START_PARTICLE_DATA"), | ||
| 107 | m_io_extendedascii_pdt_start("HepMC::IO_ExtendedAscii-START_PARTICLE_DATA"), | ||
| 108 | m_io_ascii_pdt_end("HepMC::IO_Ascii-END_PARTICLE_DATA"), | ||
| 109 | m_io_extendedascii_pdt_end("HepMC::IO_ExtendedAscii-END_PARTICLE_DATA"), | ||
| 110 | m_io_type(0) | ||
| 188 | garren | 111 | {} |
| 112 | |||
| 113 | inline void CommonIO::write_IO_GenEvent_Key( std::ostream& os ) | ||
| 114 | { os << m_io_genevent_start << "\n"; } | ||
| 115 | |||
| 116 | inline void CommonIO::write_IO_GenEvent_End( std::ostream& os ) | ||
| 117 | { os << m_io_genevent_end << "\n"; } | ||
| 118 | |||
| 119 | inline void CommonIO::write_IO_Ascii_Key( std::ostream& os ) | ||
| 120 | { os << m_io_ascii_start << "\n"; } | ||
| 121 | |||
| 122 | inline void CommonIO::write_IO_Ascii_End( std::ostream& os ) | ||
| 123 | { os << m_io_ascii_end << "\n"; } | ||
| 124 | |||
| 125 | inline void CommonIO::write_IO_ExtendedAscii_Key( std::ostream& os ) | ||
| 126 | { os << m_io_extendedascii_start << "\n"; } | ||
| 127 | |||
| 128 | inline void CommonIO::write_IO_ExtendedAscii_End( std::ostream& os ) | ||
| 129 | { os << m_io_extendedascii_end << "\n"; } | ||
| 130 | |||
| 193 | garren | 131 | inline void CommonIO::write_IO_Ascii_PDT_Key( std::ostream& os ) |
| 132 | { os << m_io_ascii_pdt_start << "\n"; } | ||
| 133 | |||
| 134 | inline void CommonIO::write_IO_Ascii_PDT_End( std::ostream& os ) | ||
| 135 | { os << m_io_ascii_pdt_end << "\n"; } | ||
| 136 | |||
| 137 | inline void CommonIO::write_IO_ExtendedAscii_PDT_Key( std::ostream& os ) | ||
| 138 | { os << m_io_extendedascii_pdt_start << "\n"; } | ||
| 139 | |||
| 140 | inline void CommonIO::write_IO_ExtendedAscii_PDT_End( std::ostream& os ) | ||
| 141 | { os << m_io_extendedascii_pdt_end << "\n"; } | ||
| 142 | |||
| 143 | |||
| 188 | garren | 144 | } |
| 145 | |||
| 146 | #endif // HEPMC_COMMON_IO_H |
