22 #include "TBranchElement.h"
23 #include "TObjArray.h"
33 rootServiceChecker_(),
35 selectedOutputItemList_(),
36 fileName_(pset.getUntrackedParameter<std::
string>(
"fileName")),
37 logicalFileName_(pset.getUntrackedParameter<std::
string>(
"logicalFileName")),
38 catalog_(pset.getUntrackedParameter<std::
string>(
"catalog")),
39 maxFileSize_(pset.getUntrackedParameter<int>(
"maxSize")),
40 compressionLevel_(pset.getUntrackedParameter<int>(
"compressionLevel")),
41 #
if ROOT_VERSION_CODE >= ROOT_VERSION(5,30,0)
42 compressionAlgorithm_(pset.getUntrackedParameter<std::
string>(
"compressionAlgorithm")),
44 compressionAlgorithm_(
"ZLIB"),
46 basketSize_(pset.getUntrackedParameter<int>(
"basketSize")),
47 eventAutoFlushSize_(pset.getUntrackedParameter<int>(
"eventAutoFlushCompressedSize")),
48 splitLevel_(std::
min<int>(pset.getUntrackedParameter<int>(
"splitLevel") + 1, 99)),
49 basketOrder_(pset.getUntrackedParameter<std::
string>(
"sortBaskets")),
50 treeMaxVirtualSize_(pset.getUntrackedParameter<int>(
"treeMaxVirtualSize")),
51 whyNotFastClonable_(pset.getUntrackedParameter<bool>(
"fastCloning") ?
FileBlock::CanFastClone :
FileBlock::DisabledInConfigFile),
52 dropMetaData_(DropNone),
53 moduleLabel_(pset.getParameter<std::
string>(
"@module_label")),
54 initializedFromInput_(
false),
58 numberOfDigitsInIndex_(0U),
59 overrideInputFileSplitLevels_(pset.getUntrackedParameter<bool>(
"overrideInputFileSplitLevels")),
64 std::ostringstream statusfilename;
77 << dropMetaData <<
".\n"
78 <<
"Legal values are 'NONE', 'DROPPED', 'PRIOR', and 'ALL'.\n";
95 for(Selections::const_iterator it = keptVector.
begin(), itEnd = keptVector.
end(); it != itEnd; ++it) {
111 branchDescription_(0),
117 branchDescription_(bd),
126 TObjArray* branches = tree->GetListOfBranches();
127 for(
int i = 0;
i < branches->GetEntries(); ++
i) {
128 TBranchElement*
br = (TBranchElement*)branches->At(
i);
138 if(treeMap_->empty())
return lh < rh;
141 std::map<std::string, int>::const_iterator lit = treeMap_->find(lstring);
142 std::map<std::string, int>::const_iterator rit = treeMap_->find(rstring);
143 bool lfound = (lit != treeMap_->end());
144 bool rfound = (rit != treeMap_->end());
145 if(lfound && rfound) {
146 return lit->second < rit->second;
174 for(Selections::const_iterator it = keptVector.
begin(), itEnd = keptVector.
end(); it != itEnd; ++it) {
182 splitLevel = theBranch->GetSplitLevel();
183 basketSize = theBranch->GetBasketSize();
188 outputItemList.emplace_back(&prod, splitLevel, basketSize);
213 TTree* theInputTree = (branchType ==
InEvent ? fb.
tree() :
230 while (iNumberOfChildren != 0) {
232 iNumberOfChildren /= 10;
246 statusFile << e.
id() <<
" time: " << std::setprecision(3) <<
TimeOfDay() <<
'\n';
260 reportSvc->reportRunNumber(r.
run());
284 <<
"Attempt to open output file before input file. "
285 <<
"Please report this to the core framework developers.\n";
289 bool ext = (offset ==
fileName().size() - suffix.size());
290 if(!ext) suffix.clear();
292 std::ostringstream ofilename;
293 std::ostringstream lfilename;
294 ofilename << fileBase;
317 desc.
setComment(
"Writes runs, lumis, and events into EDM/ROOT files.");
319 ->setComment(
"Name of output file.");
321 ->setComment(
"Passed to job report. Otherwise unused by module.");
323 ->setComment(
"Passed to job report. Otherwise unused by module.");
325 ->setComment(
"Maximum output file size, in kB.\n"
326 "If over maximum, new output file will be started at next input file transition.");
328 ->setComment(
"ROOT compression level of output file.");
329 #if ROOT_VERSION_CODE >= ROOT_VERSION(5,30,0)
331 ->setComment(
"Algorithm used to compress data in the ROOT output file, allowed values are ZLIB and LZMA");
334 ->setComment(
"Default ROOT basket size in output file.");
335 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.");
337 ->setComment(
"Default ROOT branch split level in output file.");
339 ->setComment(
"Legal values: 'sortbasketsbyoffset', 'sortbasketsbybranch', 'sortbasketsbyentry'.\n"
340 "Used by ROOT when fast copying. Affects performance.");
342 ->setComment(
"Size of ROOT TTree TBasket cache. Affects performance.");
344 ->setComment(
"True: Allow fast copying, if possible.\n"
345 "False: Disable fast copying.");
346 desc.
addUntracked<
bool>(
"overrideInputFileSplitLevels",
false)
347 ->setComment(
"False: Use branch split levels and basket sizes from input file, if possible.\n"
348 "True: Always use specified or default split levels and basket sizes.");
350 ->setComment(
"Write a status file. Intended for use by workflow management.");
352 ->setComment(
"Determines handling of per product per event metadata. Options are:\n"
353 "'NONE': Keep all of it.\n"
354 "'DROPPED': Keep it for products produced in current process and all kept products. Drop it for dropped products produced in prior processes.\n"
355 "'PRIOR': Keep it for products produced in current process. Drop it for products produced in prior processes.\n"
356 "'ALL': Drop all of it.");
360 ->setComment(
"PSet is only used by Data Operations and not by this module.");
364 descriptions.
add(
"edmOutput", desc);
virtual void writeParentageRegistry()
virtual void doOpenFile()
T getUntrackedParameter(std::string const &, T const &) const
std::string const & BranchTypeToAuxiliaryBranchName(BranchType const &branchType)
BranchDescription const * branchDescription_
int const & basketSize() const
SelectionsArray const & keptProducts() const
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
static int const invalidSplitLevel
std::string & branchName() const
void setAllowAnything()
allow any parameter label/value pairs
static int const invalidBasketSize
DropMetaData const & dropMetaData() const
virtual bool isFileOpen() const
int remainingEvents() const
EventID const & id() const
std::vector< OutputItem > OutputItemList
std::string const & fileName() const
bool initializedFromInput_
std::string const moduleLabel_
virtual void write(EventPrincipal const &e)
virtual bool shouldWeCloseFile() const
allow inheriting classes to override but still be able to call this method in the overridden version ...
std::string const & logicalFileName() const
virtual void writeParameterSetRegistry()
void fillSelectedItemList(BranchType branchtype, TTree *theInputTree)
bool wantAllEvents() const
PoolOutputModule(ParameterSet const &ps)
virtual void respondToOpenInputFile(FileBlock const &fb)
void setComment(std::string const &value)
virtual void respondToCloseInputFile(FileBlock const &fb)
bool overrideInputFileSplitLevels_
bool operator()(OutputItem const &lh, OutputItem const &rh) const
std::string const & currentFileName() const
virtual void writeFileFormatVersion()
virtual void writeLuminosityBlock(LuminosityBlockPrincipal const &lb)
OutputItemListArray selectedOutputItemList_
ParameterSet const & getUntrackedParameterSet(std::string const &name, ParameterSet const &defaultValue) const
void checkDictionaries(std::string const &name, bool noComponents=false)
virtual void writeProcessConfigurationRegistry()
int const & splitLevel() const
EventID const & min(EventID const &lh, EventID const &rh)
virtual void writeProductDependencies()
std::unique_ptr< RootOutputFile > rootOutputFile_
unsigned int offset(bool)
virtual void writeIndexIntoFile()
unsigned int numberOfDigitsInIndex_
std::string const & fullClassName() const
void sort_all(RandomAccessSequence &s)
wrappers for std::sort
virtual void writeBranchIDListRegistry()
virtual void writeProcessHistoryRegistry()
DropMetaData dropMetaData_
std::string wrappedClassName(std::string const &iFullName)
virtual void openFile(FileBlock const &fb)
LuminosityBlockNumber_t luminosityBlock() const
void add(std::string const &label, ParameterSetDescription const &psetDescription)
virtual void postForkReacquireResources(unsigned int iChildIndex, unsigned int iNumberOfChildren)
static void fillDescription(ParameterSetDescription &desc)
virtual void writeFileIdentifier()
virtual ~PoolOutputModule()
virtual void finishEndFile()
std::string statusFileName_
void beginInputFile(FileBlock const &fb)
virtual void startEndFile()
virtual void writeProductDescriptionRegistry()
boost::shared_ptr< std::map< std::string, int > > treeMap_
static void fillDescriptions(ConfigurationDescriptions &descriptions)
virtual void writeRun(RunPrincipal const &r)
LuminosityBlockID id() const