File indexing completed on 2025-01-18 10:01:14
0001
0002
0003
0004
0005
0006 #ifndef HEPMC3_WRITERROOTTREE_H
0007 #define HEPMC3_WRITERROOTTREE_H
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021 #include <string>
0022 #include <memory>
0023 #include "HepMC3/Writer.h"
0024 #include "HepMC3/GenEvent.h"
0025 #include "HepMC3/Data/GenEventData.h"
0026 #include "HepMC3/Data/GenRunInfoData.h"
0027
0028
0029
0030 #ifdef __CINT__
0031 #include "TFile.h"
0032 #include "TTree.h"
0033 #else
0034 class TFile;
0035 class TTree;
0036 #endif
0037
0038 namespace HepMC3
0039 {
0040 class WriterRootTree : public Writer
0041 {
0042
0043
0044
0045 public:
0046
0047
0048
0049 WriterRootTree(const std::string &filename,
0050 std::shared_ptr<GenRunInfo> run = std::shared_ptr<GenRunInfo>());
0051
0052 WriterRootTree(const std::string &filename, const std::string &treename, const std::string &branchname,
0053 std::shared_ptr<GenRunInfo> run = std::shared_ptr<GenRunInfo>());
0054
0055
0056
0057 public:
0058
0059
0060
0061
0062 void write_event(const GenEvent &evt) override;
0063
0064
0065 void write_run_info();
0066
0067
0068 void close() override;
0069
0070
0071 bool failed() override;
0072
0073 private:
0074
0075 bool init(std::shared_ptr<GenRunInfo> run);
0076
0077
0078
0079 private:
0080 TFile* m_file = nullptr;
0081 public:
0082 TTree* m_tree = nullptr;
0083 private:
0084 int m_events_count = 0;
0085 GenEventData* m_event_data = nullptr;
0086 GenRunInfoData* m_run_info_data = nullptr;
0087 std::string m_tree_name;
0088 std::string m_branch_name;
0089 };
0090
0091 }
0092
0093 #endif