21 #include "TBranchElement.h"
22 #include "TObjArray.h"
32 rootServiceChecker_(),
34 selectedOutputItemList_(),
35 fileName_(pset.getUntrackedParameter<std::string>(
"fileName")),
36 logicalFileName_(pset.getUntrackedParameter<std::string>(
"logicalFileName")),
37 catalog_(pset.getUntrackedParameter<std::string>(
"catalog")),
38 maxFileSize_(pset.getUntrackedParameter<int>(
"maxSize")),
39 compressionLevel_(pset.getUntrackedParameter<int>(
"compressionLevel")),
40 #
if ROOT_VERSION_CODE >= ROOT_VERSION(5,30,0)
41 compressionAlgorithm_(pset.getUntrackedParameter<std::string>(
"compressionAlgorithm")),
43 compressionAlgorithm_(
"ZLIB"),
45 basketSize_(pset.getUntrackedParameter<int>(
"basketSize")),
46 eventAutoFlushSize_(pset.getUntrackedParameter<int>(
"eventAutoFlushCompressedSize")),
47 splitLevel_(std::
min<int>(pset.getUntrackedParameter<int>(
"splitLevel") + 1, 99)),
48 basketOrder_(pset.getUntrackedParameter<std::string>(
"sortBaskets")),
49 treeMaxVirtualSize_(pset.getUntrackedParameter<int>(
"treeMaxVirtualSize")),
50 whyNotFastClonable_(pset.getUntrackedParameter<bool>(
"fastCloning") ?
FileBlock::CanFastClone :
FileBlock::DisabledInConfigFile),
51 dropMetaData_(DropNone),
52 moduleLabel_(pset.getParameter<std::string>(
"@module_label")),
53 initializedFromInput_(
false),
57 numberOfDigitsInIndex_(0U),
58 overrideInputFileSplitLevels_(pset.getUntrackedParameter<bool>(
"overrideInputFileSplitLevels")),
63 std::ostringstream statusfilename;
76 << dropMetaData <<
".\n"
77 <<
"Legal values are 'NONE', 'DROPPED', 'PRIOR', and 'ALL'.\n";
94 for(Selections::const_iterator it = keptVector.
begin(), itEnd = keptVector.
end(); it != itEnd; ++it) {
110 branchDescription_(0),
116 branchDescription_(bd),
125 TObjArray* branches = tree->GetListOfBranches();
126 for(
int i = 0;
i < branches->GetEntries(); ++
i) {
127 TBranchElement*
br = (TBranchElement*)branches->At(
i);
128 treeMap_->insert(std::make_pair(std::string(br->GetName()),
i));
137 if(treeMap_->empty())
return lh < rh;
140 std::map<std::string, int>::const_iterator lit = treeMap_->find(lstring);
141 std::map<std::string, int>::const_iterator rit = treeMap_->find(rstring);
142 bool lfound = (lit != treeMap_->end());
143 bool rfound = (rit != treeMap_->end());
144 if(lfound && rfound) {
145 return lit->second < rit->second;
173 for(Selections::const_iterator it = keptVector.
begin(), itEnd = keptVector.
end(); it != itEnd; ++it) {
181 splitLevel = theBranch->GetSplitLevel();
182 basketSize = theBranch->GetBasketSize();
187 outputItemList.emplace_back(&prod, splitLevel, basketSize);
212 TTree* theInputTree = (branchType ==
InEvent ? fb.
tree() :
229 while (iNumberOfChildren != 0) {
231 iNumberOfChildren /= 10;
245 statusFile << e.
id() <<
" time: " << std::setprecision(3) <<
TimeOfDay() <<
'\n';
259 reportSvc->reportRunNumber(r.
run());
283 <<
"Attempt to open output file before input file. "
284 <<
"Please report this to the core framework developers.\n";
286 std::string
suffix(
".root");
288 bool ext = (offset ==
fileName().size() - suffix.size());
289 if(!ext) suffix.clear();
291 std::ostringstream ofilename;
292 std::ostringstream lfilename;
293 ofilename << fileBase;
314 std::string defaultString;
316 desc.
setComment(
"Writes runs, lumis, and events into EDM/ROOT files.");
318 ->setComment(
"Name of output file.");
319 desc.
addUntracked<std::string>(
"logicalFileName", defaultString)
320 ->setComment(
"Passed to job report. Otherwise unused by module.");
321 desc.
addUntracked<std::string>(
"catalog", defaultString)
322 ->setComment(
"Passed to job report. Otherwise unused by module.");
324 ->setComment(
"Maximum output file size, in kB.\n"
325 "If over maximum, new output file will be started at next input file transition.");
327 ->setComment(
"ROOT compression level of output file.");
328 #if ROOT_VERSION_CODE >= ROOT_VERSION(5,30,0)
329 desc.
addUntracked<std::string>(
"compressionAlgorithm",
"ZLIB")
330 ->setComment(
"Algorithm used to compress data in the ROOT output file, allowed values are ZLIB and LZMA");
333 ->setComment(
"Default ROOT basket size in output file.");
334 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.");
336 ->setComment(
"Default ROOT branch split level in output file.");
337 desc.
addUntracked<std::string>(
"sortBaskets", std::string(
"sortbasketsbyoffset"))
338 ->setComment(
"Legal values: 'sortbasketsbyoffset', 'sortbasketsbybranch', 'sortbasketsbyentry'.\n"
339 "Used by ROOT when fast copying. Affects performance.");
341 ->setComment(
"Size of ROOT TTree TBasket cache. Affects performance.");
343 ->setComment(
"True: Allow fast copying, if possible.\n"
344 "False: Disable fast copying.");
345 desc.
addUntracked<
bool>(
"overrideInputFileSplitLevels",
false)
346 ->setComment(
"False: Use branch split levels and basket sizes from input file, if possible.\n"
347 "True: Always use specified or default split levels and basket sizes.");
349 ->setComment(
"Write a status file. Intended for use by workflow management.");
350 desc.
addUntracked<std::string>(
"dropMetaData", defaultString)
351 ->setComment(
"Determines handling of per product per event metadata. Options are:\n"
352 "'NONE': Keep all of it.\n"
353 "'DROPPED': Keep it for products produced in current process and all kept products. Drop it for dropped products produced in prior processes.\n"
354 "'PRIOR': Keep it for products produced in current process. Drop it for products produced in prior processes.\n"
355 "'ALL': Drop all of it.");
359 ->setComment(
"PSet is only used by Data Operations and not by this module.");
363 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_
perl if(1 lt scalar(@::datatypes))
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