Go to the documentation of this file.00001 import FWCore.ParameterSet.Config as cms
00002
00003
00004
00005
00006 def throwAndSetRandomRun(source,runsAndProbs):
00007 """Pass a list of tuple pairs, with the first item of the pair a run number
00008 and the second number of the pair a weight. The function will normalize the
00009 weights so you do not have to worry about that. The pairs will be used to randomly choose what Run
00010 should be assigned to the job.
00011 """
00012 from random import SystemRandom
00013 totalProb = 0.
00014 for r,p in runsAndProbs:
00015 totalProb+=p
00016
00017 random = SystemRandom()
00018 runProb = random.uniform(0,totalProb)
00019 sumProb = 0
00020 runNumber = 0
00021 for r,p in runsAndProbs:
00022 sumProb+=p
00023 if sumProb >= runProb:
00024 runNumber = r
00025 break
00026 print 'setting runNumber to: ',runNumber
00027 if source.type_() == "PoolSource":
00028 source.setRunNumber = cms.untracked.uint32(runNumber)
00029 else:
00030
00031 source.firstRun = cms.untracked.uint32(runNumber)
00032
00033 return