def insertSeeds(self, *seeds):
        """
        _insertSeeds_

        Given some list of specific seeds, insert them into the
        service.

        Length of seed list is required to be same as the seed count for
        the service.

        Usage: WM Tools.

        """
        seeds = list(seeds)
        if len(seeds) < self.countSeeds():
            msg = "Not enough seeds provided\n"
            msg += "Service requires %s seeds, only %s provided\n"
            msg += "to RandomeService.insertSeeds method\n"
            raise RuntimeError, msg

        for item in self.__psetsWithSeeds():
            seedSet = getattr(item, "initialSeedSet", None)
            if seedSet != None:
                numSeeds = len(seedSet.value())
                useSeeds = seeds[:numSeeds]
                seeds = seeds[numSeeds:]
                item.initialSeedSet = CfgTypes.untracked(
                    CfgTypes.vuint32(*useSeeds))
                continue
            useSeed = seeds[0]
            seeds = seeds[1:]
            item.initialSeed = CfgTypes.untracked(CfgTypes.uint32(useSeed))
            continue
        return
Esempio n. 2
0
    def insertSeeds(self, *seeds):
        """
        _insertSeeds_

        Given some list of specific seeds, insert them into the
        service.

        Length of seed list is required to be same as the seed count for
        the service.

        Usage: WM Tools.

        """
        seeds = list(seeds)
        if len(seeds) < self.countSeeds():
            msg = "Not enough seeds provided\n"
            msg += "Service requires %s seeds, only %s provided\n"
            msg += "to RandomeService.insertSeeds method\n"
            raise RuntimeError, msg

        for item in self.__psetsWithSeeds():
            seedSet = getattr(item, "initialSeedSet", None)
            if seedSet != None:
                numSeeds = len(seedSet.value())
                useSeeds = seeds[:numSeeds]
                seeds = seeds[numSeeds:]
                item.initialSeedSet = CfgTypes.untracked(CfgTypes.vuint32(*useSeeds))
                continue
            useSeed = seeds[0]
            seeds = seeds[1:]
            item.initialSeed = CfgTypes.untracked(CfgTypes.uint32(useSeed))
            continue
        return
Esempio n. 3
0
    def insertOldSeeds(self, *seeds):
        """
        _insertOldSeeds_

        Backwards compatibility methods

        """
        seedList = list(seeds)
        svc = self.data.services["RandomNumberGeneratorService"]
        #  //=====Old methods, keep for backwards compat.=======
        # //
        #//
        srcSeedVec = getattr(svc, "sourceSeedVector",
                             Utilities._CfgNoneType()).value()
        if srcSeedVec != None:
            numReq = len(srcSeedVec)
            seedsReq = seedList[0:numReq]
            seedList = seedList[numReq + 1:]
            svc.sourceSeedVector = CfgTypes.untracked(
                CfgTypes.vuint32(seedsReq))

        else:
            svc.sourceSeed = CfgTypes.untracked(
                CfgTypes.uint32(seedList.pop(0)))
        modSeeds = getattr(svc, "moduleSeeds",
                           Utilities._CfgNoneType()).value()
        if modSeeds != None:
            for param in modSeeds.parameterNames_():
                setattr(modSeeds, param,
                        CfgTypes.untracked(CfgTypes.uint32(seedList.pop(0))))
        #  //
        # //
        #//====End old stuff======================================
        return
Esempio n. 4
0
    def insertOldSeeds(self, *seeds):
        """
        _insertOldSeeds_

        Backwards compatibility methods

        """
        seedList = list(seeds)
        svc = self.data.services["RandomNumberGeneratorService"]
        #  //=====Old methods, keep for backwards compat.=======
        # //
        #//
        srcSeedVec = getattr(svc, "sourceSeedVector",
                             Utilities._CfgNoneType()).value()
        if srcSeedVec != None:
            numReq = len(srcSeedVec)
            seedsReq = seedList[0:numReq]
            seedList = seedList[numReq + 1:]
            svc.sourceSeedVector = CfgTypes.untracked(
                CfgTypes.vuint32(seedsReq))


        else:
            svc.sourceSeed = CfgTypes.untracked(
                CfgTypes.uint32(seedList.pop(0)))
        modSeeds = getattr(svc, "moduleSeeds",
                           Utilities._CfgNoneType()).value()
        if modSeeds != None:
            for param in modSeeds.parameterNames_():
                setattr(modSeeds, param,
                        CfgTypes.untracked(CfgTypes.uint32(seedList.pop(0))))
        #  //
        # //
        #//====End old stuff======================================
        return
