|
|
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";
158 BranchType branchType = static_cast<BranchType>(
i);
160 for (
auto&
item :
om_->selectedOutputItemList()[branchType]) {
161 item.setProduct(
nullptr);
168 item.branchDescription()->produced());
185 std::vector<std::string> branchNames;
186 std::vector<BranchDescription const*> branches;
187 branchNames.reserve(
om_->selectedOutputItemList()[
InEvent].size());
190 branchNames.push_back(
item.branchDescription()->branchName());
191 branches.push_back(
item.branchDescription());
194 sort_all(branches, sorterForJobReportHash);
196 std::ostringstream oss;
197 char const underscore =
'_';
198 for (
auto const&
branch : branches) {
200 oss <<
bd.fullClassName() << underscore <<
bd.moduleLabel() << underscore <<
bd.productInstanceName()
201 << underscore <<
bd.processName() << underscore;
222 void maybeIssueWarning(
int whyNotFastClonable,
std::string const& ifileName,
std::string const& ofileName) {
232 bool isWarning =
true;
233 std::ostringstream message;
234 message <<
"Fast copying of file " << ifileName <<
" to file " << ofileName <<
" is disabled because:\n";
236 message <<
"a SecondaryFileSequence was specified.\n";
241 message <<
"the input file is in an old format.\n";
246 message <<
"events need to be sorted.\n";
250 message <<
"a run or a lumi is not contiguous in the input file.\n";
254 message <<
"events or lumis were selected or skipped by ID.\n";
259 message <<
"initial events, lumis or runs were skipped.\n";
264 message <<
"some events were skipped because of duplicate checking.\n";
268 message <<
"some events were not copied because of maxEvents limit.\n";
273 message <<
"some events were not copied because of maxLumis limit.\n";
278 message <<
"parallel processing was specified.\n";
283 message <<
"an EventSelector was specified.\n";
288 message <<
"some events were not copied because of maxEvents output limit.\n";
293 message <<
"the split level or basket size of a branch or branches was modified.\n";
297 message <<
"The format of a data product has changed.\n";
302 LogWarning(
"FastCloningDisabled") << message.str();
304 LogInfo(
"FastCloningDisabled") << message.str();
314 if (
fb.tree() !=
nullptr) {
317 if (remainingEvents >= 0 && remainingEvents <
fb.tree()->GetEntries()) {
323 if (
om_->overrideInputFileSplitLevels()) {
334 <<
"Merge failure because input file " <<
file_ <<
" has different ROOT split levels or basket sizes\n"
335 <<
"than previous files. To allow merging in splite of this, use the configuration parameter\n"
336 <<
"overrideInputFileSplitLevels=cms.untracked.bool(True)\n"
337 <<
"in every PoolOutputModule.\n";
396 unsigned int const oneK = 1024;
398 return (
size >=
om_->maxFileSize());
417 if (reg->anyProductProduced() || !
om_->wantAllEvents()) {
418 esids.push_back(
om_->selectorConfig());
446 reportSvc->eventWrittenToFile(
reportToken_,
e.id().run(),
e.id().event());
502 orderedIDs[parentageID.second] = parentageID.first;
505 for (
auto const& orderedID : orderedIDs) {
533 ex <<
"The number of entries in at least one output TBranch whose entries\n"
534 "were copied from the input does not match the number of events\n"
535 "recorded in IndexIntoFile. This might (or might not) indicate a\n"
536 "problem related to fast copy.";
537 ex.
addContext(
"Calling RootOutputFile::writeIndexIntoFile");
584 ProductList& pList = const_cast<ProductList&>(pReg.productList());
585 for (
auto const&
prod : pList) {
586 if (
prod.second.branchID() !=
prod.second.originalBranchID()) {
593 for (ProductList::iterator it = pList.begin(); it != pList.end();) {
596 ProductList::iterator itCopy = it;
634 BranchType branchType = static_cast<BranchType>(
i);
643 if (treePointer.get() ==
nullptr) {
647 treePointer->close();
648 treePointer =
nullptr;
659 if (
tree &&
tree->GetNbranches() != 0) {
678 std::set<BranchID>
const& iProducedIDs,
679 std::set<StoredProductProvenance>& oToFill) {
685 for (
auto const& parentID : parentIDs) {
690 (iProducedIDs.end() != iProducedIDs.find(
info->branchID()))) {
704 std::vector<std::unique_ptr<WrapperBase> > dummies;
708 bool const doProvenance =
713 std::set<StoredProductProvenance> provenanceToKeep;
719 std::set<BranchID> producedBranches;
722 for (
auto bd : preg->allBranchDescriptions()) {
723 if (
bd->produced() &&
bd->branchType() ==
InEvent) {
724 producedBranches.insert(
bd->branchID());
731 BranchID const&
id =
item.branchDescription()->branchID();
734 bool produced =
item.branchDescription()->produced();
737 bool keepProvenance = doProvenance && (produced || keepProvenanceForPrior);
743 product =
result.wrapper();
744 if (
result.isValid() && keepProvenance) {
745 productProvenance =
result.provenance()->productProvenance();
747 if (product ==
nullptr) {
750 TClass*
cp =
item.branchDescription()->wrappedType().getClass();
755 product =
dummy.get();
758 item.setProduct(product);
760 if (keepProvenance && productProvenance ==
nullptr) {
763 if (productProvenance) {
765 insertAncestors(*productProvenance, provRetriever, produced, producedBranches, provenanceToKeep);
770 productProvenanceVecPtr->assign(provenanceToKeep.begin(), provenanceToKeep.end());
773 productProvenanceVecPtr->clear();
777 std::set<edm::StoredProductProvenance>& oToInsert) {
780 std::set<edm::StoredProductProvenance>::iterator itFound = oToInsert.find(toStore);
781 if (itFound == oToInsert.end()) {
783 std::pair<std::map<edm::ParentageID, unsigned int>::iterator,
bool>
i =
788 <<
"RootOutputFile::insertProductProvenance\n"
790 <<
" is out of bounds. The maximum value is currently " <<
parentageIDs_.size() - 1 <<
".\n"
791 <<
"This should never happen.\n"
792 <<
"Please report this to the framework hypernews forum 'hn-cms-edmFramework@cern.ch'.\n";
795 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 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
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
int getFileFormatVersion()
std::string const & productDescriptionBranchName()
BranchListIndexes const * pBranchListIndexes_
LuminosityBlockNumber_t luminosityBlock() const
bool getMapped(key_type const &k, value_type &result) const
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
std::string const & BranchTypeToProductProvenanceBranchName(BranchType const &BranchType)
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()
std::string moduleName(Provenance const &provenance, ProcessHistory const &history)
EventAuxiliary const * pEventAux_
std::string toString() const
StoredProductProvenanceVector const * pEventEntryInfoVector() const
std::vector< EventSelectionID > EventSelectionIDVector
def cp(fromDir, toDir, listOfFiles, overwrite=False, smallList=False)
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