16 #include <ROOT/RNTuple.hxx> 17 #include <ROOT/RNTupleModel.hxx> 18 #include <ROOT/RPageStorageFile.hxx> 19 using ROOT::Experimental::RNTupleModel;
20 #if ROOT_VERSION_CODE < ROOT_VERSION(6, 31, 0) 21 using ROOT::Experimental::RNTupleWriter;
22 using ROOT::Experimental::Detail::RPageSinkFile;
23 #define MakeRNTupleWriter std::make_unique<RNTupleWriter> 24 #include <ROOT/RNTupleOptions.hxx> 26 using ROOT::Experimental::Internal::RPageSinkFile;
27 #define MakeRNTupleWriter ROOT::Experimental::Internal::CreateRNTupleWriter 28 #include <ROOT/RNTupleWriteOptions.hxx> 30 using ROOT::Experimental::RNTupleWriteOptions;
32 #include "TObjString.h" 109 m_fileName(
pset.getUntrackedParameter<
std::
string>(
"fileName")),
110 m_logicalFileName(
pset.getUntrackedParameter<
std::
string>(
"logicalFileName")),
111 m_compressionAlgorithm(
pset.getUntrackedParameter<
std::
string>(
"compressionAlgorithm")),
112 m_compressionLevel(
pset.getUntrackedParameter<
int>(
"compressionLevel")),
113 m_writeProvenance(
pset.getUntrackedParameter<
bool>(
"saveProvenance",
true)),
114 m_processHistoryRegistry() {}
134 TObjString* tos =
dynamic_cast<TObjString*
>(
m_file->Get(
p.first.c_str()));
135 if (tos && hstring->
str() != tos->GetString()) {
136 throw cms::Exception(
"LogicError",
"Inconsistent nanoMetadata " +
p.first +
" (" + hstring->
str() +
")");
138 auto ostr = std::make_unique<TObjString>(hstring->
str().c_str());
139 m_file->WriteTObject(ostr.release(),
p.first.c_str());
156 "NanoAODRNTupleOutputModule",
161 std::vector<std::string>());
164 m_file->SetCompressionAlgorithm(ROOT::kZLIB);
166 m_file->SetCompressionAlgorithm(ROOT::kLZMA);
169 <<
"NanoAODOutputModule configured with unknown compression algorithm '" <<
m_compressionAlgorithm <<
"'\n" 170 <<
"Allowed compression algorithms are ZLIB and LZMA\n";
175 if (
keep.first->className() ==
"nanoaod::MergeableCounterTable") {
177 }
else if (
keep.first->className() ==
"nanoaod::UniqueString" &&
keep.first->moduleLabel() ==
"nanoMetadata") {
182 "NanoAODRNTupleOutputModule cannot handle class " +
keep.first->className() +
" in Run branch");
189 auto model = RNTupleModel::Create();
194 if (
keep.first->className() ==
"nanoaod::FlatTable") {
199 }
else if (
keep.first->className() ==
"edm::TriggerResults") {
201 }
else if (
keep.first->className() ==
"std::basic_string<char,std::char_traits<char> >" &&
202 keep.first->productInstanceName() ==
"genModel") {
205 throw cms::Exception(
"Configuration",
"NanoAODOutputModule cannot handle class " +
keep.first->className());
267 desc.addUntracked<
int>(
"compressionLevel", 9)->setComment(
"ROOT compression level of output file.");
271 "compress data in the ROOT output file, allowed values are ZLIB and LZMA");
272 desc.addUntracked<
bool>(
"saveProvenance",
true)
273 ->setComment(
"Save process provenance information, e.g. for edmProvDump");
274 const std::vector<std::string>
keep = {
"drop *",
275 "keep nanoaodFlatTable_*Table_*_*",
276 "keep edmTriggerResults_*_*_*",
277 "keep String_*_genModel_*",
278 "keep nanoaodMergeableCounterTable_*Table_*_*",
279 "keep nanoaodUniqueString_nanoMetadata_*_*"};
286 ->setComment(
"PSet is only used by Data Operations and not by this module.");
std::shared_ptr< UInt_t > m_luminosityBlock
void fill(const edm::LuminosityBlockID &id, TFile &file)
EventStringOutputFields m_evstrings
void setAllowAnything()
allow any parameter label/value pairs
bool registerProcessHistory(ProcessHistory const &processHistory)
#define MakeRNTupleWriter
void initializeNTuple(edm::EventForOutput const &e)
std::vector< std::pair< std::string, edm::EDGetToken > > m_nanoMetadata
void registerToken(const edm::EDGetToken &token)
void reportRunNumber(JobReport::Token token, unsigned int run)
BasicHandle getByToken(EDGetToken token, TypeID const &typeID) const
ModuleDescription const & description() const
void fill(const edm::EventID &id)
~NanoAODRNTupleOutputModule() override
std::string m_compressionAlgorithm
NanoAODRNTupleOutputModule(edm::ParameterSet const &pset)
void addDefault(ParameterSetDescription const &psetDescription)
edm::JobReport::Token m_jrToken
class NanoAODRNTupleOutputModule::CommonEventFields m_commonFields
#define DEFINE_FWK_MODULE(type)
void fill(const edm::EventForOutput &event)
void writeRun(edm::RunForOutput const &) override
void fill(edm::pset::Registry *pset, TFile &file)
void createFields(RNTupleModel &model)
void openFile(edm::FileBlock const &) override
std::string createGlobalIdentifier(bool binary=false)
void reallyCloseFile() override
SelectedProductsForBranchType const & keptProducts() const
unsigned long long uint64_t
std::unique_ptr< RNTupleWriter > m_ntuple
void eventWrittenToFile(Token fileToken, RunNumber_t run, EventNumber_t event)
bool isFileOpen() const override
std::unique_ptr< TFile > m_file
std::vector< TriggerOutputFields > m_triggers
void createFields(RNTupleModel &model)
LuminosityBlockID const & id() const
const std::string & str() const
void add(const edm::EDGetToken &table_token, const nanoaod::FlatTable &table)
virtual ProcessHistory const & processHistory() const
void writeLuminosityBlock(edm::LuminosityBlockForOutput const &) override
std::string m_logicalFileName
TableCollectionSet m_tables
void outputFileClosed(Token fileToken)
edm::ProcessHistoryRegistry m_processHistoryRegistry
std::shared_ptr< std::uint64_t > m_event
void fill(const edm::EventForOutput &iEvent)
std::shared_ptr< UInt_t > m_run
void registerToken(const edm::EDGetToken &token)
void fill(const edm::RunForOutput &iRun, TFile &file)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
static void fillDescription(ParameterSetDescription &desc, std::vector< std::string > const &iDefaultOutputCommands=ProductSelectorRules::defaultSelectionStrings())
std::string toString() const
void createFields(const edm::EventForOutput &event, RNTupleModel &eventModel)
static Registry * instance()
void write(edm::EventForOutput const &e) override
void reportLumiSection(JobReport::Token token, unsigned int run, unsigned int lumiSectId, unsigned long nEvents=0)