CMS 3D CMS Logo

Functions
ThrowAndSetRandomRun Namespace Reference

Functions

def throwAndSetRandomRun (source, runsAndProbs)
 

Function Documentation

def ThrowAndSetRandomRun.throwAndSetRandomRun (   source,
  runsAndProbs 
)
Pass a list of tuple pairs, with the first item of the pair a run number
and the second number of the pair a weight.  The function will normalize the
weights so you do not have to worry about that.  The pairs will be used to randomly choose what Run
should be assigned to the job.

Definition at line 6 of file ThrowAndSetRandomRun.py.

Referenced by ConfigBuilder.ConfigBuilder.filesFromOption().

6 def throwAndSetRandomRun(source,runsAndProbs):
7  """Pass a list of tuple pairs, with the first item of the pair a run number
8  and the second number of the pair a weight. The function will normalize the
9  weights so you do not have to worry about that. The pairs will be used to randomly choose what Run
10  should be assigned to the job.
11  """
12  from random import SystemRandom
13  totalProb = 0.
14  for r,p in runsAndProbs:
15  totalProb+=p
16  #this is the same random generator used to set the seeds for the RandomNumberGeneratorService
17  random = SystemRandom()
18  runProb = random.uniform(0,totalProb)
19  sumProb = 0
20  runNumber = 0
21  for r,p in runsAndProbs:
22  sumProb+=p
23  if sumProb >= runProb:
24  runNumber = r
25  break
26  print 'setting runNumber to: ',runNumber
27  if source.type_() == "PoolSource":
28  source.setRunNumber = cms.untracked.uint32(runNumber)
29  else:
30  #sources that inherit from ConfigurableInputSource use 'firstRun'
31  source.firstRun = cms.untracked.uint32(runNumber)
32 
33  return
34 
def throwAndSetRandomRun(source, runsAndProbs)