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-2019 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 "HepMC3/Reader.h"
22#include "HepMC3/GenEvent.h"
25
26// ROOT header files
27#include "TFile.h"
28#include "TKey.h"
29
30namespace HepMC3 {
31
32class ReaderRoot : public Reader {
33//
34// Constructors
35//
36public:
37 /** @brief Default constructor */
38 ReaderRoot(const std::string &filename);
39
40//
41// Functions
42//
43public:
44 /// @brief skip events
45 bool skip(const int) override;
46
47 /** @brief Read event from file
48 *
49 * @param[out] evt Contains parsed event
50 */
51 bool read_event(GenEvent &evt) override;
52
53 /** @brief Close file stream */
54 void close() override;
55
56 /** @brief Get stream error state */
57 bool failed() override;
58//
59// Fields
60//
61private:
62 TFile* m_file; //!< File handler
63 TIter* m_next; //!< Iterator for event reading
64};
65
66} // namespace HepMC3
67
68#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:32
bool read_event(GenEvent &evt) override
Read event from file.
Definition: ReaderRoot.cc:50
bool failed() override
Get stream error state.
Definition: ReaderRoot.cc:92
bool skip(const int) override
skip events
Definition: ReaderRoot.cc:39
void close() override
Close file stream.
Definition: ReaderRoot.cc:88
ReaderRoot(const std::string &filename)
Default constructor.
Definition: ReaderRoot.cc:17
TFile * m_file
File handler.
Definition: ReaderRoot.h:62
TIter * m_next
Iterator for event reading.
Definition: ReaderRoot.h:63
Base class for all I/O readers.
Definition: Reader.h:25
HepMC3 main namespace.