File indexing completed on 2025-01-30 09:17:46
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 from __future__ import absolute_import, unicode_literals
0012 import os
0013 import sys
0014 import time
0015 import DDG4
0016 from DDG4 import OutputLevel as Output
0017 from g4units import GeV, MeV
0018
0019
0020 """
0021
0022 dd4hep example setup using the python configuration
0023
0024 \author M.Frank
0025 \version 1.0
0026
0027 """
0028
0029
0030 def run():
0031 batch = False
0032 kernel = DDG4.Kernel()
0033 install_dir = os.environ['DD4hepExamplesINSTALL']
0034 geometry = "file:" + install_dir + "/examples/ClientTests/compact/MultiSegmentCollections.xml"
0035 kernel.setOutputLevel(str('Geant4Converter'), Output.DEBUG)
0036 kernel.setOutputLevel(str('Gun'), Output.INFO)
0037 for i in range(len(sys.argv)):
0038 if sys.argv[i] == '-compact':
0039 geometry = sys.argv[i + 1]
0040 elif sys.argv[i] == '-input':
0041 geometry = sys.argv[i + 1]
0042 elif sys.argv[i] == '-batch':
0043 batch = True
0044 elif sys.argv[i] == 'batch':
0045 batch = True
0046
0047 kernel.loadGeometry(str(geometry))
0048 geant4 = DDG4.Geant4(kernel)
0049 geant4.printDetectors()
0050 geant4.setupCshUI()
0051 if batch:
0052 kernel.UI = ''
0053
0054
0055 geant4.setupTrackingField(prt=True)
0056
0057 geant4.setupGun("Gun", particle='pi-', energy=50 * GeV, multiplicity=1)
0058
0059
0060 seq, act = geant4.setupCalorimeter('TestCal')
0061
0062
0063 part = DDG4.GeneratorAction(kernel, "Geant4ParticleHandler/ParticleHandler")
0064 kernel.generatorAction().adopt(part)
0065 part.MinimalKineticEnergy = 1 * MeV
0066 part.enableUI()
0067
0068
0069 evt = DDG4.EventAction(kernel, "Geant4ParticleDumpAction/ParticleDump")
0070 kernel.eventAction().adopt(evt)
0071 evt.enableUI()
0072
0073
0074 evt = DDG4.EventAction(kernel, "Geant4HitDumpAction/RawDump")
0075 kernel.eventAction().adopt(evt)
0076 evt.enableUI()
0077
0078
0079 evt = DDG4.EventAction(kernel, "Geant4HitTruthHandler/HitTruth")
0080 kernel.eventAction().adopt(evt)
0081 evt.enableUI()
0082
0083
0084 evt = DDG4.EventAction(kernel, "Geant4HitDumpAction/HitDump")
0085 kernel.eventAction().adopt(evt)
0086 evt.enableUI()
0087
0088
0089 evt_root = geant4.setupROOTOutput('RootOutput', 'Multi_coll_' + time.strftime('%Y-%m-%d_%H-%M'), mc_truth=True)
0090 evt_root.HandleMCTruth = False
0091
0092
0093 phys = kernel.physicsList()
0094 phys.extends = 'QGSP_BERT'
0095 phys.enableUI()
0096 phys.dump()
0097
0098 geant4.execute()
0099
0100
0101 if __name__ == "__main__":
0102 run()