Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:01:10

0001 //--------------------------------------------------------------------------
0002 #ifndef HEPMC_STREAM_INFO_H
0003 #define HEPMC_STREAM_INFO_H
0004 
0005 //////////////////////////////////////////////////////////////////////////
0006 // garren@fnal.gov, March 2009
0007 //
0008 // This class contains the extra information needed when using streaming IO
0009 //////////////////////////////////////////////////////////////////////////
0010 
0011 #include <string>
0012 #include "HepMC/Units.h"
0013 
0014 namespace HepMC {
0015 
0016 /// The known_io enum is used to track which type of input is being read
0017 enum known_io { gen=1, ascii, extascii, ascii_pdt, extascii_pdt };
0018 
0019 //! StreamInfo contains extra information needed when using streaming IO.
0020 
0021 ///
0022 /// \class  StreamInfo
0023 /// This class contains the extra information needed when using streaming IO
0024 /// to process HepMC GenEvents
0025 ///
0026 class StreamInfo {
0027 public:
0028     /// default constructor
0029     StreamInfo( );
0030     /// destructor
0031     ~StreamInfo() {}
0032 
0033     /// IO_GenEvent begin event block key
0034     std::string IO_GenEvent_Key()          const { return m_io_genevent_start; }
0035     /// IO_GenEvent end event block key
0036     std::string IO_GenEvent_End()          const { return m_io_genevent_end; }
0037 
0038     /// IO_Ascii begin event block key
0039     /// IO_Ascii has been removed, but we want to be able to read 
0040     /// existing files written by IO_Ascii
0041     std::string IO_Ascii_Key()             const { return m_io_ascii_start; }
0042     /// IO_Ascii end event block key
0043     std::string IO_Ascii_End()             const { return m_io_ascii_end; }
0044     /// IO_Ascii begin particle data block key
0045     std::string IO_Ascii_PDT_Key()             const { return m_io_ascii_pdt_start; }
0046     /// IO_Ascii end particle data block key
0047     std::string IO_Ascii_PDT_End()             const { return m_io_ascii_pdt_end; }
0048 
0049     /// IO_ExtendedAscii begin event block key
0050     /// IO_ExtendedAscii has been removed, but we want to be able to read 
0051     /// existing files written by IO_ExtendedAscii
0052     std::string IO_ExtendedAscii_Key()     const { return m_io_extendedascii_start; }
0053     /// IO_ExtendedAscii end event block key
0054     std::string IO_ExtendedAscii_End()     const { return m_io_extendedascii_end; }
0055     /// IO_ExtendedAscii begin particle data block key
0056     std::string IO_ExtendedAscii_PDT_Key()             const { return m_io_extendedascii_pdt_start; }
0057     /// IO_ExtendedAscii end particle data block key
0058     std::string IO_ExtendedAscii_PDT_End()             const { return m_io_extendedascii_pdt_end; }
0059 
0060     /// get IO type
0061     int io_type() const { return m_io_type; }
0062     /// set IO type
0063     void set_io_type( int );
0064 
0065     /// true if the stream has a file type key
0066     /// has_key is true by default
0067     bool has_key() const { return m_has_key; }
0068     /// set to false if the stream does not have a file type key
0069     void set_has_key( bool );
0070     
0071     /// get the I/O momentum units
0072     Units::MomentumUnit io_momentum_unit() const { return m_io_momentum_unit; }
0073     /// get the I/O length units
0074     Units::LengthUnit io_position_unit() const { return m_io_position_unit; }
0075 
0076     /// get the I/O stream id
0077     /// This is used for sanity checking.
0078     int stream_id() const { return m_stream_id; }
0079     
0080     /// Special information is processed the first time we use the IO
0081     bool finished_first_event() const { return m_finished_first_event_io; }
0082     /// Special information is processed the first time we use the IO
0083     void set_finished_first_event( bool b ) { m_finished_first_event_io = b; }
0084 
0085     /// needed when reading a file without units if those units are 
0086     /// different than the declared default units 
0087     /// (e.g., the default units are MeV, but the file was written with GeV)
0088     /// This method is not necessary if the units are written in the file
0089     void use_input_units( Units::MomentumUnit, Units::LengthUnit );
0090     
0091     /// reading_event_header will return true when streaming input is 
0092     /// processing the GenEvent header information
0093     bool reading_event_header();
0094     /// set the reading_event_header flag
0095     void set_reading_event_header(bool);
0096 
0097 private: // data members
0098     bool        m_finished_first_event_io;
0099     // GenEvent I/O method keys
0100     std::string m_io_genevent_start;
0101     std::string m_io_ascii_start;
0102     std::string m_io_extendedascii_start;
0103     std::string m_io_genevent_end;
0104     std::string m_io_ascii_end;
0105     std::string m_io_extendedascii_end;
0106     // particle data I/O method keys
0107     std::string m_io_ascii_pdt_start;
0108     std::string m_io_extendedascii_pdt_start;
0109     std::string m_io_ascii_pdt_end;
0110     std::string m_io_extendedascii_pdt_end;
0111     // io information
0112     int         m_io_type;
0113     bool        m_has_key;
0114     // default io units - used only when reading a file with no units
0115     Units::MomentumUnit m_io_momentum_unit;
0116     Units::LengthUnit   m_io_position_unit;
0117     // used to keep identify the I/O stream
0118     unsigned int m_stream_id;
0119     static unsigned int m_stream_counter;
0120     // used to keep track when reading event
0121     bool m_reading_event_header;
0122 
0123 };
0124 
0125 } // HepMC
0126 
0127 #endif  // HEPMC_STREAM_INFO_H
0128 //--------------------------------------------------------------------------