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");
150 m_autoFlush(pset.getUntrackedParameter<
int>(
"autoFlush", -10000000)),
174 maxMemory =
static_cast<float>(
m_tree->GetTotBytes()) / percentClusterDone;
175 }
else if (
m_tree->GetZipBytes() == 0) {
176 maxMemory = 100*1024*1024;
179 float cxnRatio =
m_tree->GetTotBytes() /
static_cast<float>(
m_tree->GetZipBytes());
181 float percentBytesDone = -
m_tree->GetZipBytes() /
static_cast<float>(
m_autoFlush);
189 m_tree->OptimizeBaskets(static_cast<uint32_t>(maxMemory), 1,
"");
200 for (
unsigned int extensions = 0; extensions <= 1; ++extensions) {
204 std::vector<std::string> pnames;
206 pnames.push_back(
p.processName());
209 (
std::find(pnames.begin(), pnames.end(),
b.processName()) - pnames.begin()));
245 TObjString *tos =
dynamic_cast<TObjString *
>(
m_file->Get(
p.first.c_str()));
247 if (hstring->
str() != tos->GetString())
throw cms::Exception(
"LogicError",
"Inconsistent nanoMetadata " +
p.first +
" (" + hstring->
str() +
")");
249 auto ostr = std::make_unique<TObjString>(hstring->
str().c_str());
250 m_file->WriteTObject(ostr.release(),
p.first.c_str());
261 return nullptr !=
m_file.get();
272 m_fakeName?
"PoolOutputModule":
"NanoAODOutputModule",
277 std::vector<std::string>()
281 m_file->SetCompressionAlgorithm(ROOT::kZLIB);
283 m_file->SetCompressionAlgorithm(ROOT::kLZMA);
286 <<
"Allowed compression algorithms are ZLIB and LZMA\n";
296 if(
keep.first->className() ==
"nanoaod::FlatTable" )
298 else if(
keep.first->className() ==
"edm::TriggerResults" )
302 else if(
keep.first->className() ==
"std::basic_string<char,std::char_traits<char> >" &&
keep.first->productInstanceName()==
"genModel") {
305 else throw cms::Exception(
"Configuration",
"NanoAODOutputModule cannot handle class " +
keep.first->className());
309 if(
keep.first->className() ==
"nanoaod::MergeableCounterTable" )
311 else if(
keep.first->className() ==
"nanoaod::UniqueString" &&
keep.first->moduleLabel() ==
"nanoMetadata")
313 else throw cms::Exception(
"Configuration",
"NanoAODOutputModule cannot handle class " +
keep.first->className() +
" in Run branch");
318 m_tree.reset(
new TTree(
"Events",
"Events"));
323 m_lumiTree.reset(
new TTree(
"LuminosityBlocks",
"LuminosityBlocks"));
327 m_runTree.reset(
new TTree(
"Runs",
"Runs"));
341 int basketSize = 16384;
371 ->setComment(
"ROOT compression level of output file.");
373 ->setComment(
"Algorithm used to compress data in the ROOT output file, allowed values are ZLIB and LZMA");
375 ->setComment(
"Save process provenance information, e.g. for edmProvDump");
377 ->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");
379 ->setComment(
"Autoflush parameter for ROOT file");
382 const std::vector<std::string>
keep = {
"drop *",
"keep nanoaodFlatTable_*Table_*_*",
"keep edmTriggerResults_*_*_*",
"keep String_*_genModel_*",
"keep nanoaodMergeableCounterTable_*Table_*_*",
"keep nanoaodUniqueString_nanoMetadata_*_*"};
389 ->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
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
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
bool getByToken(EDGetToken token, TypeID const &typeID, BasicHandle &result) const
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