HepMC3 event record library
ReaderHEPEVT.h
Go to the documentation of this file.
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_READERHEPEVT_H
7 #define HEPMC3_READERHEPEVT_H
8 /**
9  * @file ReaderHEPEVT.h
10  * @brief Definition of \b class ReaderHEPEVT
11  *
12  * @class HepMC3::ReaderHEPEVT
13  * @brief GenEvent I/O parsing and serialization for HEPEVT files
14  *
15  *
16  * @ingroup IO
17  *
18  */
19 #include <set>
20 #include <string>
21 #include <fstream>
22 #include <istream>
23 #include "HepMC3/Reader.h"
24 #include "HepMC3/GenEvent.h"
25 #include "HepMC3/GenRunInfo.h"
27 
28 
29 namespace HepMC3
30 {
31 
32 class ReaderHEPEVT : public Reader
33 {
34 //
35 // Constructors
36 //
37 public:
38  /** @brief Default constructor */
39  ReaderHEPEVT(const std::string &filename);
40  /// The ctor to read from stdin
41  ReaderHEPEVT(std::istream &);
42 //
43 // Functions
44 //
45 public:
46  /** @brief Find and read event header line from file
47  *
48  */
49  virtual bool read_hepevt_event_header();
50  /** @brief read particle from file
51  *
52  * @param[in] i Particle id
53  * @param[in] iflong Event style
54  */
55  virtual bool read_hepevt_particle(int i);
56 
57  /// @brief skip events
58  bool skip(const int) override;
59 
60 
61  /** @brief Read event from file*/
62  bool read_event(GenEvent &evt) override;
63 
64 
65  /** @brief Close file stream */
66  void close() override;
67 
68  /** @brief Get stream error state */
69  bool failed() override;
70 
71 public:
72  char* hepevtbuffer; //!< Pointer to HEPEVT Fortran common block/C struct
73 private:
74  std::ifstream m_file; //!< Input file
75  std::istream* m_stream; //!< For ctor when reading from stdin
76  bool m_isstream; //!< toggles usage of m_file or m_stream
77 };
78 
79 } // namespace HepMC3
80 
81 #endif
bool failed() override
Get stream error state.
Definition of class GenRunInfo.
bool skip(const int) override
skip events
Definition: ReaderHEPEVT.cc:47
void close() override
Close file stream.
Definition of interface Reader.
bool m_isstream
toggles usage of m_file or m_stream
Definition: ReaderHEPEVT.h:76
ReaderHEPEVT(const std::string &filename)
Default constructor.
Definition: ReaderHEPEVT.cc:18
bool read_event(GenEvent &evt) override
Read event from file.
GenEvent I/O parsing and serialization for HEPEVT files.
Definition: ReaderHEPEVT.h:32
Definition of struct GenEventData.
virtual bool read_hepevt_event_header()
Find and read event header line from file.
Definition: ReaderHEPEVT.cc:65
Stores event-related information.
Definition: GenEvent.h:41
virtual bool read_hepevt_particle(int i)
read particle from file
Definition: ReaderHEPEVT.cc:95
char * hepevtbuffer
Pointer to HEPEVT Fortran common block/C struct.
Definition: ReaderHEPEVT.h:72
Definition of class GenEvent.
Base class for all I/O readers.
Definition: Reader.h:25
std::ifstream m_file
Input file.
Definition: ReaderHEPEVT.h:74
std::istream * m_stream
For ctor when reading from stdin.
Definition: ReaderHEPEVT.h:75