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