Skip to content

Commit d3c654e

Browse files
makortelDr15Jones
authored andcommitted
Read event provenance data promptly as well
1 parent 4836d96 commit d3c654e

File tree

3 files changed

+34
-7
lines changed

3 files changed

+34
-7
lines changed

FWCore/Framework/interface/ProductProvenanceRetriever.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,15 @@ namespace edm {
3232
ModuleCallingContext const* moduleCallingContext,
3333
unsigned int transitionIndex,
3434
std::atomic<const std::set<ProductProvenance>*>& writeTo) const noexcept = 0;
35+
36+
virtual void unsafe_fillProvenance(unsigned int transitionIndex) const;
3537
};
3638

3739
class ProductProvenanceRetriever : public ProductProvenanceLookup {
3840
public:
3941
explicit ProductProvenanceRetriever(unsigned int iTransitionIndex);
4042
ProductProvenanceRetriever(unsigned int iTransitionIndex, edm::ProductRegistry const&);
41-
explicit ProductProvenanceRetriever(std::unique_ptr<ProvenanceReaderBase> reader);
43+
explicit ProductProvenanceRetriever(unsigned int iTransitionIndex, std::unique_ptr<ProvenanceReaderBase> reader);
4244

4345
ProductProvenanceRetriever& operator=(ProductProvenanceRetriever const&) = delete;
4446

@@ -52,10 +54,13 @@ namespace edm {
5254

5355
void readProvenanceAsync(WaitingTaskHolder task, ModuleCallingContext const* moduleCallingContext) const noexcept;
5456

57+
// Used in prompt reading mode to fill the branch at the same time
58+
// when all event data is read
59+
void unsafe_fillProvenance();
60+
5561
private:
5662
std::unique_ptr<const std::set<ProductProvenance>> readProvenance() const final;
5763
const ProductProvenanceLookup* nextRetriever() const final { return nextRetriever_.get(); }
58-
void setTransitionIndex(unsigned int transitionIndex) { transitionIndex_ = transitionIndex; }
5964

6065
edm::propagate_const<std::shared_ptr<ProductProvenanceRetriever>> nextRetriever_;
6166
std::shared_ptr<const ProvenanceReaderBase> provenanceReader_;

FWCore/Framework/src/ProductProvenanceRetriever.cc

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,21 @@
1010
*/
1111

1212
namespace edm {
13+
void ProvenanceReaderBase::unsafe_fillProvenance(unsigned int transitionIndex) const {}
14+
1315
ProductProvenanceRetriever::ProductProvenanceRetriever(unsigned int iTransitionIndex)
1416
: ProductProvenanceLookup(), nextRetriever_(), provenanceReader_(), transitionIndex_(iTransitionIndex) {}
1517

1618
ProductProvenanceRetriever::ProductProvenanceRetriever(unsigned int iTransitionIndex,
1719
edm::ProductRegistry const& iReg)
1820
: ProductProvenanceLookup(iReg), nextRetriever_(), provenanceReader_(), transitionIndex_(iTransitionIndex) {}
1921

20-
ProductProvenanceRetriever::ProductProvenanceRetriever(std::unique_ptr<ProvenanceReaderBase> reader)
22+
ProductProvenanceRetriever::ProductProvenanceRetriever(unsigned int iTransitionIndex,
23+
std::unique_ptr<ProvenanceReaderBase> reader)
2124
: ProductProvenanceLookup(),
2225
nextRetriever_(),
2326
provenanceReader_(reader.release()),
24-
transitionIndex_(std::numeric_limits<unsigned int>::max()) {
27+
transitionIndex_(iTransitionIndex) {
2528
assert(provenanceReader_);
2629
}
2730

@@ -86,5 +89,9 @@ namespace edm {
8689
parentProcessRetriever_ = &provRetriever;
8790
}
8891

92+
void ProductProvenanceRetriever::unsafe_fillProvenance() {
93+
provenanceReader_->unsafe_fillProvenance(transitionIndex_);
94+
}
95+
8996
ProvenanceReaderBase::~ProvenanceReaderBase() {}
9097
} // namespace edm

IOPool/Input/src/RootFile.cc

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@
7070
#include <algorithm>
7171
#include <cassert>
7272
#include <list>
73+
#include <iostream>
7374

7475
namespace edm {
7576

@@ -1555,16 +1556,18 @@ namespace edm {
15551556

15561557
// We're not done ... so prepare the EventPrincipal
15571558
eventTree_.insertEntryForIndex(principal.transitionIndex());
1559+
auto provRetriever = makeProductProvenanceRetriever(principal.streamID().value());
15581560
if (readAllProducts) {
15591561
eventTree_.rootDelayedReader()->readAllProductsNow(&principal);
1562+
provRetriever->unsafe_fillProvenance();
15601563
}
15611564
auto history = processHistoryRegistry_->getMapped(evtAux.processHistoryID());
15621565
principal.fillEventPrincipal(evtAux,
15631566
history,
15641567
std::move(eventSelectionIDs),
15651568
std::move(branchListIndexes),
15661569
eventToProcessBlockIndexes_,
1567-
*(makeProductProvenanceRetriever(principal.streamID().value())),
1570+
*provRetriever,
15681571
eventTree_.resetAndGetRootDelayedReader());
15691572

15701573
// If this next assert shows up in performance profiling or significantly affects memory, then these three lines should be deleted.
@@ -2175,7 +2178,7 @@ namespace edm {
21752178
if (!eventProductProvenanceRetrievers_[iStreamID]) {
21762179
// propagate_const<T> has no reset() function
21772180
eventProductProvenanceRetrievers_[iStreamID] = std::make_shared<ProductProvenanceRetriever>(
2178-
provenanceReaderMaker_->makeReader(eventTree_, daqProvenanceHelper_.get()));
2181+
iStreamID, provenanceReaderMaker_->makeReader(eventTree_, daqProvenanceHelper_.get()));
21792182
}
21802183
eventProductProvenanceRetrievers_[iStreamID]->reset();
21812184
return eventProductProvenanceRetriever(iStreamID);
@@ -2189,6 +2192,8 @@ namespace edm {
21892192

21902193
std::set<ProductProvenance> readProvenance(unsigned int) const override;
21912194

2195+
void unsafe_fillProvenance(unsigned int) const override;
2196+
21922197
private:
21932198
void readProvenanceAsync(WaitingTaskHolder task,
21942199
ModuleCallingContext const* moduleCallingContext,
@@ -2294,8 +2299,15 @@ namespace edm {
22942299
rootTree_->rootDelayedReader()->postEventReadFromSourceSignal());
22952300
}
22962301

2302+
//
2303+
void ReducedProvenanceReader::unsafe_fillProvenance(unsigned int transitionIndex) const {
2304+
ReducedProvenanceReader* me = const_cast<ReducedProvenanceReader*>(this);
2305+
me->rootTree_->fillBranchEntry(
2306+
me->provBranch_, me->rootTree_->entryNumberForIndex(transitionIndex), me->pProvVector_);
2307+
}
2308+
22972309
std::set<ProductProvenance> ReducedProvenanceReader::readProvenance(unsigned int transitionIndex) const {
2298-
{
2310+
if (provVector_.empty()) {
22992311
std::lock_guard<std::recursive_mutex> guard(*mutex_);
23002312
ReducedProvenanceReader* me = const_cast<ReducedProvenanceReader*>(this);
23012313
me->rootTree_->fillBranchEntry(
@@ -2321,6 +2333,9 @@ namespace edm {
23212333
retValue.emplace(BranchID(prov.branchID_), parentageIDLookup_[prov.parentageIDIndex_]);
23222334
}
23232335
}
2336+
//The results of this call are cached by the caller
2337+
const_cast<ReducedProvenanceReader*>(this)->provVector_.clear();
2338+
23242339
return retValue;
23252340
}
23262341

0 commit comments

Comments
 (0)