Geant4-11
run.py
Go to the documentation of this file.
1#!/usr/bin/python
2# ==================================================================
3# python script for Geant4Py test
4#
5# gtest02
6# - test for using site-module packages
7# ==================================================================
8from Geant4 import *
9import g4py.Qmaterials, g4py.NISTmaterials
10import g4py.Qgeom, g4py.ExN01geom, g4py.ExN03geom
11import g4py.ExN01pl, g4py.EMSTDpl
12import g4py.ParticleGun, g4py.MedicalBeam
13
14# ==================================================================
15# user setup
16# ==================================================================
17
18# ------------------------------------------------------------------
19# Setup-0 (Q)
20# ------------------------------------------------------------------
21def Setup0():
22 # simple materials for Qgeom
23 g4py.Qmaterials.Construct()
24
25 # NIST materials
26 #g4py.NISTmaterials.Construct()
27
28 # normal way for constructing user geometry
29 #qDC= g4py.Qgeom.QDetectorConstruction()
30 #gRunManager.SetUserInitialization(qDC)
31
32 # 2nd way, short-cut way
33 g4py.Qgeom.Construct()
34
35 # primary
36 global primary_position, primary_direction
37 primary_position= G4ThreeVector(0.,0., -14.9*cm)
38 primary_direction= G4ThreeVector(0.2, 0., 1.)
39
40
41# ------------------------------------------------------------------
42# Setup-1 (ExampleN01)
43# ------------------------------------------------------------------
44def Setup1():
45 g4py.ExN01geom.Construct()
46
47 global primary_position, primary_direction
48 primary_position= G4ThreeVector(-2.5*m, 0., 0.)
49 primary_direction= G4ThreeVector(1., 0., 0.)
50
51
52# ------------------------------------------------------------------
53# Setup-3 (ExampleN03)
54# ------------------------------------------------------------------
55def Setup3():
56 #exN03geom= g4py.ExN03geom.ExN03DetectorConstruction()
57 #gRunManager.SetUserInitialization(exN03geom)
58
59 g4py.ExN03geom.Construct()
60
61 global primary_position, primary_direction
62 primary_position= G4ThreeVector(-1.*m, 0., 0.)
63 primary_direction= G4ThreeVector(1., 0., 0.)
64
65
66# ==================================================================
67# main
68# ==================================================================
69# ------------------------------------------------------------------
70# randum number
71# ------------------------------------------------------------------
72rand_engine= Ranlux64Engine()
73HepRandom.setTheEngine(rand_engine)
74HepRandom.setTheSeed(20050830L)
75
76# ------------------------------------------------------------------
77# user setup
78# ------------------------------------------------------------------
79Setup0()
80#Setup1()
81#Setup3()
82
83
84# ------------------------------------------------------------------
85# setup for physics list
86# ------------------------------------------------------------------
87# normal way for constructing user physics list
88#exN01PL= ExN01PhysicsList.ExN01PhysicsList()
89#gRunManager.SetUserInitialization(exN01PL)
90
91# 2nd way, short-cut way
92# geantino + transportation
93#g4py.ExN01pl.Construct()
94
95# electron/gamma standard EM
96g4py.EMSTDpl.Construct()
97
98# ------------------------------------------------------------------
99# setup for primary generator action
100# ------------------------------------------------------------------
101# ------------
102# Particle Gun
103# ------------
104# normal way for constructing user physics list
105#pgPGA= g4py.ParticleGun.ParticleGunAction()
106#gRunManager.SetUserAction(pgPGA)
107#pg= pgPGA.GetParticleGun()
108
109# 2nd way, short-cut way
110pg= g4py.ParticleGun.Construct()
111
112# set parameters of particle gun
113pg.SetParticleByName("e-")
114pg.SetParticleEnergy(300.*MeV)
115pg.SetParticlePosition(primary_position)
116pg.SetParticleMomentumDirection(primary_direction)
117
118# ------------
119# Medical Beam
120# ------------
121#beam= g4py.MedicalBeam.Construct()
122
123# ------------------------------------------------------------------
124# go...
125# ------------------------------------------------------------------
126gRunManager.Initialize()
127
128# visualization
129gApplyUICommand("/control/execute vis.mac")
130
131# beamOn
132#gRunManager.BeamOn(3)
133
def Setup0()
Definition: run.py:21
def Setup3()
Definition: run.py:55
def Setup1()
Definition: run.py:44
gApplyUICommand
Definition: __init__.py:158