1 from Mixins
import _ConfigureComponent, saveOrigin
2 from Mixins
import _Unlabelable, _Labelable
3 from Mixins
import _TypedParameterizable, _Parameterizable, PrintOptions
4 from SequenceTypes
import _SequenceLeaf
5 from Types
import vstring
7 from ExceptionHandling
import *
10 super(Service,self).
__init__(type_,*arg,**kargs)
14 proc._placeService(self.
type_(),self)
16 newpset = processDesc.newPSet()
17 newpset.addString(
True,
"@service_type", self.
type_())
19 processDesc.addService(newpset)
21 return "process." + self.
type_()
31 super(ESSource,self).
__init__(type_,*arg,**kargs)
36 proc._placeESSource(name,self)
39 if self.
type_() == myname:
52 super(ESProducer,self).
__init__(type_,*arg,**kargs)
56 proc._placeESProducer(name,self)
59 if self.
type_() == myname:
71 """Used to set which EventSetup provider should provide a particular data item 72 in the case where multiple providers are capable of delivering the data. 73 The first argument specifies the C++ class type of the prodiver. 74 If the provider has been given a label, you must specify that label as the second argument. 75 Additional 'vstring' arguments maybe used to specify exactly which EventSetup Records 76 are being preferred and optionally which data items within that Record. 78 #prefer all data in record 'OrangeRecord' from 'juicer' 79 ESPrefer("ESJuicerProd", OrangeRecord=cms.vstring()) 81 #prefer only "Orange" data in "OrangeRecord" from "juicer" 82 ESPrefer("ESJuicerProd", OrangeRecord=cms.vstring("ExtraPulp")) 84 #prefer only "Orange" data with label "ExtraPulp" in "OrangeRecord" from "juicer" 85 ESPrefer("ESJuicerProd", OrangeRecord=cms.vstring("Orange/ExtraPulp")) 87 def __init__(self,type_,targetLabel='',*arg,**kargs):
88 super(ESPrefer,self).
__init__(type_,*arg,**kargs)
90 if targetLabel
is None:
93 for k,v
in kargs.iteritems():
94 if not isinstance(v,vstring):
95 raise RuntimeError(
'ESPrefer only allows vstring attributes. "'+k+
'" is a '+
str(type(v)))
97 proc._placeESPrefer(name,self)
102 returnValue = ESPrefer.__new__(type(self))
110 result = options.indentation()
113 basename = self.
type_()
116 result +=
'process.prefer("'+basename+
'"' 118 result +=
",\n"+_Parameterizable.dumpPython(self,options)+options.indentation()
122 result +=
'es_prefer_'+basename+
' = cms.ESPrefer("'+self.
type_()+
'"' 126 result +=
",\n"+_Parameterizable.dumpPython(self,options)+options.indentation()
131 """base class for classes which denote framework event based 'modules'""" 134 super(_Module,self).
__init__(type_,*arg,**kargs)
135 if _Module.__isStrict__:
140 return lookuptable[
id(self)]
146 return "%s('%s', ...)" %(typename, self.type_())
149 self.__dict__[
"libraries_"] = libs
152 if "libraries_" in self.__dict__:
153 from ctypes
import LibraryLoader, CDLL
155 loader = LibraryLoader(CDLL)
156 ext = platform.uname()[0] ==
"Darwin" and "dylib" or "so" 157 [loader.LoadLibrary(
"lib%s.%s" % (l, ext))
for l
in self.libraries_]
158 super(_Module,self).
insertInto(parameterSet,myname)
162 super(EDProducer,self).
__init__(type_,*arg,**kargs)
164 proc._placeProducer(name,self)
170 super(EDFilter,self).
__init__(type_,*arg,**kargs)
172 proc._placeFilter(name,self)
178 super(EDAnalyzer,self).
__init__(type_,*arg,**kargs)
180 proc._placeAnalyzer(name,self)
185 super(OutputModule,self).
__init__(type_,*arg,**kargs)
187 proc._placeOutputModule(name,self)
192 super(Source,self).
__init__(type_,*arg,**kargs)
194 proc._placeSource(name,self)
203 super(Looper,self).
__init__(type_,*arg,**kargs)
205 proc._placeLooper(name,self)
207 return "@main_looper" 209 return "@main_looper" 213 if __name__ ==
"__main__":
216 from SequenceTypes
import *
221 self.assertEqual(withParam.foo.value(), 1)
222 self.assertEqual(withParam.bar.value(),
"it")
223 aCopy = withParam.copy()
224 self.assertEqual(aCopy.foo.value(), 1)
225 self.assertEqual(aCopy.bar.value(),
"it")
227 self.assertEqual(withType.type.value(),1)
230 self.assertEqual(9, m.i.value())
231 self.assertEqual(10, m.j.value())
236 self.assertEqual(juicer.dumpPythonAs(
"juicer", options),
"process.prefer(\"JuiceProducer\")\n")
237 options.isCfg =
False 238 self.assertEqual(juicer.dumpPythonAs(
"juicer", options),
"es_prefer_JuiceProducer = cms.ESPrefer(\"JuiceProducer\")\n")
240 juicer =
ESPrefer(
"JuiceProducer",
"juicer")
243 self.assertEqual(juicer.dumpPythonAs(
"juicer", options),
'process.prefer("juicer")\n')
244 options.isCfg =
False 245 self.assertEqual(juicer.dumpPythonAs(
"juicer", options),
'es_prefer_juicer = cms.ESPrefer("JuiceProducer","juicer")\n')
247 self.assertEqual(juicer.dumpConfig(options),
256 self.assertEqual(juicer.dumpPythonAs(
"juicer"),
257 """process.prefer("JuiceProducer", 258 fooRcd = cms.vstring() 261 options.isCfg =
False 262 self.assertEqual(juicer.dumpPythonAs(
"juicer", options),
263 """es_prefer_JuiceProducer = cms.ESPrefer("JuiceProducer", 264 fooRcd = cms.vstring() 270 withParam =
Service(
"Parameterized",foo=untracked(
int32(1)), bar = untracked(
string(
"it")))
271 self.assertEqual(withParam.foo.value(), 1)
272 self.assertEqual(withParam.bar.value(),
"it")
273 self.assertEqual(empty.dumpPython(),
"cms.Service(\"Empty\")\n")
274 self.assertEqual(withParam.dumpPython(),
"cms.Service(\"Parameterized\",\n bar = cms.untracked.string(\'it\'),\n foo = cms.untracked.int32(1)\n)\n")
285 self.assertTrue(m._isTaskComponent())
286 self.assertTrue(m.isLeaf())
288 self.assertTrue(m._isTaskComponent())
289 self.assertTrue(m.isLeaf())
291 self.assertFalse(m._isTaskComponent())
292 self.assertTrue(m.isLeaf())
294 self.assertFalse(m._isTaskComponent())
295 self.assertTrue(m.isLeaf())
297 self.assertTrue(m._isTaskComponent())
298 self.assertTrue(m.isLeaf())
300 self.assertTrue(m._isTaskComponent())
301 self.assertTrue(m.isLeaf())
303 self.assertTrue(m._isTaskComponent())
304 self.assertTrue(m.isLeaf())
306 self.assertFalse(m._isTaskComponent())
307 self.assertFalse(m.isLeaf())
309 self.assertFalse(m._isTaskComponent())
311 self.assertFalse(m._isTaskComponent())
313 self.assertTrue(m._isTaskComponent())
314 self.assertFalse(m.isLeaf())
def _placeImpl(self, name, proc)
def moduleLabel_(self, myname)
def nameInProcessDesc_(self, myname)
def moduleLabel_(self, myname)
def _isTaskComponent(self)
def _placeImpl(self, name, proc)
def _isTaskComponent(self)
def _placeImpl(self, name, proc)
def nameInProcessDesc_(self, myname)
def _isTaskComponent(self)
def nameInProcessDesc_(self, myname)
def setPrerequisites(self, libs)
def __init__(self, type_, arg, kargs)
def testIsTaskComponent(self)
def moduleLabel_(self, myname)
def __init__(self, type_, targetLabel='', arg, kargs)
def format_typename(object)
def __init__(self, type_, arg, kargs)
def _clonesequence(self, lookuptable)
def insertInto(self, processDesc)
def __init__(self, type_, arg, kargs)
def __init__(self, type_, arg, kargs)
def _placeImpl(self, name, proc)
def __init__(self, type_, arg, kargs)
def moduleLabel_(self, myname)
def _placeImpl(self, name, proc)
def _isTaskComponent(self)
def _placeImpl(self, name, proc)
def nameInProcessDesc_(self, myname)
def saveOrigin(obj, level)
def moduleLabel_(self, myname)
def __init__(self, type_, arg, kargs)
def _placeImpl(self, name, proc)
def _isTaskComponent(self)
def _placeImpl(self, name, proc)
def _placeImpl(self, name, proc)
def parameterNames_(self)
def dumpPythonAs(self, label, options=PrintOptions())
def insertInto(self, parameterSet, myname)
def __init__(self, type_, arg, kargs)
def _placeImpl(self, name, proc)
def moduleLabel_(self, myname)
def __init__(self, type_, arg, kargs)
def nameInProcessDesc_(self, myname)
def dumpSequencePython(self, options=PrintOptions())
def __init__(self, type_, arg, kargs)
def insertContentsInto(self, parameterSet)
def __init__(self, type_, arg, kargs)