Exemple #1
0
 def handleSeeding(self):
     """
     _handleSeeding_
     
     Handle Random Seed settings for the job
     
     """
     baggage = self.job.getBaggage()
     seeding = getattr(baggage, "seeding", None)
     if seeding == None:
         return
     if seeding == "AutomaticSeeding":
         from IOMC.RandomEngine.RandomServiceHelper import RandomNumberServiceHelper
         helper = RandomNumberServiceHelper(self.process.RandomNumberGeneratorService)
         helper.populate()
         return
     if seeding == "ReproducibleSeeding":
         randService = self.process.RandomNumberGeneratorService
         tweak = PSetTweak()
         for x in randService:
             parameter = "process.RandomNumberGeneratorService.%s.initialSeed" % x._internal_name
             tweak.addParameter(parameter, x.initialSeed)
         applyTweak(self.process, tweak, self.fixupDict)
         return
     # still here means bad seeding algo name
     raise RuntimeError, "Bad Seeding Algorithm: %s" % seeding
Exemple #2
0
def customise(process):
	# Remove output modules
	process.schedule.remove(process.endjob_step)
	process.schedule.remove(process.out_step)

	# Logging options
	process.options.wantSummary = cms.untracked.bool(True)
	process.MessageLogger.cerr.FwkReport.reportEvery = 1000
#	process.genParticles.abortOnUnknownPDGCode = False

	# Seed random generator
	from IOMC.RandomEngine.RandomServiceHelper import RandomNumberServiceHelper
	randSvc = RandomNumberServiceHelper(process.RandomNumberGeneratorService)
	randSvc.populate()

	# Add kappa skim
	process.load("Kappa.Producers.KTuple_cff")
	process.kappatuple = cms.EDAnalyzer('KTuple',
		process.kappaTupleDefaultsBlock,
		outputFile = cms.string('skim.root'),
	)
	process.kappatuple.active = cms.vstring('GenMetadata', 'LV')
	process.kappatuple.Metadata.l1Source = cms.InputTag("")
	process.kappatuple.Metadata.hltSource = cms.InputTag("")
	process.kappatuple.Metadata.noiseHCAL = cms.InputTag("")
	process.kappatuple.Metadata.hlTrigger = cms.InputTag("")
	process.kappatuple.Metadata.muonTriggerObjects = cms.vstring()
	process.kappatuple.Metadata.noiseHCAL = cms.InputTag("")
	process.pathSkim = cms.Path(process.kappatuple)
	process.schedule += process.pathSkim

	return process
   def PrepareJobUser(self, jobDir, value ):
      '''Prepare one job. This function is called by the base class.'''
      
      process.source = fullSource.clone()
      
      #prepare the batch script
      scriptFileName = jobDir+'/batchScript.sh'
      scriptFile = open(scriptFileName,'w')
      storeDir = self.remoteOutputDir_.replace('/castor/cern.ch/cms','')
      mode = self.RunningMode(options.batch)
      if mode == 'LXPLUS':
         scriptFile.write( batchScriptCERN( storeDir, value) )    #here is the call to batchScriptCERN, i need to change value
      elif mode == 'LOCAL':
         scriptFile.write( batchScriptLocal( storeDir, value) )   #same as above but for batchScriptLocal
      scriptFile.close()
      os.system('chmod +x %s' % scriptFileName)

      #prepare the cfg
      # replace the list of fileNames by a chunk of filenames:
      if generator:
         randSvc = RandomNumberServiceHelper(process.RandomNumberGeneratorService)
         randSvc.populate()
      else:
         iFileMin = (value-1)*grouping 
         iFileMax = (value)*grouping 
         process.source.fileNames = fullSource.fileNames[iFileMin:iFileMax]
         print process.source
      cfgFile = open(jobDir+'/run_cfg.py','w')
      cfgFile.write('import FWCore.ParameterSet.Config as cms\n\n')
      cfgFile.write('import os,sys\n')
      # need to import most of the config from the base directory containing all jobs
      cfgFile.write("sys.path.append('%s')\n" % os.path.dirname(jobDir) )
      cfgFile.write('from base_cfg import *\n')
      cfgFile.write('process.source = ' + process.source.dumpPython() + '\n')
      cfgFile.close()
    def insertSeeds(self, *seeds):
        """
        _insertSeeds_

        Insert the list of seeds into the RandomNumber Service

        """
        seedList = list(seeds)
        if "RandomNumberGeneratorService" not in self.data.services.keys():
            return


        if self.hasOldSeeds():
            self.insertOldSeeds(*seeds)
            return

        #  //
        # // Use seed service utility to generate seeds on the fly
        #//
        svc = self.data.services["RandomNumberGeneratorService"]
        try:
            from IOMC.RandomEngine.RandomServiceHelper import RandomNumberServiceHelper
        except ImportError:
            msg = "Unable to import RandomeNumberServiceHelper"
            print msg
            raise RuntimeError, msg
        randHelper = RandomNumberServiceHelper(svc)
        randHelper.populate()
        svc.saveFileName = CfgTypes.untracked(
            CfgTypes.string("RandomEngineState.log"))

        return
def customise_for_gc(process):
	import FWCore.ParameterSet.Config as cms
	from IOMC.RandomEngine.RandomServiceHelper import RandomNumberServiceHelper

	try:
		maxevents = int(__MAX_EVENTS__)
		process.maxEvents = cms.untracked.PSet(
			input = cms.untracked.int32(max(-1, maxevents))
		)
	except:
		pass

	# Dataset related setup
	try:
		primaryFiles = [__FILE_NAMES__]
		process.source = cms.Source('PoolSource',
			skipEvents = cms.untracked.uint32(__SKIP_EVENTS__),
			fileNames = cms.untracked.vstring(primaryFiles)
		)
		try:
			secondaryFiles = [__FILE_NAMES2__]
			process.source.secondaryFileNames = cms.untracked.vstring(secondaryFiles)
		except:
			pass
		try:
			lumirange = [__LUMI_RANGE__]
			if len(lumirange) > 0:
				process.source.lumisToProcess = cms.untracked.VLuminosityBlockRange(lumirange)
				process.maxEvents = cms.untracked.PSet(input = cms.untracked.int32(-1))
		except:
			pass
	except:
		pass

	if hasattr(process, 'RandomNumberGeneratorService'):
		randSvc = RandomNumberServiceHelper(process.RandomNumberGeneratorService)
		randSvc.populate()

	process.AdaptorConfig = cms.Service('AdaptorConfig',
		enable = cms.untracked.bool(True),
		stats = cms.untracked.bool(True),
	)

	# Generator related setup
	try:
		if hasattr(process, 'generator') and process.source.type_() != 'PoolSource':
			process.source.firstLuminosityBlock = cms.untracked.uint32(1 + __GC_JOB_ID__)
			print 'Generator random seed:', process.RandomNumberGeneratorService.generator.initialSeed
	except:
		pass

	# Print GlobalTag for DBS3 registration - output is taken from edmConfigHash
	try:
		print 'globaltag:%s' % process.GlobalTag.globaltag.value()
	except:
		pass
	return (process)
