Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-10-25 09:47:31

0001 import FWCore.ParameterSet.Config as cms
0002 import sys
0003 import argparse
0004 
0005 parser = argparse.ArgumentParser(prog=sys.argv[0], description="Test SwitchProducer, that has an EDAlias with '*' wildcard, in a ConditionalTask")
0006 
0007 parser.add_argument("--disableTest2", help="Disable 'test2' case of the SwitchProducerTest", action="store_true")
0008 parser.add_argument("--wildcardOnOtherModule", help="Use the wildcard for alias from another module", action="store_true")
0009 
0010 args = parser.parse_args()
0011 
0012 enableTest2 = not args.disableTest2
0013 class SwitchProducerTest(cms.SwitchProducer):
0014     def __init__(self, **kargs):
0015         super(SwitchProducerTest,self).__init__(
0016             dict(
0017                 test1 = lambda accelerators: (True, -10),
0018                 test2 = lambda accelerators: (enableTest2, -9)
0019             ), **kargs)
0020 
0021 process = cms.Process("PROD1")
0022 
0023 process.source = cms.Source("EmptySource")
0024 
0025 process.maxEvents.input = 3
0026 
0027 process.intProducer1 = cms.EDProducer(
0028     "ManyIntProducer",
0029     ivalue = cms.int32(1),
0030     values = cms.VPSet(
0031     )
0032 )
0033 process.intProducer2 = cms.EDProducer(
0034     "ManyIntProducer",
0035     ivalue = cms.int32(11),
0036     values = cms.VPSet(
0037         cms.PSet(instance=cms.string("bar"), value=cms.int32(12))
0038     )
0039 )
0040 process.intProducer3 = cms.EDProducer(
0041     "ManyIntProducer",
0042     ivalue = cms.int32(21)
0043 )
0044 if args.wildcardOnOtherModule:
0045     process.intProducer1.values.append(cms.PSet(instance=cms.string("bar"), value=cms.int32(2)))
0046     process.intProducer2.values = []
0047 
0048 process.intProducer4 = cms.EDProducer(
0049     "ManyIntProducer",
0050     ivalue = cms.int32(31),
0051     values = cms.VPSet(
0052         cms.PSet(instance=cms.string("foo"), value=cms.int32(32)),
0053         cms.PSet(instance=cms.string("bar"), value=cms.int32(33)),
0054         cms.PSet(instance=cms.string("xyzzy"), value=cms.int32(34)),
0055    )
0056 )
0057 
0058 process.intProducer = SwitchProducerTest(
0059     test1 = cms.EDAlias(
0060         intProducer4 = cms.EDAlias.allProducts()
0061     ),
0062     test2 = cms.EDAlias()
0063 )
0064 allMatchName = "intProducer1"
0065 otherName ="intProducer2"
0066 if args.wildcardOnOtherModule:
0067     (allMatchName, otherName) = (otherName, allMatchName)
0068 setattr(process.intProducer.test2, allMatchName, cms.EDAlias.allProducts())
0069 setattr(process.intProducer.test2, otherName, cms.VPSet(
0070     cms.PSet(type = cms.string("*"), fromProductInstance = cms.string(""), toProductInstance = cms.string("foo")),
0071     cms.PSet(type = cms.string("*"), fromProductInstance = cms.string("bar"), toProductInstance = cms.string("*"))
0072 ))
0073 process.intProducer.test2.intProducer3 = cms.VPSet(
0074     cms.PSet(type = cms.string("edmtestIntProduct"), toProductInstance = cms.string("xyzzy"))
0075 )
0076 
0077 process.intConsumer = cms.EDAnalyzer("edmtest::GenericIntsAnalyzer", srcEvent = cms.untracked.VInputTag("intProducer"))
0078 process.intConsumer2 = cms.EDAnalyzer("edmtest::GenericIntsAnalyzer", srcEvent = cms.untracked.VInputTag("intProducer", "intProducer2", "intProducer3"))
0079 
0080 process.ct = cms.ConditionalTask(process.intProducer1, process.intProducer2, process.intProducer3, process.intProducer4, process.intProducer)
0081 
0082 process.p1 = cms.Path(process.intConsumer, process.ct)
0083 process.p2 = cms.Path(process.intConsumer2, process.ct)