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 DDG4
0013
0014 """
0015
0016 dd4hep example setup using the python configuration
0017
0018 \author M.Frank
0019 \version 1.0
0020
0021 """
0022
0023
0024 def run():
0025 from g4units import GeV
0026 from MiniTelSetup import Setup
0027 args = DDG4.CommandLine()
0028 m = Setup(geometry="/examples/ClientTests/compact/MiniTelGenerate.xml")
0029 kernel = m.kernel
0030 if args.batch:
0031 run = '/run/beamOn ' + str(args.events)
0032 DDG4.setPrintLevel(DDG4.OutputLevel.WARNING)
0033 cmds = []
0034 if not args.runs:
0035 args.runs = 1
0036 for _i in range(int(args.runs)):
0037 cmds.append(run)
0038 cmds.append('/ddg4/UI/terminate')
0039 m.ui.Commands = cmds
0040 m.configure()
0041 if args.output and str(args.output).lower().find('edm4hep') >= 0:
0042 wr = m.defineEdm4hepOutput(args.output)
0043 else:
0044 wr = m.defineOutput(output='MiniTel')
0045 wr.FilesByRun = True
0046
0047 gen = DDG4.GeneratorAction(kernel, "Geant4GeneratorActionInit/GenerationInit")
0048 kernel.generatorAction().adopt(gen)
0049
0050 gun = DDG4.GeneratorAction(kernel, "Geant4IsotropeGenerator/IsotropPi+1")
0051 gun.Mask = 1 << 0
0052 gun.Particle = 'pi+'
0053 gun.Energy = 100 * GeV
0054 gun.Multiplicity = 1
0055 gun.Distribution = 'cos(theta)'
0056 kernel.generatorAction().adopt(gun)
0057
0058 gun = DDG4.GeneratorAction(kernel, "Geant4IsotropeGenerator/IsotropPi+2")
0059 gun.Mask = 1 << 1
0060 gun.Particle = 'pi+'
0061 gun.Energy = 100 * GeV
0062 gun.Multiplicity = 1
0063 gun.Distribution = 'cos(theta)'
0064 kernel.generatorAction().adopt(gun)
0065
0066 gun = DDG4.GeneratorAction(kernel, "Geant4IsotropeGenerator/IsotropPi+3")
0067 gun.Mask = 1 << 2
0068 gun.Particle = 'pi+'
0069 gun.Energy = 100 * GeV
0070 gun.Multiplicity = 1
0071 gun.Distribution = 'cos(theta)'
0072 kernel.generatorAction().adopt(gun)
0073
0074 gun = DDG4.GeneratorAction(kernel, "Geant4IsotropeGenerator/IsotropPi-")
0075 gun.Mask = 1 << 3
0076 gun.Particle = 'pi-'
0077 gun.Energy = 100 * GeV
0078 gun.Multiplicity = 1
0079 gun.Distribution = 'cos(theta)'
0080 kernel.generatorAction().adopt(gun)
0081
0082 gun = DDG4.GeneratorAction(kernel, "Geant4IsotropeGenerator/IsotropE+1")
0083 gun.Mask = 1 << 4
0084 gun.Particle = 'e+'
0085 gun.Energy = 50 * GeV
0086 gun.Multiplicity = 1
0087 gun.Distribution = 'cos(theta)'
0088 kernel.generatorAction().adopt(gun)
0089
0090 gun = DDG4.GeneratorAction(kernel, "Geant4IsotropeGenerator/IsotropE+2")
0091 gun.Mask = 1 << 5
0092 gun.Particle = 'e+'
0093 gun.Energy = 100 * GeV
0094 gun.Multiplicity = 1
0095 gun.Distribution = 'cos(theta)'
0096 kernel.generatorAction().adopt(gun)
0097
0098 gun = DDG4.GeneratorAction(kernel, "Geant4IsotropeGenerator/IsotropE+3")
0099 gun.Mask = 1 << 6
0100 gun.Particle = 'e+'
0101 gun.Energy = 50 * GeV
0102 gun.Multiplicity = 1
0103 gun.Distribution = 'cos(theta)'
0104 kernel.generatorAction().adopt(gun)
0105
0106 gun = DDG4.GeneratorAction(kernel, "Geant4IsotropeGenerator/IsotropE+4")
0107 gun.Mask = 1 << 7
0108 gun.Particle = 'e+'
0109 gun.Energy = 100 * GeV
0110 gun.Multiplicity = 1
0111 gun.Distribution = 'cos(theta)'
0112 kernel.generatorAction().adopt(gun)
0113
0114 gun = DDG4.GeneratorAction(kernel, "Geant4IsotropeGenerator/IsotropE+5")
0115 gun.Mask = 1 << 8
0116 gun.Particle = 'e+'
0117 gun.Energy = 100 * GeV
0118 gun.Multiplicity = 1
0119 gun.Distribution = 'cos(theta)'
0120 kernel.generatorAction().adopt(gun)
0121
0122 gun = None
0123
0124 gen = DDG4.GeneratorAction(kernel, "Geant4InteractionMerger/InteractionMerger")
0125 gen.enableUI()
0126 kernel.generatorAction().adopt(gen)
0127
0128 gen = DDG4.GeneratorAction(kernel, "Geant4PrimaryHandler/PrimaryHandler")
0129 gen.enableUI()
0130 kernel.generatorAction().adopt(gen)
0131 gen = None
0132
0133 m.setupGenerator()
0134 m.setupPhysics()
0135 m.run()
0136
0137
0138 if __name__ == "__main__":
0139 run()