def customise_for_gc(process):
	import FWCore.ParameterSet.Config as cms
	from IOMC.RandomEngine.RandomServiceHelper import RandomNumberServiceHelper

	try:
		maxevents = __MAX_EVENTS__
		process.maxEvents = cms.untracked.PSet(
			input = cms.untracked.int32(max(-1, maxevents))
		)
	except:
		pass

	# Dataset related setup
	try:
		primaryFiles = [__FILE_NAMES__]
		process.source = cms.Source("PoolSource",
			skipEvents = cms.untracked.uint32(__SKIP_EVENTS__),
			fileNames = cms.untracked.vstring(primaryFiles)
		)
		try:
			secondaryFiles = [__FILE_NAMES2__]
			process.source.secondaryFileNames = cms.untracked.vstring(secondaryFiles)
		except:
			pass
		try:
			lumirange = [__LUMI_RANGE__]
			process.source.lumisToProcess = cms.untracked.VLuminosityBlockRange(lumirange)
		except:
			pass
	except:
		pass

	if hasattr(process, "RandomNumberGeneratorService"):
		randSvc = RandomNumberServiceHelper(process.RandomNumberGeneratorService)
		randSvc.populate()

	process.AdaptorConfig = cms.Service("AdaptorConfig",
		enable = cms.untracked.bool(True),
		stats = cms.untracked.bool(True),
	)

	# Generator related setup
	try:
		if hasattr(process, "generator"):
			#muss deaktiviert werden!
			#process.source.firstLuminosityBlock = cms.untracked.uint32(1+__MY_JOBID__)
			print "Generator random seed:", process.RandomNumberGeneratorService.generator.initialSeed
	except:
		pass

	return (process)
Exemple #7
0
    def PrepareJobUser(self, jobDir, value ):

       process.source = fullSource.clone()

       #prepare the batch script
       scriptFileName = jobDir+'/batchScript.sh'
       scriptFile = open(scriptFileName,'w')

       # are we at CERN or somewhere else? testing the afs path
       cwd = os.getcwd()
       patternCern = re.compile( '^/afs/cern.ch' )
       patterncmsphys01 = re.compile( '/data' )
       if patternCern.match( cwd ):
          print '@ CERN'
          scriptFile.write( batchScriptCERN( self.remoteOutputFile_,
                                             self.remoteOutputDir_,
                                             value) )
       elif patterncmsphys01.match( cwd ):
          print '@ cmsphys01'
          scriptFile.write( batchScriptcmsphys01( self.remoteOutputFile_,
                                                  self.remoteOutputDir_,
                                                  value) )          
       else:
          print "I don't know on which computing site you are... "
          sys.exit(2)
       
       scriptFile.close()
       os.system('chmod +x %s' % scriptFileName)

       #prepare the cfg
       
       # replace the list of fileNames by a chunk of filenames:
       if generator:
          randSvc = RandomNumberServiceHelper(process.RandomNumberGeneratorService)
          randSvc.populate()
       else:

          print "grouping : ", grouping
          print "value : ", value
          
          iFileMin = (value)*grouping 
          iFileMax = (value+1)*grouping 
          
          process.source.fileNames = fullSource.fileNames[iFileMin:iFileMax]
          print process.source
          
       cfgFile = open(jobDir+'/run_cfg.py','w')
       cfgFile.write(process.dumpPython())
       cfgFile.close()
Exemple #8
0
    def PrepareJobUser(self, jobDir, value ):

       process.source = fullSource.clone()

       #prepare the batch script
       scriptFileName = jobDir+'/batchScript.sh'
       scriptFile = open(scriptFileName,'w')

       # are we at CERN or somewhere else? testing the afs path
       cwd = os.getcwd()
       patternCern = re.compile( '^/afs/cern.ch' )

       patternBatch = re.compile( '\w*bsub')
       wantBatch = patternBatch.match( options.batch )
       if wantBatch:
          print "we want to run on the batch with bsub"
          if patternCern.match( cwd ):
             print '@ CERN'
             scriptFile.write( batchScriptCERN( self.remoteOutputDir_,
                                                value) )
       else: 
          print '@ local'
          scriptFile.write( batchScriptLocal( self.remoteOutputDir_,
                                              value) )          
       
       scriptFile.close()
       os.system('chmod +x %s' % scriptFileName)

       #prepare the cfg
       
       # replace the list of fileNames by a chunk of filenames:
       if generator:
          randSvc = RandomNumberServiceHelper(process.RandomNumberGeneratorService)
          randSvc.populate()
       else:

          print "grouping : ", grouping
          print "value : ", value
          
          iFileMin = (value)*grouping 
          iFileMax = (value+1)*grouping 
          
          process.source.fileNames = fullSource.fileNames[iFileMin:iFileMax]
          print process.source
          
       cfgFile = open(jobDir+'/run_cfg.py','w')
       cfgFile.write(process.dumpPython())
       cfgFile.close()
Exemple #9
0
    def handleSeeding(self):
        """
        _handleSeeding_

        Handle Random Seed settings for the job
        """
        baggage = self.job.getBaggage()
        seeding = getattr(baggage, "seeding", None)
        if seeding == "ReproducibleSeeding":
            randService = self.process.RandomNumberGeneratorService
            tweak = PSetTweak()
            for x in randService:
                parameter = "process.RandomNumberGeneratorService.%s.initialSeed" % x._internal_name
                tweak.addParameter(parameter, x.initialSeed)
            applyTweak(self.process, tweak, self.fixupDict)
        else:
            if hasattr(self.process, "RandomNumberGeneratorService"):
                from IOMC.RandomEngine.RandomServiceHelper import RandomNumberServiceHelper
                helper = RandomNumberServiceHelper(self.process.RandomNumberGeneratorService)
                helper.populate()
        return
