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-2020 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 
31 namespace HepMC3 {
32 
33 class ReaderRoot : public Reader {
34 //
35 // Constructors
36 //
37 public:
38  /** @brief Default constructor */
39  ReaderRoot(const std::string &filename);
40 
41 //
42 // Functions
43 //
44 public:
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 //
62 private:
63  TFile* m_file; //!< File handler
64  TIter* m_next; //!< Iterator for event reading
65 };
66 
67 } // namespace HepMC3
68 
69 #endif
TIter * m_next
Iterator for event reading.
Definition: ReaderRoot.h:64
HepMC3 main namespace.
Definition of interface Reader.
bool failed() override
Get stream error state.
Definition: ReaderRoot.cc:90
ReaderRoot(const std::string &filename)
Default constructor.
Definition: ReaderRoot.cc:17
Definition of struct GenEventData.
bool read_event(GenEvent &evt) override
Read event from file.
Definition: ReaderRoot.cc:49
Stores event-related information.
Definition: GenEvent.h:41
TFile * m_file
File handler.
Definition: ReaderRoot.h:63
bool skip(const int) override
skip events
Definition: ReaderRoot.cc:38
Definition of class GenEvent.
void close() override
Close file stream.
Definition: ReaderRoot.cc:86
Base class for all I/O readers.
Definition: Reader.h:25
Definition of struct GenRunInfoData.
GenEvent I/O parsing and serialization for root files.
Definition: ReaderRoot.h:33