hepmc - Blame information for rev 276

Subversion Repositories:
Rev:
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; }
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  
276 garren 71   bool read_units( std::istream* is, GenEvent* evt );
72  
193 garren 73   /// ParticleDataTable is deprecated.
74   /// We include this method for reading old files which may have ParticleData information.
194 garren 75   bool read_io_particle_data_table( std::istream*, ParticleDataTable* );
193 garren 76  
188 garren 77 protected:
78   // methods used by the read_io* methods
193 garren 79   HeavyIon*    read_heavy_ion( std::istream* );
80   PdfInfo*     read_pdf_info( std::istream* );
81   GenParticle* read_particle( std::istream*, TempParticleMap&  );
82   GenVertex*   read_vertex( std::istream*, TempParticleMap&  );
194 garren 83   /// ParticleDataTable is deprecated.
84   /// We include this method for reading old files which may have ParticleData information.
85   ParticleData* read_particle_data( std::istream*, ParticleDataTable* );
188 garren 86  
87 private:
88   std::string m_io_genevent_start;
89   std::string m_io_ascii_start;
90   std::string m_io_extendedascii_start;
91   std::string m_io_genevent_end;
92   std::string m_io_ascii_end;
93   std::string m_io_extendedascii_end;
193 garren 94   // particle data method keys
95   std::string m_io_ascii_pdt_start;
96   std::string m_io_extendedascii_pdt_start;
97   std::string m_io_ascii_pdt_end;
98   std::string m_io_extendedascii_pdt_end;
276 garren 99   // io type
193 garren 100   int         m_io_type;
101  
188 garren 102  
103 };
104  
105 // inline methods
106  
107 inline CommonIO::CommonIO()
108 : m_io_genevent_start("HepMC::IO_GenEvent-START_EVENT_LISTING"),
109   m_io_ascii_start("HepMC::IO_Ascii-START_EVENT_LISTING"),
110   m_io_extendedascii_start("HepMC::IO_ExtendedAscii-START_EVENT_LISTING"),
111   m_io_genevent_end("HepMC::IO_GenEvent-END_EVENT_LISTING"),
112   m_io_ascii_end("HepMC::IO_Ascii-END_EVENT_LISTING"),
193 garren 113   m_io_extendedascii_end("HepMC::IO_ExtendedAscii-END_EVENT_LISTING"),
114   m_io_ascii_pdt_start("HepMC::IO_Ascii-START_PARTICLE_DATA"),
115   m_io_extendedascii_pdt_start("HepMC::IO_ExtendedAscii-START_PARTICLE_DATA"),
116   m_io_ascii_pdt_end("HepMC::IO_Ascii-END_PARTICLE_DATA"),
117   m_io_extendedascii_pdt_end("HepMC::IO_ExtendedAscii-END_PARTICLE_DATA"),
118   m_io_type(0)
188 garren 119 {}
120  
121 inline void CommonIO::write_IO_GenEvent_Key( std::ostream& os )
122 { os << m_io_genevent_start << "\n"; }
123  
124 inline void CommonIO::write_IO_GenEvent_End( std::ostream& os )
125 { os << m_io_genevent_end << "\n"; }
126  
127 inline void CommonIO::write_IO_Ascii_Key( std::ostream& os )
128 { os << m_io_ascii_start << "\n"; }
129  
130 inline void CommonIO::write_IO_Ascii_End( std::ostream& os )
131 { os << m_io_ascii_end << "\n"; }
132  
133 inline void CommonIO::write_IO_ExtendedAscii_Key( std::ostream& os )
134 { os << m_io_extendedascii_start << "\n"; }
135  
136 inline void CommonIO::write_IO_ExtendedAscii_End( std::ostream& os )
137 { os << m_io_extendedascii_end << "\n"; }
138  
193 garren 139 inline void CommonIO::write_IO_Ascii_PDT_Key( std::ostream& os )
140 { os << m_io_ascii_pdt_start << "\n"; }
141  
142 inline void CommonIO::write_IO_Ascii_PDT_End( std::ostream& os )
143 { os << m_io_ascii_pdt_end << "\n"; }
144  
145 inline void CommonIO::write_IO_ExtendedAscii_PDT_Key( std::ostream& os )
146 { os << m_io_extendedascii_pdt_start << "\n"; }
147  
148 inline void CommonIO::write_IO_ExtendedAscii_PDT_End( std::ostream& os )
149 { os << m_io_extendedascii_pdt_end << "\n"; }
150  
188 garren 151 }
152  
153 #endif // HEPMC_COMMON_IO_H