File indexing completed on 2026-09-17 08:26:28
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013 import os
0014 import sys
0015 import DDG4
0016 from DDG4 import OutputLevel as Output
0017 from g4units import GeV
0018
0019
0020 """
0021
0022 dd4hep simulation example setup using the python configuration
0023
0024 @author M.Frank
0025 @version 1.0
0026
0027 """
0028
0029
0030 def run():
0031 kernel = DDG4.Kernel()
0032 install_dir = os.environ['DD4hepExamplesINSTALL']
0033 kernel.loadGeometry(str("file:" + install_dir + "/examples/ClientTests/compact/GdmlDetector.xml"))
0034
0035 DDG4.importConstants(kernel.detectorDescription(), debug=False)
0036 geant4 = DDG4.Geant4(kernel, tracker='Geant4TrackerCombineAction')
0037 geant4.printDetectors()
0038
0039 if len(sys.argv) > 1:
0040 geant4.setupCshUI(macro=sys.argv[1])
0041 else:
0042 geant4.setupCshUI()
0043
0044
0045 geant4.setupTrackingField(prt=True)
0046
0047 generator_output_level = Output.INFO
0048
0049
0050 seq, act = geant4.addDetectorConstruction("Geant4DetectorGeometryConstruction/ConstructGeo")
0051 act.DebugVolumes = True
0052 act.DebugShapes = True
0053 act.DebugPlacements = True
0054 act.DumpHierarchy = True
0055
0056
0057 gun = geant4.setupGun("Gun", particle='mu-', energy=20 * GeV, multiplicity=1)
0058 gun.OutputLevel = generator_output_level
0059
0060
0061 phys = geant4.setupPhysics('QGSP_BERT')
0062 phys.dump()
0063
0064 geant4.execute()
0065
0066
0067 if __name__ == "__main__":
0068 run()