Exemple #10
0
def customise_for_gc(process):
    import FWCore.ParameterSet.Config as cms
    from IOMC.RandomEngine.RandomServiceHelper import RandomNumberServiceHelper

    try:
        maxevents = int(__MAX_EVENTS__)
        process.maxEvents = cms.untracked.PSet(
            input=cms.untracked.int32(max(-1, maxevents)))
    except Exception:
        pass

    # Dataset related setup
    try:
        primaryFiles = [__FILE_NAMES__]
        process.source = cms.Source(
            'PoolSource',
            skipEvents=cms.untracked.uint32(__SKIP_EVENTS__),
            fileNames=cms.untracked.vstring(primaryFiles))
        try:
            secondaryFiles = [__FILE_NAMES2__]
            process.source.secondaryFileNames = cms.untracked.vstring(
                secondaryFiles)
        except Exception:
            pass
        try:
            lumirange = [__LUMI_RANGE__]
            if len(lumirange) > 0:
                process.source.lumisToProcess = cms.untracked.VLuminosityBlockRange(
                    lumirange)
                process.maxEvents = cms.untracked.PSet(
                    input=cms.untracked.int32(-1))
        except Exception:
            pass
    except Exception:
        pass

    if hasattr(process, 'RandomNumberGeneratorService'):
        randSvc = RandomNumberServiceHelper(
            process.RandomNumberGeneratorService)
        randSvc.populate()

    process.AdaptorConfig = cms.Service(
        'AdaptorConfig',
        enable=cms.untracked.bool(True),
        stats=cms.untracked.bool(True),
    )

    # Generator related setup
    try:
        if hasattr(process,
                   'generator') and process.source.type_() != 'PoolSource':
            process.source.firstLuminosityBlock = cms.untracked.uint32(
                1 + __GC_JOB_ID__)
            print('Generator random seed: %s' %
                  process.RandomNumberGeneratorService.generator.initialSeed)
    except Exception:
        pass

    # Print GlobalTag for DBS3 registration - output is taken from edmConfigHash
    try:
        print('globaltag:%s' % process.GlobalTag.globaltag.value())
    except Exception:
        pass
    return (process)
Exemple #11
0
def randomizeSeeds(process):
    from IOMC.RandomEngine.RandomServiceHelper import RandomNumberServiceHelper
    rndSvc = RandomNumberServiceHelper(process.RandomNumberGeneratorService)
    rndSvc.populate()
    return process
def customise(process):
	if hasattr(process, "RandomNumberGeneratorService"):
		randSvc = RandomNumberServiceHelper(process.RandomNumberGeneratorService)
		randSvc.populate()
	
	process._Process__name="SELECTION"
	process.LoadAllDictionaries = cms.Service("LoadAllDictionaries")
	process.options   = cms.untracked.PSet( wantSummary = cms.untracked.bool(True) )
	#process.Tracer = cms.Service("Tracer")
	
	process.TFileService = cms.Service("TFileService", 
		fileName = cms.string("histo.root"),
		closeFileFast = cms.untracked.bool(True)
	)
	
	process.load("ElectroWeakAnalysis.ZReco.dimuons_SkimPaths_cff")
	#process.load("ElectroWeakAnalysis.Skimming.dimuons_SkimPaths_cff")
	process.schedule.insert(len(process.schedule)-1,process.dimuonsPath)
	
	# Output module configuration
	#process.load("ElectroWeakAnalysis.Skimming.dimuonsOutputModule_cfi")
	
	process.load("TrackingTools.TrackAssociator.default_cfi")
	
	process.selectMuons = cms.EDProducer('SelectReplacementCandidates',
		process.TrackAssociatorParameterBlock,
		muonInputTag = cms.InputTag("muons")
	)

	process.prepareMuonsPath = cms.Path(process.selectMuons)
	process.schedule.insert(len(process.schedule)-1,process.prepareMuonsPath)
	process.load("Configuration.StandardSequences.SimulationRandomNumberGeneratorSeeds_cff")
	process.RandomNumberGeneratorService.newSource = cms.PSet(
		initialSeed = cms.untracked.uint32(12345),
		engineName = cms.untracked.string('HepJamesRandom')
	)                                                                                               
	process.load("IOMC/RandomEngine/IOMC_cff")
	
	process.load("Configuration.StandardSequences.SimulationRandomNumberGeneratorSeeds_cff")
	process.RandomNumberGeneratorService.newSource = cms.PSet(
		      initialSeed = cms.untracked.uint32(12345),
		      engineName = cms.untracked.string('HepJamesRandom')
	) 
	process.RandomNumberGeneratorService.theSource = cms.PSet(
		      initialSeed = cms.untracked.uint32(12345),
		      engineName = cms.untracked.string('HepJamesRandom')
	)
			    
	process.newSource = cms.EDProducer("MCParticleReplacer",
    src                = cms.InputTag("muons"),
    beamSpotSrc        = cms.InputTag("dummy"),
    primaryVertexLabel = cms.InputTag("dummy"),
    hepMcSrc           = cms.InputTag("generator"),

    algorithm = cms.string("ZTauTau"), # "ParticleGun", "ZTauTau", "CommissioningGun"
    hepMcMode = cms.string("new"),         # "new" for new HepMCProduct with taus and decay products,
                                           # "replace" for replacing muons in the existing HepMCProcuct
                                           # commissioning
    verbose = cms.bool(False),

                CommissioningGun = cms.PSet(
                        maxMuonEta = cms.double(2.1),
                        minMuonPt = cms.double(5.)
                ),


    ZTauTau = cms.PSet(
		    TauolaOptions = cms.PSet(
		  		TauolaPolar,
		  		InputCards = cms.PSet
					(
					    pjak1 = cms.int32(0),
		    			pjak2 = cms.int32(0),
					    mdtau = cms.int32(102)
		 			)
		 		),
        filterEfficiency = cms.untracked.double(1.0),
        pythiaHepMCVerbosity = cms.untracked.bool(False),
        generatorMode = cms.string("Tauola"),  # "Tauola", "Pythia" (not implemented yet)
        
    )
	)
	
	
	process.insertNewSourcePath = cms.Path(process.newSource)
	process.schedule.insert(len(process.schedule)-1,process.insertNewSourcePath)
                                              
	process.options = cms.untracked.PSet( SkipEvent = cms.untracked.vstring('ProductNotFound') )

	if runOnTheGrid:
		process.source.fileNames=cms.untracked.vstring(__FILE_NAMES__)
		process.source.skipEvents=cms.untracked.uint32(__SKIP_EVENTS__)
		process.maxEvents.input = cms.untracked.int32(__MAX_EVENTS__)
		process.output.fileName=cms.untracked.string("output.root")

	process.filterNumHepMCEvents = cms.EDFilter('EmptyEventsFilter',
		minEvents=cms.untracked.int32(2),
		target=cms.untracked.int32(1)
	)		
	process.filterNumHepMCEventsPath = cms.Path(process.filterNumHepMCEvents)
	process.schedule.insert(len(process.schedule)-1,process.filterNumHepMCEventsPath)
		
	process.output.SelectEvents = cms.untracked.PSet(SelectEvents = cms.vstring('filterNumHepMCEventsPath'))	
	process.output.outputCommands = cms.untracked.vstring(
                "drop *_*_*_*",
								"keep edmHepMCProduct_*_*_*",
                "keep CaloTowersSorted_*_*_*",
                "keep recoMuons_*_*_*",
                "keep recoCaloMETs_met_*_*",
                "keep *_overlay_*_*",
                "keep *_selectMuons_*_*",
                "keep *_selectMuonsForMuonMuonReplacement_*_*",                
                "keep EBDigiCollection_*_*_*",
                "keep EEDigiCollection_*_*_*",
                "keep ESDataFramesSorted_*_*_*",
                "keep DTLayerIdDTDigiMuonDigiCollection_*_*_*",
                "keep CSCDetIdCSCStripDigiMuonDigiCollection_*_*_*",
                "keep CSCDetIdCSCWireDigiMuonDigiCollection_*_*_*",
                "keep CSCDetIdCSCComparatorDigiMuonDigiCollection_*_*_*",
                "keep RPCDetIdRPCDigiMuonDigiCollection_*_*_*",
                "keep HBHEDataFramesSorted_*_*_*",
                "keep HFDataFramesSorted_*_*_*",
                "keep HODataFramesSorted_*_*_*",
                "keep *_hcalDigis_*_*",
                "keep SiStripDigiedmDetSetVector_*_*_*",
                "keep PixelDigiedmDetSetVector_*_*_*"
        )
	#print process.schedule
	print process.dumpPython()
	return(process)
