Back to home page

Project CMSSW displayed by LXR

 
 

    


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

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("PROD2")
0014 
0015 # Test that having SwitchProducers with same labels as products from
0016 # earlier processes works
0017 process.source = cms.Source("PoolSource",
0018     fileNames = cms.untracked.vstring("file:testSwitchProducerTask%d.root" % (1 if enableTest2 else 2,))
0019 )
0020 
0021 process.maxEvents.input = -1
0022 
0023 process.out = cms.OutputModule("PoolOutputModule",
0024     fileName = cms.untracked.string('testSwitchProducerTaskInput%d.root' % (1 if enableTest2 else 2,)),
0025     outputCommands = cms.untracked.vstring(
0026         'keep *_intProducer_*_*',
0027         'keep *_intProducerOther_*_*',
0028         'keep *_intProducerAlias_*_*',
0029         'keep *_intProducerAlias2_other_*',
0030         'keep *_intProducerDep1_*_*',
0031         'keep *_intProducerDep2_*_*',
0032         'keep *_intProducerDep3_*_*',
0033     )
0034 )
0035 
0036 process.intProducer1 = cms.EDProducer("ManyIntProducer", ivalue = cms.int32(1))
0037 process.intProducer2 = cms.EDProducer("ManyIntProducer", ivalue = cms.int32(2))
0038 process.intProducer3 = cms.EDProducer("ManyIntProducer", ivalue = cms.int32(2), values = cms.VPSet(cms.PSet(instance=cms.string("foo"),value=cms.int32(2))))
0039 process.intProducer4 = cms.EDProducer("ManyIntProducer", ivalue = cms.int32(42), throw = cms.untracked.bool(True))
0040 if enableTest2:
0041     process.intProducer1.throw = cms.untracked.bool(True)
0042 else:
0043     process.intProducer2.throw = cms.untracked.bool(True)
0044     process.intProducer3.throw = cms.untracked.bool(True)
0045 
0046 process.intProducer = SwitchProducerTest(
0047     test1 = cms.EDProducer("AddIntsProducer", labels = cms.VInputTag("intProducer1")),
0048     test2 = cms.EDProducer("AddIntsProducer", labels = cms.VInputTag("intProducer2"))
0049 )
0050 # Test also existence of another SwitchProducer here
0051 process.intProducerOther = SwitchProducerTest(
0052     test1 = cms.EDProducer("AddIntsProducer", labels = cms.VInputTag("intProducer1")),
0053     test2 = cms.EDProducer("AddIntsProducer", labels = cms.VInputTag("intProducer2"))
0054 )
0055 # SwitchProducer with an alias
0056 process.intProducerAlias = SwitchProducerTest(
0057     test1 = cms.EDProducer("AddIntsProducer", labels = cms.VInputTag("intProducer1")),
0058     test2 = cms.EDAlias(intProducer3 = cms.VPSet(cms.PSet(type = cms.string("edmtestIntProduct"), fromProductInstance = cms.string(""), toProductInstance = cms.string("")),
0059                                                  cms.PSet(type = cms.string("edmtestIntProduct"), fromProductInstance = cms.string("foo"), toProductInstance = cms.string("other"))))
0060 )
0061 
0062 process.intProducerAlias2 = SwitchProducerTest(
0063     test1 = cms.EDProducer("AddIntsProducer", labels = cms.VInputTag("intProducer1")),
0064     test2 = cms.EDAlias(intProducer4 = cms.VPSet(cms.PSet(type = cms.string("edmtestIntProduct"), fromProductInstance = cms.string(""), toProductInstance = cms.string(""))),
0065                         intProducer3 = cms.VPSet(cms.PSet(type = cms.string("edmtestIntProduct"), fromProductInstance = cms.string("foo"), toProductInstance = cms.string("other"))))
0066 )
0067 
0068 # Test multiple consumers of a SwitchProducer
0069 process.intProducerDep1 = cms.EDProducer("AddIntsProducer", labels = cms.VInputTag("intProducer"))
0070 process.intProducerDep2 = cms.EDProducer("AddIntsProducer", labels = cms.VInputTag("intProducer"))
0071 process.intProducerDep3 = cms.EDProducer("AddIntsProducer", labels = cms.VInputTag("intProducer"))
0072 
0073 process.t = cms.Task(process.intProducer, process.intProducerOther, process.intProducerAlias, process.intProducerAlias2,
0074                      process.intProducerDep1, process.intProducerDep2, process.intProducerDep3,
0075                      process.intProducer1, process.intProducer2, process.intProducer3, process.intProducer4)
0076 process.p = cms.Path(process.t)
0077 
0078 process.e = cms.EndPath(process.out)