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.
16 Revision: "$Id: RandomServiceHelper.py,v 1.6 2012/10/30 11:18:57 fabiocos Exp $"
17 Version "$Revision: 1.6 $"
19 Modified: Eric Vaandering
31 True/False if the psetInstance has seeds in it
34 if psetInstance
is None:
36 if not isinstance(psetInstance,CfgTypes.PSet):
38 seedList = getattr(psetInstance,
"initialSeedSet",
None)
41 seedVal = getattr(psetInstance,
"initialSeed",
None)
53 return the list of PSet instances with seeds in them
57 for item
in self._randService.parameters_()
69 Count the number of seeds required by this service by
70 summing up the initialSeed and initialSeedSet entries
71 in all PSets in the service that contain those parameters.
80 seedSet = getattr(itemRef,
"initialSeedSet",
None)
82 count += len( seedSet.value())
87 seedVal = getattr(itemRef,
"initialSeed",
None)
101 If a specific set of seeds is needed for a PSet in this
102 service, they can be set by name using this method.
104 - *psetName* : Name of the pset containing the seeds
106 - *seeds* : list of seeds to be added, should be a single seed
107 for initialSeed values.
112 msg =
"No PSet named %s belongs to this instance of the" % (
114 msg +=
"Random Seed Service"
115 raise RuntimeError, msg
117 seedVal = getattr(pset,
"initialSeed",
None)
119 pset.initialSeed = CfgTypes.untracked(
120 CfgTypes.uint32(seeds[0])
124 seedSet = getattr(pset,
"initialSeedSet",
None)
130 pset.initialSeedSet = CfgTypes.untracked(
131 CfgTypes.vuint32(*seeds))
143 This method returns the seeds in a PSet in this service. Returned
145 - *psetName* : Name of the pset containing the seeds
150 msg =
"No PSet named %s belongs to this instance of the" % (
152 msg +=
"Random Seed Service"
153 raise RuntimeError, msg
155 seedVal = getattr(pset,
"initialSeed",
None)
157 return [pset.initialSeed.value()]
159 seedSet = getattr(pset,
"initialSeedSet",
None)
161 return pset.initialSeedSet
168 Given some list of specific seeds, insert them into the
171 Length of seed list is required to be same as the seed count for
179 msg =
"Not enough seeds provided\n"
180 msg +=
"Service requires %s seeds, only %s provided\n"
181 msg +=
"to RandomeService.insertSeeds method\n"
182 raise RuntimeError, msg
185 seedSet = getattr(item,
"initialSeedSet",
None)
187 numSeeds = len(seedSet.value())
188 useSeeds = seeds[:numSeeds]
189 seeds = seeds[numSeeds:]
190 item.initialSeedSet = CfgTypes.untracked(
191 CfgTypes.vuint32(*useSeeds))
195 item.initialSeed = CfgTypes.untracked(
196 CfgTypes.uint32(useSeed)
206 generate a bunch of seeds and stick them into this service
207 This is the lazy user method.
209 Optional args are names of PSets to *NOT* alter seeds.
212 populate() will set all seeds
213 populate("pset1", "pset2") will set all seeds but not those in
214 psets named pset1 and pset2
219 from random
import SystemRandom
220 _inst = SystemRandom()
226 newSeeds = [ _inst.randint(1, _MAXINT)
240 reset all seeds to given value
243 newSeeds = [ value
for i
in range(self.
countSeeds())]
249 if __name__ ==
'__main__':
253 randSvc = Service(
"RandomNumberGeneratorService")
256 randSvc.i1 = CfgTypes.untracked(CfgTypes.uint32(1))
257 randSvc.t1 = CfgTypes.PSet()
258 randSvc.t2 = CfgTypes.PSet()
259 randSvc.t3 = CfgTypes.PSet()
261 randSvc.t1.initialSeed = CfgTypes.untracked(
262 CfgTypes.uint32(123455678)
265 randSvc.t2.initialSeedSet = CfgTypes.untracked(
266 CfgTypes.vuint32(12345,234567,345677)
270 randSvc.t3.initialSeed = CfgTypes.untracked(
271 CfgTypes.uint32(987654321)
281 print "Totally Random PSet"
282 randHelper.populate()
289 print "All seeds 9999"
290 randHelper.resetSeeds(9999)
297 randHelper.setNamedSeed(
"t1", 9998)
298 randHelper.setNamedSeed(
"t3", 9998, 9998)
301 print "t1 seed(s)",randHelper.getNamedSeed(
"t1")
302 print "t2 seed(s)",randHelper.getNamedSeed(
"t2")
308 randHelper.populate(
"t1",
"t3")
309 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