def randomizeSeeds(process):
    from IOMC.RandomEngine.RandomServiceHelper import RandomNumberServiceHelper
    rndSvc=RandomNumberServiceHelper(process.RandomNumberGeneratorService)
    rndSvc.populate()
    return process
Exemple #14
0
def main(argv):
    """
    writeCfg

    - Read in existing, user supplied pycfg or pickled pycfg file
    - Modify job specific parameters based on environment variables and arguments.xml
    - Write out pickled pycfg file

    required parameters: none

    optional parameters:
    --help             :       help
    --debug            :       debug statements

    """

    # defaults
    inputFileNames = None
    parentFileNames = None
    debug = False
    _MAXINT = 900000000

    try:
        opts, args = getopt.getopt(argv, "", ["debug", "help"])
    except getopt.GetoptError:
        print main.__doc__
        sys.exit(2)

    try:
        CMSSW = os.environ['CMSSW_VERSION']
        parts = CMSSW.split('_')
        CMSSW_major = int(parts[1])
        CMSSW_minor = int(parts[2])
        CMSSW_patch = int(parts[3])
    except (KeyError, ValueError):
        msg = "Your environment doesn't specify the CMSSW version or specifies it incorrectly"
        raise ConfigException(msg)

    # Parse command line options
    for opt, arg in opts:
        if opt == "--help":
            print main.__doc__
            sys.exit()
        elif opt == "--debug":
            debug = True

    # Parse remaining parameters
    try:
        fileName = args[0]
        outFileName = args[1]
    except IndexError:
        print main.__doc__
        sys.exit()

# Read in Environment, XML and get optional Parameters

    nJob = int(os.environ.get('NJob', '0'))
    preserveSeeds = os.environ.get('PreserveSeeds', '')
    incrementSeeds = os.environ.get('IncrementSeeds', '')

    # Defaults

    maxEvents = 0
    skipEvents = 0
    firstEvent = -1
    compHEPFirstEvent = 0
    firstRun = 0
    # FUTURE: Remove firstRun
    firstLumi = 0

    dom = xml.dom.minidom.parse(os.environ['RUNTIME_AREA'] + '/arguments.xml')

    for elem in dom.getElementsByTagName("Job"):
        if nJob == int(elem.getAttribute("JobID")):
            if elem.getAttribute("MaxEvents"):
                maxEvents = int(elem.getAttribute("MaxEvents"))
            if elem.getAttribute("SkipEvents"):
                skipEvents = int(elem.getAttribute("SkipEvents"))
            if elem.getAttribute("FirstEvent"):
                firstEvent = int(elem.getAttribute("FirstEvent"))
            if elem.getAttribute("FirstRun"):
                firstRun = int(elem.getAttribute("FirstRun"))
            if elem.getAttribute("FirstLumi"):
                firstLumi = int(elem.getAttribute("FirstLumi"))

            generator = str(elem.getAttribute('Generator'))
            inputFiles = str(elem.getAttribute('InputFiles'))
            parentFiles = str(elem.getAttribute('ParentFiles'))
            lumis = str(elem.getAttribute('Lumis'))

# Read Input python config file

    handle = open(fileName, 'r')
    try:  # Nested form for Python < 2.5
        try:
            print "Importing .py file"
            cfo = imp.load_source("pycfg", fileName, handle)
            cmsProcess = cfo.process
        except Exception, ex:
            msg = "Your pycfg file is not valid python: %s" % str(ex)
            raise ConfigException(msg)
    finally:
        handle.close()

    cfg = CfgInterface(cmsProcess)

    # Set parameters for job
    print "Setting parameters"
    inModule = cfg.inputSource
    if maxEvents:
        cfg.maxEvents.setMaxEventsInput(maxEvents)

    if skipEvents:
        inModule.setSkipEvents(skipEvents)

    # Set "skip events" for various generators
    if generator == 'comphep':
        cmsProcess.source.CompHEPFirstEvent = CfgTypes.int32(firstEvent)
    elif generator == 'lhe':
        cmsProcess.source.skipEvents = CfgTypes.untracked(
            CfgTypes.uint32(firstEvent))
        cmsProcess.source.firstEvent = CfgTypes.untracked(
            CfgTypes.uint32(firstEvent + 1))
    elif firstEvent != -1:  # (Old? Madgraph)
        cmsProcess.source.firstEvent = CfgTypes.untracked(
            CfgTypes.uint32(firstEvent))

    if inputFiles:
        inputFileNames = inputFiles.split(',')
        inModule.setFileNames(*inputFileNames)

    # handle parent files if needed
    if parentFiles:
        parentFileNames = parentFiles.split(',')
        inModule.setSecondaryFileNames(*parentFileNames)

    if lumis:
        if CMSSW_major < 3:  # FUTURE: Can remove this check
            print "Cannot skip lumis for CMSSW 2_x"
        else:
            lumiRanges = lumis.split(',')
            inModule.setLumisToProcess(*lumiRanges)

    # Pythia parameters
    if (firstRun):
        inModule.setFirstRun(firstRun)
    if (firstLumi):
        inModule.setFirstLumi(firstLumi)

    # Check if there are random #'s to deal with
    if cfg.data.services.has_key('RandomNumberGeneratorService'):
        print "RandomNumberGeneratorService found, will attempt to change seeds"
        from IOMC.RandomEngine.RandomServiceHelper import RandomNumberServiceHelper
        ranGenerator = cfg.data.services['RandomNumberGeneratorService']
        randSvc = RandomNumberServiceHelper(ranGenerator)

        incrementSeedList = []
        preserveSeedList = []

        if incrementSeeds:
            incrementSeedList = incrementSeeds.split(',')
        if preserveSeeds:
            preserveSeedList = preserveSeeds.split(',')

        # Increment requested seed sets
        for seedName in incrementSeedList:
            curSeeds = randSvc.getNamedSeed(seedName)
            newSeeds = [x + nJob for x in curSeeds]
            randSvc.setNamedSeed(seedName, *newSeeds)
            preserveSeedList.append(seedName)

        # Randomize remaining seeds
        randSvc.populate(*preserveSeedList)

    # Write out new config file
    outFile = open(outFileName, "w")
    outFile.write("import FWCore.ParameterSet.Config as cms\n")
    outFile.write("import pickle\n")
    outFile.write("pickledCfg=\"\"\"%s\"\"\"\n" % pickle.dumps(cmsProcess))
    outFile.write("process = pickle.loads(pickledCfg)\n")
    outFile.close()
    if (debug):
        print "writeCfg output (May not be exact):"
        print "import FWCore.ParameterSet.Config as cms"
        print cmsProcess.dumpPython()
