3 |
|
import sys, getopt, string |
4 |
|
import imp |
5 |
|
import os |
6 |
+ |
import random |
7 |
+ |
from random import SystemRandom |
8 |
+ |
_inst = SystemRandom() |
9 |
|
|
10 |
|
from ProdCommon.CMSConfigTools.ConfigAPI.CfgInterface import CfgInterface |
11 |
|
from FWCore.ParameterSet.DictTypes import SortedKeysDict |
34 |
|
""" |
35 |
|
|
36 |
|
# defaults |
37 |
< |
maxEvents = 0 |
38 |
< |
skipEvents = 0 |
37 |
> |
maxEvents = 0 |
38 |
> |
skipEvents = 0 |
39 |
|
inputFileNames = None |
40 |
< |
debug = False |
40 |
> |
firstRun = 0 |
41 |
> |
sourceSeed = 0 |
42 |
> |
vtxSeed = 0 |
43 |
> |
g4Seed = 0 |
44 |
> |
mixSeed = 0 |
45 |
> |
debug = False |
46 |
|
|
47 |
|
try: |
48 |
|
opts, args = getopt.getopt(argv, "", ["debug", "help","inputFiles=","maxEvents=","skipEvents="]) |
66 |
|
inputFiles = inputFiles.replace('\\','') |
67 |
|
inputFiles = inputFiles.replace('"','') |
68 |
|
inputFileNames = inputFiles.split(',') |
69 |
+ |
elif opt == "--firstRun": |
70 |
+ |
firstRun = int(arg) |
71 |
+ |
elif opt == "--sourceSeed": |
72 |
+ |
sourceSeed = int(arg) |
73 |
+ |
elif opt == "--vtxSeed": |
74 |
+ |
vtxSeed = int(arg) |
75 |
+ |
elif opt == "--g4Seed": |
76 |
+ |
g4Seed = int(arg) |
77 |
+ |
elif opt == "--mixSeed": |
78 |
+ |
mixSeed = int(arg) |
79 |
|
|
80 |
|
# Parse remaining parameters |
81 |
|
|
113 |
|
if (inputFileNames): |
114 |
|
inModule.setFileNames(*inputFileNames) |
115 |
|
|
116 |
+ |
# Pythia parameters |
117 |
+ |
if (firstRun): |
118 |
+ |
inModule.setFirstRun(firstRun) |
119 |
+ |
if (sourceSeed) : |
120 |
+ |
ranGenerator = cfg.data.services['RandomNumberGeneratorService'] |
121 |
+ |
ranGenerator.sourceSeed = CfgTypes.untracked(CfgTypes.uint32(sourceSeed)) |
122 |
+ |
if (vtxSeed) : |
123 |
+ |
ranModules = ranGenerator.moduleSeeds |
124 |
+ |
ranModules.VtxSmeared = CfgTypes.untracked(CfgTypes.uint32(vtxSeed)) |
125 |
+ |
if (g4Seed) : |
126 |
+ |
ranModules = ranGenerator.moduleSeeds |
127 |
+ |
ranModules.g4SimHits = CfgTypes.untracked(CfgTypes.uint32(g4Seed)) |
128 |
+ |
if (mixSeed) : |
129 |
+ |
ranModules = ranGenerator.moduleSeeds |
130 |
+ |
ranModules.mix = CfgTypes.untracked(CfgTypes.uint32(mixSeed)) |
131 |
+ |
|
132 |
+ |
# Randomize all seeds |
133 |
+ |
|
134 |
+ |
print "There are ",cfg.seedCount()," seeds" |
135 |
+ |
seedList = [random.randint(100,200) for i in range(cfg.seedCount)] |
136 |
+ |
seedTuple = seedList.tuple() |
137 |
+ |
|
138 |
+ |
cfg.insertSeeds(*seedTuple) |
139 |
+ |
|
140 |
|
# Write out new config file |
141 |
|
|
142 |
|
outFile = open(outFileName,"w") |