CMS 3D CMS Logo

RntDumper.h
Go to the documentation of this file.
1 #ifndef RecoTracker_MkFitCore_standalone_RntDumper_RntDumper_h
2 #define RecoTracker_MkFitCore_standalone_RntDumper_RntDumper_h
3 
4 #include <memory>
5 #include <string>
6 #include <unordered_map>
7 #include <vector>
8 
9 class TFile;
10 class TTree;
11 
12 namespace ROOT::Experimental {
13  class RNTupleModel;
14  class RNTupleWriter;
15 } // namespace ROOT::Experimental
16 
17 class RntDumper {
18  using RNTupleModel = ROOT::Experimental::RNTupleModel;
19  using RNTupleWriter = ROOT::Experimental::RNTupleWriter;
20 
21 public:
22  std::unique_ptr<RNTupleModel> CreateModel();
23  RNTupleWriter *WritifyModel(std::unique_ptr<RNTupleModel> &model, std::string_view mname);
24 
25  void RegisterTree(TTree *t);
26 
27  static RntDumper *Create(const char *fname);
28  static void FinalizeAll();
29 
30  TFile *file() { return m_file.get(); }
31 
32 private:
33  explicit RntDumper(const char *fname);
34  ~RntDumper();
35 
36  std::unique_ptr<TFile> m_file;
37  std::unordered_map<std::string, std::unique_ptr<RNTupleWriter>> m_writers;
38  std::vector<TTree *> m_trees;
39 
40  static std::vector<RntDumper *> s_instances;
41 };
42 
43 #endif
~RntDumper()
Definition: RntDumper.cc:23
std::unique_ptr< TFile > m_file
Definition: RntDumper.h:36
std::unordered_map< std::string, std::unique_ptr< RNTupleWriter > > m_writers
Definition: RntDumper.h:37
TFile * file()
Definition: RntDumper.h:30
RntDumper(const char *fname)
Definition: RntDumper.cc:15
static std::vector< RntDumper * > s_instances
Definition: RntDumper.h:40
RNTupleWriter * WritifyModel(std::unique_ptr< RNTupleModel > &model, std::string_view mname)
Definition: RntDumper.cc:40
ROOT::Experimental::RNTupleWriter RNTupleWriter
Definition: RntDumper.h:19
static void FinalizeAll()
Definition: RntDumper.cc:58
std::unique_ptr< RNTupleModel > CreateModel()
Definition: RntDumper.cc:38
std::vector< TTree * > m_trees
Definition: RntDumper.h:38
ROOT::Experimental::RNTupleModel RNTupleModel
Definition: RntDumper.h:18
string fname
main script
static RntDumper * Create(const char *fname)
Definition: RntDumper.cc:51
void RegisterTree(TTree *t)
Definition: RntDumper.cc:47