File indexing completed on 2025-01-18 09:14:55
0001
0002
0003 from __future__ import absolute_import, unicode_literals
0004 import os
0005 import time
0006 import DDG4
0007 from DDG4 import OutputLevel as Output
0008 from g4units import GeV
0009
0010
0011 """
0012
0013 dd4hep simulation example setup using the python configuration
0014
0015 @author M.Frank
0016 @version 1.0
0017
0018 """
0019
0020
0021 def run():
0022 args = DDG4.CommandLine()
0023 kernel = DDG4.Kernel()
0024 install_dir = os.environ['DD4hepExamplesINSTALL']
0025 kernel.loadGeometry(str("file:" + install_dir + "/examples/ClientTests/compact/SiliconBlock.xml"))
0026 DDG4.importConstants(kernel.detectorDescription(), debug=False)
0027
0028
0029
0030 geant4 = DDG4.Geant4(kernel, tracker='MyTrackerSDAction')
0031 geant4.printDetectors()
0032
0033
0034 if args.macro:
0035 ui = geant4.setupCshUI(macro=args.macro)
0036 else:
0037 ui = geant4.setupCshUI()
0038 if args.batch:
0039 ui.Commands = ['/run/beamOn ' + str(args.events), '/ddg4/UI/terminate']
0040
0041
0042 geant4.setupTrackingField(prt=True)
0043
0044 prt = DDG4.EventAction(kernel, 'Geant4ParticlePrint/ParticlePrint')
0045 prt.OutputLevel = Output.WARNING
0046 prt.OutputType = 3
0047 kernel.eventAction().adopt(prt)
0048
0049
0050 geant4.setupROOTOutput('RootOutput', 'MySD_' + time.strftime('%Y-%m-%d_%H-%M'), mc_truth=False)
0051
0052 geant4.setupGun("Gun", particle='mu-', energy=5 * GeV, multiplicity=1, Standalone=True, position=(0, 0, 0))
0053 seq, act = geant4.setupTracker('SiliconBlockUpper')
0054 act.OutputLevel = Output.INFO
0055 seq, act = geant4.setupTracker('SiliconBlockDown')
0056 act.OutputLevel = Output.INFO
0057
0058 phys = kernel.physicsList()
0059 phys.extends = 'QGSP_BERT'
0060 phys.enableUI()
0061 phys.dump()
0062
0063 kernel.configure()
0064 kernel.initialize()
0065 kernel.run()
0066 kernel.terminate()
0067
0068
0069 if __name__ == "__main__":
0070 run()