HepMC3 event record library: ReaderHEPEVT.h Source File

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-2023 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"
26#include "HepMC3/Data/GenEventData.h"
27#include "HepMC3/HEPEVT_Wrapper_Template.h"
28
29namespace HepMC3
30{
31
32 class ReaderHEPEVT : public Reader
33{
34//
35// Constructors
36//
37public:
38 /** @brief Default constructor */
39 ReaderHEPEVT(const std::string &filename);
40 /// The ctor to read from stream
41 ReaderHEPEVT(std::istream &);
42 /// The ctor to read from temp stream
43 ReaderHEPEVT(std::shared_ptr<std::istream> s_stream);
44//
45// Functions
46//
47public:
48 /** @brief Find and read event header line from file
49 *
50 */
51 virtual bool read_hepevt_event_header();
52 /** @brief read particle from file
53 *
54 * @param[in] i Particle id
55 */
56 virtual bool read_hepevt_particle(int i);
57
58 /// @brief skip events
59 bool skip(const int) override;
60
61
62 /** @brief Read event from file*/
63 bool read_event(GenEvent &evt) override;
64
65
66 /** @brief Close file stream */
67 void close() override;
68
69 /** @brief Get stream error state */
70 bool failed() override;
71
72 char* hepevtbuffer = nullptr; //!< Pointer to HEPEVT Fortran common block/C struct
73private:
74 std::ifstream m_file; //!< Input file
75 std::shared_ptr<std::istream> m_shared_stream = nullptr; //!< For ctor when reading from temp stream
76 std::istream* m_stream = nullptr; //!< For ctor when reading from stream
77 bool m_isstream; //!< toggles usage of m_file or m_stream
78 HEPEVT_Wrapper_Template<100000> m_hepevt_interface; //!< Templated HEPEVT interface
79};
80
81} // namespace HepMC3
82
83#endif
GenEventData.h
Definition of struct GenEventData.
GenEvent.h
Definition of class GenEvent.
GenRunInfo.h
Definition of class GenRunInfo.
HEPEVT_Wrapper_Template.h
Definition of class HEPEVT_Wrapper_Template.
Reader.h
Definition of interface Reader.
HepMC3::GenEvent
Stores event-related information.
Definition GenEvent.h:47
HepMC3::HEPEVT_Wrapper_Template
An interface to HEPEVT common block implemented as template class.
Definition HEPEVT_Wrapper_Template.h:32
HepMC3::ReaderHEPEVT::m_isstream
bool m_isstream
toggles usage of m_file or m_stream
Definition ReaderHEPEVT.h:77
HepMC3::ReaderHEPEVT::read_event
bool read_event(GenEvent &evt) override
Read event from file.
Definition ReaderHEPEVT.cc:157
HepMC3::ReaderHEPEVT::ReaderHEPEVT
ReaderHEPEVT(const std::string &filename)
Default constructor.
Definition ReaderHEPEVT.cc:18
HepMC3::ReaderHEPEVT::m_hepevt_interface
HEPEVT_Wrapper_Template< 100000 > m_hepevt_interface
Templated HEPEVT interface.
Definition ReaderHEPEVT.h:78
HepMC3::ReaderHEPEVT::failed
bool failed() override
Get stream error state.
Definition ReaderHEPEVT.cc:189
HepMC3::ReaderHEPEVT::skip
bool skip(const int) override
skip events
Definition ReaderHEPEVT.cc:59
HepMC3::ReaderHEPEVT::m_file
std::ifstream m_file
Input file.
Definition ReaderHEPEVT.h:74
HepMC3::ReaderHEPEVT::read_hepevt_particle
virtual bool read_hepevt_particle(int i)
read particle from file
Definition ReaderHEPEVT.cc:106
HepMC3::ReaderHEPEVT::read_hepevt_event_header
virtual bool read_hepevt_event_header()
Find and read event header line from file.
Definition ReaderHEPEVT.cc:76
HepMC3::ReaderHEPEVT::close
void close() override
Close file stream.
Definition ReaderHEPEVT.cc:183
HepMC3::ReaderHEPEVT::hepevtbuffer
char * hepevtbuffer
Pointer to HEPEVT Fortran common block/C struct.
Definition ReaderHEPEVT.h:72
HepMC3::ReaderHEPEVT::m_stream
std::istream * m_stream
For ctor when reading from stream.
Definition ReaderHEPEVT.h:76
HepMC3::ReaderHEPEVT::m_shared_stream
std::shared_ptr< std::istream > m_shared_stream
For ctor when reading from temp stream.
Definition ReaderHEPEVT.h:75
HepMC3::Reader::Reader
Reader()
Constructor.
Definition Reader.h:28
HepMC3
HepMC3 main namespace.
Definition AnalysisExample.h:24