|
|
Go to the documentation of this file.
19 #include "TObjString.h"
20 #include "Compression.h"
143 edm::one::OutputModule<>(
pset),
144 m_fileName(
pset.getUntrackedParameter<
std::
string>(
"fileName")),
145 m_logicalFileName(
pset.getUntrackedParameter<
std::
string>(
"logicalFileName")),
146 m_compressionLevel(
pset.getUntrackedParameter<
int>(
"compressionLevel")),
147 m_compressionAlgorithm(
pset.getUntrackedParameter<
std::
string>(
"compressionAlgorithm")),
148 m_writeProvenance(
pset.getUntrackedParameter<
bool>(
"saveProvenance",
true)),
149 m_fakeName(
pset.getUntrackedParameter<
bool>(
"fakeNameForCrab",
false)),
150 m_autoFlush(
pset.getUntrackedParameter<
int>(
"autoFlush", -10000000)),
151 m_processHistoryRegistry() {}
169 maxMemory = static_cast<float>(
m_tree->GetTotBytes()) / percentClusterDone;
170 }
else if (
m_tree->GetZipBytes() == 0) {
171 maxMemory = 100 * 1024 * 1024;
174 float cxnRatio =
m_tree->GetTotBytes() / static_cast<float>(
m_tree->GetZipBytes());
176 float percentBytesDone = -
m_tree->GetZipBytes() / static_cast<float>(
m_autoFlush);
184 m_tree->OptimizeBaskets(static_cast<uint32_t>(maxMemory), 1,
"");
195 for (
unsigned int extensions = 0; extensions <= 1; ++extensions) {
200 std::vector<std::string> pnames;
201 for (
auto&
p :
iEvent.processHistory())
202 pnames.push_back(
p.processName());
204 return ((
std::find(pnames.begin(), pnames.end(),
a.processName()) - pnames.begin()) >
205 (
std::find(pnames.begin(), pnames.end(),
b.processName()) - pnames.begin()));
242 TObjString* tos = dynamic_cast<TObjString*>(
m_file->Get(
p.first.c_str()));
244 if (hstring->
str() != tos->GetString())
245 throw cms::Exception(
"LogicError",
"Inconsistent nanoMetadata " +
p.first +
" (" + hstring->
str() +
")");
247 auto ostr = std::make_unique<TObjString>(hstring->
str().c_str());
248 m_file->WriteTObject(ostr.release(),
p.first.c_str());
266 m_fakeName ?
"PoolOutputModule" :
"NanoAODOutputModule",
271 std::vector<std::string>());
274 m_file->SetCompressionAlgorithm(ROOT::kZLIB);
276 m_file->SetCompressionAlgorithm(ROOT::kLZMA);
279 <<
"NanoAODOutputModule configured with unknown compression algorithm '" <<
m_compressionAlgorithm <<
"'\n"
280 <<
"Allowed compression algorithms are ZLIB and LZMA\n";
290 if (
keep.first->className() ==
"nanoaod::FlatTable")
292 else if (
keep.first->className() ==
"edm::TriggerResults") {
294 }
else if (
keep.first->className() ==
"std::basic_string<char,std::char_traits<char> >" &&
295 keep.first->productInstanceName() ==
"genModel") {
298 throw cms::Exception(
"Configuration",
"NanoAODOutputModule cannot handle class " +
keep.first->className());
302 if (
keep.first->className() ==
"nanoaod::MergeableCounterTable")
304 else if (
keep.first->className() ==
"nanoaod::UniqueString" &&
keep.first->moduleLabel() ==
"nanoMetadata")
308 "NanoAODOutputModule cannot handle class " +
keep.first->className() +
" in Run branch");
312 m_tree.reset(
new TTree(
"Events",
"Events"));
317 m_lumiTree.reset(
new TTree(
"LuminosityBlocks",
"LuminosityBlocks"));
321 m_runTree.reset(
new TTree(
"Runs",
"Runs"));
334 int basketSize = 16384;
362 desc.
addUntracked<
int>(
"compressionLevel", 9)->setComment(
"ROOT compression level of output file.");
364 ->setComment(
"Algorithm used to compress data in the ROOT output file, allowed values are ZLIB and LZMA");
366 ->setComment(
"Save process provenance information, e.g. for edmProvDump");
369 "Change the OutputModule name in the fwk job report to fake PoolOutputModule. This is needed to run on cran "
370 "(and publish) till crab is fixed");
371 desc.
addUntracked<
int>(
"autoFlush", -10000000)->setComment(
"Autoflush parameter for ROOT file");
374 const std::vector<std::string>
keep = {
"drop *",
375 "keep nanoaodFlatTable_*Table_*_*",
376 "keep edmTriggerResults_*_*_*",
377 "keep String_*_genModel_*",
378 "keep nanoaodMergeableCounterTable_*Table_*_*",
379 "keep nanoaodUniqueString_nanoMetadata_*_*"};
386 ->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)
ParameterDescriptionBase * add(U const &iLabel, T const &value)
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
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
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
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::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
std::string createGlobalIdentifier()