|
|
Go to the documentation of this file.
26 #include "TBranchElement.h"
27 #include "TObjArray.h"
33 #include "boost/algorithm/string.hpp"
39 rootServiceChecker_(),
41 selectedOutputItemList_(),
42 fileName_(
pset.getUntrackedParameter<
std::
string>(
"fileName")),
43 logicalFileName_(
pset.getUntrackedParameter<
std::
string>(
"logicalFileName")),
45 maxFileSize_(
pset.getUntrackedParameter<
int>(
"maxSize")),
46 compressionLevel_(
pset.getUntrackedParameter<
int>(
"compressionLevel")),
47 compressionAlgorithm_(
pset.getUntrackedParameter<
std::
string>(
"compressionAlgorithm")),
48 basketSize_(
pset.getUntrackedParameter<
int>(
"basketSize")),
49 eventAuxBasketSize_(
pset.getUntrackedParameter<
int>(
"eventAuxiliaryBasketSize")),
50 eventAutoFlushSize_(
pset.getUntrackedParameter<
int>(
"eventAutoFlushCompressedSize")),
51 splitLevel_(
std::
min<
int>(
pset.getUntrackedParameter<
int>(
"splitLevel") + 1, 99)),
52 basketOrder_(
pset.getUntrackedParameter<
std::
string>(
"sortBaskets")),
53 treeMaxVirtualSize_(
pset.getUntrackedParameter<
int>(
"treeMaxVirtualSize")),
54 whyNotFastClonable_(
pset.getUntrackedParameter<
bool>(
"fastCloning") ?
FileBlock::CanFastClone
56 dropMetaData_(DropNone),
57 moduleLabel_(
pset.getParameter<
std::
string>(
"@module_label")),
58 initializedFromInput_(
false),
63 overrideInputFileSplitLevels_(
pset.getUntrackedParameter<
bool>(
"overrideInputFileSplitLevels")),
64 compactEventAuxiliary_(
pset.getUntrackedParameter<
bool>(
"compactEventAuxiliary")),
67 if (
pset.getUntrackedParameter<
bool>(
"writeStatusFile")) {
68 std::ostringstream statusfilename;
87 <<
"Legal values are 'NONE', 'DROPPED', 'PRIOR', and 'ALL'.\n";
94 auto const& specialSplit{
pset.getUntrackedParameterSetVector(
"overrideBranchesSplitLevel")};
97 for (
auto const&
s : specialSplit) {
99 s.getUntrackedParameter<
int>(
"splitLevel"));
105 pset.getUntrackedParameterSet(
"dataset");
110 for (
auto const&
prod : reg->productList()) {
123 : branchDescription_(nullptr),
137 if (
tree !=
nullptr) {
138 TObjArray* branches =
tree->GetListOfBranches();
139 for (
int i = 0;
i < branches->GetEntries(); ++
i) {
140 TBranchElement*
br = (TBranchElement*)branches->At(
i);
149 if (treeMap_->empty())
151 std::string const& lstring =
lh.branchDescription_->branchName();
153 std::map<std::string, int>::const_iterator lit = treeMap_->find(lstring);
154 std::map<std::string, int>::const_iterator rit = treeMap_->find(rstring);
155 bool lfound = (lit != treeMap_->end());
156 bool rfound = (rit != treeMap_->end());
157 if (lfound && rfound) {
158 return lit->second < rit->second;
168 return std::regex_match(iBranchName, branch_);
173 boost::replace_all(
tmp,
"*",
".*");
174 boost::replace_all(
tmp,
"?",
".");
175 return std::regex(
tmp);
198 for (
auto const& kept : keptVector) {
204 ? theInputTree->GetBranch(
prod.branchName().c_str())
207 if (theBranch !=
nullptr) {
213 if (
b.match(
prod.branchName())) {
231 auto const& branchToChildMap =
fb.branchChildren().childLookup();
232 for (
auto const& parentToChildren : branchToChildMap) {
233 for (
auto const&
child : parentToChildren.second) {
255 BranchType branchType = static_cast<BranchType>(
i);
256 TTree* theInputTree =
257 (branchType ==
InEvent ?
fb.tree() : (branchType ==
InLumi ?
fb.lumiTree() :
fb.runTree()));
282 statusFile <<
e.id() <<
" time: " << std::setprecision(3) <<
TimeOfDay() <<
'\n';
343 <<
"Please report this to the core framework developers.\n";
351 std::ostringstream ofilename;
352 std::ostringstream lfilename;
353 ofilename << fileBase;
364 return std::make_pair(ofilename.str(), lfilename.str());
379 if (provenance !=
nullptr) {
405 auto const*
ep = dynamic_cast<EventPrincipal const*>(&iPrincipal);
407 auto pr =
ep->productProvenanceRetrieverPtr();
409 pr->readProvenanceAsync(iTask, &iModuleCallingContext);
418 std::set<ParentageID>
const& eIds = branchParent.second;
419 for (
auto const& eId : eIds) {
433 desc.setComment(
"Writes runs, lumis, and events into EDM/ROOT files.");
434 desc.addUntracked<
std::string>(
"fileName")->setComment(
"Name of output file.");
436 ->setComment(
"Passed to job report. Otherwise unused by module.");
438 ->setComment(
"Passed to job report. Otherwise unused by module.");
439 desc.addUntracked<
int>(
"maxSize", 0x7f000000)
441 "Maximum output file size, in kB.\n"
442 "If over maximum, new output file will be started at next input file transition.");
443 desc.addUntracked<
int>(
"compressionLevel", 9)->setComment(
"ROOT compression level of output file.");
445 ->setComment(
"Algorithm used to compress data in the ROOT output file, allowed values are ZLIB and LZMA");
446 desc.addUntracked<
int>(
"basketSize", 16384)->setComment(
"Default ROOT basket size in output file.");
447 desc.addUntracked<
int>(
"eventAuxiliaryBasketSize", 16384)
448 ->setComment(
"Default ROOT basket size in output file for EventAuxiliary branch.");
449 desc.addUntracked<
int>(
"eventAutoFlushCompressedSize", 20 * 1024 * 1024)
451 "Set ROOT auto flush stored data size (in bytes) for event TTree. The value sets how large the compressed "
452 "buffer is allowed to get. The uncompressed buffer can be quite a bit larger than this depending on the "
453 "average compression ratio. The value of -1 just uses ROOT's default value. The value of 0 turns off this "
455 desc.addUntracked<
int>(
"splitLevel", 99)->setComment(
"Default ROOT branch split level in output file.");
458 "Legal values: 'sortbasketsbyoffset', 'sortbasketsbybranch', 'sortbasketsbyentry'.\n"
459 "Used by ROOT when fast copying. Affects performance.");
460 desc.addUntracked<
int>(
"treeMaxVirtualSize", -1)
461 ->setComment(
"Size of ROOT TTree TBasket cache. Affects performance.");
462 desc.addUntracked<
bool>(
"fastCloning",
true)
464 "True: Allow fast copying, if possible.\n"
465 "False: Disable fast copying.");
466 desc.addUntracked<
bool>(
"compactEventAuxiliary",
false)
468 "False: Write EventAuxiliary as we go like any other event metadata branch.\n"
469 "True: Optimize the file layout be deferring writing the EventAuxiliary branch until the output file is "
471 desc.addUntracked<
bool>(
"overrideInputFileSplitLevels",
false)
473 "False: Use branch split levels and basket sizes from input file, if possible.\n"
474 "True: Always use specified or default split levels and basket sizes.");
475 desc.addUntracked<
bool>(
"writeStatusFile",
false)
476 ->setComment(
"Write a status file. Intended for use by workflow management.");
479 "Determines handling of per product per event metadata. Options are:\n"
480 "'NONE': Keep all of it.\n"
481 "'DROPPED': Keep it for products produced in current process and all kept products. Drop it for dropped "
482 "products produced in prior processes.\n"
483 "'PRIOR': Keep it for products produced in current process. Drop it for products produced in prior "
485 "'ALL': Drop all of it.");
490 ->setComment(
"PSet is only used by Data Operations and not by this module.");
495 "Name of branch needing a special split level. The name can contain wildcards '*' and '?'");
496 specialSplit.
addUntracked<
int>(
"splitLevel")->setComment(
"The special split level for the branch");
497 desc.addVPSetUntracked(
"overrideBranchesSplitLevel", specialSplit, std::vector<ParameterSet>());
499 OutputModule::fillDescription(
desc);
505 descriptions.
add(
"edmOutput",
desc);
~PoolOutputModule() override
int remainingEvents() const
std::vector< BranchID > const & parents() const
void updateBranchParents(EventForOutput const &e)
BranchChildren branchChildren_
void respondToOpenInputFile(FileBlock const &fb) override
SubProcessParentageHelper const * subProcessParentageHelper() const
BranchID branchID() const
std::regex convert(std::string const &iGlobBranchExpression) const
std::vector< std::string > processesWithSelectedMergeableRunProducts_
void sort_all(RandomAccessSequence &s)
wrappers for std::sort
std::vector< OutputItem > OutputItemList
EventID const & min(EventID const &lh, EventID const &rh)
edm::propagate_const< std::unique_ptr< RootOutputFile > > rootOutputFile_
void openFile(FileBlock const &fb) override
void writeParameterSetRegistry()
static ParentageRegistry * instance()
std::string const & currentFileName() const
bool initializedFromInput_
void fillSelectedItemList(BranchType branchtype, TTree *theInputTree)
bool match(std::string const &iBranchName) const
void setProcessesWithSelectedMergeableRunProducts(std::set< std::string > const &) override
void updateBranchParentsForOneBranch(ProductProvenanceRetriever const *provRetriever, BranchID const &branchID)
BranchDescription const * branchDescription_
virtual void doExtrasAfterCloseFile()
std::string const & BranchTypeToAuxiliaryBranchName(BranchType const &branchType)
std::vector< SpecialSplitLevelForBranch > specialSplitLevelForBranches_
std::vector< std::pair< BranchDescription const *, EDGetToken > > SelectedProducts
PoolOutputModule(ParameterSet const &ps)
void preActionBeforeRunEventAsync(WaitingTaskHolder iTask, ModuleCallingContext const &iModuleCallingContext, Principal const &iPrincipal) const override
const std::string moduleLabel_
void add(std::string const &label, ParameterSetDescription const &psetDescription)
void writeFileFormatVersion()
const std::string names[nVars_]
bool operator()(OutputItem const &lh, OutputItem const &rh) const
OutputItemListArray selectedOutputItemList_
std::vector< BranchID > producedBranches_
BranchParents branchParents_
static const int invalidSplitLevel
DropMetaData const & dropMetaData() const
bool wantAllEvents() const
std::shared_ptr< std::map< std::string, int > > treeMap_
bool overrideInputFileSplitLevels_
void writeThinnedAssociationsHelper()
void writeEventAuxiliary()
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
void writeIndexIntoFile()
bool getMapped(key_type const &k, value_type &result) const
SelectedProductsForBranchType const & keptProducts() const
void writeProductDependencies()
std::string const & branchName() const
ParentageID const & parentageID() const
bool isFileOpen() const override
void writeStoredMergeableRunProductMetadata()
void writeRun(RunForOutput const &r) override
void beginInputFile(FileBlock const &fb)
std::string const & fileName() const
void writeProductDescriptionRegistry()
void writeBranchIDListRegistry()
void fillDependencyGraph()
static void fillDescriptions(ConfigurationDescriptions &descriptions)
bool shouldWeCloseFile() const override
allow inheriting classes to override but still be able to call this method in the overridden version
void reallyCloseFile() override
std::string statusFileName_
std::string const & logicalFileName() const
static const int invalidBasketSize
ProductProvenance const * branchIDToProvenanceForProducedOnly(BranchID const &bid) const
void writeLuminosityBlock(LuminosityBlockForOutput const &lb) override
void writeProcessHistoryRegistry()
void respondToCloseInputFile(FileBlock const &fb) override
DropMetaData dropMetaData_
void writeFileIdentifier()
void write(EventForOutput const &e) override
void writeParentageRegistry()
static void fillDescription(ParameterSetDescription &desc)
void insertChild(BranchID parent, BranchID child)
virtual std::pair< std::string, std::string > physicalAndLogicalNameForNewFile()
const int eventAuxBasketSize_