|
|
Go to the documentation of this file.
17 #include "Compression.h"
19 #include "TObjString.h"
48 #include "tbb/task_arena.h"
150 m_fileName(
pset.getUntrackedParameter<
std::
string>(
"fileName")),
151 m_logicalFileName(
pset.getUntrackedParameter<
std::
string>(
"logicalFileName")),
152 m_compressionLevel(
pset.getUntrackedParameter<
int>(
"compressionLevel")),
153 m_compressionAlgorithm(
pset.getUntrackedParameter<
std::
string>(
"compressionAlgorithm")),
154 m_writeProvenance(
pset.getUntrackedParameter<
bool>(
"saveProvenance",
true)),
155 m_fakeName(
pset.getUntrackedParameter<
bool>(
"fakeNameForCrab",
false)),
156 m_autoFlush(
pset.getUntrackedParameter<
int>(
"autoFlush", -10000000)),
157 m_processHistoryRegistry() {}
175 maxMemory = static_cast<float>(
m_tree->GetTotBytes()) / percentClusterDone;
176 }
else if (
m_tree->GetZipBytes() == 0) {
177 maxMemory = 100 * 1024 * 1024;
180 float cxnRatio =
m_tree->GetTotBytes() / static_cast<float>(
m_tree->GetZipBytes());
182 float percentBytesDone = -
m_tree->GetZipBytes() / static_cast<float>(
m_autoFlush);
190 m_tree->OptimizeBaskets(static_cast<uint32_t>(maxMemory), 1,
"");
201 for (
unsigned int extensions = 0; extensions <= 1; ++extensions) {
206 std::vector<std::string> pnames;
207 for (
auto&
p :
iEvent.processHistory())
208 pnames.push_back(
p.processName());
210 return ((
std::find(pnames.begin(), pnames.end(),
a.processName()) - pnames.begin()) >
211 (
std::find(pnames.begin(), pnames.end(),
b.processName()) - pnames.begin()));
221 tbb::this_task_arena::isolate([&] {
m_tree->Fill(); });
235 tbb::this_task_arena::isolate([&] {
m_lumiTree->Fill(); });
249 for (
unsigned int extensions = 0; extensions <= 1; ++extensions) {
257 TObjString* tos = dynamic_cast<TObjString*>(
m_file->Get(
p.first.c_str()));
259 if (hstring->
str() != tos->GetString())
260 throw cms::Exception(
"LogicError",
"Inconsistent nanoMetadata " +
p.first +
" (" + hstring->
str() +
")");
262 auto ostr = std::make_unique<TObjString>(hstring->
str().c_str());
263 m_file->WriteTObject(ostr.release(),
p.first.c_str());
267 tbb::this_task_arena::isolate([&] {
m_runTree->Fill(); });
281 m_fakeName ?
"PoolOutputModule" :
"NanoAODOutputModule",
286 std::vector<std::string>());
289 m_file->SetCompressionAlgorithm(ROOT::kZLIB);
291 m_file->SetCompressionAlgorithm(ROOT::kLZMA);
294 <<
"NanoAODOutputModule configured with unknown compression algorithm '" <<
m_compressionAlgorithm <<
"'\n"
295 <<
"Allowed compression algorithms are ZLIB and LZMA\n";
307 if (
keep.first->className() ==
"nanoaod::FlatTable")
309 else if (
keep.first->className() ==
"edm::TriggerResults") {
311 }
else if (
keep.first->className() ==
"std::basic_string<char,std::char_traits<char> >" &&
312 keep.first->productInstanceName() ==
"genModel") {
315 throw cms::Exception(
"Configuration",
"NanoAODOutputModule cannot handle class " +
keep.first->className());
319 if (
keep.first->className() ==
"nanoaod::MergeableCounterTable")
321 else if (
keep.first->className() ==
"nanoaod::UniqueString" &&
keep.first->moduleLabel() ==
"nanoMetadata")
326 "NanoAODOutputModule cannot handle class " +
keep.first->className() +
" in LuminosityBlock branch");
330 if (
keep.first->className() ==
"nanoaod::MergeableCounterTable")
332 else if (
keep.first->className() ==
"nanoaod::UniqueString" &&
keep.first->moduleLabel() ==
"nanoMetadata")
334 else if (
keep.first->className() ==
"nanoaod::FlatTable")
338 "NanoAODOutputModule cannot handle class " +
keep.first->className() +
" in Run branch");
342 m_tree = std::make_unique<TTree>(
"Events",
"Events");
347 m_lumiTree = std::make_unique<TTree>(
"LuminosityBlocks",
"LuminosityBlocks");
351 m_runTree = std::make_unique<TTree>(
"Runs",
"Runs");
364 int basketSize = 16384;
392 desc.addUntracked<
int>(
"compressionLevel", 9)->setComment(
"ROOT compression level of output file.");
394 ->setComment(
"Algorithm used to compress data in the ROOT output file, allowed values are ZLIB and LZMA");
395 desc.addUntracked<
bool>(
"saveProvenance",
true)
396 ->setComment(
"Save process provenance information, e.g. for edmProvDump");
397 desc.addUntracked<
bool>(
"fakeNameForCrab",
false)
399 "Change the OutputModule name in the fwk job report to fake PoolOutputModule. This is needed to run on cran "
400 "(and publish) till crab is fixed");
401 desc.addUntracked<
int>(
"autoFlush", -10000000)->setComment(
"Autoflush parameter for ROOT file");
404 const std::vector<std::string>
keep = {
"drop *",
405 "keep nanoaodFlatTable_*Table_*_*",
406 "keep edmTriggerResults_*_*_*",
407 "keep String_*_genModel_*",
408 "keep nanoaodMergeableCounterTable_*Table_*_*",
409 "keep nanoaodUniqueString_nanoMetadata_*_*"};
416 ->setComment(
"PSet is only used by Data Operations and not by this module.");
void fill(const edm::EventID &id)
std::unique_ptr< TTree > m_tree
bool registerProcessHistory(ProcessHistory const &processHistory)
edm::JobReport::Token m_jrToken
std::vector< SummaryTableOutputBranches > m_runTables
void writeLuminosityBlock(edm::LuminosityBlockForOutput const &) override
class NanoAODOutputModule::CommonRunBranches m_commonRunBranches
std::unique_ptr< TTree > m_lumiTree
class NanoAODOutputModule::CommonLumiBranches m_commonLumiBranches
std::string const & parameterSetsTreeName()
bool isFileOpen() const override
std::string m_logicalFileName
void eventWrittenToFile(Token fileToken, RunNumber_t run, EventNumber_t event)
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
std::vector< EventStringOutputBranches > m_evstrings
void openFile(edm::FileBlock const &) override
std::vector< TableOutputBranches > m_tables
class NanoAODOutputModule::CommonEventBranches m_commonBranches
BasicHandle getByToken(EDGetToken token, TypeID const &typeID) const
edm::ProcessHistoryRegistry m_processHistoryRegistry
#define DEFINE_FWK_MODULE(type)
void fillParameterSetBranch(TTree *parameterSetsTree, int basketSize)
void fill(const edm::LuminosityBlockID &id)
void outputFileClosed(Token fileToken)
std::unique_ptr< TTree > m_runTree
static constexpr int m_firstFlush
void reallyCloseFile() override
static void fillDescription(ParameterSetDescription &desc, std::vector< std::string > const &iDefaultOutputCommands=ProductSelectorRules::defaultSelectionStrings())
NanoAODOutputModule(edm::ParameterSet const &pset)
std::string m_compressionAlgorithm
void writeRun(edm::RunForOutput const &) override
void reportLumiSection(JobReport::Token token, unsigned int run, unsigned int lumiSectId, unsigned long nEvents=0)
SelectedProductsForBranchType const & keptProducts() const
std::unique_ptr< TTree > m_parameterSetsTree
std::string createGlobalIdentifier(bool binary=false)
LuminosityBlockID const & id() const
void reportRunNumber(JobReport::Token token, unsigned int run)
void setAllowAnything()
allow any parameter label/value pairs
virtual ProcessHistory const & processHistory() const
std::vector< std::pair< std::string, edm::EDGetToken > > m_nanoMetadata
ModuleDescription const & description() const
std::vector< SummaryTableOutputBranches > m_lumiTables
std::unique_ptr< TFile > m_file
std::vector< TriggerOutputBranches > m_triggers
std::string const & metaDataTreeName()
void fillProcessHistoryBranch(TTree *metaDataTree, int basketSize, ProcessHistoryRegistry const &processHistoryRegistry)
std::unique_ptr< TTree > m_metaDataTree
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
~NanoAODOutputModule() override
void write(edm::EventForOutput const &e) override
std::string toString() const
void addDefault(ParameterSetDescription const &psetDescription)
std::vector< TableOutputBranches > m_runFlatTables
bool m_triggers_areSorted
void fill(const edm::RunID &id)
const std::string & str() const