Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:12:43

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 = cms.untracked.PSet(
0020     input = cms.untracked.int32(3)
0021 )
0022 
0023 process.out = cms.OutputModule("PoolOutputModule",
0024     fileName = cms.untracked.string('testSwitchProducerPath%d.root' % (1 if enableTest2 else 2,)),
0025     outputCommands = cms.untracked.vstring(
0026         'keep *_intProducer_*_*',
0027         'keep *_intProducerAlias_*_*',
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 if enableTest2:
0038     process.intProducer1.throw = cms.untracked.bool(True)
0039 else:
0040     process.intProducer2.throw = cms.untracked.bool(True)
0041     process.intProducer3.throw = cms.untracked.bool(True)
0042 
0043 process.intProducer = SwitchProducerTest(
0044     test1 = cms.EDProducer("AddIntsProducer", labels = cms.VInputTag("intProducer1")),
0045     test2 = cms.EDProducer("AddIntsProducer", labels = cms.VInputTag("intProducer2"))
0046 )
0047 # SwitchProducer with an alias
0048 process.intProducerAlias = SwitchProducerTest(
0049     test1 = cms.EDProducer("AddIntsProducer", labels = cms.VInputTag("intProducer1")),
0050     test2 = cms.EDAlias(intProducer3 = cms.VPSet(cms.PSet(type = cms.string("edmtestIntProduct"), fromProductInstance = cms.string(""), toProductInstance = cms.string("")),
0051                                                  cms.PSet(type = cms.string("edmtestIntProduct"), fromProductInstance = cms.string("foo"), toProductInstance = cms.string("other"))))
0052 )
0053 
0054 # SwitchProducer of EDAlias in a Path causes alone is enough to trigger aliased-for EDProducers to be run
0055 if enableTest2:
0056     process.intProducer4 = cms.EDProducer("ManyIntProducer", ivalue = cms.int32(314), throw=cms.untracked.bool(True))
0057     process.intProducer6 = cms.EDProducer("edmtest::MustRunIntProducer", ivalue = cms.int32(4))
0058 else:
0059     process.intProducer4 = cms.EDProducer("edmtest::MustRunIntProducer", ivalue = cms.int32(314))
0060     process.intProducer6 = cms.EDProducer("ManyIntProducer", ivalue = cms.int32(4), throw=cms.untracked.bool(True))
0061 process.intProducer5 = process.intProducer4.clone(ivalue = 159)
0062 process.intProducer7 = process.intProducer6.clone(ivalue = 2)
0063 
0064 process.intProducerAlias2 = SwitchProducerTest(
0065     test1 = cms.EDAlias(intProducer4 = cms.VPSet(cms.PSet(type = cms.string("*"), fromProductInstance = cms.string(""), toProductInstance = cms.string(""))),
0066                         intProducer5 = cms.VPSet(cms.PSet(type = cms.string("*"), fromProductInstance = cms.string(""), toProductInstance = cms.string("other")))),
0067     test2 = cms.EDAlias(intProducer6 = cms.VPSet(cms.PSet(type = cms.string("*"), fromProductInstance = cms.string(""), toProductInstance = cms.string(""))),
0068                         intProducer7 = cms.VPSet(cms.PSet(type = cms.string("*"), fromProductInstance = cms.string(""), toProductInstance = cms.string("other"))))
0069 )
0070 
0071 
0072 # Test multiple consumers of a SwitchProducer
0073 process.intProducerDep1 = cms.EDProducer("AddIntsProducer", labels = cms.VInputTag("intProducer"))
0074 process.intProducerDep2 = cms.EDProducer("AddIntsProducer", labels = cms.VInputTag("intProducer"))
0075 process.intProducerDep3 = cms.EDProducer("AddIntsProducer", labels = cms.VInputTag("intProducer"))
0076 
0077 
0078 process.t = cms.Task(process.intProducer1, process.intProducer2, process.intProducer3,
0079                      process.intProducerDep1, process.intProducerDep2, process.intProducerDep3)
0080 process.p = cms.Path(process.intProducer + process.intProducerAlias, process.t)
0081 
0082 process.t2 = cms.Task(process.intProducer4, process.intProducer5, process.intProducer6, process.intProducer7)
0083 process.p2 = cms.Path(process.intProducerAlias2, process.t2)
0084 
0085 process.e = cms.EndPath(process.out)