CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
RunNTuple Class Reference

#include <NanoAODRNTuples.h>

Public Member Functions

void fill (const edm::RunForOutput &iRun, TFile &file)
 
void finalizeWrite ()
 
void registerToken (const edm::EDGetToken &token)
 
 RunNTuple ()=default
 

Private Member Functions

void createFields (const edm::RunForOutput &iRun, TFile &file)
 

Private Attributes

std::unique_ptr< RNTupleWriter > m_ntuple
 
RNTupleFieldPtr< UInt_t > m_run
 
std::vector< SummaryTableOutputFieldsm_tables
 
std::vector< edm::EDGetTokenm_tokens
 

Detailed Description

Definition at line 43 of file NanoAODRNTuples.h.

Constructor & Destructor Documentation

◆ RunNTuple()

RunNTuple::RunNTuple ( )
default

Member Function Documentation

◆ createFields()

void RunNTuple::createFields ( const edm::RunForOutput iRun,
TFile &  file 
)
private

Definition at line 49 of file NanoAODRNTuples.cc.

References geometryDiff::file, edm::OccurrenceForOutput::getByToken(), patZpeak::handle, m_ntuple, m_run, m_tables, m_tokens, MakeRNTupleWriter, isotrackApplyRegressor::model, eostools::move(), AlcaSiPixelAliHarvester0T_cff::options, and unpackBuffers-CaloStage2::token.

Referenced by fill().

49  {
50  auto model = RNTupleModel::Create();
51  m_run = RNTupleFieldPtr<UInt_t>("run", "", *model);
52 
54  for (const auto& token : m_tokens) {
55  iRun.getByToken(token, handle);
57  m_tables.push_back(SummaryTableOutputFields(tab, *model));
58  }
59 
60  // TODO use Append when we bump our RNTuple version
61  RNTupleWriteOptions options;
62  options.SetCompression(file.GetCompressionSettings());
63  m_ntuple = MakeRNTupleWriter(std::move(model), std::make_unique<RPageSinkFile>("Runs", file, options));
64 }
BasicHandle getByToken(EDGetToken token, TypeID const &typeID) const
#define MakeRNTupleWriter
RNTupleFieldPtr< UInt_t > m_run
std::unique_ptr< RNTupleWriter > m_ntuple
std::vector< edm::EDGetToken > m_tokens
std::vector< SummaryTableOutputFields > m_tables
def move(src, dest)
Definition: eostools.py:511

◆ fill()

void RunNTuple::fill ( const edm::RunForOutput iRun,
TFile &  file 
)

Definition at line 66 of file NanoAODRNTuples.cc.

References createFields(), geometryDiff::file, RNTupleFieldPtr< T >::fill(), edm::OccurrenceForOutput::getByToken(), patZpeak::handle, mps_fire::i, edm::RunForOutput::id(), m_ntuple, m_run, m_tables, m_tokens, and edm::RunID::run().

Referenced by NanoAODRNTupleOutputModule::writeRun().

66  {
67  if (!m_ntuple) {
68  createFields(iRun, file);
69  }
70  m_run.fill(iRun.id().run());
72  for (std::size_t i = 0; i < m_tokens.size(); i++) {
73  iRun.getByToken(m_tokens.at(i), handle);
75  m_tables.at(i).fill(tab);
76  }
77  m_ntuple->Fill();
78 }
void fill(const T &value)
BasicHandle getByToken(EDGetToken token, TypeID const &typeID) const
RNTupleFieldPtr< UInt_t > m_run
std::unique_ptr< RNTupleWriter > m_ntuple
std::vector< edm::EDGetToken > m_tokens
void createFields(const edm::RunForOutput &iRun, TFile &file)
RunID const & id() const
Definition: RunForOutput.h:55
std::vector< SummaryTableOutputFields > m_tables
RunNumber_t run() const
Definition: RunID.h:26

◆ finalizeWrite()

void RunNTuple::finalizeWrite ( )

Definition at line 80 of file NanoAODRNTuples.cc.

References m_ntuple.

Referenced by NanoAODRNTupleOutputModule::reallyCloseFile().

80 { m_ntuple.reset(); }
std::unique_ptr< RNTupleWriter > m_ntuple

◆ registerToken()

void RunNTuple::registerToken ( const edm::EDGetToken token)

Definition at line 47 of file NanoAODRNTuples.cc.

References m_tokens, and unpackBuffers-CaloStage2::token.

Referenced by NanoAODRNTupleOutputModule::openFile().

47 { m_tokens.push_back(token); }
std::vector< edm::EDGetToken > m_tokens

Member Data Documentation

◆ m_ntuple

std::unique_ptr<RNTupleWriter> RunNTuple::m_ntuple
private

Definition at line 53 of file NanoAODRNTuples.h.

Referenced by createFields(), fill(), and finalizeWrite().

◆ m_run

RNTupleFieldPtr<UInt_t> RunNTuple::m_run
private

Definition at line 54 of file NanoAODRNTuples.h.

Referenced by createFields(), and fill().

◆ m_tables

std::vector<SummaryTableOutputFields> RunNTuple::m_tables
private

Definition at line 55 of file NanoAODRNTuples.h.

Referenced by createFields(), and fill().

◆ m_tokens

std::vector<edm::EDGetToken> RunNTuple::m_tokens
private

Definition at line 52 of file NanoAODRNTuples.h.

Referenced by createFields(), fill(), and registerToken().