CMS 3D CMS Logo

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

#include <NanoAODRNTuples.h>

Public Member Functions

void fill (edm::pset::Registry *pset, TFile &file)
 
void finalizeWrite ()
 
 PSetNTuple ()=default
 

Private Member Functions

void createFields (TFile &file)
 

Private Attributes

std::shared_ptr< RCollectionNTupleWriter > m_collection
 
std::unique_ptr< RNTupleWriter > m_ntuple
 
RNTupleFieldPtr< std::string > m_psetBlob
 
RNTupleFieldPtr< std::string > m_psetId
 

Detailed Description

Definition at line 52 of file NanoAODRNTuples.h.

Constructor & Destructor Documentation

◆ PSetNTuple()

PSetNTuple::PSetNTuple ( )
default

Member Function Documentation

◆ createFields()

void PSetNTuple::createFields ( TFile &  file)
private

Definition at line 76 of file NanoAODRNTuples.cc.

References geometryDiff::file, edm::poolNames::idToParameterSetBlobsBranchName(), m_collection, m_ntuple, m_psetBlob, m_psetId, ReggeGribovPartonMC_EposLHC_2760GeV_PbPb_cfi::model, eostools::move(), AlcaSiPixelAliHarvester0T_cff::options, and edm::poolNames::parameterSetsTreeName().

Referenced by fill().

76  {
77  // use a collection to emulate std::pair
78  auto pairModel = RNTupleModel::Create();
79  m_psetId = RNTupleFieldPtr<std::string>("first", "", *pairModel);
80  m_psetBlob = RNTupleFieldPtr<std::string>("second", "", *pairModel);
81  auto model = RNTupleModel::Create();
83  // TODO use Append when we bump our RNTuple version
84  RNTupleWriteOptions options;
85  options.SetCompression(file.GetCompressionSettings());
86  m_ntuple = std::make_unique<RNTupleWriter>(
87  std::move(model), std::make_unique<RPageSinkFile>(edm::poolNames::parameterSetsTreeName(), file, options));
88 }
RNTupleFieldPtr< std::string > m_psetId
RNTupleFieldPtr< std::string > m_psetBlob
std::shared_ptr< RCollectionNTupleWriter > m_collection
std::string const & parameterSetsTreeName()
Definition: BranchType.cc:216
std::string const & idToParameterSetBlobsBranchName()
Definition: BranchType.cc:218
std::unique_ptr< RNTupleWriter > m_ntuple
def move(src, dest)
Definition: eostools.py:511

◆ fill()

void PSetNTuple::fill ( edm::pset::Registry pset,
TFile &  file 
)

Definition at line 90 of file NanoAODRNTuples.cc.

References createFields(), Exception, geometryDiff::file, RNTupleFieldPtr< T >::fill(), m_collection, m_ntuple, m_psetBlob, m_psetId, and muonDTDigis_cfi::pset.

Referenced by NanoAODRNTupleOutputModule::writeProvenance().

90  {
91  if (!pset) {
92  throw cms::Exception("LogicError", "null edm::pset::Registry::Instance pointer");
93  }
94  if (!m_ntuple) {
96  }
97  for (const auto& ps : *pset) {
98  std::ostringstream oss;
99  oss << ps.first;
100  m_psetId.fill(oss.str());
101  m_psetBlob.fill(ps.second.toString());
102  m_collection->Fill();
103  m_ntuple->Fill();
104  }
105 }
RNTupleFieldPtr< std::string > m_psetId
RNTupleFieldPtr< std::string > m_psetBlob
void createFields(TFile &file)
void fill(const T &value)
std::shared_ptr< RCollectionNTupleWriter > m_collection
std::unique_ptr< RNTupleWriter > m_ntuple

◆ finalizeWrite()

void PSetNTuple::finalizeWrite ( )

Definition at line 107 of file NanoAODRNTuples.cc.

References m_ntuple.

Referenced by NanoAODRNTupleOutputModule::writeProvenance().

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

Member Data Documentation

◆ m_collection

std::shared_ptr<RCollectionNTupleWriter> PSetNTuple::m_collection
private

Definition at line 67 of file NanoAODRNTuples.h.

Referenced by createFields(), and fill().

◆ m_ntuple

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

Definition at line 70 of file NanoAODRNTuples.h.

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

◆ m_psetBlob

RNTupleFieldPtr<std::string> PSetNTuple::m_psetBlob
private

Definition at line 69 of file NanoAODRNTuples.h.

Referenced by createFields(), and fill().

◆ m_psetId

RNTupleFieldPtr<std::string> PSetNTuple::m_psetId
private

Definition at line 68 of file NanoAODRNTuples.h.

Referenced by createFields(), and fill().