Esempio n. 1
0
    def _addModule(self,
                   objSelItem,
                   getter,
                   sysName=None,
                   sysInputTag=None,
                   pyNameSpace=None,
                   process=None):
        # create module
        moduleType = objSelItem.type_()
        module = cms.EDFilter(moduleType)

        # set module attributes
        for objSelAttrName in dir(objSelItem):
            objSelAttr = getattr(objSelItem, objSelAttrName)
            if isinstance(objSelAttr,
                          cms._ParameterTypeBase) and not objSelAttrName in [
                              "pluginName", "pluginType"
                          ]:
                setattr(module, objSelAttrName, objSelAttr)

        moduleName = getter.get_moduleName(
            getInstanceName(objSelItem, pyNameSpace, process), sysName)
        #print "moduleName = %s" % moduleName
        module.setLabel(moduleName)

        src = None
        if sysName is None:
            src = getter.get_src(self.src, self.lastModuleName)
        else:
            src = getter.get_src(sysInputTag, self.lastModuleName)
        if not isinstance(src, cms.InputTag):
            src = cms.InputTag(src)
        setattr(module, self.srcAttr, src)

        # if process object exists, attach module to process object;
        # else register module in global python name-space
        if process is not None:
            setattr(process, moduleName, module)
        else:
            pyModule = sys.modules[self.pyModuleName[0]]
            if pyModule is None:
                raise ValueError("'pyModuleName' Parameter invalid !!")
            setattr(pyModule, moduleName, module)

        self.lastModuleName = moduleName

        # add module to sequence
        self.sequence += module
    def _addModule(self, objProdItem, sysName, sysAttributes, pyNameSpace = None, process = None):
        # create module
        moduleType = objProdItem.type_()
        module = cms.EDProducer(moduleType)

        # set module attributes
        # to default values
        for objProdAttrName in dir(objProdItem):
            objProdAttr = getattr(objProdItem, objProdAttrName)
            if isinstance(objProdAttr, cms._ParameterTypeBase) and not objProdAttrName in [ "pluginName", "pluginType" ]:
                if isinstance(objProdAttr, cms.PSet):
                    # CV: need to clone configuration parameters of type cms.PSet,...
                    #     in order to avoid that recursiveSetAttr function
                    #     overwrites objProd "template" object passed to objProdConfigurator constructor !!
                    setattr(module, objProdAttrName, objProdAttr.clone())
                else:
                    setattr(module, objProdAttrName, objProdAttr)

        # set names of source collections
        # to objects shifted in energy/transverse momentum, theta, phi...
        for sysAttrName, sysAttrValue in sysAttributes.items():
            recursiveSetAttr(module, sysAttrName, sysAttrValue)
                
        moduleName = composeModuleName([ getInstanceName(objProdItem, pyNameSpace, process), sysName ])
        module.setLabel(moduleName)

        # if process object exists, attach module to process object;
        # else register module in global python name-space
        if process is not None:
            setattr(process, moduleName, module)
        else:
            pyModule = sys.modules[self.pyModuleName[0]]
            if pyModule is None:
                raise ValueError("'pyModuleName' Parameter invalid !!")
            setattr(pyModule, moduleName, module)

        # add module to sequence
        if self.sequence == None:
            self.sequence = module
        else:
            self.sequence *= module
    def _addModule(self, objSelItem, getter, sysName = None, sysInputTag = None, pyNameSpace = None, process = None):
        # create module
        moduleType = objSelItem.type_()
        module = cms.EDFilter(moduleType)

        # set module attributes
        for objSelAttrName in dir(objSelItem):
            objSelAttr = getattr(objSelItem, objSelAttrName)
            if isinstance(objSelAttr, cms._ParameterTypeBase) and not objSelAttrName in ["pluginName", "pluginType"]:
                setattr(module, objSelAttrName, objSelAttr)

        moduleName = getter.get_moduleName(getInstanceName(objSelItem, pyNameSpace, process), sysName)
        module.setLabel(moduleName)        

        src = None
        if sysName is None:
            src = getter.get_src(self.src, self.lastModuleName)
        else:
            src = getter.get_src(sysInputTag, self.lastModuleName)
        if not isinstance(src, cms.InputTag):
            src = cms.InputTag(src)
        setattr(module, self.srcAttr, src)

        # if process object exists, attach module to process object;
        # else register module in global python name-space
        if process is not None:
            setattr(process, moduleName, module)
        else:
            pyModule = sys.modules[self.pyModuleName[0]]
            if pyModule is None:
                raise ValueError("'pyModuleName' Parameter invalid !!")
            setattr(pyModule, moduleName, module)

        self.lastModuleName = moduleName

        # add module to sequence
        if self.sequence is None:
            self.sequence = module
        else:
            self.sequence *= module
    def _addModule(self, objProdItem, sysName, sysAttributes, pyNameSpace = None, process = None):
        # create module
        moduleType = objProdItem.type_()
        module = cms.EDProducer(moduleType)

        # set module attributes
        # to default values
        for objProdAttrName in dir(objProdItem):
            objProdAttr = getattr(objProdItem, objProdAttrName)
            if isinstance(objProdAttr, cms._ParameterTypeBase) and not objProdAttrName in [ "pluginName", "pluginType" ]:
                if isinstance(objProdAttr, cms.PSet):
                    # CV: need to clone configuration parameters of type cms.PSet,...
                    #     in order to avoid that recursiveSetAttr function
                    #     overwrites objProd "template" object passed to objProdConfigurator constructor !!
                    setattr(module, objProdAttrName, objProdAttr.clone())
                else:
                    setattr(module, objProdAttrName, objProdAttr)

        # set names of source collections
        # to objects shifted in energy/transverse momentum, theta, phi...
        for sysAttrName, sysAttrValue in sysAttributes.items():
            recursiveSetAttr(module, sysAttrName, sysAttrValue)
                
        moduleName = composeModuleName([ getInstanceName(objProdItem, pyNameSpace, process), sysName ])
        #print "moduleName = %s" % moduleName
        module.setLabel(moduleName)

        # if process object exists, attach module to process object;
        # else register module in global python name-space
        if process is not None:
            setattr(process, moduleName, module)
        else:
            pyModule = sys.modules[self.pyModuleName[0]]
            if pyModule is None:
                raise ValueError("'pyModuleName' Parameter invalid !!")
            setattr(pyModule, moduleName, module)

        # add module to sequence
        self.sequence += module