Subversion Repositories hepmc

Rev

Rev 193 | Rev 276 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
188 garren 1
  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; }
  • 194 garren 40
  •   /// get IO type
  • 41
  •   int io_type() const { return m_io_type; }
  • 42
     
    188 garren 43
  •   // write keys
  • 44
  •   void write_IO_GenEvent_Key( std::ostream& );
  • 45
  •   void write_IO_GenEvent_End( std::ostream& );
  • 193 garren 46
  •   // write keys for deprecated IO methods
  • 188 garren 47
  •   void write_IO_Ascii_Key( std::ostream& );
  • 48
  •   void write_IO_Ascii_End( std::ostream& );
  • 49
  •   void write_IO_ExtendedAscii_Key( std::ostream& );
  • 50
  •   void write_IO_ExtendedAscii_End( std::ostream& );
  • 193 garren 51
  •   // write keys for deprecated particle data IO methods
  • 52
  •   void write_IO_Ascii_PDT_Key( std::ostream& );
  • 53
  •   void write_IO_Ascii_PDT_End( std::ostream& );
  • 54
  •   void write_IO_ExtendedAscii_PDT_Key( std::ostream& );
  • 55
  •   void write_IO_ExtendedAscii_PDT_End( std::ostream& );
  • 188 garren 56
     
    57
  •   // methods to read input
  • 193 garren 58
     
    59
  •   /// look for line type (key)
  • 188 garren 60
  •   int find_file_type( std::istream& );
  • 61
     
    193 garren 62
  •   /// look for line type (key)
  • 188 garren 63
  •   int find_end_key( std::istream& );
  • 64
     
    193 garren 65
  •   bool read_io_ascii( std::istream* is, GenEvent* evt );
  • 188 garren 66
     
    193 garren 67
  •   bool read_io_extendedascii( std::istream* is, GenEvent* evt );
  • 188 garren 68
     
    194 garren 69
  •   bool read_io_genevent( std::istream* is, GenEvent* evt );
  • 193 garren 70
     
    71
  •   /// ParticleDataTable is deprecated.
  • 72
  •   /// We include this method for reading old files which may have ParticleData information.
  • 194 garren 73
  •   bool read_io_particle_data_table( std::istream*, ParticleDataTable* );
  • 193 garren 74
     
    188 garren 75
  • protected:
  • 76
  •   // methods used by the read_io* methods
  • 193 garren 77
  •   HeavyIon*    read_heavy_ion( std::istream* );
  • 78
  •   PdfInfo*     read_pdf_info( std::istream* );
  • 79
  •   GenParticle* read_particle( std::istream*, TempParticleMap&  );
  • 80
  •   GenVertex*   read_vertex( std::istream*, TempParticleMap&  );
  • 194 garren 81
  •   /// ParticleDataTable is deprecated.
  • 82
  •   /// We include this method for reading old files which may have ParticleData information.
  • 83
  •   ParticleData* read_particle_data( std::istream*, ParticleDataTable* );
  • 188 garren 84
     
    85
  • private:
  • 86
  •   std::string m_io_genevent_start;
  • 87
  •   std::string m_io_ascii_start;
  • 88
  •   std::string m_io_extendedascii_start;
  • 89
  •   std::string m_io_genevent_end;
  • 90
  •   std::string m_io_ascii_end;
  • 91
  •   std::string m_io_extendedascii_end;
  • 193 garren 92
  •   // particle data method keys
  • 93
  •   std::string m_io_ascii_pdt_start;
  • 94
  •   std::string m_io_extendedascii_pdt_start;
  • 95
  •   std::string m_io_ascii_pdt_end;
  • 96
  •   std::string m_io_extendedascii_pdt_end;
  • 97
  •   int         m_io_type;
  • 98
     
    188 garren 99
     
    100
  • };
  • 101
     
    102
  • // inline methods
  • 103
     
    104
  • inline CommonIO::CommonIO()
  • 105
  • : m_io_genevent_start("HepMC::IO_GenEvent-START_EVENT_LISTING"),
  • 106
  •   m_io_ascii_start("HepMC::IO_Ascii-START_EVENT_LISTING"),
  • 107
  •   m_io_extendedascii_start("HepMC::IO_ExtendedAscii-START_EVENT_LISTING"),
  • 108
  •   m_io_genevent_end("HepMC::IO_GenEvent-END_EVENT_LISTING"),
  • 109
  •   m_io_ascii_end("HepMC::IO_Ascii-END_EVENT_LISTING"),
  • 193 garren 110
  •   m_io_extendedascii_end("HepMC::IO_ExtendedAscii-END_EVENT_LISTING"),
  • 111
  •   m_io_ascii_pdt_start("HepMC::IO_Ascii-START_PARTICLE_DATA"),
  • 112
  •   m_io_extendedascii_pdt_start("HepMC::IO_ExtendedAscii-START_PARTICLE_DATA"),
  • 113
  •   m_io_ascii_pdt_end("HepMC::IO_Ascii-END_PARTICLE_DATA"),
  • 114
  •   m_io_extendedascii_pdt_end("HepMC::IO_ExtendedAscii-END_PARTICLE_DATA"),
  • 115
  •   m_io_type(0)
  • 188 garren 116
  • {}
  • 117
     
    118
  • inline void CommonIO::write_IO_GenEvent_Key( std::ostream& os )
  • 119
  • { os << m_io_genevent_start << "\n"; }
  • 120
     
    121
  • inline void CommonIO::write_IO_GenEvent_End( std::ostream& os )
  • 122
  • { os << m_io_genevent_end << "\n"; }
  • 123
     
    124
  • inline void CommonIO::write_IO_Ascii_Key( std::ostream& os )
  • 125
  • { os << m_io_ascii_start << "\n"; }
  • 126
     
    127
  • inline void CommonIO::write_IO_Ascii_End( std::ostream& os )
  • 128
  • { os << m_io_ascii_end << "\n"; }
  • 129
     
    130
  • inline void CommonIO::write_IO_ExtendedAscii_Key( std::ostream& os )
  • 131
  • { os << m_io_extendedascii_start << "\n"; }
  • 132
     
    133
  • inline void CommonIO::write_IO_ExtendedAscii_End( std::ostream& os )
  • 134
  • { os << m_io_extendedascii_end << "\n"; }
  • 135
     
    193 garren 136
  • inline void CommonIO::write_IO_Ascii_PDT_Key( std::ostream& os )
  • 137
  • { os << m_io_ascii_pdt_start << "\n"; }
  • 138
     
    139
  • inline void CommonIO::write_IO_Ascii_PDT_End( std::ostream& os )
  • 140
  • { os << m_io_ascii_pdt_end << "\n"; }
  • 141
     
    142
  • inline void CommonIO::write_IO_ExtendedAscii_PDT_Key( std::ostream& os )
  • 143
  • { os << m_io_extendedascii_pdt_start << "\n"; }
  • 144
     
    145
  • inline void CommonIO::write_IO_ExtendedAscii_PDT_End( std::ostream& os )
  • 146
  • { os << m_io_extendedascii_pdt_end << "\n"; }
  • 147
     
    148
     
    188 garren 149
  • }
  • 150
     
    151
  • #endif // HEPMC_COMMON_IO_H