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