Fork me on GitHub

source: git/external/HepMC3/ReaderAsciiHepMC2.h@ 95a917c

Last change on this file since 95a917c was 95a917c, checked in by Pavel Demin <pavel.demin@…>, 3 years ago

add HepMC3 library

  • Property mode set to 100644
File size: 4.0 KB
Line 
1// -*- C++ -*-
2//
3// This file is part of HepMC
4// Copyright (C) 2014-2020 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
42 ~ReaderAsciiHepMC2();
43//
44// Functions
45//
46public:
47 /// @brief skip events
48 bool skip(const int) override;
49
50 /** @brief Implementation of Reader::read_event */
51 bool read_event(GenEvent &evt) override;
52
53 /// @brief Return status of the stream
54 bool failed() override;
55
56 /// @brief Close file stream
57 void close() override;
58
59private:
60 /** @brief Parse event
61 *
62 * Helper routine for parsing event information
63 * @param[out] evt Event that will be filled with new data
64 * @param[in] buf Line of text that needs to be parsed
65 */
66 int parse_event_information(GenEvent &evt, const char *buf);
67
68 /** @brief Parse units
69 *
70 * Helper routine for parsing unit information
71 * @param[out] evt Event that will be filled with unit information
72 * @param[in] buf Line of text that needs to be parsed
73 */
74 bool parse_units(GenEvent &evt, const char *buf);
75
76 /** @brief Parse vertex
77 *
78 * Helper routine for parsing single event information
79 * @param[in] buf Line of text that needs to be parsed
80 */
81 int parse_vertex_information(const char *buf);
82
83 /** @brief Parse particle
84 *
85 * Helper routine for parsing single particle information
86 * @param[in] buf Line of text that needs to be parsed
87 */
88 int parse_particle_information(const char *buf);
89
90 /** @brief Parse weight names
91 *
92 * Helper routine for parsing weight names
93 * @param[in] buf Line of text that needs to be parsed
94 */
95 bool parse_weight_names(const char *buf);
96
97 /** @brief Parse heavy ion information
98 *
99 * Helper routine for parsing heavy ion information
100 * @param[out] evt Event that will be filled with new data
101 * @param[in] buf Line of text that needs to be parsed
102 */
103 bool parse_heavy_ion(GenEvent &evt, const char *buf);
104
105 /** @brief Parse pdf information
106 *
107 * Helper routine for parsing pdf information
108 * @param[out] evt Event that will be filled with new data
109 * @param[in] buf Line of text that needs to be parsed
110 */
111 bool parse_pdf_info(GenEvent &evt, const char *buf);
112
113
114 /** @brief Parse pdf information
115 *
116 * Helper routine for parsing cross-section information
117 * @param[out] evt Event that will be filled with new data
118 * @param[in] buf Line of text that needs to be parsed
119 */
120 bool parse_xs_info(GenEvent &evt, const char *buf);
121
122
123
124//
125// Fields
126//
127private:
128 std::ifstream m_file; //!< Input file
129 std::istream* m_stream; ///< For ctor when reading from stdin
130 bool m_isstream; ///< toggles usage of m_file or m_stream
131
132 std::vector<GenVertexPtr> m_vertex_cache; //!< Vertex cache
133 std::vector<int> m_vertex_barcodes; //!< Old vertex barcodes
134
135 std::vector<GenParticlePtr> m_particle_cache; //!< Particle cache
136 std::vector<int> m_end_vertex_barcodes; //!< Old end vertex barcodes
137
138 GenEvent* m_event_ghost; //!< To save particle and verstex attributes.
139 std::vector<GenParticlePtr> m_particle_cache_ghost;//!< Particle cache for attributes
140 std::vector<GenVertexPtr> m_vertex_cache_ghost; //!< Vertex cache for attributes
141};
142
143} // namespace HepMC3
144
145#endif
Note: See TracBrowser for help on using the repository browser.