Fork me on GitHub

source: svn/trunk/Utilities/HepMC/interface/StreamInfo.h@ 771

Last change on this file since 771 was 574, checked in by cp3-support, 13 years ago

upgrade HepMC to version 2.06.05

File size: 5.0 KB
Line 
1//--------------------------------------------------------------------------
2#ifndef HEPMC_STREAM_INFO_H
3#define HEPMC_STREAM_INFO_H
4
5//////////////////////////////////////////////////////////////////////////
6// garren@fnal.gov, March 2009
7//
8// This class contains the extra information needed when using streaming IO
9//////////////////////////////////////////////////////////////////////////
10
11#include <string>
12#include "Units.h"
13
14namespace HepMC {
15
16/// The known_io enum is used to track which type of input is being read
17enum known_io { gen=1, ascii, extascii, ascii_pdt, extascii_pdt };
18
19//! StreamInfo contains extra information needed when using streaming IO.
20
21///
22/// \class StreamInfo
23/// This class contains the extra information needed when using streaming IO
24/// to process HepMC GenEvents
25///
26class StreamInfo {
27public:
28 /// default constructor
29 StreamInfo( );
30 /// destructor
31 ~StreamInfo() {}
32
33 /// IO_GenEvent begin event block key
34 std::string IO_GenEvent_Key() const { return m_io_genevent_start; }
35 /// IO_GenEvent end event block key
36 std::string IO_GenEvent_End() const { return m_io_genevent_end; }
37
38 /// IO_Ascii begin event block key
39 /// IO_Ascii has been removed, but we want to be able to read
40 /// existing files written by IO_Ascii
41 std::string IO_Ascii_Key() const { return m_io_ascii_start; }
42 /// IO_Ascii end event block key
43 std::string IO_Ascii_End() const { return m_io_ascii_end; }
44 /// IO_Ascii begin particle data block key
45 std::string IO_Ascii_PDT_Key() const { return m_io_ascii_pdt_start; }
46 /// IO_Ascii end particle data block key
47 std::string IO_Ascii_PDT_End() const { return m_io_ascii_pdt_end; }
48
49 /// IO_ExtendedAscii begin event block key
50 /// IO_ExtendedAscii has been removed, but we want to be able to read
51 /// existing files written by IO_ExtendedAscii
52 std::string IO_ExtendedAscii_Key() const { return m_io_extendedascii_start; }
53 /// IO_ExtendedAscii end event block key
54 std::string IO_ExtendedAscii_End() const { return m_io_extendedascii_end; }
55 /// IO_ExtendedAscii begin particle data block key
56 std::string IO_ExtendedAscii_PDT_Key() const { return m_io_extendedascii_pdt_start; }
57 /// IO_ExtendedAscii end particle data block key
58 std::string IO_ExtendedAscii_PDT_End() const { return m_io_extendedascii_pdt_end; }
59
60 /// get IO type
61 int io_type() const { return m_io_type; }
62 /// set IO type
63 void set_io_type( int );
64
65 /// true if the stream has a file type key
66 /// has_key is true by default
67 bool has_key() const { return m_has_key; }
68 /// set to false if the stream does not have a file type key
69 void set_has_key( bool );
70
71 /// get the I/O momentum units
72 Units::MomentumUnit io_momentum_unit() const { return m_io_momentum_unit; }
73 /// get the I/O length units
74 Units::LengthUnit io_position_unit() const { return m_io_position_unit; }
75
76 /// get the I/O stream id
77 /// This is used for sanity checking.
78 int stream_id() const { return m_stream_id; }
79
80 /// Special information is processed the first time we use the IO
81 bool finished_first_event() const { return m_finished_first_event_io; }
82 /// Special information is processed the first time we use the IO
83 void set_finished_first_event( bool b ) { m_finished_first_event_io = b; }
84
85 /// needed when reading a file without units if those units are
86 /// different than the declared default units
87 /// (e.g., the default units are MeV, but the file was written with GeV)
88 /// This method is not necessary if the units are written in the file
89 void use_input_units( Units::MomentumUnit, Units::LengthUnit );
90
91 /// reading_event_header will return true when streaming input is
92 /// processing the GenEvent header information
93 bool reading_event_header();
94 /// set the reading_event_header flag
95 void set_reading_event_header(bool);
96
97private: // data members
98 bool m_finished_first_event_io;
99 // GenEvent I/O method keys
100 std::string m_io_genevent_start;
101 std::string m_io_ascii_start;
102 std::string m_io_extendedascii_start;
103 std::string m_io_genevent_end;
104 std::string m_io_ascii_end;
105 std::string m_io_extendedascii_end;
106 // particle data I/O method keys
107 std::string m_io_ascii_pdt_start;
108 std::string m_io_extendedascii_pdt_start;
109 std::string m_io_ascii_pdt_end;
110 std::string m_io_extendedascii_pdt_end;
111 // io information
112 int m_io_type;
113 bool m_has_key;
114 // default io units - used only when reading a file with no units
115 Units::MomentumUnit m_io_momentum_unit;
116 Units::LengthUnit m_io_position_unit;
117 // used to keep identify the I/O stream
118 unsigned int m_stream_id;
119 static unsigned int m_stream_counter;
120 // used to keep track when reading event
121 bool m_reading_event_header;
122
123};
124
125} // HepMC
126
127#endif // HEPMC_STREAM_INFO_H
128//--------------------------------------------------------------------------
Note: See TracBrowser for help on using the repository browser.