HepMC event record
build/outputs/include/HepMC/ReaderAsciiHepMC2.h
1 // -*- C++ -*-
2 //
3 // This file is part of HepMC
4 // Copyright (C) 2014-2015 The HepMC collaboration (see AUTHORS for details)
5 //
6 #ifndef HEPMC_READER_ASCII_HEPMC2_H
7 #define HEPMC_READER_ASCII_HEPMC2_H
8 /**
9  * @file ReaderAsciiHepMC2.h
10  * @brief Definition of \b class ReaderAsciiHepMC2
11  *
12  * @class HepMC::ReaderAsciiHepMC2
13  * @brief Parser for HepMC2 I/O files
14  *
15  * @ingroup IO
16  *
17  */
18 #include "HepMC/Reader.h"
19 
20 #include "HepMC/Data/SmartPointer.h"
21 
22 #include <string>
23 #include <fstream>
24 #include <vector>
25 using std::vector;
26 using std::ifstream;
27 
28 namespace HepMC {
29 
30 class GenEvent;
31 
32 class ReaderAsciiHepMC2 : public Reader {
33 //
34 // Constructors
35 //
36 public:
37  /** @brief Default constructor */
38  ReaderAsciiHepMC2(const std::string& filename);
39 //
40 // Functions
41 //
42 public:
43  /** @brief Implementation of Reader::read_event */
44  bool read_event(GenEvent &evt);
45 
46  /// @brief Return status of the stream
47  bool failed() { return (bool)m_file.rdstate(); }
48 
49  /// @brief Close file stream
50  void close();
51 
52 private:
53  /** @brief Parse event
54  *
55  * Helper routine for parsing event information
56  * @param[out] evt Event that will be filled with new data
57  * @param[in] buf Line of text that needs to be parsed
58  */
59  int parse_event_information(GenEvent &evt, const char *buf);
60 
61  /** @brief Parse units
62  *
63  * Helper routine for parsing unit information
64  * @param[out] evt Event that will be filled with unit information
65  * @param[in] buf Line of text that needs to be parsed
66  */
67  bool parse_units(GenEvent &evt, const char *buf);
68 
69  /** @brief Parse vertex
70  *
71  * Helper routine for parsing single event information
72  * @param[in] buf Line of text that needs to be parsed
73  */
74  int parse_vertex_information(const char *buf);
75 
76  /** @brief Parse particle
77  *
78  * Helper routine for parsing single particle information
79  * @param[in] buf Line of text that needs to be parsed
80  */
81  int parse_particle_information(const char *buf);
82 
83  /** @brief Parse weight names
84  *
85  * Helper routine for parsing weight names
86  * @param[in] buf Line of text that needs to be parsed
87  */
88  bool parse_weight_names(const char *buf);
89 
90  /** @brief Parse heavy ion information
91  *
92  * Helper routine for parsing heavy ion information
93  * @param[out] evt Event that will be filled with new data
94  * @param[in] buf Line of text that needs to be parsed
95  */
96  bool parse_heavy_ion(GenEvent &evt, const char *buf);
97 
98  /** @brief Parse pdf information
99  *
100  * Helper routine for parsing pdf information
101  * @param[out] evt Event that will be filled with new data
102  * @param[in] buf Line of text that needs to be parsed
103  */
104  bool parse_pdf_info(GenEvent &evt, const char *buf);
105 
106 
107  /** @brief Parse pdf information
108  *
109  * Helper routine for parsing cross-section information
110  * @param[out] evt Event that will be filled with new data
111  * @param[in] buf Line of text that needs to be parsed
112  */
113  bool parse_xs_info(GenEvent &evt, const char *buf);
114 
115 
116 
117 //
118 // Fields
119 //
120 private:
121  ifstream m_file; //!< Input file
122 
123  vector<GenVertexPtr> m_vertex_cache; //!< Vertex cache
124  vector<int> m_vertex_barcodes; //!< Old vertex barcodes
125 
126  vector<GenParticlePtr> m_particle_cache; //!< Particle cache
127  vector<int> m_end_vertex_barcodes; //!< Old end vertex barcodes
128 };
129 
130 } // namespace HepMC
131 
132 #endif
bool parse_heavy_ion(GenEvent &evt, const char *buf)
Parse heavy ion information.
Base class for all I/O readers.
vector< GenParticlePtr > m_particle_cache
Particle cache.
ReaderAsciiHepMC2(const std::string &filename)
Default constructor.
bool read_event(GenEvent &evt)
Implementation of Reader::read_event.
bool parse_weight_names(const char *buf)
Parse weight names.
vector< int > m_vertex_barcodes
Old vertex barcodes.
bool parse_units(GenEvent &evt, const char *buf)
Parse units.
void close()
Close file stream.
vector< GenVertexPtr > m_vertex_cache
Vertex cache.
Stores event-related information.
bool parse_xs_info(GenEvent &evt, const char *buf)
Parse pdf information.
int parse_vertex_information(const char *buf)
Parse vertex.
int parse_event_information(GenEvent &evt, const char *buf)
Parse event.
Definition of template class SmartPointer.
bool parse_pdf_info(GenEvent &evt, const char *buf)
Parse pdf information.
vector< int > m_end_vertex_barcodes
Old end vertex barcodes.
int parse_particle_information(const char *buf)
Parse particle.