ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/CRAB/python/writeCfg.py
(Generate patch)

Comparing COMP/CRAB/python/writeCfg.py (file contents):
Revision 1.25 by ewv, Fri Aug 28 18:56:43 2009 UTC vs.
Revision 1.30 by ewv, Wed Oct 6 13:57:46 2010 UTC

# Line 17 | Line 17 | import xml.dom.minidom
17   from random import SystemRandom
18  
19   from ProdCommon.CMSConfigTools.ConfigAPI.CfgInterface import CfgInterface
20 from FWCore.ParameterSet.Config                       import include
20   import FWCore.ParameterSet.Types as CfgTypes
21  
22   MyRandom  = SystemRandom()
# Line 102 | Line 101 | def main(argv) :
101      firstEvent = -1
102      compHEPFirstEvent = 0
103      firstRun   = 0
104 +    # FUTURE: Remove firstRun
105 +    firstLumi  = 0
106  
107      dom = xml.dom.minidom.parse(os.environ['RUNTIME_AREA']+'/arguments.xml')
108  
# Line 115 | Line 116 | def main(argv) :
116                  firstEvent = int(elem.getAttribute("FirstEvent"))
117              if elem.getAttribute("FirstRun"):
118                  firstRun = int(elem.getAttribute("FirstRun"))
119 +            if elem.getAttribute("FirstLumi"):
120 +                firstLumi = int(elem.getAttribute("FirstLumi"))
121  
122              generator      = str(elem.getAttribute('Generator'))
123              inputFiles     = str(elem.getAttribute('InputFiles'))
# Line 143 | Line 146 | def main(argv) :
146      if maxEvents:
147          cfg.maxEvents.setMaxEventsInput(maxEvents)
148  
149 <    if skipEvents:
149 >    if skipEvents and inModule.sourceType not in ['EmptySource']:
150          inModule.setSkipEvents(skipEvents)
151  
152      # Set "skip events" for various generators
# Line 174 | Line 177 | def main(argv) :
177      # Pythia parameters
178      if (firstRun):
179          inModule.setFirstRun(firstRun)
180 +    if (firstLumi):
181 +        inModule.setFirstLumi(firstLumi)
182  
183      # Check if there are random #'s to deal with
184      if cfg.data.services.has_key('RandomNumberGeneratorService'):
185          print "RandomNumberGeneratorService found, will attempt to change seeds"
186          from IOMC.RandomEngine.RandomServiceHelper import RandomNumberServiceHelper
187          ranGenerator = cfg.data.services['RandomNumberGeneratorService']
188 +
189 +        ranModules   = getattr(ranGenerator, "moduleSeeds", None)
190 +        oldSource    = getattr(ranGenerator, "sourceSeed",  None)
191 +        if ranModules != None or oldSource != None:
192 +            msg = "Your random number seeds are set in an old,\n"
193 +            msg += "deprecated style. Please change to new style:\n"
194 +            msg += "https://twiki.cern.ch/twiki/bin/view/CMS/SWGuideEDMRandomNumberGeneratorService"
195 +            raise ConfigException(msg)
196 +
197          randSvc = RandomNumberServiceHelper(ranGenerator)
198  
199          incrementSeedList = []
# Line 201 | Line 215 | def main(argv) :
215          randSvc.populate(*preserveSeedList)
216  
217      # Write out new config file
218 +    pklFileName = outFileName + '.pkl'
219      outFile = open(outFileName,"w")
220      outFile.write("import FWCore.ParameterSet.Config as cms\n")
221      outFile.write("import pickle\n")
222 <    outFile.write("pickledCfg=\"\"\"%s\"\"\"\n" % pickle.dumps(cmsProcess))
208 <    outFile.write("process = pickle.loads(pickledCfg)\n")
222 >    outFile.write("process = pickle.load(open('%s', 'rb'))\n" % pklFileName)
223      outFile.close()
224 +
225 +    pklFile = open(pklFileName,"wb")
226 +    myPickle = pickle.Pickler(pklFile)
227 +    myPickle.dump(cmsProcess)
228 +    pklFile.close()
229 +
230      if (debug):
231          print "writeCfg output (May not be exact):"
232          print "import FWCore.ParameterSet.Config as cms"

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines