@@ -1023,20 +1023,27 @@ namespace edm {
10231023 SendSourceTerminationSignalIfException sentry (actReg_.get ());
10241024
10251025 if (streamRunActive_ > 0 ) {
1026+ // deals with data structures that allows merged Run products to be split on Lumi boundaries then
1027+ // in later processes reintegrated.
10261028 streamRunStatus_[0 ]->runPrincipal ()->preReadFile ();
1027- streamRunStatus_[0 ]->runPrincipal ()->adjustIndexesAfterProductRegistryAddition ();
1028- }
1029-
1030- if (streamLumiActive_ > 0 ) {
1031- streamLumiStatus_[0 ]->lumiPrincipal ()->adjustIndexesAfterProductRegistryAddition ();
10321029 }
10331030
1031+ auto sizeBefore = input_->productRegistry ().size ();
10341032 fb_ = input_->readFile ();
10351033 // incase the input's registry changed
1036- const size_t size = preg_->size ();
1037- preg_->merge (input_->productRegistry (), fb_ ? fb_->fileName () : std::string ());
1038- if (size < preg_->size ()) {
1039- principalCache_.adjustIndexesAfterProductRegistryAddition ();
1034+ if (input_->productRegistry ().size () != sizeBefore) {
1035+ auto temp = std::make_shared<edm::ProductRegistry>(*preg_);
1036+ temp->merge (input_->productRegistry (), fb_ ? fb_->fileName () : std::string ());
1037+ preg_ = std::move (temp);
1038+ // This handles are presently unused Run/Lumis
1039+ principalCache_.adjustIndexesAfterProductRegistryAddition (edm::get_underlying_safe (preg_));
1040+ if (streamLumiActive_ > 0 ) {
1041+ // Can update the active ones now, even before an `end` transition is called because no OutputModule
1042+ // supports storing ProductDescriptions for Run/LuminosityBlock products which were dropped. Since only
1043+ // dropped products can change the ProductRegistry, only changes in Event can cause that.
1044+ streamRunStatus_[0 ]->runPrincipal ()->possiblyUpdateAfterAddition (edm::get_underlying_safe (preg_));
1045+ streamLumiStatus_[0 ]->lumiPrincipal ()->possiblyUpdateAfterAddition (edm::get_underlying_safe (preg_));
1046+ }
10401047 }
10411048 principalCache_.adjustEventsToNewProductRegistry (preg ());
10421049 if (preallocations_.numberOfStreams () > 1 and preallocations_.numberOfThreads () > 1 ) {
@@ -2022,6 +2029,7 @@ namespace edm {
20222029
20232030 std::shared_ptr<RunPrincipal> EventProcessor::readRun () {
20242031 auto rp = principalCache_.getAvailableRunPrincipalPtr ();
2032+ rp->possiblyUpdateAfterAddition (preg ());
20252033 assert (rp);
20262034 rp->setAux (*input_->runAuxiliary ());
20272035 {
@@ -2046,6 +2054,7 @@ namespace edm {
20462054
20472055 std::shared_ptr<LuminosityBlockPrincipal> EventProcessor::readLuminosityBlock (std::shared_ptr<RunPrincipal> rp) {
20482056 auto lbp = principalCache_.getAvailableLumiPrincipalPtr ();
2057+ lbp->possiblyUpdateAfterAddition (preg ());
20492058 assert (lbp);
20502059 lbp->setAux (*input_->luminosityBlockAuxiliary ());
20512060 {
0 commit comments