Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-09-01 23:02:29

0001 ###############################################################################
0002 # Way to use this:
0003 #   cmsRun grunPrintG4Solids_cfg.py geometry=D110 dd4hep=False
0004 #
0005 #   Options for geometry D95, D96, D98, D99, D100, D101, D102, D103, D104,
0006 #                        D105, D106, D107, D108, D109, D110, D111, D112, D113,
0007 #                        D114, D115
0008 #   Options for type DDD, DD4hep
0009 #
0010 ###############################################################################
0011 import FWCore.ParameterSet.Config as cms
0012 import os, sys, importlib, re
0013 import FWCore.ParameterSet.VarParsing as VarParsing
0014 
0015 ####################################################################
0016 ### SETUP OPTIONS
0017 options = VarParsing.VarParsing('standard')
0018 options.register('geometry',
0019                  "D110",
0020                   VarParsing.VarParsing.multiplicity.singleton,
0021                   VarParsing.VarParsing.varType.string,
0022                   "geometry of operations: D95, D96, D98, D99, D100, D101, D102, D103, D104, D105, D106, D107, D108, D109, D110, D111, D112, D113, D114, D115")
0023 options.register('type',
0024                  "DDD",
0025                   VarParsing.VarParsing.multiplicity.singleton,
0026                   VarParsing.VarParsing.varType.string,
0027                   "type of operations: DDD, DD4hep")
0028 
0029 ### get and parse the command line arguments
0030 options.parseArguments()
0031 
0032 print(options)
0033 
0034 ####################################################################
0035 # Use the options
0036 from Configuration.ProcessModifiers.dd4hep_cff import dd4hep
0037 
0038 if (options.geometry == "D115"):
0039     from Configuration.Eras.Era_Phase2C20I13M9_cff import Phase2C20I13M9
0040     if (options.type == "DD4hep"):
0041         process = cms.Process('G4PrintGeometry',Phase2C20I13M9,dd4hep)
0042     else:
0043         process = cms.Process('G4PrintGeometry',Phase2C20I13M9)
0044 elif (options.geometry == "D104"):
0045     from Configuration.Eras.Era_Phase2C22I13M9_cff import Phase2C22I13M9
0046     if (options.type == "DD4hep"):
0047         process = cms.Process('G4PrintGeometry',Phase2C22I13M9,dd4hep)
0048     else:
0049         process = cms.Process('G4PrintGeometry',Phase2C22I13M9)
0050 elif (options.geometry == "D106"):
0051     from Configuration.Eras.Era_Phase2C22I13M9_cff import Phase2C22I13M9
0052     if (options.type == "DD4hep"):
0053         process = cms.Process('G4PrintGeometry',Phase2C22I13M9,dd4hep)
0054     else:
0055         process = cms.Process('G4PrintGeometry',Phase2C22I13M9)
0056 elif (options.geometry == "D109"):
0057     from Configuration.Eras.Era_Phase2C22I13M9_cff import Phase2C22I13M9
0058     if (options.type == "DD4hep"):
0059         process = cms.Process('G4PrintGeometry',Phase2C22I13M9,dd4hep)
0060     else:
0061         process = cms.Process('G4PrintGeometry',Phase2C22I13M9)
0062 elif (options.geometry == "D111"):
0063     from Configuration.Eras.Era_Phase2C22I13M9_cff import Phase2C22I13M9
0064     if (options.type == "DD4hep"):
0065         process = cms.Process('G4PrintGeometry',Phase2C22I13M9,dd4hep)
0066     else:
0067         process = cms.Process('G4PrintGeometry',Phase2C22I13M9)
0068 elif (options.geometry == "D112"):
0069     from Configuration.Eras.Era_Phase2C22I13M9_cff import Phase2C22I13M9
0070     if (options.type == "DD4hep"):
0071         process = cms.Process('G4PrintGeometry',Phase2C22I13M9,dd4hep)
0072     else:
0073         process = cms.Process('G4PrintGeometry',Phase2C22I13M9)
0074 elif (options.geometry == "D113"):
0075     from Configuration.Eras.Era_Phase2C22I13M9_cff import Phase2C22I13M9
0076     if (options.type == "DD4hep"):
0077         process = cms.Process('G4PrintGeometry',Phase2C22I13M9,dd4hep)
0078     else:
0079         process = cms.Process('G4PrintGeometry',Phase2C22I13M9)
0080 else:
0081     from Configuration.Eras.Era_Phase2C17I13M9_cff import Phase2C17I13M9
0082     if (options.type == "DD4hep"):
0083         process = cms.Process('G4PrintGeometry',Phase2C17I13M9,dd4hep)
0084     else:
0085         process = cms.Process('G4PrintGeometry',Phase2C17I13M9)
0086 
0087 if (options.type == "DD4hep"):
0088     geomFile = "Configuration.Geometry.GeometryDD4hepExtended2026" + options.geometry + "Reco_cff"
0089 else:
0090     geomFile = "Configuration.Geometry.GeometryExtended2026" + options.geometry + "Reco_cff"
0091 
0092 print("Geometry file Name: ", geomFile)
0093 
0094 if hasattr(process,'MessageLogger'):
0095     process.MessageLogger.G4cerr=dict()
0096     process.MessageLogger.G4cout=dict()
0097 
0098 if (options.type == "DD4hep"):
0099     dd4hep = True
0100 else:
0101     dd4hep = False
0102 
0103 process.load('SimGeneral.HepPDTESSource.pdt_cfi')
0104 process.load(geomFile)
0105 process.load('IOMC.RandomEngine.IOMC_cff')
0106 process.load('IOMC.EventVertexGenerators.VtxSmearedFlat_cfi')
0107 process.load('GeneratorInterface.Core.generatorSmeared_cfi')
0108 process.load('FWCore.MessageService.MessageLogger_cfi')
0109 process.load("Configuration.StandardSequences.MagneticField_38T_cff")
0110 process.load('SimG4Core.Application.g4SimHits_cfi')
0111 process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff')
0112 from Configuration.AlCa.GlobalTag import GlobalTag
0113 process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:phase2_realistic_T21', '')
0114 
0115 process.source = cms.Source("EmptySource")
0116 
0117 process.generator = cms.EDProducer("FlatRandomEGunProducer",
0118     PGunParameters = cms.PSet(
0119         PartID = cms.vint32(14),
0120         MinEta = cms.double(-3.5),
0121         MaxEta = cms.double(3.5),
0122         MinPhi = cms.double(-3.14159265359),
0123         MaxPhi = cms.double(3.14159265359),
0124         MinE   = cms.double(9.99),
0125         MaxE   = cms.double(10.01)
0126     ),
0127     AddAntiParticle = cms.bool(False),
0128     Verbosity       = cms.untracked.int32(0),
0129     firstRun        = cms.untracked.uint32(1)
0130 )
0131 
0132 process.maxEvents = cms.untracked.PSet(
0133     input = cms.untracked.int32(1)
0134 )
0135 
0136 process.p1 = cms.Path(process.generator*process.VtxSmeared*process.generatorSmeared*process.g4SimHits)