Esempio n. 5
0
    def setNamedSeed(self, psetName, *seeds):
        """
        _setNamedSeed_

        If a specific set of seeds is needed for a PSet in this
        service, they can be set by name using this method.

        - *psetName* : Name of the pset containing the seeds

        - *seeds*    : list of seeds to be added, should be a single seed
        for initialSeed values.

        """
        pset = getattr(self._randService, psetName, None)
        if pset == None:
            msg = "No PSet named %s belongs to this instance of the" % (
                psetName,)
            msg += "Random Seed Service"
            raise RuntimeError, msg

        seedVal = getattr(pset, "initialSeed", None)
        if seedVal != None:
            pset.initialSeed = CfgTypes.untracked(
                CfgTypes.uint32(seeds[0])
                )

            return
        seedSet = getattr(pset, "initialSeedSet", None)
        if seedSet != None:
            #  //
            # // Do we want to check the number of seeds??
            #//
            #if len(seeds) != len( seedSet.value()): pass
            pset.initialSeedSet = CfgTypes.untracked(
                CfgTypes.vuint32(*seeds))
            return
        #  //
        # // No seeds for that PSet
        #//  Error throw?
        return
Esempio n. 6
0
    def setNamedSeed(self, psetName, *seeds):
        """
        _setNamedSeed_

        If a specific set of seeds is needed for a PSet in this
        service, they can be set by name using this method.

        - *psetName* : Name of the pset containing the seeds

        - *seeds*    : list of seeds to be added, should be a single seed
        for initialSeed values.

        """
        pset = getattr(self._randService, psetName, None)
        if pset == None:
            msg = "No PSet named %s belongs to this instance of the" % (
                psetName,)
            msg += "Random Seed Service"
            raise RuntimeError, msg

        seedVal = getattr(pset, "initialSeed", None)
        if seedVal != None:
            pset.initialSeed = CfgTypes.untracked(
                CfgTypes.uint32(seeds[0])
                )

            return
        seedSet = getattr(pset, "initialSeedSet", None)
        if seedSet != None:
            #  //
            # // Do we want to check the number of seeds??
            #//
            #if len(seeds) != len( seedSet.value()): pass
            pset.initialSeedSet = CfgTypes.untracked(
                CfgTypes.vuint32(*seeds))
            return
        #  //
        # // No seeds for that PSet
        #//  Error throw?
        return
Esempio n. 7
0
    # // Setup a test service and populate it
    #//
    randSvc = Service("RandomNumberGeneratorService")
    randHelper = RandomNumberServiceHelper(randSvc)

    randSvc.i1 =  CfgTypes.untracked(CfgTypes.uint32(1))
    randSvc.t1 = CfgTypes.PSet()
    randSvc.t2 = CfgTypes.PSet()
    randSvc.t3 = CfgTypes.PSet()

    randSvc.t1.initialSeed = CfgTypes.untracked(
        CfgTypes.uint32(123455678)
        )

    randSvc.t2.initialSeedSet = CfgTypes.untracked(
        CfgTypes.vuint32(12345,234567,345677)
        )


    randSvc.t3.initialSeed = CfgTypes.untracked(
        CfgTypes.uint32(987654321)
        )

    print "Inital PSet"
    print randSvc


    #  //
    # // Autofill seeds
    #//
    print "Totally Random PSet"
Esempio n. 8
0
    # // Setup a test service and populate it
    #//
    randSvc = Service("RandomNumberGeneratorService")
    randHelper = RandomNumberServiceHelper(randSvc)

    randSvc.i1 =  CfgTypes.untracked(CfgTypes.uint32(1))
    randSvc.t1 = CfgTypes.PSet()
    randSvc.t2 = CfgTypes.PSet()
    randSvc.t3 = CfgTypes.PSet()

    randSvc.t1.initialSeed = CfgTypes.untracked(
        CfgTypes.uint32(123455678)
        )

    randSvc.t2.initialSeedSet = CfgTypes.untracked(
        CfgTypes.vuint32(12345,234567,345677)
        )


    randSvc.t3.initialSeed = CfgTypes.untracked(
        CfgTypes.uint32(987654321)
        )

    print "Inital PSet"
    print randSvc


    #  //
    # // Autofill seeds
    #//
    print "Totally Random PSet"
Esempio n. 9
0
if __name__ == "__main__":
    #  //
    # // Setup a test service and populate it
    # //
    randSvc = Service("RandomNumberGeneratorService")
    randHelper = RandomNumberServiceHelper(randSvc)

    randSvc.i1 = CfgTypes.untracked(CfgTypes.uint32(1))
    randSvc.t1 = CfgTypes.PSet()
    randSvc.t2 = CfgTypes.PSet()
    randSvc.t3 = CfgTypes.PSet()

    randSvc.t1.initialSeed = CfgTypes.untracked(CfgTypes.uint32(123455678))

    randSvc.t2.initialSeedSet = CfgTypes.untracked(CfgTypes.vuint32(12345, 234567, 345677))

    randSvc.t3.initialSeed = CfgTypes.untracked(CfgTypes.uint32(987654321))

    print "Inital PSet"
    print randSvc

    #  //
    # // Autofill seeds
    # //
    print "Totally Random PSet"
    randHelper.populate()
    print randSvc

    #  //
    # // Set all seeds with reset method