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-2021 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"
26
27// ROOT header files
28#include "TFile.h"
29#include "TKey.h"
30
31namespace HepMC3 {
32
33class 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
Definition of struct GenEventData.
Definition of class GenEvent.
Definition of struct GenRunInfoData.
Definition of interface Reader.
Stores event-related information.
Definition: GenEvent.h:41
GenEvent I/O parsing and serialization for root files.
Definition: ReaderRoot.h:33
bool read_event(GenEvent &evt) override
Read event from file.
Definition: ReaderRoot.cc:49
bool failed() override
Get stream error state.
Definition: ReaderRoot.cc:90
bool skip(const int) override
skip events
Definition: ReaderRoot.cc:38
void close() override
Close file stream.
Definition: ReaderRoot.cc:86
TFile * m_file
File handler.
Definition: ReaderRoot.h:63
TIter * m_next
Iterator for event reading.
Definition: ReaderRoot.h:64
Base class for all I/O readers.
Definition: Reader.h:25
HepMC3 main namespace.