@@ -218,6 +218,17 @@ namespace edm {
218218 processingOrderMerge (processOrder, transient_.processOrder_ );
219219 }
220220
221+ void ProductRegistry::mergeProcessOrderFromAddInput (std::vector<std::string> const & processOrder) {
222+ if (processOrder.empty ())
223+ return ;
224+ // see if the input already has the current process
225+ if (not transient_.processOrder_ .empty () and (transient_.processOrder_ [0 ] != processOrder[0 ])) {
226+ transient_.processOrder_ .insert (transient_.processOrder_ .end (), processOrder.begin (), processOrder.end ());
227+ } else {
228+ updateProcessOrder (processOrder);
229+ }
230+ }
231+
221232 void ProductRegistry::setUnscheduledProducts (std::set<std::string> const & unscheduledLabels) {
222233 throwIfFrozen ();
223234
@@ -250,9 +261,20 @@ namespace edm {
250261 std::string ProductRegistry::merge (ProductRegistry const & other,
251262 std::string const & fileName,
252263 ProductDescription::MatchMode branchesMustMatch) {
253- if (branchesMustMatch == ProductDescription::FromInputToCurrent and transient_.processOrder_ .size () == 1 ) {
254- transient_.processOrder_ .insert (
255- transient_.processOrder_ .end (), other.transient_ .processOrder_ .begin (), other.transient_ .processOrder_ .end ());
264+ if (branchesMustMatch == ProductDescription::FromInputToCurrent) {
265+ if (processOrder ().size () == 1 and not other.processOrder ().empty () and
266+ processOrder ()[0 ] != other.processOrder ()[0 ]) {
267+ assert (transient_.processOrder_ .size () == 1 );
268+ transient_.processOrder_ .insert (transient_.processOrder_ .end (),
269+ other.transient_ .processOrder_ .begin (),
270+ other.transient_ .processOrder_ .end ());
271+ } else {
272+ // the current process must not change
273+ assert (not processOrder ().empty ());
274+ auto current = processOrder ()[0 ];
275+ processingOrderMerge (other.processOrder (), transient_.processOrder_ );
276+ assert (current == processOrder ()[0 ]);
277+ }
256278 } else {
257279 processingOrderMerge (other.processOrder (), transient_.processOrder_ );
258280 }
@@ -310,6 +332,7 @@ namespace edm {
310332 std::vector<std::string> producedTypes;
311333
312334 transient_.branchIDToIndex_ .clear ();
335+ assert (productList_.empty () or processOrder ().size () > 0 );
313336
314337 std::array<std::shared_ptr<ProductResolverIndexHelper>, NumBranchTypes> new_productLookups{
315338 {std::make_shared<ProductResolverIndexHelper>(),
@@ -452,7 +475,7 @@ namespace edm {
452475
453476 std::string_view processNameSV (processName ? std::string_view (*processName) : std::string_view ());
454477 for (auto & iterProductLookup : new_productLookups) {
455- iterProductLookup->setFrozen (processNameSV );
478+ iterProductLookup->setFrozen (processOrder () );
456479 }
457480 for (size_t i = 0 ; i < new_productLookups.size (); ++i) {
458481 transient_.productLookups_ [i] = std::move (new_productLookups[i]);
0 commit comments