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 #if ROOT_VERSION_CODE < ROOT_VERSION(6, 31, 0)
16 using ROOT::Experimental::RCollectionNTupleWriter;
17 #else
18 #include <ROOT/RNTupleWriter.hxx>
19 #include <ROOT/RNTupleCollectionWriter.hxx>
20 using ROOT::Experimental::RNTupleCollectionWriter;
21 #endif
22 using ROOT::Experimental::RNTupleWriter;
23 
25 #include "RNTupleFieldPtr.h"
27 #include "TableOutputFields.h"
28 #include "TriggerOutputFields.h"
29 
30 class LumiNTuple {
31 public:
32  LumiNTuple() = default;
33  void fill(const edm::LuminosityBlockID& id, TFile& file);
34  void finalizeWrite();
35 
36 private:
37  void createFields(const edm::LuminosityBlockID& id, TFile& file);
38  std::unique_ptr<RNTupleWriter> m_ntuple;
41 };
42 
43 class RunNTuple {
44 public:
45  RunNTuple() = default;
46  void registerToken(const edm::EDGetToken& token);
47  void fill(const edm::RunForOutput& iRun, TFile& file);
48  void finalizeWrite();
49 
50 private:
51  void createFields(const edm::RunForOutput& iRun, TFile& file);
52  std::vector<edm::EDGetToken> m_tokens;
53  std::unique_ptr<RNTupleWriter> m_ntuple;
55  std::vector<SummaryTableOutputFields> m_tables;
56 };
57 
58 class PSetNTuple {
59 public:
60  PSetNTuple() = default;
61  void fill(edm::pset::Registry* pset, TFile& file);
62  void finalizeWrite();
63 
64 private:
65  // TODO blocked on RNTuple std::pair support
66  // using PSetType = std::pair<edm::ParameterSetID, edm::ParameterSetBlob>;
67  // RNTupleFieldPtr<PSetType> m_pset;
68  void createFields(TFile& file);
69  // TODO blocked on RNTuple typedef member field support:
70  // https://github.com/root-project/root/issues/7861
71  // RNTupleFieldPtr<edm::ParameterSetID> m_psetId;
72  // RNTupleFieldPtr<edm::ParameterSetBlob> m_psetBlob;
73 #if ROOT_VERSION_CODE < ROOT_VERSION(6, 31, 0)
74  std::shared_ptr<RCollectionNTupleWriter> m_collection;
75 #else
76  std::shared_ptr<RNTupleCollectionWriter> m_collection;
77 #endif
80  std::unique_ptr<RNTupleWriter> m_ntuple;
81 };
82 
84 public:
85  MetadataNTuple() = default;
86  void fill(const edm::ProcessHistoryRegistry& procHist, TFile& file);
87  void finalizeWrite();
88 
89 private:
90  void createFields(TFile& file);
91 #if ROOT_VERSION_CODE < ROOT_VERSION(6, 31, 0)
92  std::shared_ptr<RCollectionNTupleWriter> m_procHist;
93 #else
94  std::shared_ptr<RNTupleCollectionWriter> m_procHist;
95 #endif
96 
98  std::unique_ptr<RNTupleWriter> m_ntuple;
99 };
100 
101 #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
RNTupleFieldPtr< UInt_t > m_run
PSetNTuple()=default
std::shared_ptr< RNTupleCollectionWriter > m_procHist
void createFields(const edm::LuminosityBlockID &id, TFile &file)
void finalizeWrite()
void fill(const edm::ProcessHistoryRegistry &procHist, TFile &file)
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::shared_ptr< RNTupleCollectionWriter > m_collection
std::vector< SummaryTableOutputFields > m_tables