|
| 1 | +############################################################################### |
| 2 | +# Way to use this: |
| 3 | +# cmsRun minbias2021_cfg.py type=DDD var=ZeroMaterial |
| 4 | +# |
| 5 | +# Options for type: DDD, DD4hep |
| 6 | +# for var: ZeroMaterial, FlatMinus05Percent, FlatMinus10Percent, |
| 7 | +# FlatPlus05Percent, FlatPlus10Percent |
| 8 | +# |
| 9 | +############################################################################### |
| 10 | +import FWCore.ParameterSet.Config as cms |
| 11 | +import os, sys, importlib, re, random |
| 12 | +import FWCore.ParameterSet.VarParsing as VarParsing |
| 13 | + |
| 14 | +#################################################################### |
| 15 | +### SETUP OPTIONS |
| 16 | +options = VarParsing.VarParsing('standard') |
| 17 | +options.register('type', |
| 18 | + "DD4hep", |
| 19 | + VarParsing.VarParsing.multiplicity.singleton, |
| 20 | + VarParsing.VarParsing.varType.string, |
| 21 | + "type of operations: DDD, DD4hep") |
| 22 | +options.register('var', |
| 23 | + "", |
| 24 | + VarParsing.VarParsing.multiplicity.singleton, |
| 25 | + VarParsing.VarParsing.varType.string, |
| 26 | + "var of operations: ZeroMaterial, FlatMinus05Percent, FlatMinus10Percent, FlatPlus05Percent, FlatPlus10Percent") |
| 27 | + |
| 28 | +### get and parse the command line arguments |
| 29 | +options.parseArguments() |
| 30 | + |
| 31 | +print(options) |
| 32 | + |
| 33 | +#################################################################### |
| 34 | +# Use the options |
| 35 | +if (options.type == "DD4hep"): |
| 36 | + from Configuration.Eras.Era_Run3_cff import Run3 |
| 37 | + process = cms.Process("Sim",Run3) |
| 38 | + geomfile = "Configuration.Geometry.GeometryDD4hepExtended2021" + options.var + "Reco_cff" |
| 39 | + outfile = "minbias_FTFP_BERT_EMM_" + options.var + "_DD4hep.root" |
| 40 | +else: |
| 41 | + from Configuration.Eras.Era_Run3_DDD_cff import Run3_DDD |
| 42 | + process = cms.Process("Sim",Run3_DDD) |
| 43 | + geomfile = "Configuration.Geometry.GeometryExtended2021" + options.var + "Reco_cff" |
| 44 | + outfile = "minbias_FTFP_BERT_EMM_" + options.var + "_DDD.root" |
| 45 | + |
| 46 | +print("Geometry file: ", geomfile) |
| 47 | +print("Output file: ", outfile) |
| 48 | + |
| 49 | +process.load("SimG4CMS.Calo.PythiaMinBias_cfi") |
| 50 | +process.load("SimGeneral.HepPDTESSource.pythiapdt_cfi") |
| 51 | +process.load('FWCore.MessageService.MessageLogger_cfi') |
| 52 | +process.load("IOMC.EventVertexGenerators.VtxSmearedGauss_cfi") |
| 53 | +process.load(geomfile) |
| 54 | +process.load("Configuration.StandardSequences.MagneticField_cff") |
| 55 | +process.load("Configuration.EventContent.EventContent_cff") |
| 56 | +process.load('Configuration.StandardSequences.Generator_cff') |
| 57 | +process.load('Configuration.StandardSequences.SimIdeal_cff') |
| 58 | +process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff') |
| 59 | +from Configuration.AlCa.GlobalTag import GlobalTag |
| 60 | +process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:phase1_2022_realistic', '') |
| 61 | + |
| 62 | +if 'MessageLogger' in process.__dict__: |
| 63 | + process.MessageLogger.G4cerr=dict() |
| 64 | + process.MessageLogger.SimG4CoreApplication=dict() |
| 65 | + |
| 66 | +process.source = cms.Source("EmptySource") |
| 67 | + |
| 68 | +process.maxEvents = cms.untracked.PSet( |
| 69 | + input = cms.untracked.int32(2) |
| 70 | +) |
| 71 | + |
| 72 | +process.Timing = cms.Service("Timing") |
| 73 | + |
| 74 | +process.SimpleMemoryCheck = cms.Service("SimpleMemoryCheck", |
| 75 | + oncePerEventMode = cms.untracked.bool(True), |
| 76 | + showMallocInfo = cms.untracked.bool(True), |
| 77 | + ignoreTotal = cms.untracked.int32(1) |
| 78 | +) |
| 79 | + |
| 80 | +process.load("IOMC.RandomEngine.IOMC_cff") |
| 81 | +process.RandomNumberGeneratorService.generator.initialSeed = 456789 |
| 82 | +process.RandomNumberGeneratorService.g4SimHits.initialSeed = 9876 |
| 83 | +process.RandomNumberGeneratorService.VtxSmeared.initialSeed = 123456789 |
| 84 | +process.rndmStore = cms.EDProducer("RandomEngineStateProducer") |
| 85 | + |
| 86 | +process.TFileService = cms.Service("TFileService", |
| 87 | + fileName = cms.string('minbias_FTFP_BERT_EMM.root') |
| 88 | +) |
| 89 | + |
| 90 | +# Event output |
| 91 | +process.output = cms.OutputModule("PoolOutputModule", |
| 92 | + process.FEVTSIMEventContent, |
| 93 | + fileName = cms.untracked.string(outfile) |
| 94 | +) |
| 95 | + |
| 96 | +process.generation_step = cms.Path(process.pgen) |
| 97 | +process.simulation_step = cms.Path(process.psim) |
| 98 | +process.out_step = cms.EndPath(process.output) |
| 99 | + |
| 100 | +process.g4SimHits.Physics.type = 'SimG4Core/Physics/FTFP_BERT_EMM' |
| 101 | + |
| 102 | +# Schedule definition |
| 103 | +process.schedule = cms.Schedule(process.generation_step, |
| 104 | + process.simulation_step, |
| 105 | + process.out_step |
| 106 | + ) |
| 107 | + |
| 108 | +# filter all path with the production filter sequence |
| 109 | +for path in process.paths: |
| 110 | + getattr(process,path)._seq = process.generator * getattr(process,path)._seq |
| 111 | + |
0 commit comments