4 from __future__
import print_function
5 from FWCore.ParameterSet.Config
import Service
6 import FWCore.ParameterSet.Types
as CfgTypes
11 _RandomNumberServiceHelper_ 13 Helper class to hold and handle the Random number generator service. 15 Provide both user level and WM APIs. 18 Modified: Eric Vaandering 30 True/False if the psetInstance has seeds in it 33 if psetInstance
is None:
35 if not isinstance(psetInstance,CfgTypes.PSet):
37 seedList = getattr(psetInstance,
"initialSeedSet",
None)
40 seedVal = getattr(psetInstance,
"initialSeed",
None)
52 return the list of PSet instances with seeds in them 56 for item
in self._randService.parameters_()
68 Count the number of seeds required by this service by 69 summing up the initialSeed and initialSeedSet entries 70 in all PSets in the service that contain those parameters. 79 seedSet = getattr(itemRef,
"initialSeedSet",
None)
81 count += len( seedSet.value())
86 seedVal = getattr(itemRef,
"initialSeed",
None)
100 If a specific set of seeds is needed for a PSet in this 101 service, they can be set by name using this method. 103 - *psetName* : Name of the pset containing the seeds 105 - *seeds* : list of seeds to be added, should be a single seed 106 for initialSeed values. 111 msg =
"No PSet named %s belongs to this instance of the" % (
113 msg +=
"Random Seed Service" 114 raise RuntimeError(msg)
116 seedVal = getattr(pset,
"initialSeed",
None)
118 pset.initialSeed = CfgTypes.untracked(
119 CfgTypes.uint32(seeds[0])
123 seedSet = getattr(pset,
"initialSeedSet",
None)
129 pset.initialSeedSet = CfgTypes.untracked(
130 CfgTypes.vuint32(*seeds))
142 This method returns the seeds in a PSet in this service. Returned 144 - *psetName* : Name of the pset containing the seeds 149 msg =
"No PSet named %s belongs to this instance of the" % (
151 msg +=
"Random Seed Service" 152 raise RuntimeError(msg)
154 seedVal = getattr(pset,
"initialSeed",
None)
156 return [pset.initialSeed.value()]
158 seedSet = getattr(pset,
"initialSeedSet",
None)
160 return pset.initialSeedSet
167 Given some list of specific seeds, insert them into the 170 Length of seed list is required to be same as the seed count for 178 msg =
"Not enough seeds provided\n" 179 msg +=
"Service requires %s seeds, only %s provided\n" 180 msg +=
"to RandomeService.insertSeeds method\n" 181 raise RuntimeError(msg)
184 seedSet = getattr(item,
"initialSeedSet",
None)
186 numSeeds = len(seedSet.value())
187 useSeeds = seeds[:numSeeds]
188 seeds = seeds[numSeeds:]
189 item.initialSeedSet = CfgTypes.untracked(
190 CfgTypes.vuint32(*useSeeds))
194 item.initialSeed = CfgTypes.untracked(
195 CfgTypes.uint32(useSeed)
205 generate a bunch of seeds and stick them into this service 206 This is the lazy user method. 208 Optional args are names of PSets to *NOT* alter seeds. 211 populate() will set all seeds 212 populate("pset1", "pset2") will set all seeds but not those in 213 psets named pset1 and pset2 218 from random
import SystemRandom
219 _inst = SystemRandom()
225 newSeeds = [ _inst.randint(1, _MAXINT)
239 reset all seeds to given value 242 newSeeds = [ value
for i
in range(self.
countSeeds())]
248 if __name__ ==
'__main__':
252 randSvc = Service(
"RandomNumberGeneratorService")
255 randSvc.i1 = CfgTypes.untracked(CfgTypes.uint32(1))
256 randSvc.t1 = CfgTypes.PSet()
257 randSvc.t2 = CfgTypes.PSet()
258 randSvc.t3 = CfgTypes.PSet()
260 randSvc.t1.initialSeed = CfgTypes.untracked(
261 CfgTypes.uint32(123455678)
264 randSvc.t2.initialSeedSet = CfgTypes.untracked(
265 CfgTypes.vuint32(12345,234567,345677)
269 randSvc.t3.initialSeed = CfgTypes.untracked(
270 CfgTypes.uint32(987654321)
280 print(
"Totally Random PSet")
281 randHelper.populate()
288 print(
"All seeds 9999")
289 randHelper.resetSeeds(9999)
296 randHelper.setNamedSeed(
"t1", 9998)
297 randHelper.setNamedSeed(
"t3", 9998, 9998)
300 print(
"t1 seed(s)",randHelper.getNamedSeed(
"t1"))
301 print(
"t2 seed(s)",randHelper.getNamedSeed(
"t2"))
307 randHelper.populate(
"t1",
"t3")
308 print(
"t2 randomized")
def setNamedSeed(self, psetName, seeds)
def __containsSeed(self, psetInstance)
S & print(S &os, JobReport::InputFile const &f)
def getNamedSeed(self, psetName)
def populate(self, excludePSets)
def __init__(self, randService)
def insertSeeds(self, seeds)
def resetSeeds(self, value)
def __psetsWithSeeds(self)
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger list("!*","!HLTx*"if it matches 2 triggers or more) will accept the event if all the matching triggers are FAIL.It will reject the event if any of the triggers are PASS or EXCEPTION(this matches the behavior of"!*"before the partial wildcard feature was incorporated).Triggers which are in the READY state are completely ignored.(READY should never be returned since the trigger paths have been run