Skip to content

Commit

Permalink
Make duplicate branch check work properly with SwitchProducer that ha…
Browse files Browse the repository at this point in the history
…s EDAlias case

Earlier check worked only if the non-SwitchProducer branch was in the map earlier.
  • Loading branch information
makortel committed Nov 23, 2022
1 parent d1056c4 commit 3759817
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
10 changes: 3 additions & 7 deletions FWCore/Framework/src/ProductSelector.cc
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,10 @@ namespace edm {
<< "Please drop at least one of them.\n";
}
};
BranchID const& trueBranchID = desc.originalBranchID();
// In case of SwitchProducer, we have to check the aliased-for
// BranchID for the case that the chosen case is an EDAlias
BranchID const& trueBranchID = desc.isSwitchAlias() ? desc.switchAliasForBranchID() : desc.originalBranchID();
check(trueBranchID);
// In case of SwitchProducer, we have to check also the
// aliased-for BranchID for the case that the chosen case is an EDAlias
if (desc.isSwitchAlias()) {
check(desc.switchAliasForBranchID());
}

trueBranchIDToKeptBranchDesc.insert(std::make_pair(trueBranchID, &desc));
}
}
Expand Down
8 changes: 5 additions & 3 deletions FWCore/Integration/test/testSwitchProducerTask_cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,13 @@ def __init__(self, **kargs):
process.intProducer2 = cms.EDProducer("ManyIntProducer", ivalue = cms.int32(2))
process.intProducer3 = cms.EDProducer("ManyIntProducer", ivalue = cms.int32(2), values = cms.VPSet(cms.PSet(instance=cms.string("foo"),value=cms.int32(2))))
process.intProducer4 = cms.EDProducer("ManyIntProducer", ivalue = cms.int32(42), throw = cms.untracked.bool(True))
process.intProducer5 = cms.EDProducer("ManyIntProducer", ivalue = cms.int32(3), values = cms.VPSet(cms.PSet(instance=cms.string("foo"),value=cms.int32(3))))
if enableTest2:
process.intProducer1.throw = cms.untracked.bool(True)
else:
process.intProducer2.throw = cms.untracked.bool(True)
process.intProducer3.throw = cms.untracked.bool(True)
process.intProducer5.throw = cms.untracked.bool(True)

process.intProducer = SwitchProducerTest(
test1 = cms.EDProducer("AddIntsProducer", labels = cms.VInputTag("intProducer1")),
Expand All @@ -86,7 +88,7 @@ def __init__(self, **kargs):
process.intProducerAlias2 = SwitchProducerTest(
test1 = cms.EDProducer("AddIntsProducer", labels = cms.VInputTag("intProducer1")),
test2 = cms.EDAlias(intProducer4 = cms.VPSet(cms.PSet(type = cms.string("edmtestIntProduct"), fromProductInstance = cms.string(""), toProductInstance = cms.string(""))),
intProducer3 = cms.VPSet(cms.PSet(type = cms.string("edmtestIntProduct"), fromProductInstance = cms.string("foo"), toProductInstance = cms.string("other"))))
intProducer5 = cms.VPSet(cms.PSet(type = cms.string("edmtestIntProduct"), fromProductInstance = cms.string("foo"), toProductInstance = cms.string("other"))))
)

# Test multiple consumers of a SwitchProducer
Expand All @@ -96,12 +98,12 @@ def __init__(self, **kargs):

if args.conditionalTask:
process.ct = cms.ConditionalTask(process.intProducer, process.intProducerOther, process.intProducerAlias, process.intProducerAlias2,
process.intProducer1, process.intProducer2, process.intProducer3, process.intProducer4)
process.intProducer1, process.intProducer2, process.intProducer3, process.intProducer4, process.intProducer5)
process.p = cms.Path(process.intProducerDep1+process.intProducerDep2+process.intProducerDep3, process.ct)
else:
process.t = cms.Task(process.intProducer, process.intProducerOther, process.intProducerAlias, process.intProducerAlias2,
process.intProducerDep1, process.intProducerDep2, process.intProducerDep3,
process.intProducer1, process.intProducer2, process.intProducer3, process.intProducer4)
process.intProducer1, process.intProducer2, process.intProducer3, process.intProducer4, process.intProducer5)
process.p = cms.Path(process.t)

process.e = cms.EndPath(process.out)

0 comments on commit 3759817

Please sign in to comment.