7 |
|
__revision__ = "$Id$" |
8 |
|
__version__ = "$Revision$" |
9 |
|
|
10 |
< |
import sys, getopt |
10 |
> |
import getopt |
11 |
|
import imp |
12 |
|
import os |
13 |
+ |
import pickle |
14 |
+ |
import sys |
15 |
+ |
import xml.dom.minidom |
16 |
+ |
|
17 |
|
from random import SystemRandom |
18 |
|
|
19 |
|
from ProdCommon.CMSConfigTools.ConfigAPI.CfgInterface import CfgInterface |
89 |
|
print main.__doc__ |
90 |
|
sys.exit() |
91 |
|
|
92 |
< |
# Optional Parameters |
92 |
> |
# Read in XML and get optional Parameters |
93 |
|
|
90 |
– |
maxEvents = int(os.environ.get('MaxEvents', '0')) |
91 |
– |
skipEvents = int(os.environ.get('SkipEvents','0')) |
92 |
– |
firstRun = int(os.environ.get('FirstRun', '0')) |
94 |
|
nJob = int(os.environ.get('NJob', '0')) |
95 |
|
|
96 |
< |
inputFiles = os.environ.get('InputFiles','') |
97 |
< |
parentFiles = os.environ.get('ParentFiles','') |
98 |
< |
preserveSeeds = os.environ.get('PreserveSeeds','') |
99 |
< |
incrementSeeds = os.environ.get('IncrementSeeds','') |
96 |
> |
# Defaults |
97 |
> |
|
98 |
> |
maxEvents = 0 |
99 |
> |
skipEvents = 0 |
100 |
> |
firstEvent = -1 |
101 |
> |
compHEPFirstEvent = 0 |
102 |
> |
firstRun = 0 |
103 |
> |
|
104 |
> |
dom = xml.dom.minidom.parse(os.environ['RUNTIME_AREA']+'/arguments.xml') |
105 |
> |
|
106 |
> |
for elem in dom.getElementsByTagName("Job"): |
107 |
> |
if nJob == int(elem.getAttribute("JobID")): |
108 |
> |
if elem.getAttribute("MaxEvents"): |
109 |
> |
maxEvents = int(elem.getAttribute("MaxEvents")) |
110 |
> |
if elem.getAttribute("SkipEvents"): |
111 |
> |
skipEvents = int(elem.getAttribute("SkipEvents")) |
112 |
> |
if elem.getAttribute("FirstEvent"): |
113 |
> |
firstEvent = int(elem.getAttribute("FirstEvent")) |
114 |
> |
if elem.getAttribute("CompHEPFirstEvent"): |
115 |
> |
compHEPFirstEvent = int(elem.getAttribute("CompHEPFirstEvent")) |
116 |
> |
if elem.getAttribute("FirstRun"): |
117 |
> |
firstRun = int(elem.getAttribute("FirstRun")) |
118 |
> |
|
119 |
> |
inputFiles = str(elem.getAttribute('InputFiles')) |
120 |
> |
parentFiles = str(elem.getAttribute('ParentFiles')) |
121 |
> |
preserveSeeds = str(elem.getAttribute('PreserveSeeds')) |
122 |
> |
incrementSeeds = str(elem.getAttribute('IncrementSeeds')) |
123 |
|
|
124 |
|
# Read Input cfg or python cfg file, FUTURE: Get rid cfg mode |
125 |
|
|
154 |
|
|
155 |
|
if skipEvents: |
156 |
|
inModule.setSkipEvents(skipEvents) |
157 |
< |
|
157 |
> |
if firstEvent != -1: |
158 |
> |
cmsProcess.source.firstEvent = CfgTypes.untracked(CfgTypes.uint32(firstEvent)) |
159 |
> |
if compHEPFirstEvent: |
160 |
> |
cmsProcess.source.CompHEPFirstEvent = CfgTypes.int32(compHEPFirstEvent) |
161 |
|
if inputFiles: |
135 |
– |
inputFiles = inputFiles.replace('\\','') |
136 |
– |
inputFiles = inputFiles.replace('"','') |
162 |
|
inputFileNames = inputFiles.split(',') |
163 |
|
inModule.setFileNames(*inputFileNames) |
164 |
|
|
165 |
|
# handle parent files if needed |
166 |
|
if parentFiles: |
142 |
– |
parentFiles = parentFiles.replace('\\','') |
143 |
– |
parentFiles = parentFiles.replace('"','') |
167 |
|
parentFileNames = parentFiles.split(',') |
168 |
|
inModule.setSecondaryFileNames(*parentFileNames) |
169 |
|
|
235 |
|
outFile = open(outFileName,"w") |
236 |
|
if outFileName.endswith('py'): |
237 |
|
outFile.write("import FWCore.ParameterSet.Config as cms\n") |
238 |
< |
outFile.write(cmsProcess.dumpPython()) |
238 |
> |
outFile.write("import pickle\n") |
239 |
> |
outFile.write("pickledCfg=\"\"\"%s\"\"\"\n" % pickle.dumps(cmsProcess)) |
240 |
> |
outFile.write("process = pickle.loads(pickledCfg)\n") |
241 |
|
if (debug): |
242 |
< |
print "writeCfg output:" |
242 |
> |
print "writeCfg output (May not be exact):" |
243 |
|
print "import FWCore.ParameterSet.Config as cms" |
244 |
|
print cmsProcess.dumpPython() |
245 |
|
else: |