|
|
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";
153 BranchType branchType = static_cast<BranchType>(
i);
155 for (
auto&
item :
om_->selectedOutputItemList()[branchType]) {
156 item.setProduct(
nullptr);
163 item.branchDescription()->produced());
180 std::vector<std::string> branchNames;
181 std::vector<BranchDescription const*> branches;
182 branchNames.reserve(
om_->selectedOutputItemList()[
InEvent].size());
185 branchNames.push_back(
item.branchDescription()->branchName());
186 branches.push_back(
item.branchDescription());
189 sort_all(branches, sorterForJobReportHash);
191 std::ostringstream oss;
192 char const underscore =
'_';
193 for (
auto const&
branch : branches) {
195 oss <<
bd.fullClassName() << underscore <<
bd.moduleLabel() << underscore <<
bd.productInstanceName()
196 << underscore <<
bd.processName() << underscore;
217 void maybeIssueWarning(
int whyNotFastClonable,
std::string const& ifileName,
std::string const& ofileName) {
227 bool isWarning =
true;
228 std::ostringstream message;
229 message <<
"Fast copying of file " << ifileName <<
" to file " << ofileName <<
" is disabled because:\n";
231 message <<
"a SecondaryFileSequence was specified.\n";
236 message <<
"the input file is in an old format.\n";
241 message <<
"events need to be sorted.\n";
245 message <<
"a run or a lumi is not contiguous in the input file.\n";
249 message <<
"events or lumis were selected or skipped by ID.\n";
254 message <<
"initial events, lumis or runs were skipped.\n";
259 message <<
"some events were skipped because of duplicate checking.\n";
263 message <<
"some events were not copied because of maxEvents limit.\n";
268 message <<
"some events were not copied because of maxLumis limit.\n";
273 message <<
"parallel processing was specified.\n";
278 message <<
"an EventSelector was specified.\n";
283 message <<
"some events were not copied because of maxEvents output limit.\n";
288 message <<
"the split level or basket size of a branch or branches was modified.\n";
292 message <<
"The format of a data product has changed.\n";
297 LogWarning(
"FastCloningDisabled") << message.str();
299 LogInfo(
"FastCloningDisabled") << message.str();
309 if (
fb.tree() !=
nullptr) {
312 if (remainingEvents >= 0 && remainingEvents <
fb.tree()->GetEntries()) {
318 if (
om_->overrideInputFileSplitLevels()) {
329 <<
"Merge failure because input file " <<
file_ <<
" has different ROOT split levels or basket sizes\n"
330 <<
"than previous files. To allow merging in splite of this, use the configuration parameter\n"
331 <<
"overrideInputFileSplitLevels=cms.untracked.bool(True)\n"
332 <<
"in every PoolOutputModule.\n";
391 unsigned int const oneK = 1024;
393 return (
size >=
om_->maxFileSize());
412 if (reg->anyProductProduced() || !
om_->wantAllEvents()) {
413 esids.push_back(
om_->selectorConfig());
441 reportSvc->eventWrittenToFile(
reportToken_,
e.id().run(),
e.id().event());
497 orderedIDs[parentageID.second] = parentageID.first;
500 for (
auto const& orderedID : orderedIDs) {
528 ex <<
"The number of entries in at least one output TBranch whose entries\n"
529 "were copied from the input does not match the number of events\n"
530 "recorded in IndexIntoFile. This might (or might not) indicate a\n"
531 "problem related to fast copy.";
532 ex.
addContext(
"Calling RootOutputFile::writeIndexIntoFile");
579 ProductList& pList = const_cast<ProductList&>(pReg.productList());
580 for (
auto const&
prod : pList) {
581 if (
prod.second.branchID() !=
prod.second.originalBranchID()) {
588 for (ProductList::iterator it = pList.begin(); it != pList.end();) {
591 ProductList::iterator itCopy = it;
625 BranchType branchType = static_cast<BranchType>(
i);
634 treePointer->close();
635 treePointer =
nullptr;
646 if (
tree &&
tree->GetNbranches() != 0) {
665 std::set<BranchID>
const& iProducedIDs,
666 std::set<StoredProductProvenance>& oToFill) {
672 for (
auto const& parentID : parentIDs) {
677 (iProducedIDs.end() != iProducedIDs.find(
info->branchID()))) {
691 std::vector<std::unique_ptr<WrapperBase> > dummies;
695 bool const doProvenance =
700 std::set<StoredProductProvenance> provenanceToKeep;
706 std::set<BranchID> producedBranches;
709 for (
auto bd : preg->allBranchDescriptions()) {
710 if (
bd->produced() &&
bd->branchType() ==
InEvent) {
711 producedBranches.insert(
bd->branchID());
718 BranchID const&
id =
item.branchDescription()->branchID();
721 bool produced =
item.branchDescription()->produced();
724 bool keepProvenance = doProvenance && (produced || keepProvenanceForPrior);
730 product =
result.wrapper();
731 if (
result.isValid() && keepProvenance) {
732 productProvenance =
result.provenance()->productProvenance();
734 if (product ==
nullptr) {
737 TClass*
cp =
item.branchDescription()->wrappedType().getClass();
742 product =
dummy.get();
745 item.setProduct(product);
747 if (keepProvenance && productProvenance ==
nullptr) {
750 if (productProvenance) {
752 insertAncestors(*productProvenance, provRetriever, produced, producedBranches, provenanceToKeep);
757 productProvenanceVecPtr->assign(provenanceToKeep.begin(), provenanceToKeep.end());
760 productProvenanceVecPtr->clear();
764 std::set<edm::StoredProductProvenance>& oToInsert) {
767 std::set<edm::StoredProductProvenance>::iterator itFound = oToInsert.find(toStore);
768 if (itFound == oToInsert.end()) {
770 std::pair<std::map<edm::ParentageID, unsigned int>::iterator,
bool>
i =
775 <<
"RootOutputFile::insertProductProvenance\n"
777 <<
" is out of bounds. The maximum value is currently " <<
parentageIDs_.size() - 1 <<
".\n"
778 <<
"This should never happen.\n"
779 <<
"Please report this to the framework hypernews forum 'hn-cms-edmFramework@cern.ch'.\n";
782 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_
std::string const & indexIntoFileBranchName()
IndexIntoFile::EntryNumber_t lumiEntryNumber_
std::exception_ptr getException()
void writeThinnedAssociationsHelper()
static void writeTTree(TTree *tree)
std::string const & branchListIndexesBranchName()
void writeBranchIDListRegistry()
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_
element_type const * get() const
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)
std::string const & wrappedName() const
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
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()
std::string createGlobalIdentifier()
int eventAutoFlushSize() const