Exemple #15
0
ivars.eventNumber = 1

ivars.outputFile = 'Hydjet_Quenched_MinBias_2760GeV_RAW_test.root'

ivars.parseArguments()

#################################################################################
# Random seed
#

process.load(
    'Configuration/StandardSequences/SimulationRandomNumberGeneratorSeeds_cff')
from IOMC.RandomEngine.RandomServiceHelper import RandomNumberServiceHelper
randSvc = RandomNumberServiceHelper(process.RandomNumberGeneratorService)
randSvc.populate()

########################################################################################
# Timing and memory services
#

process.Timing = cms.Service("Timing")

# Input source
process.source = cms.Source("EmptySource",
                            firstEvent=cms.untracked.uint32(ivars.eventNumber),
                            firstRun=cms.untracked.uint32(146421))

# Input source
process.source = cms.Source("EmptySource", )
Exemple #16
0
def customise(process):
    if hasattr(process, "RandomNumberGeneratorService"):
        randSvc = RandomNumberServiceHelper(
            process.RandomNumberGeneratorService)
        randSvc.populate()

    process._Process__name = "SELECTION"
    process.LoadAllDictionaries = cms.Service("LoadAllDictionaries")
    process.options = cms.untracked.PSet(wantSummary=cms.untracked.bool(True))
    #process.Tracer = cms.Service("Tracer")

    process.TFileService = cms.Service("TFileService",
                                       fileName=cms.string("histo.root"),
                                       closeFileFast=cms.untracked.bool(True))

    process.load("ElectroWeakAnalysis.ZReco.dimuons_SkimPaths_cff")
    #process.load("ElectroWeakAnalysis.Skimming.dimuons_SkimPaths_cff")
    process.schedule.insert(len(process.schedule) - 1, process.dimuonsPath)

    # Output module configuration
    #process.load("ElectroWeakAnalysis.Skimming.dimuonsOutputModule_cfi")

    process.load("TrackingTools.TrackAssociator.default_cfi")

    process.selectMuons = cms.EDProducer('SelectReplacementCandidates',
                                         process.TrackAssociatorParameterBlock,
                                         muonInputTag=cms.InputTag("muons"))

    process.prepareMuonsPath = cms.Path(process.selectMuons)
    process.schedule.insert(
        len(process.schedule) - 1, process.prepareMuonsPath)
    process.load(
        "Configuration.StandardSequences.SimulationRandomNumberGeneratorSeeds_cff"
    )
    process.RandomNumberGeneratorService.newSource = cms.PSet(
        initialSeed=cms.untracked.uint32(12345),
        engineName=cms.untracked.string('HepJamesRandom'))
    process.load("IOMC/RandomEngine/IOMC_cff")

    process.load(
        "Configuration.StandardSequences.SimulationRandomNumberGeneratorSeeds_cff"
    )
    process.RandomNumberGeneratorService.newSource = cms.PSet(
        initialSeed=cms.untracked.uint32(12345),
        engineName=cms.untracked.string('HepJamesRandom'))
    process.RandomNumberGeneratorService.theSource = cms.PSet(
        initialSeed=cms.untracked.uint32(12345),
        engineName=cms.untracked.string('HepJamesRandom'))

    process.newSource = cms.EDProducer(
        "MCParticleReplacer",
        src=cms.InputTag("muons"),
        beamSpotSrc=cms.InputTag("dummy"),
        primaryVertexLabel=cms.InputTag("dummy"),
        hepMcSrc=cms.InputTag("generator"),
        algorithm=cms.string(
            "ZTauTau"),  # "ParticleGun", "ZTauTau", "CommissioningGun"
        hepMcMode=cms.string(
            "new"),  # "new" for new HepMCProduct with taus and decay products,
        # "replace" for replacing muons in the existing HepMCProcuct
        # commissioning
        verbose=cms.bool(False),
        CommissioningGun=cms.PSet(maxMuonEta=cms.double(2.1),
                                  minMuonPt=cms.double(5.)),
        ZTauTau=cms.PSet(
            TauolaOptions=cms.PSet(TauolaPolar,
                                   InputCards=cms.PSet(pjak1=cms.int32(0),
                                                       pjak2=cms.int32(0),
                                                       mdtau=cms.int32(102))),
            filterEfficiency=cms.untracked.double(1.0),
            pythiaHepMCVerbosity=cms.untracked.bool(False),
            generatorMode=cms.string(
                "Tauola"),  # "Tauola", "Pythia" (not implemented yet)
        ))

    process.insertNewSourcePath = cms.Path(process.newSource)
    process.schedule.insert(
        len(process.schedule) - 1, process.insertNewSourcePath)

    process.options = cms.untracked.PSet(
        SkipEvent=cms.untracked.vstring('ProductNotFound'))

    if runOnTheGrid:
        process.source.fileNames = cms.untracked.vstring(__FILE_NAMES__)
        process.source.skipEvents = cms.untracked.uint32(__SKIP_EVENTS__)
        process.maxEvents.input = cms.untracked.int32(__MAX_EVENTS__)
        process.output.fileName = cms.untracked.string("output.root")

    process.filterNumHepMCEvents = cms.EDFilter(
        'EmptyEventsFilter',
        minEvents=cms.untracked.int32(2),
        target=cms.untracked.int32(1))
    process.filterNumHepMCEventsPath = cms.Path(process.filterNumHepMCEvents)
    process.schedule.insert(
        len(process.schedule) - 1, process.filterNumHepMCEventsPath)

    process.output.SelectEvents = cms.untracked.PSet(
        SelectEvents=cms.vstring('filterNumHepMCEventsPath'))
    process.output.outputCommands = cms.untracked.vstring(
        "drop *_*_*_*", "keep edmHepMCProduct_*_*_*",
        "keep CaloTowersSorted_*_*_*", "keep recoMuons_*_*_*",
        "keep recoCaloMETs_met_*_*", "keep *_overlay_*_*",
        "keep *_selectMuons_*_*",
        "keep *_selectMuonsForMuonMuonReplacement_*_*",
        "keep EBDigiCollection_*_*_*", "keep EEDigiCollection_*_*_*",
        "keep ESDataFramesSorted_*_*_*",
        "keep DTLayerIdDTDigiMuonDigiCollection_*_*_*",
        "keep CSCDetIdCSCStripDigiMuonDigiCollection_*_*_*",
        "keep CSCDetIdCSCWireDigiMuonDigiCollection_*_*_*",
        "keep CSCDetIdCSCComparatorDigiMuonDigiCollection_*_*_*",
        "keep RPCDetIdRPCDigiMuonDigiCollection_*_*_*",
        "keep HBHEDataFramesSorted_*_*_*", "keep HFDataFramesSorted_*_*_*",
        "keep HODataFramesSorted_*_*_*", "keep *_hcalDigis_*_*",
        "keep SiStripDigiedmDetSetVector_*_*_*",
        "keep PixelDigiedmDetSetVector_*_*_*")
    #print process.schedule
    print process.dumpPython()
    return (process)
