7070#include < algorithm>
7171#include < cassert>
7272#include < list>
73+ #include < iostream>
7374
7475namespace 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