File indexing completed on 2025-01-18 09:14:44
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 from __future__ import absolute_import, unicode_literals
0013 import os
0014 import time
0015 import DDG4
0016 from DDG4 import OutputLevel as Output
0017 from g4units import GeV
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 args = DDG4.CommandLine()
0031 kernel = DDG4.Kernel()
0032 install_dir = os.environ['DD4hepExamplesINSTALL']
0033 kernel.loadGeometry(str("file:" + install_dir + "/examples/DDCAD/compact/DD4hep_Issue_1134.xml"))
0034
0035 DDG4.importConstants(kernel.detectorDescription(), debug=False)
0036 geant4 = DDG4.Geant4(kernel, tracker='Geant4TrackerCombineAction')
0037 geant4.printDetectors()
0038
0039 if args.macro:
0040 ui = geant4.setupCshUI(macro=args.macro)
0041 else:
0042 ui = geant4.setupCshUI()
0043 if args.batch:
0044 ui.Commands = ['/run/beamOn ' + str(args.events), '/ddg4/UI/terminate']
0045
0046
0047 geant4.setupTrackingField(prt=True)
0048
0049 prt = DDG4.EventAction(kernel, 'Geant4ParticlePrint/ParticlePrint')
0050 prt.OutputLevel = Output.DEBUG
0051 prt.OutputType = 3
0052 kernel.eventAction().adopt(prt)
0053
0054
0055 seq, act = geant4.addDetectorConstruction("Geant4DetectorGeometryConstruction/ConstructGeo")
0056 act.DebugVolumes = True
0057 act.DebugShapes = True
0058 seq, act = geant4.addDetectorConstruction("Geant4DetectorSensitivesConstruction/ConstructSD")
0059
0060
0061 geant4.setupROOTOutput('RootOutput', 'DD4hep_Issue_1134_' + time.strftime('%Y-%m-%d_%H-%M'))
0062
0063 gun = geant4.setupGun("Gun", particle='e+', energy=20 * GeV, multiplicity=1)
0064 gun.OutputLevel = Output.INFO
0065
0066 phys = geant4.setupPhysics('QGSP_BERT')
0067 ph = DDG4.PhysicsList(kernel, str('Geant4PhysicsList/Myphysics'))
0068 ph.addParticleConstructor(str('G4Geantino'))
0069 ph.enableUI()
0070 phys.adopt(ph)
0071 geant4.execute()
0072
0073
0074 if __name__ == "__main__":
0075 run()