File indexing completed on 2026-09-20 08:25:14
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 import os
0012 import time
0013 import DDG4
0014 from DDG4 import OutputLevel as Output
0015 from g4units import GeV, MeV
0016
0017
0018 """
0019
0020 dd4hep example setup using the python configuration
0021
0022 \author M.Frank
0023 \version 1.0
0024
0025 """
0026
0027
0028 def run():
0029 args = DDG4.CommandLine()
0030 kernel = DDG4.Kernel()
0031 install_dir = os.environ['DD4hepExamplesINSTALL']
0032 kernel.setOutputLevel(str('Geant4Converter'), Output.DEBUG)
0033 kernel.setOutputLevel(str('Gun'), Output.INFO)
0034 kernel.loadGeometry(str("file:" + install_dir + "/examples/ClientTests/compact/NestedDetectors.xml"))
0035
0036 geant4 = DDG4.Geant4(kernel)
0037 geant4.printDetectors()
0038 geant4.setupCshUI()
0039 if args.batch:
0040 kernel.UI = ''
0041
0042
0043 geant4.setupTrackingField(prt=True)
0044
0045 geant4.setupROOTOutput('RootOutput', 'Nested_' + time.strftime('%Y-%m-%d_%H-%M'), mc_truth=True)
0046
0047 geant4.setupGun("Gun", particle='pi-', energy=100 * GeV, multiplicity=1)
0048
0049 seq, act = geant4.setupTracker('SiTrackerBarrel')
0050 seq, act = geant4.setupTracker('SiVertexBarrel')
0051
0052 part = DDG4.GeneratorAction(kernel, "Geant4ParticleHandler/ParticleHandler")
0053 kernel.generatorAction().adopt(part)
0054 part.SaveProcesses = ['conv', 'Decay']
0055 part.MinimalKineticEnergy = 1 * MeV
0056 part.enableUI()
0057
0058
0059 phys = kernel.physicsList()
0060 phys.extends = 'QGSP_BERT'
0061 phys.enableUI()
0062 phys.dump()
0063
0064 geant4.execute()
0065
0066
0067 if __name__ == "__main__":
0068 run()