File indexing completed on 2025-01-30 09:17:45
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013 from __future__ import absolute_import, unicode_literals
0014 import os
0015 import time
0016 import DDG4
0017 from DDG4 import OutputLevel as Output
0018 from g4units import GeV, mm, cm
0019 import logging
0020
0021 logging.basicConfig(format='%(levelname)s: %(message)s', level=logging.INFO)
0022 logger = logging.getLogger(__name__)
0023
0024
0025
0026 """
0027
0028 dd4hep simulation example setup using the python configuration
0029
0030 @author M.Frank
0031 @version 1.0
0032
0033 """
0034
0035
0036 def run():
0037 args = DDG4.CommandLine()
0038 kernel = DDG4.Kernel()
0039 description = kernel.detectorDescription()
0040
0041 install_dir = os.environ['DD4hepExamplesINSTALL']
0042 kernel.loadGeometry(str("file:" + install_dir + "/examples/ClientTests/compact/LheD_tracker.xml"))
0043
0044 DDG4.importConstants(description, debug=False)
0045 geant4 = DDG4.Geant4(kernel, tracker='Geant4TrackerCombineAction')
0046 geant4.printDetectors()
0047
0048
0049 geant4.setupCshUI()
0050
0051
0052 if args.batch:
0053 kernel.UI = ''
0054
0055
0056 geant4.setupTrackingField(prt=True)
0057
0058 prt = DDG4.EventAction(kernel, 'Geant4ParticlePrint/ParticlePrint')
0059 prt.OutputLevel = Output.WARNING
0060 prt.OutputType = 3
0061 kernel.eventAction().adopt(prt)
0062
0063
0064 geant4.setupROOTOutput('RootOutput', 'LHeD_tracker_' + time.strftime('%Y-%m-%d_%H-%M'))
0065 gen = geant4.setupGun("Gun", particle='geantino', energy=20 * GeV, position=(0 * mm, 0 * mm, 0 * cm), multiplicity=3)
0066 gen.isotrop = False
0067 gen.direction = (1, 0, 0)
0068 gen.OutputLevel = Output.WARNING
0069
0070
0071
0072
0073 phys = geant4.setupPhysics('QGSP_BERT')
0074 ph = DDG4.PhysicsList(kernel, 'Geant4PhysicsList/Myphysics')
0075 ph.addParticleConstructor(str('G4Geantino'))
0076 ph.addParticleConstructor(str('G4BosonConstructor'))
0077 ph.enableUI()
0078 phys.adopt(ph)
0079 phys.dump()
0080
0081 kernel.configure()
0082 kernel.initialize()
0083
0084
0085 kernel.run()
0086 logger.info('End of run. Terminating .......')
0087 kernel.terminate()
0088
0089
0090 if __name__ == "__main__":
0091 run()