#process.RandomNumberGeneratorService.VtxSmeared.engineName = cms.untracked.string('TRandom3')
#process.RandomNumberGeneratorService.g4SimHits.engineName = cms.untracked.string('TRandom3')
#process.RandomNumberGeneratorService.mix.engineName = cms.untracked.string('TRandom3')
#process.RandomNumberGeneratorService.LHCTransport.engineName = cms.untracked.string('TRandom3')
#process.RandomNumberGeneratorService.simSiPixelDigis.engineName = cms.untracked.string('TRandom3')

process.RandomNumberGeneratorService.generator.initialSeed = theSeedValue+111211
process.RandomNumberGeneratorService.VtxSmeared.initialSeed=theSeedValue+22222
process.RandomNumberGeneratorService.g4SimHits.initialSeed=theSeedValue+33333
process.RandomNumberGeneratorService.mix.initialSeed=theSeedValue+33333
process.RandomNumberGeneratorService.LHCTransport.initialSeed=theSeedValue+33333
process.RandomNumberGeneratorService.simSiPixelDigis.initialSeed=theSeedValue+33333

from IOMC.RandomEngine.RandomServiceHelper import  RandomNumberServiceHelper
randHelper = RandomNumberServiceHelper(process.RandomNumberGeneratorService)
randHelper.populate()

# muon specific ----------------------------------------------------------------
process.load("Geometry.DTGeometry.dtGeometry_cfi")
process.load("Geometry.MuonNumbering.muonNumberingInitialization_cfi")
process.load("SimMuon/DTDigitizer/muonDTDigis_cfi")

# tracker specific -------------------------------------------------------------
# replace with long barrel geometry
#MOVED UPSTAIRS sep = '1'
if os.getenv('pgun_sep'):
   sep= str(os.getenv('pgun_sep'))
print 'Stack Separation: '+sep

process.siPixelFakeGainOfflineESSource = cms.ESSource("SiPixelFakeGainOfflineESSource",
        file = cms.FileInPath('SLHCUpgradeSimulations/Geometry/data/longbarrel/PixelSkimmedGeometry_empty.txt'))
Exemple #18
0
def main(argv) :
    """
    writeCfg

    - Read in existing, user supplied pycfg or pickled pycfg file
    - Modify job specific parameters based on environment variables and arguments.xml
    - Write out pickled pycfg file

    required parameters: none

    optional parameters:
    --help             :       help
    --debug            :       debug statements

    """

    # defaults
    inputFileNames  = None
    parentFileNames = None
    debug           = False
    _MAXINT         = 900000000

    try:
        opts, args = getopt.getopt(argv, "", ["debug", "help"])
    except getopt.GetoptError:
        print main.__doc__
        sys.exit(2)

    try:
        CMSSW  = os.environ['CMSSW_VERSION']
        parts = CMSSW.split('_')
        CMSSW_major = int(parts[1])
        CMSSW_minor = int(parts[2])
    except (KeyError, ValueError):
        msg = "Your environment doesn't specify the CMSSW version or specifies it incorrectly"
        raise ConfigException(msg)

    # Parse command line options
    for opt, arg in opts :
        if opt  == "--help" :
            print main.__doc__
            sys.exit()
        elif opt == "--debug" :
            debug = True

    # Parse remaining parameters
    try:
        fileName    = args[0]
        outFileName = args[1]
    except IndexError:
        print main.__doc__
        sys.exit()

  # Read in Environment, XML and get optional Parameters

    nJob       = int(os.environ.get('NJob',      '0'))
    preserveSeeds  = os.environ.get('PreserveSeeds','')
    incrementSeeds = os.environ.get('IncrementSeeds','')

  # Defaults

    maxEvents  = 0
    skipEvents = 0
    firstEvent = -1
    compHEPFirstEvent = 0
    firstRun   = 0
    # FUTURE: Remove firstRun
    firstLumi  = 0

    dom = xml.dom.minidom.parse(os.environ['RUNTIME_AREA']+'/arguments.xml')

    for elem in dom.getElementsByTagName("Job"):
        if nJob == int(elem.getAttribute("JobID")):
            if elem.getAttribute("MaxEvents"):
                maxEvents = int(elem.getAttribute("MaxEvents"))
            if elem.getAttribute("SkipEvents"):
                skipEvents = int(elem.getAttribute("SkipEvents"))
            if elem.getAttribute("FirstEvent"):
                firstEvent = int(elem.getAttribute("FirstEvent"))
            if elem.getAttribute("FirstRun"):
                firstRun = int(elem.getAttribute("FirstRun"))
            if elem.getAttribute("FirstLumi"):
                firstLumi = int(elem.getAttribute("FirstLumi"))

            generator      = str(elem.getAttribute('Generator'))
            inputBlocks    = str(elem.getAttribute('InputBlocks'))
            inputFiles     = str(elem.getAttribute('InputFiles'))
            parentFiles    = str(elem.getAttribute('ParentFiles'))
            lumis          = str(elem.getAttribute('Lumis'))

    report(inputBlocks,inputFiles,parentFiles,lumis)

  # Read Input python config file

    handle = open(fileName, 'r')
    try:   # Nested form for Python < 2.5
        try:
            print "Importing .py file"
            cfo = imp.load_source("pycfg", fileName, handle)
            cmsProcess = cfo.process
        except Exception, ex:
            msg = "Your pycfg file is not valid python: %s" % str(ex)
            raise ConfigException(msg)
    finally:
        handle.close()

    cfg = CfgInterface(cmsProcess)

    # Set parameters for job
    print "Setting parameters"
    inModule = cfg.inputSource
    if maxEvents:
        cfg.maxEvents.setMaxEventsInput(maxEvents)

    if skipEvents and inModule.sourceType not in ['EmptySource']:
        inModule.setSkipEvents(skipEvents)

    # Set "skip events" for various generators
    if generator == 'comphep':
        cmsProcess.source.CompHEPFirstEvent = CfgTypes.int32(firstEvent)
    elif generator == 'lhe':
        cmsProcess.source.skipEvents = CfgTypes.untracked(CfgTypes.uint32(firstEvent))
        cmsProcess.source.firstEvent = CfgTypes.untracked(CfgTypes.uint32(firstEvent+1))
    elif firstEvent != -1: # (Old? Madgraph)
        cmsProcess.source.firstEvent = CfgTypes.untracked(CfgTypes.uint32(firstEvent))

    if inputFiles:
        inputFileNames = inputFiles.split(',')
        inModule.setFileNames(*inputFileNames)

    # handle parent files if needed
    if parentFiles:
        parentFileNames = parentFiles.split(',')
        inModule.setSecondaryFileNames(*parentFileNames)

    if lumis:
        if CMSSW_major < 3: # FUTURE: Can remove this check
            print "Cannot skip lumis for CMSSW 2_x"
        else:
            lumiRanges = lumis.split(',')
            inModule.setLumisToProcess(*lumiRanges)

    # Pythia parameters
    if (firstRun):
        inModule.setFirstRun(firstRun)
    if (firstLumi):
        inModule.setFirstLumi(firstLumi)

    # Check if there are random #'s to deal with
    if cfg.data.services.has_key('RandomNumberGeneratorService'):
        print "RandomNumberGeneratorService found, will attempt to change seeds"
        from IOMC.RandomEngine.RandomServiceHelper import RandomNumberServiceHelper
        ranGenerator = cfg.data.services['RandomNumberGeneratorService']

        ranModules   = getattr(ranGenerator, "moduleSeeds", None)
        oldSource    = getattr(ranGenerator, "sourceSeed",  None)
        if ranModules != None or oldSource != None:
            msg = "Your random number seeds are set in an old,\n"
            msg += "deprecated style. Please change to new style:\n"
            msg += "https://twiki.cern.ch/twiki/bin/view/CMS/SWGuideEDMRandomNumberGeneratorService"
            raise ConfigException(msg)

        randSvc = RandomNumberServiceHelper(ranGenerator)

        incrementSeedList = []
        preserveSeedList  = []

        if incrementSeeds:
            incrementSeedList = incrementSeeds.split(',')
        if preserveSeeds:
            preserveSeedList  = preserveSeeds.split(',')

        # Increment requested seed sets
        for seedName in incrementSeedList:
            curSeeds = randSvc.getNamedSeed(seedName)
            newSeeds = [x+nJob for x in curSeeds]
            randSvc.setNamedSeed(seedName, *newSeeds)
            preserveSeedList.append(seedName)

        # Randomize remaining seeds
        randSvc.populate(*preserveSeedList)

    # Write out new config file
    pklFileName = outFileName + '.pkl'
    outFile = open(outFileName,"w")
    outFile.write("import FWCore.ParameterSet.Config as cms\n")
    outFile.write("import pickle\n")
    outFile.write("process = pickle.load(open('%s', 'rb'))\n" % pklFileName)
    outFile.close()

    pklFile = open(pklFileName,"wb")
    myPickle = pickle.Pickler(pklFile)
    myPickle.dump(cmsProcess)
    pklFile.close()

    if (debug):
        print "writeCfg output (May not be exact):"
        print "import FWCore.ParameterSet.Config as cms"
        print cmsProcess.dumpPython()
