Geant4-11
test.py
Go to the documentation of this file.
1#!/usr/bin/python3
2# ==================================================================
3# python script for Geant4Py test
4#
5# gtest02
6# - test for using site-module packages
7# ==================================================================
8from Geant4 import *
10import g4pytest.ezgeom
11from g4pytest.ezgeom import G4EzVolume
14
15# ==================================================================
16# intialize
17# ==================================================================
19 # ------------------------------------------------------------------
20 # setup for materials
21 # ------------------------------------------------------------------
22 # simple materials for Qgeom
23 g4pytest.NISTmaterials.Construct()
24
25 # ------------------------------------------------------------------
26 # setup for geometry
27 # ------------------------------------------------------------------
28 #g4pytest.Qgeom.Construct()
29 g4pytest.ezgeom.Construct() # initialize
30
31 # ------------------------------------------------------------------
32 # setup for physics list
33 # ------------------------------------------------------------------
34 g4pytest.EMSTDpl.Construct()
35
36 # ------------------------------------------------------------------
37 # setup for primary generator action
38 # ------------------------------------------------------------------
39 g4pytest.ParticleGun.Construct()
40 gControlExecute("gun.mac")
41
42# ==================================================================
43# constructing geometry
44# ==================================================================
46 print("* Constructing geometry...")
47 # reset world material
48 air= G4Material.GetMaterial("G4_AIR")
49 g4pytest.ezgeom.SetWorldMaterial(air)
50
51 # target
52 global target
53 target= G4EzVolume("Target")
54 au= G4Material.GetMaterial("G4_Au")
55 target.CreateTubeVolume(au, 0., 1.*cm, 1.*mm)
56 target.PlaceIt(G4ThreeVector(0.,0.,-10.*cm))
57
58 # dummy box
59 global detector_box, detector_box_pv
60 detector_box= G4EzVolume("DetectorBox")
61 detector_box.CreateBoxVolume(air, 20.*cm, 20.*cm, 40.*cm)
62 detector_box_pv= detector_box.PlaceIt(G4ThreeVector(0.,0.,20.*cm))
63
64 # calorimeter
65 global cal
66 cal= G4EzVolume("Calorimeter")
67 nai= G4Material.GetMaterial("G4_SODIUM_IODIDE")
68 cal.CreateBoxVolume(nai, 5.*cm, 5.*cm, 30.*cm)
69 dd= 5.*cm
70 for ical in range(-1, 2):
71 calPos= G4ThreeVector(dd*ical, 0., 0.)
72 print(calPos)
73 cal.PlaceIt(calPos, ical+1, detector_box)
74
75
76# ==================================================================
77# main
78# ==================================================================
79# ------------------------------------------------------------------
80# randum number
81# ------------------------------------------------------------------
82rand_engine= Ranlux64Engine()
83HepRandom.setTheEngine(rand_engine)
84HepRandom.setTheSeed(20050830)
85
86# setup...
89
90# ------------------------------------------------------------------
91# go...
92# ------------------------------------------------------------------
93gRunManager.Initialize()
94
95# visualization
96gControlExecute("vis.mac")
97
98# beamOn
99#gRunManager.BeamOn(3)
100
void print(G4double elem)
static G4Material * GetMaterial(const G4String &name, G4bool warning=true)
Definition: G4Material.cc:686
gControlExecute
Definition: __init__.py:157
def ConstructGeom()
Definition: test.py:45
def Configure()
Definition: test.py:18