Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-04-20 23:56:38

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('testSwitchProducerConditionalTask%d.root' % (1 if enableTest2 else 2,)),
0023     outputCommands = cms.untracked.vstring(
0024         'keep *_intProducer_*_*',
0025         'keep *_intProducerOther_*_*',
0026         'keep *_intProducerAlias_*_*',
0027         'keep *_intProducerAlias2_other_*',
0028         'keep *_intProducerDep1_*_*',
0029         'keep *_intProducerDep2_*_*',
0030         'keep *_intProducerDep3_*_*',
0031     )
0032 )
0033 
0034 process.intProducer1 = cms.EDProducer("ManyIntProducer", ivalue = cms.int32(1))
0035 process.intProducer2 = cms.EDProducer("ManyIntProducer", ivalue = cms.int32(2))
0036 process.intProducer3 = cms.EDProducer("ManyIntProducer", ivalue = cms.int32(2), values = cms.VPSet(cms.PSet(instance=cms.string("foo"),value=cms.int32(2))))
0037 process.intProducer4 = cms.EDProducer("ManyIntProducer", ivalue = cms.int32(42), throw = cms.untracked.bool(True))
0038 if enableTest2:
0039     process.intProducer1.throw = cms.untracked.bool(True)
0040 else:
0041     process.intProducer2.throw = cms.untracked.bool(True)
0042     process.intProducer3.throw = cms.untracked.bool(True)
0043 
0044 process.intProducer = SwitchProducerTest(
0045     test1 = cms.EDProducer("AddIntsProducer", labels = cms.VInputTag("intProducer1")),
0046     test2 = cms.EDProducer("AddIntsProducer", labels = cms.VInputTag("intProducer2"))
0047 )
0048 # Test also existence of another SwitchProducer here
0049 process.intProducerOther = SwitchProducerTest(
0050     test1 = cms.EDProducer("AddIntsProducer", labels = cms.VInputTag("intProducer1")),
0051     test2 = cms.EDProducer("AddIntsProducer", labels = cms.VInputTag("intProducer2"))
0052 )
0053 # SwitchProducer with an alias
0054 process.intProducerAlias = SwitchProducerTest(
0055     test1 = cms.EDProducer("AddIntsProducer", labels = cms.VInputTag("intProducer1")),
0056     test2 = cms.EDAlias(intProducer3 = cms.VPSet(cms.PSet(type = cms.string("edmtestIntProduct"), fromProductInstance = cms.string(""), toProductInstance = cms.string("")),
0057                                                  cms.PSet(type = cms.string("edmtestIntProduct"), fromProductInstance = cms.string("foo"), toProductInstance = cms.string("other"))))
0058 )
0059 
0060 process.intProducerAlias2 = SwitchProducerTest(
0061     test1 = cms.EDProducer("AddIntsProducer", labels = cms.VInputTag("intProducer1")),
0062     test2 = cms.EDAlias(intProducer4 = cms.VPSet(cms.PSet(type = cms.string("edmtestIntProduct"), fromProductInstance = cms.string(""), toProductInstance = cms.string(""))),
0063                         intProducer3 = cms.VPSet(cms.PSet(type = cms.string("edmtestIntProduct"), fromProductInstance = cms.string("foo"), toProductInstance = cms.string("other"))))
0064 )
0065 
0066 # Test multiple consumers of a SwitchProducer
0067 process.intProducerDep1 = cms.EDProducer("AddIntsProducer", labels = cms.VInputTag("intProducer"))
0068 process.intProducerDep2 = cms.EDProducer("AddIntsProducer", labels = cms.VInputTag("intProducer"))
0069 process.intProducerDep3 = cms.EDProducer("AddIntsProducer", labels = cms.VInputTag("intProducer"))
0070 
0071 process.ct = cms.ConditionalTask(process.intProducer, process.intProducerOther, process.intProducerAlias, process.intProducerAlias2,
0072                                  process.intProducer1, process.intProducer2, process.intProducer3, process.intProducer4)
0073 process.p = cms.Path(process.intProducerDep1+process.intProducerDep2+process.intProducerDep3, process.ct)
0074 
0075 process.e = cms.EndPath(process.out)