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 37 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 43 of file NanoAODRNTuples.cc.

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

Referenced by fill().

43  {
44  auto model = RNTupleModel::Create();
45  m_run = RNTupleFieldPtr<UInt_t>("run", "", *model);
46 
48  for (const auto& token : m_tokens) {
49  iRun.getByToken(token, handle);
51  m_tables.push_back(SummaryTableOutputFields(tab, *model));
52  }
53 
54  // TODO use Append when we bump our RNTuple version
55  RNTupleWriteOptions options;
56  options.SetCompression(file.GetCompressionSettings());
57  m_ntuple = std::make_unique<RNTupleWriter>(std::move(model), std::make_unique<RPageSinkFile>("Runs", file, options));
58 }
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
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 60 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().

60  {
61  if (!m_ntuple) {
62  createFields(iRun, file);
63  }
64  m_run.fill(iRun.id().run());
66  for (std::size_t i = 0; i < m_tokens.size(); i++) {
67  iRun.getByToken(m_tokens.at(i), handle);
69  m_tables.at(i).fill(tab);
70  }
71  m_ntuple->Fill();
72 }
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 74 of file NanoAODRNTuples.cc.

References m_ntuple.

Referenced by NanoAODRNTupleOutputModule::reallyCloseFile().

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

◆ registerToken()

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

Definition at line 41 of file NanoAODRNTuples.cc.

References m_tokens, and unpackBuffers-CaloStage2::token.

Referenced by NanoAODRNTupleOutputModule::openFile().

41 { 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 47 of file NanoAODRNTuples.h.

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

◆ m_run

RNTupleFieldPtr<UInt_t> RunNTuple::m_run
private

Definition at line 48 of file NanoAODRNTuples.h.

Referenced by createFields(), and fill().

◆ m_tables

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

Definition at line 49 of file NanoAODRNTuples.h.

Referenced by createFields(), and fill().

◆ m_tokens

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

Definition at line 46 of file NanoAODRNTuples.h.

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