Exemple #19
0
                                process.genfiltersummary_step,
                                process.endjob_step, process.RAWSIMoutput_step,
                                process.LHEoutput_step)
from PhysicsTools.PatAlgos.tools.helpers import associatePatAlgosToolsTask
associatePatAlgosToolsTask(process)

#Setup FWK for multithreaded
process.options.numberOfThreads = cms.untracked.uint32(nThreads)
process.options.numberOfStreams = cms.untracked.uint32(0)
# filter all path with the production filter sequence
for path in process.paths:
    if path in ['lhe_step']: continue
    getattr(process, path).insert(0, process.generator)

# customisation of the process.

# Automatic addition of the customisation function from Configuration.DataProcessing.Utils
from Configuration.DataProcessing.Utils import addMonitoring
process = addMonitoring(process)

# End of customisation functions

# Customisation from command line
randSvc = RandomNumberServiceHelper(process.RandomNumberGeneratorService)
randSvc.populate()  # set random number each cmsRun

# Add early deletion of temporary data products to reduce peak memory need
from Configuration.StandardSequences.earlyDeleteSettings_cff import customiseEarlyDelete
process = customiseEarlyDelete(process)
# End adding early deletion
def main(argv):
    """
    writeCfg

    - Read in existing, user supplied pycfg or pickled pycfg file
    - Modify job specific parameters based on environment variables and arguments.xml
    - Write out pickled pycfg file

    required parameters: none

    optional parameters:
    --help             :       help
    --debug            :       debug statements

    """

    # defaults
    inputFileNames = None
    parentFileNames = None
    debug = False
    _MAXINT = 900000000

    try:
        opts, args = getopt.getopt(argv, "", ["debug", "help"])
    except getopt.GetoptError:
        print main.__doc__
        sys.exit(2)

    try:
        CMSSW = os.environ["CMSSW_VERSION"]
        parts = CMSSW.split("_")
        CMSSW_major = int(parts[1])
        CMSSW_minor = int(parts[2])
        CMSSW_patch = int(parts[3])
    except (KeyError, ValueError):
        msg = "Your environment doesn't specify the CMSSW version or specifies it incorrectly"
        raise ConfigException(msg)

    # Parse command line options
    for opt, arg in opts:
        if opt == "--help":
            print main.__doc__
            sys.exit()
        elif opt == "--debug":
            debug = True

    # Parse remaining parameters
    try:
        fileName = args[0]
        outFileName = args[1]
    except IndexError:
        print main.__doc__
        sys.exit()

    # Read in Environment, XML and get optional Parameters

    nJob = int(os.environ.get("NJob", "0"))
    preserveSeeds = os.environ.get("PreserveSeeds", "")
    incrementSeeds = os.environ.get("IncrementSeeds", "")

    # Defaults

    maxEvents = 0
    skipEvents = 0
    firstEvent = -1
    compHEPFirstEvent = 0
    firstRun = 0
    # FUTURE: Remove firstRun
    firstLumi = 0

    dom = xml.dom.minidom.parse(os.environ["RUNTIME_AREA"] + "/arguments.xml")

    for elem in dom.getElementsByTagName("Job"):
        if nJob == int(elem.getAttribute("JobID")):
            if elem.getAttribute("MaxEvents"):
                maxEvents = int(elem.getAttribute("MaxEvents"))
            if elem.getAttribute("SkipEvents"):
                skipEvents = int(elem.getAttribute("SkipEvents"))
            if elem.getAttribute("FirstEvent"):
                firstEvent = int(elem.getAttribute("FirstEvent"))
            if elem.getAttribute("FirstRun"):
                firstRun = int(elem.getAttribute("FirstRun"))
            if elem.getAttribute("FirstLumi"):
                firstLumi = int(elem.getAttribute("FirstLumi"))

            generator = str(elem.getAttribute("Generator"))
            inputFiles = str(elem.getAttribute("InputFiles"))
            parentFiles = str(elem.getAttribute("ParentFiles"))
            lumis = str(elem.getAttribute("Lumis"))

    # Read Input python config file

    handle = open(fileName, "r")
    try:  # Nested form for Python < 2.5
        try:
            print "Importing .py file"
            cfo = imp.load_source("pycfg", fileName, handle)
            cmsProcess = cfo.process
        except Exception, ex:
            msg = "Your pycfg file is not valid python: %s" % str(ex)
            raise ConfigException(msg)
    finally:
        handle.close()

    cfg = CfgInterface(cmsProcess)

    # Set parameters for job
    print "Setting parameters"
    inModule = cfg.inputSource
    if maxEvents:
        cfg.maxEvents.setMaxEventsInput(maxEvents)

    if skipEvents:
        inModule.setSkipEvents(skipEvents)

    # Set "skip events" for various generators
    if generator == "comphep":
        cmsProcess.source.CompHEPFirstEvent = CfgTypes.int32(firstEvent)
    elif generator == "lhe":
        cmsProcess.source.skipEvents = CfgTypes.untracked(CfgTypes.uint32(firstEvent))
        cmsProcess.source.firstEvent = CfgTypes.untracked(CfgTypes.uint32(firstEvent + 1))
    elif firstEvent != -1:  # (Old? Madgraph)
        cmsProcess.source.firstEvent = CfgTypes.untracked(CfgTypes.uint32(firstEvent))

    if inputFiles:
        inputFileNames = inputFiles.split(",")
        inModule.setFileNames(*inputFileNames)

    # handle parent files if needed
    if parentFiles:
        parentFileNames = parentFiles.split(",")
        inModule.setSecondaryFileNames(*parentFileNames)

    if lumis:
        if CMSSW_major < 3:  # FUTURE: Can remove this check
            print "Cannot skip lumis for CMSSW 2_x"
        else:
            lumiRanges = lumis.split(",")
            inModule.setLumisToProcess(*lumiRanges)

    # Pythia parameters
    if firstRun:
        inModule.setFirstRun(firstRun)
    if firstLumi:
        inModule.setFirstLumi(firstLumi)

    # Check if there are random #'s to deal with
    if cfg.data.services.has_key("RandomNumberGeneratorService"):
        print "RandomNumberGeneratorService found, will attempt to change seeds"
        from IOMC.RandomEngine.RandomServiceHelper import RandomNumberServiceHelper

        ranGenerator = cfg.data.services["RandomNumberGeneratorService"]
        randSvc = RandomNumberServiceHelper(ranGenerator)

        incrementSeedList = []
        preserveSeedList = []

        if incrementSeeds:
            incrementSeedList = incrementSeeds.split(",")
        if preserveSeeds:
            preserveSeedList = preserveSeeds.split(",")

        # Increment requested seed sets
        for seedName in incrementSeedList:
            curSeeds = randSvc.getNamedSeed(seedName)
            newSeeds = [x + nJob for x in curSeeds]
            randSvc.setNamedSeed(seedName, *newSeeds)
            preserveSeedList.append(seedName)

        # Randomize remaining seeds
        randSvc.populate(*preserveSeedList)

    # Write out new config file
    outFile = open(outFileName, "w")
    outFile.write("import FWCore.ParameterSet.Config as cms\n")
    outFile.write("import pickle\n")
    outFile.write('pickledCfg="""%s"""\n' % pickle.dumps(cmsProcess))
    outFile.write("process = pickle.loads(pickledCfg)\n")
    outFile.close()
    if debug:
        print "writeCfg output (May not be exact):"
        print "import FWCore.ParameterSet.Config as cms"
        print cmsProcess.dumpPython()
            'customProcesses', 
            'pythiaPromptPhotons', 
            'kinematics'),
        kinematics = cms.vstring('CKIN(3)=15', 
            'CKIN(4)=9999', 
            'CKIN(7)=-3.', 
            'CKIN(8)=3.')
    )
)
process.ProductionFilterSequence = cms.Sequence(process.hiSignal)


