18 #include "TObjString.h" 19 #include "Compression.h" 79 tree.Branch(
"run", &
m_run,
"run/i");
81 tree.Branch(
"event", &
m_event,
"event/l");
93 tree.Branch(
"run", &
m_run,
"run/i");
107 tree.Branch(
"run", &
m_run,
"run/i");
148 m_autoFlush(pset.getUntrackedParameter<
int>(
"autoFlush", -10000000)),
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) {
233 TObjString *tos =
dynamic_cast<TObjString *
>(
m_file->Get(
p.first.c_str()));
235 if (hstring->
str() != tos->GetString())
throw cms::Exception(
"LogicError",
"Inconsistent nanoMetadata " +
p.first +
" (" + hstring->
str() +
")");
237 auto ostr = std::make_unique<TObjString>(hstring->
str().c_str());
238 m_file->WriteTObject(ostr.release(),
p.first.c_str());
249 return nullptr !=
m_file.get();
260 m_fakeName?
"PoolOutputModule":
"NanoAODOutputModule",
265 std::vector<std::string>()
269 m_file->SetCompressionAlgorithm(ROOT::kZLIB);
271 m_file->SetCompressionAlgorithm(ROOT::kLZMA);
274 <<
"Allowed compression algorithms are ZLIB and LZMA\n";
283 if(
keep.first->className() ==
"nanoaod::FlatTable" )
285 else if(
keep.first->className() ==
"edm::TriggerResults" )
289 else if(
keep.first->className() ==
"std::basic_string<char,std::char_traits<char> >" &&
keep.first->productInstanceName()==
"genModel") {
292 else throw cms::Exception(
"Configuration",
"NanoAODOutputModule cannot handle class " +
keep.first->className());
296 if(
keep.first->className() ==
"nanoaod::MergeableCounterTable" )
298 else if(
keep.first->className() ==
"nanoaod::UniqueString" &&
keep.first->moduleLabel() ==
"nanoMetadata")
300 else throw cms::Exception(
"Configuration",
"NanoAODOutputModule cannot handle class " +
keep.first->className() +
" in Run branch");
305 m_tree.reset(
new TTree(
"Events",
"Events"));
310 m_lumiTree.reset(
new TTree(
"LuminosityBlocks",
"LuminosityBlocks"));
314 m_runTree.reset(
new TTree(
"Runs",
"Runs"));
328 int basketSize = 16384;
358 ->setComment(
"ROOT compression level of output file.");
360 ->setComment(
"Algorithm used to compress data in the ROOT output file, allowed values are ZLIB and LZMA");
362 ->setComment(
"Save process provenance information, e.g. for edmProvDump");
364 ->setComment(
"Change the OutputModule name in the fwk job report to fake PoolOutputModule. This is needed to run on cran (and publish) till crab is fixed");
366 ->setComment(
"Autoflush parameter for ROOT file");
369 const std::vector<std::string>
keep = {
"drop *",
"keep nanoaodFlatTable_*Table_*_*",
"keep edmTriggerResults_*_*_*",
"keep String_*_genModel_*",
"keep nanoaodMergeableCounterTable_*Table_*_*",
"keep nanoaodUniqueString_nanoMetadata_*_*"};
376 ->setComment(
"PSet is only used by Data Operations and not by this module.");
std::unique_ptr< TTree > m_runTree
EventNumber_t event() const
virtual ProcessHistory const & processHistory() const
std::unique_ptr< TTree > m_lumiTree
EventID const & id() const
boost::uint64_t value() const
ModuleDescription const & description() const
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
BasicHandle getByToken(EDGetToken token, TypeID const &typeID) const
bool isFileOpen() const override
std::unique_ptr< TTree > m_tree
void setAllowAnything()
allow any parameter label/value pairs
void fillParameterSetBranch(TTree *parameterSetsTree, int basketSize)
bool registerProcessHistory(ProcessHistory const &processHistory)
void fillProcessHistoryBranch(TTree *metaDataTree, int basketSize, ProcessHistoryRegistry const &processHistoryRegistry)
NanoAODOutputModule(edm::ParameterSet const &pset)
void fill(const edm::LuminosityBlockID &id)
void reportRunNumber(JobReport::Token token, unsigned int run)
std::vector< std::pair< std::string, edm::EDGetToken > > m_nanoMetadata
std::string const & parameterSetsTreeName()
std::unique_ptr< TTree > m_parameterSetsTree
void writeRun(edm::RunForOutput const &) override
class NanoAODOutputModule::CommonLumiBranches m_commonLumiBranches
std::unique_ptr< TTree > m_metaDataTree
std::unique_ptr< TFile > m_file
#define DEFINE_FWK_MODULE(type)
void addDefault(ParameterSetDescription const &psetDescription)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
std::vector< EventStringOutputBranches > m_evstrings
void fill(const edm::RunID &id)
static void fillDescription(ParameterSetDescription &desc, std::vector< std::string > const &iDefaultOutputCommands=ProductSelectorRules::defaultSelectionStrings())
std::vector< SummaryTableOutputBranches > m_runTables
std::vector< TableOutputBranches > m_tables
std::vector< TriggerOutputBranches > m_triggers
SelectedProductsForBranchType const & keptProducts() const
std::string const & metaDataTreeName()
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void openFile(edm::FileBlock const &) override
void reallyCloseFile() override
void fill(const edm::EventID &id)
std::string m_logicalFileName
void eventWrittenToFile(Token fileToken, RunNumber_t run, EventNumber_t event)
std::string toString() const
void outputFileClosed(Token fileToken)
void write(edm::EventForOutput const &e) override
class NanoAODOutputModule::CommonRunBranches m_commonRunBranches
~NanoAODOutputModule() override
edm::JobReport::Token m_jrToken
class NanoAODOutputModule::CommonEventBranches m_commonBranches
const std::string & str() const
edm::ProcessHistoryRegistry m_processHistoryRegistry
LuminosityBlockID const & id() const
OutputModule(edm::ParameterSet const &iPSet)
std::string m_compressionAlgorithm
std::string createGlobalIdentifier()
void reportLumiSection(JobReport::Token token, unsigned int run, unsigned int lumiSectId, unsigned long nEvents=0)
void writeLuminosityBlock(edm::LuminosityBlockForOutput const &) override