|
|
Go to the documentation of this file.
45 #include "Compression.h"
54 bool sorterForJobReportHash(BranchDescription
const*
lh, BranchDescription
const* rh) {
55 return lh->fullClassName() < rh->fullClassName()
57 :
lh->fullClassName() > rh->fullClassName()
59 :
lh->moduleLabel() < rh->moduleLabel()
61 :
lh->moduleLabel() > rh->moduleLabel()
63 :
lh->productInstanceName() < rh->productInstanceName()
65 :
lh->productInstanceName() > rh->productInstanceName()
67 :
lh->processName() < rh->processName() ?
true :
false;
73 if (
e != std::exception_ptr()) {
75 std::rethrow_exception(
e);
84 std::vector<std::string>
const& processesWithSelectedMergeableRunProducts)
86 logicalFile_(logicalFileName),
89 whyNotFastClonable_(om_->whyNotFastClonable()),
90 canFastCloneAux_(
false),
93 eventEntryNumber_(0
LL),
94 lumiEntryNumber_(0
LL),
97 storedMergeableRunProductMetadata_(processesWithSelectedMergeableRunProducts),
99 metaDataTree_(nullptr),
100 parameterSetsTree_(nullptr),
101 parentageTree_(nullptr),
105 pLumiAux_(&lumiAux_),
107 eventEntryInfoVector_(),
108 pEventEntryInfoVector_(&eventEntryInfoVector_),
109 pBranchListIndexes_(nullptr),
110 pEventSelectionIDs_(nullptr),
113 runTree_(filePtr(),
InRun, om_->
splitLevel(), om_->treeMaxVirtualSize()),
115 dataTypeReported_(
false),
116 processHistoryRegistry_(),
118 branchesWithStoredHistory_(),
119 wrapperBaseTClass_(TClass::GetClass(
"edm::WrapperBase")) {
121 filePtr_->SetCompressionAlgorithm(ROOT::kZLIB);
123 filePtr_->SetCompressionAlgorithm(ROOT::kLZMA);
126 <<
"PoolOutputModule configured with unknown compression algorithm '" <<
om_->compressionAlgorithm() <<
"'\n"
127 <<
"Allowed compression algorithms are ZLIB and LZMA\n";
132 if (
om_->compactEventAuxiliary()) {
166 BranchType branchType = static_cast<BranchType>(
i);
168 for (
auto&
item :
om_->selectedOutputItemList()[branchType]) {
169 item.setProduct(
nullptr);
176 item.branchDescription()->produced());
193 std::vector<std::string> branchNames;
194 std::vector<BranchDescription const*> branches;
195 branchNames.reserve(
om_->selectedOutputItemList()[
InEvent].size());
198 branchNames.push_back(
item.branchDescription()->branchName());
199 branches.push_back(
item.branchDescription());
202 sort_all(branches, sorterForJobReportHash);
204 std::ostringstream oss;
205 char const underscore =
'_';
206 for (
auto const&
branch : branches) {
208 oss <<
bd.fullClassName() << underscore <<
bd.moduleLabel() << underscore <<
bd.productInstanceName()
209 << underscore <<
bd.processName() << underscore;
230 void maybeIssueWarning(
int whyNotFastClonable,
std::string const& ifileName,
std::string const& ofileName) {
240 bool isWarning =
true;
241 std::ostringstream message;
242 message <<
"Fast copying of file " << ifileName <<
" to file " << ofileName <<
" is disabled because:\n";
244 message <<
"a SecondaryFileSequence was specified.\n";
249 message <<
"the input file is in an old format.\n";
254 message <<
"events need to be sorted.\n";
258 message <<
"a run or a lumi is not contiguous in the input file.\n";
262 message <<
"events or lumis were selected or skipped by ID.\n";
267 message <<
"initial events, lumis or runs were skipped.\n";
272 message <<
"some events were skipped because of duplicate checking.\n";
276 message <<
"some events were not copied because of maxEvents limit.\n";
281 message <<
"some events were not copied because of maxLumis limit.\n";
286 message <<
"parallel processing was specified.\n";
291 message <<
"an EventSelector was specified.\n";
296 message <<
"some events were not copied because of maxEvents output limit.\n";
301 message <<
"the split level or basket size of a branch or branches was modified.\n";
305 message <<
"The format of a data product has changed.\n";
310 LogWarning(
"FastCloningDisabled") << message.str();
312 LogInfo(
"FastCloningDisabled") << message.str();
322 if (
fb.tree() !=
nullptr) {
325 if (remainingEvents >= 0 && remainingEvents <
fb.tree()->GetEntries()) {
331 if (
om_->overrideInputFileSplitLevels()) {
342 <<
"Merge failure because input file " <<
file_ <<
" has different ROOT split levels or basket sizes\n"
343 <<
"than previous files. To allow merging in splite of this, use the configuration parameter\n"
344 <<
"overrideInputFileSplitLevels=cms.untracked.bool(True)\n"
345 <<
"in every PoolOutputModule.\n";
396 if (
om_->compactEventAuxiliary() &&
399 long long int reserve = remainingEvents;
400 if (
fb.tree() !=
nullptr) {
401 reserve = reserve > 0 ?
std::min(
fb.tree()->GetEntries(), reserve) :
fb.tree()->GetEntries();
411 if (not
om_->compactEventAuxiliary()) {
419 unsigned int const oneK = 1024;
421 return (
size >=
om_->maxFileSize());
440 if (reg->anyProductProduced() || !
om_->wantAllEvents()) {
441 esids.push_back(
om_->selectorConfig());
467 if (
om_->compactEventAuxiliary()) {
473 reportSvc->eventWrittenToFile(
reportToken_,
e.id().run(),
e.id().event());
529 orderedIDs[parentageID.second] = parentageID.first;
532 for (
auto const& orderedID : orderedIDs) {
560 ex <<
"The number of entries in at least one output TBranch whose entries\n"
561 "were copied from the input does not match the number of events\n"
562 "recorded in IndexIntoFile. This might (or might not) indicate a\n"
563 "problem related to fast copy.";
564 ex.
addContext(
"Calling RootOutputFile::writeIndexIntoFile");
611 ProductList& pList = const_cast<ProductList&>(pReg.productList());
612 for (
auto const&
prod : pList) {
613 if (
prod.second.branchID() !=
prod.second.originalBranchID()) {
620 for (ProductList::iterator it = pList.begin(); it != pList.end();) {
623 ProductList::iterator itCopy = it;
654 constexpr std::size_t maxEaBasketSize = 4 * 1024 * 1024;
656 if (
om_->compactEventAuxiliary()) {
660 tree->SetBranchStatus(bname,
true);
664 tree->SetBasketSize(bname, basketsize);
665 auto b =
tree->GetBranch(bname);
669 LogDebug(
"writeEventAuxiliary") <<
"EventAuxiliary ratio extras/GUIDs/all = "
674 const auto ea =
aux.eventAuxiliary();
698 BranchType branchType = static_cast<BranchType>(
i);
707 if (treePointer.get() ==
nullptr) {
711 treePointer->close();
712 treePointer =
nullptr;
723 if (
tree &&
tree->GetNbranches() != 0) {
742 std::set<BranchID>
const& iProducedIDs,
743 std::set<StoredProductProvenance>& oToFill) {
749 for (
auto const& parentID : parentIDs) {
754 (iProducedIDs.end() != iProducedIDs.find(
info->branchID()))) {
768 std::vector<std::unique_ptr<WrapperBase> > dummies;
772 bool const doProvenance =
777 std::set<StoredProductProvenance> provenanceToKeep;
783 std::set<BranchID> producedBranches;
786 for (
auto bd : preg->allBranchDescriptions()) {
787 if (
bd->produced() &&
bd->branchType() ==
InEvent) {
788 producedBranches.insert(
bd->branchID());
795 BranchID const&
id =
item.branchDescription()->branchID();
798 bool produced =
item.branchDescription()->produced();
801 bool keepProvenance = doProvenance && (produced || keepProvenanceForPrior);
807 product =
result.wrapper();
808 if (
result.isValid() && keepProvenance) {
809 productProvenance =
result.provenance()->productProvenance();
811 if (product ==
nullptr) {
814 TClass*
cp =
item.branchDescription()->wrappedType().getClass();
819 product =
dummy.get();
822 item.setProduct(product);
824 if (keepProvenance && productProvenance ==
nullptr) {
827 if (productProvenance) {
829 insertAncestors(*productProvenance, provRetriever, produced, producedBranches, provenanceToKeep);
834 productProvenanceVecPtr->assign(provenanceToKeep.begin(), provenanceToKeep.end());
837 productProvenanceVecPtr->clear();
841 std::set<edm::StoredProductProvenance>& oToInsert) {
844 std::set<edm::StoredProductProvenance>::iterator itFound = oToInsert.find(toStore);
845 if (itFound == oToInsert.end()) {
847 std::pair<std::map<edm::ParentageID, unsigned int>::iterator,
bool>
i =
852 <<
"RootOutputFile::insertProductProvenance\n"
854 <<
" is out of bounds. The maximum value is currently " <<
parentageIDs_.size() - 1 <<
".\n"
855 <<
"This should never happen.\n"
856 <<
"Please report this to the framework hypernews forum 'hn-cms-edmFramework@cern.ch'.\n";
859 oToInsert.insert(toStore);
std::vector< BranchID > const & parents() const
EventNumber_t event() const
bool shouldWeCloseFile() const
std::string const & branchIDListBranchName()
RootOutputFile(PoolOutputModule *om, std::string const &fileName, std::string const &logicalFileName, std::vector< std::string > const &processesWithSelectedMergeableRunProducts)
std::string const & productInstanceName() const
void optimizeBaskets(ULong64_t size)
bool registerProcessHistory(ProcessHistory const &processHistory)
void setBranchAliases(TTree *tree, SelectedProducts const &branches) const
std::string const & fileFormatVersionBranchName()
IndexIntoFile indexIntoFile_
RunAuxiliary const * pRunAux_
IndexIntoFile::EntryNumber_t runEntryNumber_
std::unique_ptr< WrapperBase > getWrapperBasePtr(void *p, int offset)
void addContext(std::string const &context)
std::map< ParentageID, unsigned int > parentageIDs_
void addEntry(ProcessHistoryID const &processHistoryID, RunNumber_t run, LuminosityBlockNumber_t lumi, EventNumber_t event, EntryNumber_t entry)
void sort_all(RandomAccessSequence &s)
wrappers for std::sort
std::string const & fid() const
void writeProductDescriptionRegistry()
void beginInputFile(FileBlock const &fb, int remainingEvents)
static ParentageRegistry * instance()
std::string moduleName(StableProvenance const &provenance, ProcessHistory const &history)
std::string const & parameterSetsTreeName()
OutputItemListArray const & selectedOutputItemList() const
std::vector< BranchListIndex > BranchListIndexes
RootOutputTreePtrArray treePointers_
constexpr element_type const * get() const
std::string const & indexIntoFileBranchName()
IndexIntoFile::EntryNumber_t lumiEntryNumber_
std::exception_ptr getException()
Log< level::Info, false > LogInfo
void writeThinnedAssociationsHelper()
static void writeTTree(TTree *tree)
std::string const & branchListIndexesBranchName()
void writeBranchIDListRegistry()
Log< level::Warning, false > LogWarning
std::string const & BranchTypeToAuxiliaryBranchName(BranchType const &branchType)
bool checkSplitLevelsAndBasketSizes(TTree *inputTree) const
std::vector< std::pair< BranchDescription const *, EDGetToken > > SelectedProducts
void fillBranches(BranchType const &branchType, OccurrenceForOutput const &occurrence, StoredProductProvenanceVector *productProvenanceVecPtr=nullptr, ProductProvenanceRetriever const *provRetriever=nullptr)
std::string const & mergeableRunProductMetadataBranchName()
LuminosityBlockAuxiliary const * pLumiAux_
edm::propagate_const< TTree * > metaDataTree_
std::string const & parentageBranchName()
unsigned long nEventsInLumi_
edm::propagate_const< StoredProductProvenanceVector * > pEventEntryInfoVector_
ProcessHistoryRegistry processHistoryRegistry_
edm::propagate_const< std::shared_ptr< TFile > > filePtr_
LuminosityBlockAuxiliary const & luminosityBlockAuxiliary() const
ProcessHistoryID const & processHistoryID() const
void maybeFastCloneTree(bool canFastClone, bool canFastCloneAux, TTree *tree, std::string const &option)
void setAutoFlush(Long64_t size)
void fillParameterSetBranch(TTree *parameterSetsTree, int basketSize)
void setException(std::exception_ptr e)
bool insertProductProvenance(const ProductProvenance &, std::set< StoredProductProvenance > &oToInsert)
void writeParameterSetRegistry()
BranchID const & branchID() const
std::set< BranchID > branchesWithStoredHistory_
PoolOutputModule::OutputItemList OutputItemList
bool checkIfFastClonable(TTree *inputTree) const
size_type guidsSize() const
CompactEventAuxiliaryVector compactEventAuxiliary_
edm::propagate_const< TClass * > wrapperBaseTClass_
virtual ProcessHistory const & processHistory() const
std::string const & parentageTreeName()
std::vector< BranchIDList > BranchIDLists
void insertAncestors(ProductProvenance const &iGetParents, ProductProvenanceRetriever const *iMapper, bool produced, std::set< BranchID > const &producedBranches, std::set< StoredProductProvenance > &oToFill)
BasicHandle getByToken(EDGetToken token, TypeID const &typeID) const
std::string const & eventSelectionsBranchName()
RootOutputTree eventTree_
void writeStoredMergeableRunProductMetadata()
static TTree * makeTTree(TFile *filePtr, std::string const &name, int splitLevel)
std::map< BranchKey, BranchDescription > ProductList
void writeEventAuxiliary()
int getFileFormatVersion()
size_type extrasSize() const
std::string const & productDescriptionBranchName()
BranchListIndexes const * pBranchListIndexes_
LuminosityBlockNumber_t luminosityBlock() const
bool getMapped(key_type const &k, value_type &result) const
void push_back(const EventAuxiliary &ea)
void writeLuminosityBlock(LuminosityBlockForOutput const &lb)
bool checkEntriesInReadBranches(Long64_t expectedNumberOfEntries) const
std::string createGlobalIdentifier(bool binary=false)
void writeRun(RunForOutput const &r)
edm::propagate_const< TTree * > parentageTree_
void writeOne(EventForOutput const &e)
LuminosityBlockNumber_t luminosityBlock() const
LuminosityBlockID const & id() const
JobReport::Token reportToken_
std::string const & branchName() const
ParentageID const & parentageID() const
ProcessHistoryID const & reducedProcessHistoryID(ProcessHistoryID const &fullID) const
TTree const * tree() const
std::string const & BranchTypeToProductProvenanceBranchName(BranchType const &BranchType)
void reserve(std::size_t size)
edm::propagate_const< PoolOutputModule * > om_
void writeFileFormatVersion()
std::string match(BranchDescription const &a, BranchDescription const &b, std::string const &fileName)
LuminosityBlockNumber_t luminosityBlock() const
IndexIntoFile::EntryNumber_t eventEntryNumber_
void writeFileIdentifier()
void setProcessHistoryID(ProcessHistoryID const &phid)
std::string const & moduleLabel() const
std::string const & metaDataTreeName()
ProcessHistoryID const & processHistoryID() const
void addAuxiliary(std::string const &branchName, T const *&pAux, int bufSize, bool allowCloning=true)
ProductProvenance const * branchIDToProvenance(BranchID const &bid) const
std::set< std::string > const & branchAliases() const
void fillProcessHistoryBranch(TTree *metaDataTree, int basketSize, ProcessHistoryRegistry const &processHistoryRegistry)
std::string const & thinnedAssociationsHelperBranchName()
Parentage const & parentage() const
void sortVector_Run_Or_Lumi_Entries()
void setProcessHistoryID(ProcessHistoryID const &phid)
std::string const & productDependenciesBranchName()
unsigned int parentageIDIndex_
void respondToCloseInputFile(FileBlock const &fb)
void writeProductDependencies()
std::string const & fileIdentifierBranchName()
EventAuxiliary const * pEventAux_
std::string toString() const
StoredProductProvenanceVector const * pEventEntryInfoVector() const
std::vector< EventSelectionID > EventSelectionIDVector
void addBranch(std::string const &branchName, std::string const &className, void const *&pProd, int splitLevel, int basketSize, bool produced)
LuminosityBlockAuxiliary lumiAux_
void writeParentageRegistry()
EventSelectionIDVector const * pEventSelectionIDs_
edm::propagate_const< TTree * > parameterSetsTree_
StoredMergeableRunProductMetadata storedMergeableRunProductMetadata_
void writeIndexIntoFile()
std::vector< StoredProductProvenance > StoredProductProvenanceVector
void writeProcessHistoryRegistry()
int eventAutoFlushSize() const