144 |
|
if preserveSeeds: |
145 |
|
preserveSeedList = preserveSeeds.split(',') |
146 |
|
|
147 |
< |
# FUTURE: This function tests the CMSSW version. Can be simplified as we drop support for old versions |
148 |
< |
if CMSSW_major < 2 or (CMSSW_major == 2 and CMSSW_minor == 0): # Treatment for seeds, CMSSW < 2_1_x |
149 |
< |
if cfg.data.services.has_key('RandomNumberGeneratorService'): |
150 |
< |
ranGenerator = cfg.data.services['RandomNumberGeneratorService'] |
151 |
< |
ranModules = ranGenerator.moduleSeeds |
152 |
< |
|
147 |
> |
# FUTURE: This function tests the CMSSW version and presence of old-style seed specification. Reduce when we drop support for old versions |
148 |
> |
if cfg.data.services.has_key('RandomNumberGeneratorService'): # There are random #'s to deal with |
149 |
> |
ranGenerator = cfg.data.services['RandomNumberGeneratorService'] |
150 |
> |
ranModules = getattr(ranGenerator,"moduleSeeds",None) |
151 |
> |
if ranModules != None: # Old format present, no matter the CMSSW version |
152 |
|
sourceSeed = int(ranGenerator.sourceSeed.value()) |
153 |
|
if 'sourceSeed' in preserveSeedList: |
154 |
|
pass |
170 |
|
if curSeed: |
171 |
|
curValue = int(curSeed.value()) |
172 |
|
setattr(ranGenerator.moduleSeeds,seed,CfgTypes.untracked(CfgTypes.uint32(_inst.randint(1,_MAXINT)))) |
173 |
< |
else: # Treatment for seeds, CMSSW 2_1_x and later |
175 |
< |
if cfg.data.services.has_key('RandomNumberGeneratorService'): |
173 |
> |
elif CMSSW_major > 2 or (CMSSW_major == 2 and CMSSW_minor >= 1): # Treatment for seeds, CMSSW 2_1_x and later |
174 |
|
from IOMC.RandomEngine.RandomServiceHelper import RandomNumberServiceHelper |
177 |
– |
|
178 |
– |
ranGenerator = cfg.data.services['RandomNumberGeneratorService'] |
175 |
|
randSvc = RandomNumberServiceHelper(ranGenerator) |
180 |
– |
# sourceSeed is different from the rest, John says will become "theSource" |
181 |
– |
if 'sourceSeed' in preserveSeedList: |
182 |
– |
pass |
183 |
– |
elif 'sourceSeed' in incrementSeedList: |
184 |
– |
sourceSeed = int(ranGenerator.sourceSeed.value()) |
185 |
– |
ranGenerator.sourceSeed = CfgTypes.untracked(CfgTypes.uint32(sourceSeed+nJob)) |
186 |
– |
else: |
187 |
– |
ranGenerator.sourceSeed = CfgTypes.untracked(CfgTypes.uint32(_inst.randint(1,_MAXINT))) |
176 |
|
|
177 |
|
# Increment requested seed sets |
178 |
|
for seedName in incrementSeedList: |
184 |
|
# Randomize remaining seeds |
185 |
|
randSvc.populate(*preserveSeedList) |
186 |
|
|
187 |
< |
# End version specific code |
187 |
> |
# End version specific code |
188 |
|
|
189 |
|
# Write out new config file in one format or the other, FUTURE: Get rid of cfg mode |
190 |
|
outFile = open(outFileName,"w") |