18 #include "TObjString.h" 19 #include "Compression.h" 78 tree.Branch(
"run", &
m_run,
"run/i");
80 tree.Branch(
"event", &
m_event,
"event/l");
92 tree.Branch(
"run", &
m_run,
"run/i");
106 tree.Branch(
"run", &
m_run,
"run/i");
146 m_autoFlush(pset.getUntrackedParameter<
int>(
"autoFlush", -10000000)),
170 maxMemory =
static_cast<float>(
m_tree->GetTotBytes()) / percentClusterDone;
171 }
else if (
m_tree->GetZipBytes() == 0) {
172 maxMemory = 100*1024*1024;
175 float cxnRatio =
m_tree->GetTotBytes() /
static_cast<float>(
m_tree->GetZipBytes());
177 float percentBytesDone = -
m_tree->GetZipBytes() /
static_cast<float>(
m_autoFlush);
185 m_tree->OptimizeBaskets(static_cast<uint32_t>(maxMemory), 1,
"");
196 for (
unsigned int extensions = 0; extensions <= 1; ++extensions) {
229 TObjString *tos =
dynamic_cast<TObjString *
>(
m_file->Get(
p.first.c_str()));
231 if (hstring->
str() != tos->GetString())
throw cms::Exception(
"LogicError",
"Inconsistent nanoMetadata " +
p.first +
" (" + hstring->
str() +
")");
233 auto ostr = std::make_unique<TObjString>(hstring->
str().c_str());
234 m_file->WriteTObject(ostr.release(),
p.first.c_str());
245 return nullptr !=
m_file.get();
256 m_fakeName?
"PoolOutputModule":
"NanoAODOutputModule",
261 std::vector<std::string>()
265 m_file->SetCompressionAlgorithm(ROOT::kZLIB);
267 m_file->SetCompressionAlgorithm(ROOT::kLZMA);
270 <<
"Allowed compression algorithms are ZLIB and LZMA\n";
278 if(
keep.first->className() ==
"nanoaod::FlatTable" )
280 else if(
keep.first->className() ==
"edm::TriggerResults" )
284 else throw cms::Exception(
"Configuration",
"NanoAODOutputModule cannot handle class " +
keep.first->className());
288 if(
keep.first->className() ==
"nanoaod::MergeableCounterTable" )
290 else if(
keep.first->className() ==
"nanoaod::UniqueString" &&
keep.first->moduleLabel() ==
"nanoMetadata")
292 else throw cms::Exception(
"Configuration",
"NanoAODOutputModule cannot handle class " +
keep.first->className() +
" in Run branch");
297 m_tree.reset(
new TTree(
"Events",
"Events"));
302 m_lumiTree.reset(
new TTree(
"LuminosityBlocks",
"LuminosityBlocks"));
306 m_runTree.reset(
new TTree(
"Runs",
"Runs"));
320 int basketSize = 16384;
350 ->setComment(
"ROOT compression level of output file.");
352 ->setComment(
"Algorithm used to compress data in the ROOT output file, allowed values are ZLIB and LZMA");
354 ->setComment(
"Save process provenance information, e.g. for edmProvDump");
356 ->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");
358 ->setComment(
"Autoflush parameter for ROOT file");
361 const std::vector<std::string>
keep = {
"drop *",
"keep nanoaodFlatTable_*Table_*_*",
"keep edmTriggerResults_*_*_*",
"keep nanoaodMergeableCounterTable_*Table_*_*",
"keep nanoaodUniqueString_nanoMetadata_*_*"};
368 ->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)
bool isFileOpen() const override
std::unique_ptr< TTree > m_tree
void setAllowAnything()
allow any parameter label/value pairs
#define DEFINE_FWK_MODULE(type)
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
bool getByToken(EDGetToken token, TypeID const &typeID, BasicHandle &result) const
void addDefault(ParameterSetDescription const &psetDescription)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
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