HepMC3 event record library: ReaderRoot.h Source File

HepMC3 event record library

ReaderRoot.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_READERROOT_H
7#define HEPMC3_READERROOT_H
8/**
9 * @file ReaderRoot.h
10 * @brief Definition of \b class ReaderRoot
11 *
12 * @class HepMC3::ReaderRoot
13 * @brief GenEvent I/O parsing and serialization for root files
14 *
15 * If HepMC was compiled with path to ROOT available, this class can be used
16 * for root file I/O in the same manner as with HepMC::ReaderAscii class.
17 *
18 * @ingroup IO
19 *
20 */
21#include <string>
22#include "HepMC3/Reader.h"
23#include "HepMC3/GenEvent.h"
24#include "HepMC3/Data/GenEventData.h"
25#include "HepMC3/Data/GenRunInfoData.h"
26
27// ROOT header files
28#include "TFile.h"
29#include "TKey.h"
30
31namespace HepMC3 {
32
33 class ReaderRoot : public Reader {
34//
35// Constructors
36//
37public:
38 /** @brief Default constructor */
39 ReaderRoot(const std::string &filename);
40
41//
42// Functions
43//
44public:
45 /// @brief skip events
46 bool skip(const int) override;
47
48 /** @brief Read event from file
49 *
50 * @param[out] evt Contains parsed event
51 */
52 bool read_event(GenEvent &evt) override;
53
54 /** @brief Close file stream */
55 void close() override;
56
57 /** @brief Get stream error state */
58 bool failed() override;
59//
60// Fields
61//
62private:
63 TFile* m_file; //!< File handler
64 TIter* m_next; //!< Iterator for event reading
65};
66
67} // namespace HepMC3
68
69#endif
GenEventData.h
Definition of struct GenEventData.
GenEvent.h
Definition of class GenEvent.
GenRunInfoData.h
Definition of struct GenRunInfoData.
Reader.h
Definition of interface Reader.
HepMC3::GenEvent
Stores event-related information.
Definition GenEvent.h:47
HepMC3::ReaderRoot::read_event
bool read_event(GenEvent &evt) override
Read event from file.
Definition ReaderRoot.cc:49
HepMC3::ReaderRoot::failed
bool failed() override
Get stream error state.
Definition ReaderRoot.cc:92
HepMC3::ReaderRoot::skip
bool skip(const int) override
skip events
Definition ReaderRoot.cc:38
HepMC3::ReaderRoot::close
void close() override
Close file stream.
Definition ReaderRoot.cc:88
HepMC3::ReaderRoot::ReaderRoot
ReaderRoot(const std::string &filename)
Default constructor.
Definition ReaderRoot.cc:17
HepMC3::ReaderRoot::m_file
TFile * m_file
File handler.
Definition ReaderRoot.h:63
HepMC3::ReaderRoot::m_next
TIter * m_next
Iterator for event reading.
Definition ReaderRoot.h:64
HepMC3::Reader::Reader
Reader()
Constructor.
Definition Reader.h:28
HepMC3
HepMC3 main namespace.
Definition AnalysisExample.h:24