19 #include "TObjString.h" 20 #include "Compression.h" 80 tree.Branch(
"run", &
m_run,
"run/i");
82 tree.Branch(
"event", &
m_event,
"event/l");
94 tree.Branch(
"run", &
m_run,
"run/i");
108 tree.Branch(
"run", &
m_run,
"run/i");
151 m_autoFlush(pset.getUntrackedParameter<
int>(
"autoFlush", -10000000)),
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) {
205 std::vector<std::string> pnames;
207 pnames.push_back(
p.processName());
210 (
std::find(pnames.begin(), pnames.end(),
b.processName()) - pnames.begin()));
248 TObjString *tos =
dynamic_cast<TObjString *
>(
m_file->Get(
p.first.c_str()));
250 if (hstring->
str() != tos->GetString())
throw cms::Exception(
"LogicError",
"Inconsistent nanoMetadata " +
p.first +
" (" + hstring->
str() +
")");
252 auto ostr = std::make_unique<TObjString>(hstring->
str().c_str());
253 m_file->WriteTObject(ostr.release(),
p.first.c_str());
264 return nullptr !=
m_file.get();
275 m_fakeName?
"PoolOutputModule":
"NanoAODOutputModule",
280 std::vector<std::string>()
284 m_file->SetCompressionAlgorithm(ROOT::kZLIB);
286 m_file->SetCompressionAlgorithm(ROOT::kLZMA);
289 <<
"Allowed compression algorithms are ZLIB and LZMA\n";
300 if(
keep.first->className() ==
"nanoaod::FlatTable" )
302 else if(
keep.first->className() ==
"edm::TriggerResults" )
306 else if(
keep.first->className() ==
"std::basic_string<char,std::char_traits<char> >" &&
keep.first->productInstanceName()==
"genModel") {
309 else throw cms::Exception(
"Configuration",
"NanoAODOutputModule cannot handle class " +
keep.first->className());
313 if(
keep.first->className() ==
"nanoaod::MergeableCounterTable" )
315 else if(
keep.first->className() ==
"nanoaod::UniqueString" &&
keep.first->moduleLabel() ==
"nanoMetadata")
317 else throw cms::Exception(
"Configuration",
"NanoAODOutputModule cannot handle class " +
keep.first->className() +
" in Run branch");
321 if (
keep.first->className() ==
"nanoaod::MergeableCounterTable")
323 else if (
keep.first->className() ==
"nanoaod::UniqueString" &&
keep.first->moduleLabel() ==
"nanoMetadata")
325 else throw cms::Exception(
"Configuration",
"NanoAODOutputModule cannot handle class " +
keep.first->className() +
" in LuminosityBlock branch");
329 m_tree.reset(
new TTree(
"Events",
"Events"));
334 m_lumiTree.reset(
new TTree(
"LuminosityBlocks",
"LuminosityBlocks"));
338 m_runTree.reset(
new TTree(
"Runs",
"Runs"));
352 int basketSize = 16384;
382 ->setComment(
"ROOT compression level of output file.");
384 ->setComment(
"Algorithm used to compress data in the ROOT output file, allowed values are ZLIB and LZMA");
386 ->setComment(
"Save process provenance information, e.g. for edmProvDump");
388 ->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");
390 ->setComment(
"Autoflush parameter for ROOT file");
393 const std::vector<std::string>
keep = {
"drop *",
"keep nanoaodFlatTable_*Table_*_*",
"keep edmTriggerResults_*_*_*",
"keep String_*_genModel_*",
"keep nanoaodMergeableCounterTable_*Table_*_*",
"keep nanoaodUniqueString_nanoMetadata_*_*"};
400 ->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::string processName()
std::unique_ptr< TTree > m_lumiTree
EventID const & id() const
boost::uint64_t value() const
ModuleDescription const & description() const
std::vector< SummaryTableOutputBranches > m_lumiTables
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
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
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)
bool m_triggers_areSorted
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