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< RNTupleCollectionWriter > m_collection
 
std::unique_ptr< RNTupleWriter > m_ntuple
 
RNTupleFieldPtr< std::string > m_psetBlob
 
RNTupleFieldPtr< std::string > m_psetId
 

Detailed Description

Definition at line 58 of file NanoAODRNTuples.h.

Constructor & Destructor Documentation

◆ PSetNTuple()

PSetNTuple::PSetNTuple ( )
default

Member Function Documentation

◆ createFields()

void PSetNTuple::createFields ( TFile &  file)
private

Definition at line 82 of file NanoAODRNTuples.cc.

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

Referenced by fill().

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

◆ fill()

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

Definition at line 96 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().

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

◆ finalizeWrite()

void PSetNTuple::finalizeWrite ( )

Definition at line 113 of file NanoAODRNTuples.cc.

References m_ntuple.

Referenced by NanoAODRNTupleOutputModule::writeProvenance().

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

Member Data Documentation

◆ m_collection

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

Definition at line 76 of file NanoAODRNTuples.h.

Referenced by createFields(), and fill().

◆ m_ntuple

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

Definition at line 80 of file NanoAODRNTuples.h.

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

◆ m_psetBlob

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

Definition at line 79 of file NanoAODRNTuples.h.

Referenced by createFields(), and fill().

◆ m_psetId

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

Definition at line 78 of file NanoAODRNTuples.h.

Referenced by createFields(), and fill().