16 #include <ROOT/RNTuple.hxx> 17 #include <ROOT/RNTupleModel.hxx> 18 #include <ROOT/RNTupleOptions.hxx> 19 #include <ROOT/RPageStorageFile.hxx> 20 using ROOT::Experimental::RNTupleModel;
21 using ROOT::Experimental::RNTupleWriteOptions;
22 using ROOT::Experimental::RNTupleWriter;
23 using ROOT::Experimental::Detail::RPageSinkFile;
25 #include "TObjString.h" 102 m_fileName(
pset.getUntrackedParameter<
std::
string>(
"fileName")),
103 m_logicalFileName(
pset.getUntrackedParameter<
std::
string>(
"logicalFileName")),
104 m_compressionAlgorithm(
pset.getUntrackedParameter<
std::
string>(
"compressionAlgorithm")),
105 m_compressionLevel(
pset.getUntrackedParameter<
int>(
"compressionLevel")),
106 m_writeProvenance(
pset.getUntrackedParameter<
bool>(
"saveProvenance",
true)),
107 m_processHistoryRegistry() {}
127 TObjString* tos =
dynamic_cast<TObjString*
>(
m_file->Get(
p.first.c_str()));
128 if (tos && hstring->
str() != tos->GetString()) {
129 throw cms::Exception(
"LogicError",
"Inconsistent nanoMetadata " +
p.first +
" (" + hstring->
str() +
")");
131 auto ostr = std::make_unique<TObjString>(hstring->
str().c_str());
132 m_file->WriteTObject(ostr.release(),
p.first.c_str());
149 "NanoAODRNTupleOutputModule",
154 std::vector<std::string>());
157 m_file->SetCompressionAlgorithm(ROOT::kZLIB);
159 m_file->SetCompressionAlgorithm(ROOT::kLZMA);
162 <<
"NanoAODOutputModule configured with unknown compression algorithm '" <<
m_compressionAlgorithm <<
"'\n" 163 <<
"Allowed compression algorithms are ZLIB and LZMA\n";
168 if (
keep.first->className() ==
"nanoaod::MergeableCounterTable") {
170 }
else if (
keep.first->className() ==
"nanoaod::UniqueString" &&
keep.first->moduleLabel() ==
"nanoMetadata") {
175 "NanoAODRNTupleOutputModule cannot handle class " +
keep.first->className() +
" in Run branch");
182 auto model = RNTupleModel::Create();
187 if (
keep.first->className() ==
"nanoaod::FlatTable") {
192 }
else if (
keep.first->className() ==
"edm::TriggerResults") {
194 }
else if (
keep.first->className() ==
"std::basic_string<char,std::char_traits<char> >" &&
195 keep.first->productInstanceName() ==
"genModel") {
198 throw cms::Exception(
"Configuration",
"NanoAODOutputModule cannot handle class " +
keep.first->className());
261 desc.addUntracked<
int>(
"compressionLevel", 9)->setComment(
"ROOT compression level of output file.");
265 "compress data in the ROOT output file, allowed values are ZLIB and LZMA");
266 desc.addUntracked<
bool>(
"saveProvenance",
true)
267 ->setComment(
"Save process provenance information, e.g. for edmProvDump");
268 const std::vector<std::string>
keep = {
"drop *",
269 "keep nanoaodFlatTable_*Table_*_*",
270 "keep edmTriggerResults_*_*_*",
271 "keep String_*_genModel_*",
272 "keep nanoaodMergeableCounterTable_*Table_*_*",
273 "keep nanoaodUniqueString_nanoMetadata_*_*"};
280 ->setComment(
"PSet is only used by Data Operations and not by this module.");
void fill(const edm::LuminosityBlockID &id, TFile &file)
EventStringOutputFields m_evstrings
void setAllowAnything()
allow any parameter label/value pairs
bool registerProcessHistory(ProcessHistory const &processHistory)
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
void fill(const edm::EventForOutput &iEvent)
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)