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