CMS 3D CMS Logo

NanoAODRNTuples.h
Go to the documentation of this file.
1 #ifndef PhysicsTools_NanoAOD_NanoAODRNTuples_h
2 #define PhysicsTools_NanoAOD_NanoAODRNTuples_h
3 
12 
13 #include "TFile.h"
14 #include <ROOT/RNTuple.hxx>
15 using ROOT::Experimental::RCollectionNTupleWriter;
16 using ROOT::Experimental::RNTupleWriter;
17 
19 #include "RNTupleFieldPtr.h"
21 #include "TableOutputFields.h"
22 #include "TriggerOutputFields.h"
23 
24 class LumiNTuple {
25 public:
26  LumiNTuple() = default;
27  void fill(const edm::LuminosityBlockID& id, TFile& file);
28  void finalizeWrite();
29 
30 private:
31  void createFields(const edm::LuminosityBlockID& id, TFile& file);
32  std::unique_ptr<RNTupleWriter> m_ntuple;
35 };
36 
37 class RunNTuple {
38 public:
39  RunNTuple() = default;
40  void registerToken(const edm::EDGetToken& token);
41  void fill(const edm::RunForOutput& iRun, TFile& file);
42  void finalizeWrite();
43 
44 private:
45  void createFields(const edm::RunForOutput& iRun, TFile& file);
46  std::vector<edm::EDGetToken> m_tokens;
47  std::unique_ptr<RNTupleWriter> m_ntuple;
49  std::vector<SummaryTableOutputFields> m_tables;
50 };
51 
52 class PSetNTuple {
53 public:
54  PSetNTuple() = default;
55  void fill(edm::pset::Registry* pset, TFile& file);
56  void finalizeWrite();
57 
58 private:
59  // TODO blocked on RNTuple std::pair support
60  // using PSetType = std::pair<edm::ParameterSetID, edm::ParameterSetBlob>;
61  // RNTupleFieldPtr<PSetType> m_pset;
62  void createFields(TFile& file);
63  // TODO blocked on RNTuple typedef member field support:
64  // https://github.com/root-project/root/issues/7861
65  // RNTupleFieldPtr<edm::ParameterSetID> m_psetId;
66  // RNTupleFieldPtr<edm::ParameterSetBlob> m_psetBlob;
67  std::shared_ptr<RCollectionNTupleWriter> m_collection;
70  std::unique_ptr<RNTupleWriter> m_ntuple;
71 };
72 
74 public:
75  MetadataNTuple() = default;
76  void fill(const edm::ProcessHistoryRegistry& procHist, TFile& file);
77  void finalizeWrite();
78 
79 private:
80  void createFields(TFile& file);
81  std::shared_ptr<RCollectionNTupleWriter> m_procHist;
82 
84  std::unique_ptr<RNTupleWriter> m_ntuple;
85 };
86 
87 #endif
RNTupleFieldPtr< std::string > m_psetId
std::unique_ptr< RNTupleWriter > m_ntuple
void finalizeWrite()
LumiNTuple()=default
RNTupleFieldPtr< std::string > m_psetBlob
void fill(const edm::LuminosityBlockID &id, TFile &file)
std::unique_ptr< RNTupleWriter > m_ntuple
RNTupleFieldPtr< UInt_t > m_run
void createFields(TFile &file)
void registerToken(const edm::EDGetToken &token)
RunNTuple()=default
std::shared_ptr< RCollectionNTupleWriter > m_collection
RNTupleFieldPtr< UInt_t > m_run
PSetNTuple()=default
void createFields(const edm::LuminosityBlockID &id, TFile &file)
void finalizeWrite()
void fill(const edm::ProcessHistoryRegistry &procHist, TFile &file)
std::shared_ptr< RCollectionNTupleWriter > m_procHist
std::unique_ptr< RNTupleWriter > m_ntuple
void createFields(TFile &file)
std::vector< edm::EDGetToken > m_tokens
void createFields(const edm::RunForOutput &iRun, TFile &file)
void fill(edm::pset::Registry *pset, TFile &file)
RNTupleFieldPtr< UInt_t > m_luminosityBlock
std::unique_ptr< RNTupleWriter > m_ntuple
void finalizeWrite()
RNTupleFieldPtr< std::string > m_phId
MetadataNTuple()=default
void fill(const edm::RunForOutput &iRun, TFile &file)
std::vector< SummaryTableOutputFields > m_tables