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
8 from ExceptionHandling
import *
11 super(Service,self).
__init__(type_,*arg,**kargs)
15 proc._placeService(self.
type_(),self)
17 newpset = processDesc.newPSet()
18 newpset.addString(
True,
"@service_type", self.
type_())
20 processDesc.addService(newpset)
22 return "process." + self.
type_()
32 super(ESSource,self).
__init__(type_,*arg,**kargs)
37 proc._placeESSource(name,self)
40 if self.
type_() == myname:
53 super(ESProducer,self).
__init__(type_,*arg,**kargs)
57 proc._placeESProducer(name,self)
60 if self.
type_() == myname:
72 """Used to set which EventSetup provider should provide a particular data item 73 in the case where multiple providers are capable of delivering the data. 74 The first argument specifies the C++ class type of the prodiver. 75 If the provider has been given a label, you must specify that label as the second argument. 76 Additional 'vstring' arguments maybe used to specify exactly which EventSetup Records 77 are being preferred and optionally which data items within that Record. 79 #prefer all data in record 'OrangeRecord' from 'juicer' 80 ESPrefer("ESJuicerProd", OrangeRecord=cms.vstring()) 82 #prefer only "Orange" data in "OrangeRecord" from "juicer" 83 ESPrefer("ESJuicerProd", OrangeRecord=cms.vstring("ExtraPulp")) 85 #prefer only "Orange" data with label "ExtraPulp" in "OrangeRecord" from "juicer" 86 ESPrefer("ESJuicerProd", OrangeRecord=cms.vstring("Orange/ExtraPulp")) 88 def __init__(self,type_,targetLabel='',*arg,**kargs):
89 super(ESPrefer,self).
__init__(type_,*arg,**kargs)
91 if targetLabel
is None:
94 for k,v
in six.iteritems(kargs):
95 if not isinstance(v,vstring):
96 raise RuntimeError(
'ESPrefer only allows vstring attributes. "'+k+
'" is a '+
str(type(v)))
98 proc._placeESPrefer(name,self)
103 returnValue = ESPrefer.__new__(type(self))
111 result = options.indentation()
114 basename = self.
type_()
117 result +=
'process.prefer("'+basename+
'"' 119 result +=
",\n"+_Parameterizable.dumpPython(self,options)+options.indentation()
123 result +=
'es_prefer_'+basename+
' = cms.ESPrefer("'+self.
type_()+
'"' 127 result +=
",\n"+_Parameterizable.dumpPython(self,options)+options.indentation()
132 """base class for classes which denote framework event based 'modules'""" 135 super(_Module,self).
__init__(type_,*arg,**kargs)
136 if _Module.__isStrict__:
141 return lookuptable[
id(self)]
147 return "%s('%s', ...)" %(typename, self.type_())
150 self.__dict__[
"libraries_"] = libs
153 if "libraries_" in self.__dict__:
154 from ctypes
import LibraryLoader, CDLL
156 loader = LibraryLoader(CDLL)
157 ext = platform.uname()[0] ==
"Darwin" and "dylib" or "so" 158 [loader.LoadLibrary(
"lib%s.%s" % (l, ext))
for l
in self.libraries_]
159 super(_Module,self).
insertInto(parameterSet,myname)
163 super(EDProducer,self).
__init__(type_,*arg,**kargs)
165 proc._placeProducer(name,self)
171 super(EDFilter,self).
__init__(type_,*arg,**kargs)
173 proc._placeFilter(name,self)
179 super(EDAnalyzer,self).
__init__(type_,*arg,**kargs)
181 proc._placeAnalyzer(name,self)
186 super(OutputModule,self).
__init__(type_,*arg,**kargs)
188 proc._placeOutputModule(name,self)
193 super(Source,self).
__init__(type_,*arg,**kargs)
195 proc._placeSource(name,self)
204 super(Looper,self).
__init__(type_,*arg,**kargs)
206 proc._placeLooper(name,self)
208 return "@main_looper" 210 return "@main_looper" 214 if __name__ ==
"__main__":
217 from SequenceTypes
import *
222 self.assertEqual(withParam.foo.value(), 1)
223 self.assertEqual(withParam.bar.value(),
"it")
224 aCopy = withParam.copy()
225 self.assertEqual(aCopy.foo.value(), 1)
226 self.assertEqual(aCopy.bar.value(),
"it")
228 self.assertEqual(withType.type.value(),1)
231 self.assertEqual(9, m.i.value())
232 self.assertEqual(10, m.j.value())
237 self.assertEqual(juicer.dumpPythonAs(
"juicer", options),
"process.prefer(\"JuiceProducer\")\n")
238 options.isCfg =
False 239 self.assertEqual(juicer.dumpPythonAs(
"juicer", options),
"es_prefer_JuiceProducer = cms.ESPrefer(\"JuiceProducer\")\n")
241 juicer =
ESPrefer(
"JuiceProducer",
"juicer")
244 self.assertEqual(juicer.dumpPythonAs(
"juicer", options),
'process.prefer("juicer")\n')
245 options.isCfg =
False 246 self.assertEqual(juicer.dumpPythonAs(
"juicer", options),
'es_prefer_juicer = cms.ESPrefer("JuiceProducer","juicer")\n')
248 self.assertEqual(juicer.dumpConfig(options),
257 self.assertEqual(juicer.dumpPythonAs(
"juicer"),
258 """process.prefer("JuiceProducer", 259 fooRcd = cms.vstring() 262 options.isCfg =
False 263 self.assertEqual(juicer.dumpPythonAs(
"juicer", options),
264 """es_prefer_JuiceProducer = cms.ESPrefer("JuiceProducer", 265 fooRcd = cms.vstring() 271 withParam =
Service(
"Parameterized",foo=untracked(
int32(1)), bar = untracked(
string(
"it")))
272 self.assertEqual(withParam.foo.value(), 1)
273 self.assertEqual(withParam.bar.value(),
"it")
274 self.assertEqual(empty.dumpPython(),
"cms.Service(\"Empty\")\n")
275 self.assertEqual(withParam.dumpPython(),
"cms.Service(\"Parameterized\",\n bar = cms.untracked.string(\'it\'),\n foo = cms.untracked.int32(1)\n)\n")
286 self.assertTrue(m._isTaskComponent())
287 self.assertTrue(m.isLeaf())
289 self.assertTrue(m._isTaskComponent())
290 self.assertTrue(m.isLeaf())
292 self.assertFalse(m._isTaskComponent())
293 self.assertTrue(m.isLeaf())
295 self.assertFalse(m._isTaskComponent())
296 self.assertTrue(m.isLeaf())
298 self.assertTrue(m._isTaskComponent())
299 self.assertTrue(m.isLeaf())
301 self.assertTrue(m._isTaskComponent())
302 self.assertTrue(m.isLeaf())
304 self.assertTrue(m._isTaskComponent())
305 self.assertTrue(m.isLeaf())
307 self.assertFalse(m._isTaskComponent())
308 self.assertFalse(m.isLeaf())
310 self.assertFalse(m._isTaskComponent())
312 self.assertFalse(m._isTaskComponent())
314 self.assertTrue(m._isTaskComponent())
315 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)