|
|
Go to the documentation of this file.
17 #include "Compression.h"
19 #include "TObjString.h"
147 m_fileName(
pset.getUntrackedParameter<
std::
string>(
"fileName")),
148 m_logicalFileName(
pset.getUntrackedParameter<
std::
string>(
"logicalFileName")),
149 m_compressionLevel(
pset.getUntrackedParameter<
int>(
"compressionLevel")),
150 m_compressionAlgorithm(
pset.getUntrackedParameter<
std::
string>(
"compressionAlgorithm")),
151 m_writeProvenance(
pset.getUntrackedParameter<
bool>(
"saveProvenance",
true)),
152 m_fakeName(
pset.getUntrackedParameter<
bool>(
"fakeNameForCrab",
false)),
153 m_autoFlush(
pset.getUntrackedParameter<
int>(
"autoFlush", -10000000)),
154 m_processHistoryRegistry() {}
172 maxMemory = static_cast<float>(
m_tree->GetTotBytes()) / percentClusterDone;
173 }
else if (
m_tree->GetZipBytes() == 0) {
174 maxMemory = 100 * 1024 * 1024;
177 float cxnRatio =
m_tree->GetTotBytes() / static_cast<float>(
m_tree->GetZipBytes());
179 float percentBytesDone = -
m_tree->GetZipBytes() / static_cast<float>(
m_autoFlush);
187 m_tree->OptimizeBaskets(static_cast<uint32_t>(maxMemory), 1,
"");
198 for (
unsigned int extensions = 0; extensions <= 1; ++extensions) {
203 std::vector<std::string> pnames;
204 for (
auto&
p :
iEvent.processHistory())
205 pnames.push_back(
p.processName());
207 return ((
std::find(pnames.begin(), pnames.end(),
a.processName()) - pnames.begin()) >
208 (
std::find(pnames.begin(), pnames.end(),
b.processName()) - pnames.begin()));
249 TObjString* tos = dynamic_cast<TObjString*>(
m_file->Get(
p.first.c_str()));
251 if (hstring->
str() != tos->GetString())
252 throw cms::Exception(
"LogicError",
"Inconsistent nanoMetadata " +
p.first +
" (" + hstring->
str() +
")");
254 auto ostr = std::make_unique<TObjString>(hstring->
str().c_str());
255 m_file->WriteTObject(ostr.release(),
p.first.c_str());
273 m_fakeName ?
"PoolOutputModule" :
"NanoAODOutputModule",
278 std::vector<std::string>());
281 m_file->SetCompressionAlgorithm(ROOT::kZLIB);
283 m_file->SetCompressionAlgorithm(ROOT::kLZMA);
286 <<
"NanoAODOutputModule configured with unknown compression algorithm '" <<
m_compressionAlgorithm <<
"'\n"
287 <<
"Allowed compression algorithms are ZLIB and LZMA\n";
298 if (
keep.first->className() ==
"nanoaod::FlatTable")
300 else if (
keep.first->className() ==
"edm::TriggerResults") {
302 }
else if (
keep.first->className() ==
"std::basic_string<char,std::char_traits<char> >" &&
303 keep.first->productInstanceName() ==
"genModel") {
306 throw cms::Exception(
"Configuration",
"NanoAODOutputModule cannot handle class " +
keep.first->className());
310 if (
keep.first->className() ==
"nanoaod::MergeableCounterTable")
312 else if (
keep.first->className() ==
"nanoaod::UniqueString" &&
keep.first->moduleLabel() ==
"nanoMetadata")
317 "NanoAODOutputModule cannot handle class " +
keep.first->className() +
" in LuminosityBlock branch");
321 if (
keep.first->className() ==
"nanoaod::MergeableCounterTable")
323 else if (
keep.first->className() ==
"nanoaod::UniqueString" &&
keep.first->moduleLabel() ==
"nanoMetadata")
327 "NanoAODOutputModule cannot handle class " +
keep.first->className() +
" in Run branch");
331 m_tree = std::make_unique<TTree>(
"Events",
"Events");
336 m_lumiTree = std::make_unique<TTree>(
"LuminosityBlocks",
"LuminosityBlocks");
340 m_runTree = std::make_unique<TTree>(
"Runs",
"Runs");
353 int basketSize = 16384;
381 desc.addUntracked<
int>(
"compressionLevel", 9)->setComment(
"ROOT compression level of output file.");
383 ->setComment(
"Algorithm used to compress data in the ROOT output file, allowed values are ZLIB and LZMA");
384 desc.addUntracked<
bool>(
"saveProvenance",
true)
385 ->setComment(
"Save process provenance information, e.g. for edmProvDump");
386 desc.addUntracked<
bool>(
"fakeNameForCrab",
false)
388 "Change the OutputModule name in the fwk job report to fake PoolOutputModule. This is needed to run on cran "
389 "(and publish) till crab is fixed");
390 desc.addUntracked<
int>(
"autoFlush", -10000000)->setComment(
"Autoflush parameter for ROOT file");
393 const std::vector<std::string>
keep = {
"drop *",
394 "keep nanoaodFlatTable_*Table_*_*",
395 "keep edmTriggerResults_*_*_*",
396 "keep String_*_genModel_*",
397 "keep nanoaodMergeableCounterTable_*Table_*_*",
398 "keep nanoaodUniqueString_nanoMetadata_*_*"};
405 ->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
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())
virtual ProcessHistory const & processHistory() const
NanoAODOutputModule(edm::ParameterSet const &pset)
std::string m_compressionAlgorithm
BasicHandle getByToken(EDGetToken token, TypeID const &typeID) const
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
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)
bool m_triggers_areSorted
void fill(const edm::RunID &id)
const std::string & str() const