4 from FWCore.ParameterSet.Config
import Service
5 import FWCore.ParameterSet.Types
as CfgTypes
10 _RandomNumberServiceHelper_
12 Helper class to hold and handle the Random number generator service.
14 Provide both user level and WM APIs.
17 Modified: Eric Vaandering
29 True/False if the psetInstance has seeds in it
32 if psetInstance
is None:
34 if not isinstance(psetInstance,CfgTypes.PSet):
36 seedList = getattr(psetInstance,
"initialSeedSet",
None)
39 seedVal = getattr(psetInstance,
"initialSeed",
None)
51 return the list of PSet instances with seeds in them
55 for item
in self._randService.parameters_()
67 Count the number of seeds required by this service by
68 summing up the initialSeed and initialSeedSet entries
69 in all PSets in the service that contain those parameters.
78 seedSet = getattr(itemRef,
"initialSeedSet",
None)
80 count += len( seedSet.value())
85 seedVal = getattr(itemRef,
"initialSeed",
None)
99 If a specific set of seeds is needed for a PSet in this
100 service, they can be set by name using this method.
102 - *psetName* : Name of the pset containing the seeds
104 - *seeds* : list of seeds to be added, should be a single seed
105 for initialSeed values.
110 msg =
"No PSet named %s belongs to this instance of the" % (
112 msg +=
"Random Seed Service"
113 raise RuntimeError(msg)
115 seedVal = getattr(pset,
"initialSeed",
None)
117 pset.initialSeed = CfgTypes.untracked(
118 CfgTypes.uint32(seeds[0])
122 seedSet = getattr(pset,
"initialSeedSet",
None)
128 pset.initialSeedSet = CfgTypes.untracked(
129 CfgTypes.vuint32(*seeds))
141 This method returns the seeds in a PSet in this service. Returned
143 - *psetName* : Name of the pset containing the seeds
148 msg =
"No PSet named %s belongs to this instance of the" % (
150 msg +=
"Random Seed Service"
151 raise RuntimeError(msg)
153 seedVal = getattr(pset,
"initialSeed",
None)
155 return [pset.initialSeed.value()]
157 seedSet = getattr(pset,
"initialSeedSet",
None)
159 return pset.initialSeedSet
166 Given some list of specific seeds, insert them into the
169 Length of seed list is required to be same as the seed count for
177 msg =
"Not enough seeds provided\n"
178 msg +=
"Service requires %s seeds, only %s provided\n"
179 msg +=
"to RandomeService.insertSeeds method\n"
180 raise RuntimeError(msg)
183 seedSet = getattr(item,
"initialSeedSet",
None)
185 numSeeds = len(seedSet.value())
186 useSeeds = seeds[:numSeeds]
187 seeds = seeds[numSeeds:]
188 item.initialSeedSet = CfgTypes.untracked(
189 CfgTypes.vuint32(*useSeeds))
193 item.initialSeed = CfgTypes.untracked(
194 CfgTypes.uint32(useSeed)
204 generate a bunch of seeds and stick them into this service
205 This is the lazy user method.
207 Optional args are names of PSets to *NOT* alter seeds.
210 populate() will set all seeds
211 populate("pset1", "pset2") will set all seeds but not those in
212 psets named pset1 and pset2
217 from random
import SystemRandom
218 _inst = SystemRandom()
224 newSeeds = [ _inst.randint(1, _MAXINT)
238 reset all seeds to given value
241 newSeeds = [ value
for i
in range(self.
countSeeds())]
247 if __name__ ==
'__main__':
251 randSvc = Service(
"RandomNumberGeneratorService")
254 randSvc.i1 = CfgTypes.untracked(CfgTypes.uint32(1))
255 randSvc.t1 = CfgTypes.PSet()
256 randSvc.t2 = CfgTypes.PSet()
257 randSvc.t3 = CfgTypes.PSet()
259 randSvc.t1.initialSeed = CfgTypes.untracked(
260 CfgTypes.uint32(123455678)
263 randSvc.t2.initialSeedSet = CfgTypes.untracked(
264 CfgTypes.vuint32(12345,234567,345677)
268 randSvc.t3.initialSeed = CfgTypes.untracked(
269 CfgTypes.uint32(987654321)
279 print "Totally Random PSet"
280 randHelper.populate()
287 print "All seeds 9999"
288 randHelper.resetSeeds(9999)
295 randHelper.setNamedSeed(
"t1", 9998)
296 randHelper.setNamedSeed(
"t3", 9998, 9998)
299 print "t1 seed(s)",randHelper.getNamedSeed(
"t1")
300 print "t2 seed(s)",randHelper.getNamedSeed(
"t2")
306 randHelper.populate(
"t1",
"t3")
307 print "t2 randomized"
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