MARLEY (Model of Argon Reaction Low Energy Yields) v2.0.0
A Monte Carlo event generator for tens-of-MeV neutrino interactions
Loading...
Searching...
No Matches
ReaderAscii.h
1// -*- C++ -*-
2//
3// This file is part of HepMC
4// Copyright (C) 2014-2023 The HepMC collaboration (see AUTHORS for details)
5//
6#ifndef HEPMC3_READERASCII_H
7#define HEPMC3_READERASCII_H
17#include <set>
18#include <string>
19#include <fstream>
20#include <istream>
21#include <iterator>
22#include <unordered_map>
23#include "HepMC3/Reader.h"
24#include "HepMC3/GenEvent.h"
25#include "HepMC3/Data/GenEventData.h"
26
27
28namespace HepMC3 {
29
30
31class ReaderAscii : public Reader {
32public:
33
35 ReaderAscii(const std::string& filename);
37 ReaderAscii(std::istream &);
39 ReaderAscii(std::shared_ptr<std::istream> s_stream);
42
44 bool skip(const int) override;
45
49 bool read_event(GenEvent& evt) override;
50
52 bool failed() override;
53
55 void close() override;
56
57private:
58
60 static std::string unescape(const std::string& s);
61
64
70 std::pair<int,int> parse_event_information(const char *buf);
71
77 bool parse_weight_values(const char *buf);
78
84 bool parse_units(const char *buf);
85
90 bool parse_pdf_info(const char *buf);
91
96 bool parse_heavy_ion(const char *buf);
97
102 bool parse_cross_section( const char *buf);
103
109 bool parse_vertex_information(const char *buf);
110
115 bool parse_particle_information(const char *buf);
116
121 bool parse_attribute( const char *buf);
122
127 bool parse_run_attribute(const char *buf);
128
134 bool parse_weight_names(const char *buf);
135
141 bool parse_tool(const char *buf);
143
144
145private:
146
147 std::ifstream m_file;
148 std::shared_ptr<std::istream> m_shared_stream = nullptr;
149 std::istream* m_stream = nullptr;
150 bool m_isstream;
151
153 std::map<int, std::pair< std::set<int>, std::set<int> > > m_io_explicit;
155 std::unordered_map<int, std::pair< std::set<int>, std::set<int> > > m_io_implicit;
157 std::vector<int> m_io_implicit_ids;
159 std::set<int> m_io_explicit_ids;
160
161 GenEventData m_data;
162};
163
164
165} // namespace HepMC3
166
167#endif
Stores event-related information.
Definition GenEvent.h:47
ReaderAscii(const std::string &filename)
Constructor.
bool failed() override
Return status of the stream.
bool skip(const int) override
skip events
bool read_event(GenEvent &evt) override
Load event from file.
void close() override
Close file stream.
~ReaderAscii()
Destructor.
Reader()
Constructor.
Definition Reader.h:28
Stores serializable event information.