File indexing completed on 2024-04-06 12:12:42
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.out = cms.OutputModule("PoolOutputModule",
0022 fileName = cms.untracked.string('testSwitchProducerConditionalTaskEDAlias%d.root' % (1 if enableTest2 else 2,)),
0023 outputCommands = cms.untracked.vstring(
0024 'keep *_intProducerAlias_*_*',
0025 'keep *_intProducerDep_*_*',
0026 'keep *_intProducerDepAliasDep_*_*',
0027 )
0028 )
0029
0030
0031 process.intProducer1 = cms.EDProducer("ManyIntProducer", ivalue = cms.int32(1))
0032 process.intProducer2 = cms.EDProducer("ManyIntProducer", ivalue = cms.int32(2), values = cms.VPSet(cms.PSet(instance=cms.string("foo"),value=cms.int32(2))))
0033 process.intProducer3 = cms.EDProducer("ManyIntProducer", ivalue = cms.int32(3))
0034 process.intProducer4 = cms.EDProducer("ManyIntProducer", ivalue = cms.int32(4))
0035 if enableTest2:
0036 process.intProducer1.throw = cms.untracked.bool(True)
0037 else:
0038 process.intProducer2.throw = cms.untracked.bool(True)
0039 process.intProducer3.throw = cms.untracked.bool(True)
0040 process.intProducer4.throw = cms.untracked.bool(True)
0041
0042
0043 process.intProducerAlias = SwitchProducerTest(
0044 test1 = cms.EDProducer("AddIntsProducer", labels = cms.VInputTag("intProducer1")),
0045 test2 = cms.EDAlias(intProducer2 = cms.VPSet(cms.PSet(type = cms.string("edmtestIntProduct"), fromProductInstance = cms.string(""), toProductInstance = cms.string("")),
0046 cms.PSet(type = cms.string("edmtestIntProduct"), fromProductInstance = cms.string("foo"), toProductInstance = cms.string("other"))))
0047 )
0048
0049
0050
0051
0052 process.intProducerDep = cms.EDProducer("AddIntsProducer", labels = cms.VInputTag("intProducer2"))
0053 if not enableTest2:
0054 process.intProducerDep.labels = ["intProducer1"]
0055
0056 process.intProducerDepAlias = SwitchProducerTest(
0057 test1 = cms.EDProducer("AddIntsProducer", labels = cms.VInputTag("intProducerDep", "intProducerAlias")),
0058 test2 = cms.EDAlias(intProducer3 = cms.VPSet(cms.PSet(type = cms.string("*"), fromProductInstance = cms.string(""), toProductInstance = cms.string(""))),
0059 intProducer4 = cms.VPSet(cms.PSet(type = cms.string("*"), fromProductInstance = cms.string(""), toProductInstance = cms.string("other"))))
0060 )
0061 process.intProducerDepAliasDep = cms.EDProducer("AddIntsProducer", labels = cms.VInputTag("intProducer3", "intProducer4"))
0062 if not enableTest2:
0063 process.intProducerDepAliasDep.labels = ["intProducerAlias"]
0064
0065 process.ct = cms.ConditionalTask(process.intProducer1, process.intProducer2, process.intProducer3, process.intProducer4)
0066 process.p = cms.Path(process.intProducerAlias+process.intProducerDep +
0067 process.intProducerDepAlias + process.intProducerDepAliasDep,
0068 process.ct)
0069
0070 process.ct2 = cms.ConditionalTask(process.intProducerAlias, process.intProducerDep, process.intProducerDepAlias, process.ct)
0071 process.p2 = cms.Path(process.intProducerDepAliasDep, process.ct2)
0072
0073 process.ep = cms.EndPath(process.out)