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-2019 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 
41  /// The ctor to read from stdin
42  ReaderHEPEVT(std::istream &);
43 //
44 // Functions
45 //
46 public:
47  /** @brief Find and read event header line from file
48  *
49  */
50  virtual bool read_hepevt_event_header();
51  /** @brief read particle from file
52  *
53  * @param[in] i Particle id
54  * @param[in] iflong Event style
55  */
56  virtual bool read_hepevt_particle(int i, bool iflong=true);
57 
58 
59  /** @brief Read event from file
60  *
61  * @param[in] iflong Event style
62  * @param[out] evt Contains parsed even
63  */
64  bool read_event(GenEvent &evt, bool iflong);
65 
66  /** @brief Read event from file
67  *
68  * @param[out] evt Contains parsed even
69  */
70  bool read_event(GenEvent &evt);
71 
72 
73  /** @brief Close file stream */
74  void close();
75 
76  /** @brief Get stream error state */
77  bool failed();
78 
79  /** @brief set flag if vertex positions are available */
80  void set_vertices_positions_present(bool iflong);
81  /** @brief get flag if vertex positions are available */
82  bool get_vertices_positions_present() const;
83 
84 public:
85  char* hepevtbuffer; //!< Pointer to HEPEVT Fortran common block/C struct
86 private:
87  std::ifstream m_file; //!< Input file
88  std::istream* m_stream; //!< For ctor when reading from stdin
89  bool m_isstream; //!< toggles usage of m_file or m_stream
90  bool m_vertices_positions_present; //!< true if vertex positions are available
91 };
92 
93 } // namespace HepMC3
94 
95 #endif
void close()
Close file stream.
Definition of class GenRunInfo.
Definition of interface Reader.
bool m_isstream
toggles usage of m_file or m_stream
Definition: ReaderHEPEVT.h:89
ReaderHEPEVT(const std::string &filename)
Default constructor.
Definition: ReaderHEPEVT.cc:18
GenEvent I/O parsing and serialization for HEPEVT files.
Definition: ReaderHEPEVT.h:32
void set_vertices_positions_present(bool iflong)
set flag if vertex positions are available
Definition of struct GenEventData.
virtual bool read_hepevt_event_header()
Find and read event header line from file.
Definition: ReaderHEPEVT.cc:46
Stores event-related information.
Definition: GenEvent.h:42
bool m_vertices_positions_present
true if vertex positions are available
Definition: ReaderHEPEVT.h:90
bool read_event(GenEvent &evt, bool iflong)
Read event from file.
bool get_vertices_positions_present() const
get flag if vertex positions are available
char * hepevtbuffer
Pointer to HEPEVT Fortran common block/C struct.
Definition: ReaderHEPEVT.h:85
virtual bool read_hepevt_particle(int i, bool iflong=true)
read particle from file
Definition: ReaderHEPEVT.cc:76
Definition of class GenEvent.
Base class for all I/O readers.
Definition: Reader.h:25
std::ifstream m_file
Input file.
Definition: ReaderHEPEVT.h:87
bool failed()
Get stream error state.
std::istream * m_stream
For ctor when reading from stdin.
Definition: ReaderHEPEVT.h:88