process.load('Configuration/StandardSequences/SimulationRandomNumberGeneratorSeeds_cff')
from IOMC.RandomEngine.RandomServiceHelper import RandomNumberServiceHelper
randSvc = RandomNumberServiceHelper(process.RandomNumberGeneratorService)
randSvc.populate()

# Path and EndPath definitions
process.generation_step = cms.Path(process.pgen_himix)
process.simulation_step = cms.Path(process.psim)
process.digitisation_step = cms.Path(process.pdigi)
process.L1simulation_step = cms.Path(process.SimL1Emulator)
process.digi2raw_step = cms.Path(process.DigiToRaw)
process.endjob_step = cms.Path(process.endOfProcess)
process.out_step = cms.EndPath(process.output)

# Schedule definition
process.schedule = cms.Schedule(process.generation_step,process.simulation_step,process.digitisation_step,process.L1simulation_step,process.digi2raw_step)
process.schedule.extend(process.HLTSchedule)
process.schedule.extend([process.endjob_step,process.out_step])
# special treatment in case of production filter sequence  
def customizeRandomSeed(process):

    randSvc = RandomNumberServiceHelper(process.RandomNumberGeneratorService)
    randSvc.populate()

    return (process)
Exemple #23
0
										     "keep *_rpcRecHits_*_*", "keep *_genParticles_*_*"),
					      #outputCommands = process.FEVTDEBUGHLTEventContent.outputCommands,
					      splitLevel = cms.untracked.int32(0)
					      )

# Additional output definition

# Other statements
process.genstepfilter.triggerConditions=cms.vstring("generation_step")
from Configuration.AlCa.GlobalTag import GlobalTag
process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:run2_mc', '')


from IOMC.RandomEngine.RandomServiceHelper import  RandomNumberServiceHelper
randHelper =  RandomNumberServiceHelper(process.RandomNumberGeneratorService)
randHelper.populate()

process.RandomNumberGeneratorService.saveFileName =  cms.untracked.string("RandomEngineState.log")


process.generator = cms.EDFilter("Pythia8PtGun",
				 PGunParameters = cms.PSet(
		AddAntiParticle = cms.bool(True),
		MaxEta = cms.double(1.6),
		MaxPhi = cms.double(3.14159265359),
		MaxPt = cms.double(30.1),
		MinEta = cms.double(1.2),
		MinPhi = cms.double(-3.14159265359),
		MinPt = cms.double(1.1),
		ParticleID = cms.vint32(-13)
		),
Exemple #24
0
def randomize_seeds(process, save_fn='RandomEngineState.xml'):
    from IOMC.RandomEngine.RandomServiceHelper import RandomNumberServiceHelper
    randHelper =  RandomNumberServiceHelper(process.RandomNumberGeneratorService)
    randHelper.populate()
    if save_fn:
        process.RandomNumberGeneratorService.saveFileName =  cms.untracked.string(save_fn)