22 #include "TBranchElement.h"
23 #include "TObjArray.h"
34 rootServiceChecker_(),
36 selectedOutputItemList_(),
37 fileName_(pset.getUntrackedParameter<std::
string>(
"fileName")),
38 logicalFileName_(pset.getUntrackedParameter<std::
string>(
"logicalFileName")),
39 catalog_(pset.getUntrackedParameter<std::
string>(
"catalog")),
40 maxFileSize_(pset.getUntrackedParameter<int>(
"maxSize")),
41 compressionLevel_(pset.getUntrackedParameter<int>(
"compressionLevel")),
42 #
if ROOT_VERSION_CODE >= ROOT_VERSION(5,30,0)
43 compressionAlgorithm_(pset.getUntrackedParameter<std::
string>(
"compressionAlgorithm")),
45 compressionAlgorithm_(
"ZLIB"),
47 basketSize_(pset.getUntrackedParameter<int>(
"basketSize")),
48 eventAutoFlushSize_(pset.getUntrackedParameter<int>(
"eventAutoFlushCompressedSize")),
49 splitLevel_(std::
min<int>(pset.getUntrackedParameter<int>(
"splitLevel") + 1, 99)),
50 basketOrder_(pset.getUntrackedParameter<std::
string>(
"sortBaskets")),
51 treeMaxVirtualSize_(pset.getUntrackedParameter<int>(
"treeMaxVirtualSize")),
52 whyNotFastClonable_(pset.getUntrackedParameter<bool>(
"fastCloning") ?
FileBlock::CanFastClone :
FileBlock::DisabledInConfigFile),
53 dropMetaData_(DropNone),
55 initializedFromInput_(
false),
59 numberOfDigitsInIndex_(0U),
62 overrideInputFileSplitLevels_(pset.getUntrackedParameter<bool>(
"overrideInputFileSplitLevels")),
67 std::ostringstream statusfilename;
80 << dropMetaData <<
".\n"
81 <<
"Legal values are 'NONE', 'DROPPED', 'PRIOR', and 'ALL'.\n";
98 for(
auto const&
prod : keptVector) {
112 branchDescription_(0),
118 branchDescription_(bd),
127 TObjArray* branches = tree->GetListOfBranches();
128 for(
int i = 0;
i < branches->GetEntries(); ++
i) {
129 TBranchElement*
br = (TBranchElement*)branches->At(
i);
139 if(treeMap_->empty())
return lh < rh;
142 std::map<std::string, int>::const_iterator lit = treeMap_->find(lstring);
143 std::map<std::string, int>::const_iterator rit = treeMap_->find(rstring);
144 bool lfound = (lit != treeMap_->end());
145 bool rfound = (rit != treeMap_->end());
146 if(lfound && rfound) {
147 return lit->second < rit->second;
175 for(SelectedProducts::const_iterator it = keptVector.begin(), itEnd = keptVector.end(); it != itEnd; ++it) {
183 splitLevel = theBranch->GetSplitLevel();
184 basketSize = theBranch->GetBasketSize();
189 outputItemList.emplace_back(&prod, splitLevel, basketSize);
214 TTree* theInputTree = (branchType ==
InEvent ? fb.
tree() :
231 while (iNumberOfChildren != 0) {
233 iNumberOfChildren /= 10;
248 statusFile << e.
id() <<
" time: " << std::setprecision(3) <<
TimeOfDay() <<
'\n';
300 std::pair<std::string, std::string>
304 <<
"Attempt to open output file before input file. "
305 <<
"Please report this to the core framework developers.\n";
309 bool ext = (offset ==
fileName().size() - suffix.size());
310 if(!ext) suffix.clear();
312 std::ostringstream ofilename;
313 std::ostringstream lfilename;
314 ofilename << fileBase;
331 return std::make_pair(ofilename.str(), lfilename.str());
342 if((*
i) && (*i)->productProvenancePtr() != 0) {
343 BranchID const& bid = (*i)->branchDescription().branchID();
346 it =
branchParents_.insert(std::make_pair(bid, std::set<ParentageID>())).first;
348 it->second.insert((*i)->productProvenancePtr()->parentageID());
359 std::set<ParentageID>
const& eIds =
i->second;
360 for(std::set<ParentageID>::const_iterator it = eIds.begin(), itEnd = eIds.end();
365 for(std::vector<BranchID>::const_iterator
j = parents.begin(), jEnd = parents.end();
377 desc.
setComment(
"Writes runs, lumis, and events into EDM/ROOT files.");
379 ->setComment(
"Name of output file.");
381 ->setComment(
"Passed to job report. Otherwise unused by module.");
383 ->setComment(
"Passed to job report. Otherwise unused by module.");
385 ->setComment(
"Maximum output file size, in kB.\n"
386 "If over maximum, new output file will be started at next input file transition.");
388 ->setComment(
"ROOT compression level of output file.");
389 #if ROOT_VERSION_CODE >= ROOT_VERSION(5,30,0)
391 ->setComment(
"Algorithm used to compress data in the ROOT output file, allowed values are ZLIB and LZMA");
394 ->setComment(
"Default ROOT basket size in output file.");
395 desc.
addUntracked<
int>(
"eventAutoFlushCompressedSize",-1)->setComment(
"Set ROOT auto flush stored data size (in bytes) for event TTree. The value sets how large the compressed buffer is allowed to get. The uncompressed buffer can be quite a bit larger than this depending on the average compression ratio. The value of -1 just uses ROOT's default value. The value of 0 turns off this feature.");
397 ->setComment(
"Default ROOT branch split level in output file.");
399 ->setComment(
"Legal values: 'sortbasketsbyoffset', 'sortbasketsbybranch', 'sortbasketsbyentry'.\n"
400 "Used by ROOT when fast copying. Affects performance.");
402 ->setComment(
"Size of ROOT TTree TBasket cache. Affects performance.");
404 ->setComment(
"True: Allow fast copying, if possible.\n"
405 "False: Disable fast copying.");
406 desc.
addUntracked<
bool>(
"overrideInputFileSplitLevels",
false)
407 ->setComment(
"False: Use branch split levels and basket sizes from input file, if possible.\n"
408 "True: Always use specified or default split levels and basket sizes.");
410 ->setComment(
"Write a status file. Intended for use by workflow management.");
412 ->setComment(
"Determines handling of per product per event metadata. Options are:\n"
413 "'NONE': Keep all of it.\n"
414 "'DROPPED': Keep it for products produced in current process and all kept products. Drop it for dropped products produced in prior processes.\n"
415 "'PRIOR': Keep it for products produced in current process. Drop it for products produced in prior processes.\n"
416 "'ALL': Drop all of it.");
420 ->setComment(
"PSet is only used by Data Operations and not by this module.");
429 descriptions.
add(
"edmOutput", desc);
void writeParentageRegistry()
virtual void openFile(FileBlock const &fb) override
virtual std::pair< std::string, std::string > physicalAndLogicalNameForNewFile()
T getUntrackedParameter(std::string const &, T const &) const
std::string const & branchName() const
std::string const & BranchTypeToAuxiliaryBranchName(BranchType const &branchType)
virtual void writeRun(RunPrincipal const &r, ModuleCallingContext const *) override
BranchDescription const * branchDescription_
int const & basketSize() const
bool wantAllEvents() const
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
static const HistoName names[]
static int const invalidSplitLevel
const_iterator end() const
void setAllowAnything()
allow any parameter label/value pairs
static int const invalidBasketSize
void checkClassDictionaries(TypeID const &type, bool recursive=true)
DropMetaData const & dropMetaData() const
BranchChildren branchChildren_
EventID const & id() const
std::vector< OutputItem > OutputItemList
std::string const & fileName() const
void insertEmpty(BranchID parent)
bool initializedFromInput_
void insertChild(BranchID parent, BranchID child)
std::string const moduleLabel_
ParameterSet getUntrackedParameterSet(std::string const &name, ParameterSet const &defaultValue) const
virtual void doExtrasAfterCloseFile()
std::string const & logicalFileName() const
void writeParameterSetRegistry()
void fillSelectedItemList(BranchType branchtype, TTree *theInputTree)
std::vector< BranchID > const & parents() const
PoolOutputModule(ParameterSet const &ps)
int remainingEvents() const
void setComment(std::string const &value)
bool overrideInputFileSplitLevels_
bool operator()(OutputItem const &lh, OutputItem const &rh) const
std::string const & currentFileName() const
bool getMapped(key_type const &k, value_type &result) const
void writeFileFormatVersion()
OutputItemListArray selectedOutputItemList_
void updateBranchParents(EventPrincipal const &ep)
SelectedProductsForBranchType const & keptProducts() const
int const & splitLevel() const
EventID const & min(EventID const &lh, EventID const &rh)
void writeProductDependencies()
virtual void reallyOpenFile() override
BranchParents branchParents_
std::unique_ptr< RootOutputFile > rootOutputFile_
void writeIndexIntoFile()
unsigned int numberOfDigitsInIndex_
void writeThinnedAssociationsHelper()
void sort_all(RandomAccessSequence &s)
wrappers for std::sort
void writeBranchIDListRegistry()
void writeProcessHistoryRegistry()
void fillDependencyGraph()
virtual bool shouldWeCloseFile() const override
allow inheriting classes to override but still be able to call this method in the overridden version ...
virtual void respondToCloseInputFile(FileBlock const &fb) override
DropMetaData dropMetaData_
virtual bool isFileOpen() const override
virtual void write(EventPrincipal const &e, ModuleCallingContext const *) override
const_iterator begin() const
virtual void beginJob() override
virtual void reallyCloseFile() override
void add(std::string const &label, ParameterSetDescription const &psetDescription)
virtual void writeLuminosityBlock(LuminosityBlockPrincipal const &lb, ModuleCallingContext const *) override
static void fillDescription(ParameterSetDescription &desc)
void writeFileIdentifier()
virtual ~PoolOutputModule()
virtual void postForkReacquireResources(unsigned int iChildIndex, unsigned int iNumberOfChildren) override
std::shared_ptr< std::map< std::string, int > > treeMap_
boost::filter_iterator< FilledProductPtr, ProductHolderCollection::const_iterator > const_iterator
std::vector< BranchDescription const * > SelectedProducts
std::string statusFileName_
void beginInputFile(FileBlock const &fb)
void writeProductDescriptionRegistry()
volatile std::atomic< bool > shutdown_flag false
virtual void respondToOpenInputFile(FileBlock const &fb) override
if(conf.exists("allCellsPositionCalc"))
static void fillDescriptions(ConfigurationDescriptions &descriptions)
static void fillDescription(ParameterSetDescription &desc)
static ParentageRegistry * instance()