Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-05-21 03:38:51

0001 import FWCore.ParameterSet.Config as cms
0002 
0003 import sys
0004 enableTest2 = (sys.argv[-1] != "disableTest2")
0005 class SwitchProducerTest(cms.SwitchProducer):
0006     def __init__(self, **kargs):
0007         super(SwitchProducerTest,self).__init__(
0008             dict(
0009                 test1 = lambda accelerators: (True, -10),
0010                 test2 = lambda accelerators: (enableTest2, -9)
0011             ), **kargs)
0012 
0013 process = cms.Process("PROD1")
0014 
0015 process.source = cms.Source("EmptySource")
0016 if enableTest2:
0017     process.source.firstLuminosityBlock = cms.untracked.uint32(2)
0018 
0019 process.maxEvents.input = 3
0020 
0021 process.intProducer1 = cms.EDProducer("ManyIntProducer", ivalue = cms.int32(1))
0022 process.intProducer2 = cms.EDProducer("ManyIntProducer", ivalue = cms.int32(2), values = cms.VPSet(cms.PSet(instance=cms.string("foo"),value=cms.int32(2))))
0023 if enableTest2:
0024     process.intProducer1.throw = cms.untracked.bool(True)
0025 else:
0026     process.intProducer2.throw = cms.untracked.bool(True)
0027 
0028 process.intProducerAlias = SwitchProducerTest(
0029     test1 = cms.EDProducer("AddIntsProducer", labels = cms.VInputTag("intProducer1")),
0030     test2 = cms.EDAlias(intProducer2 = cms.VPSet(cms.PSet(type = cms.string("edmtestIntProduct"), fromProductInstance = cms.string(""), toProductInstance = cms.string("")),
0031                                                  cms.PSet(type = cms.string("edmtestIntProduct"), fromProductInstance = cms.string("foo"), toProductInstance = cms.string("other"))))
0032 )
0033 process.intProducerAliasConsumer = cms.EDProducer("AddIntsProducer", labels = cms.VInputTag("intProducerAlias"))
0034 
0035 # Test that direct dependence on SwitchProducer case-EDAlias within
0036 # the same ConditionalTask does not cause the aliased-for EDProducer
0037 # (in the same ConditionalTask) to become unscheduled, also when the
0038 # consumption is registered within callWhenNewProductsRegistered().
0039 # Note that neither case of intProducerAlias gets run by the Paths in
0040 # this test.
0041 process.rejectingFilter = cms.EDFilter("TestFilterModule",
0042     acceptValue = cms.untracked.int32(-1)
0043 )
0044 process.allCaseGenericConsumer = cms.EDAnalyzer("GenericConsumer", eventProducts = cms.untracked.vstring(
0045     "intProducerAlias@test1",
0046     "intProducerAlias@test2"
0047 ))
0048 process.test1Consumer = cms.EDAnalyzer("edmtest::GenericIntsAnalyzer", srcEvent = cms.untracked.VInputTag("intProducerAlias@test1"))
0049 process.test2Consumer = cms.EDAnalyzer("edmtest::GenericIntsAnalyzer", srcEvent = cms.untracked.VInputTag("intProducerAlias@test2"))
0050 if enableTest2:
0051     process.test1Consumer.inputShouldBeMissing = cms.untracked.bool(True)
0052     process.test2Consumer.inputShouldExist = cms.untracked.bool(True)
0053 else:
0054     process.test1Consumer.inputShouldExist = cms.untracked.bool(True)
0055     process.test2Consumer.inputShouldBeMissing = cms.untracked.bool(True)
0056 
0057 process.ct = cms.ConditionalTask(process.intProducerAlias, process.intProducer1, process.intProducer2)
0058 
0059 # This path causes the chosen case of intProducerAlias to run
0060 process.p1 = cms.Path(process.intProducerAliasConsumer, process.ct)
0061 
0062 # This path makes the ConditionalTask system to think that all cases
0063 # of intProducerAlias would be run, but they are not run as part of
0064 # this Path because their consumer is behind an EDFilter that rejects
0065 # all events
0066 process.p2 = cms.Path(process.rejectingFilter + process.allCaseGenericConsumer, process.ct)
0067 
0068 # This path tests that only the chosen case of intProducerAlias was run
0069 process.p3 = cms.Path(process.test1Consumer + process.test2Consumer)