Geant4-11
test_voxel.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.NISTmaterials
10import g4py.ezgeom
11from g4py.ezgeom import G4EzVolume
12import g4py.EMSTDpl
13import g4py.ParticleGun
14
15# ==================================================================
16# intialize
17# ==================================================================
19 # ------------------------------------------------------------------
20 # setup for materials
21 # ------------------------------------------------------------------
22 # simple materials for Qgeom
23 g4py.NISTmaterials.Construct()
24
25 # ------------------------------------------------------------------
26 # setup for geometry
27 # ------------------------------------------------------------------
28 #g4py.Qgeom.Construct()
29 g4py.ezgeom.Construct() # initialize
30
31 # ------------------------------------------------------------------
32 # setup for physics list
33 # ------------------------------------------------------------------
34 g4py.EMSTDpl.Construct()
35
36 # ------------------------------------------------------------------
37 # setup for primary generator action
38 # ------------------------------------------------------------------
39 g4py.ParticleGun.Construct()
40 gControlExecute("gun.mac")
41
42
43# ==================================================================
44# constructing geometry
45# ==================================================================
47 print "* Constructing geometry..."
48 # reset world material
49 air= G4Material.GetMaterial("G4_AIR")
50 g4py.ezgeom.SetWorldMaterial(air)
51
52 # phantom
53 global phantom
54 phantom= G4EzVolume("DetectorBox")
55 water= G4Material.GetMaterial("G4_WATER")
56 phantom.CreateBoxVolume(water, 40.*cm, 40.*cm, 50.*cm)
57 phantom.PlaceIt(G4ThreeVector(0.,0.,20.*cm))
58 vsize=phantom.VoxelizeIt(100, 100, 100)
59 print "voxel size=", vsize
60
61# ==================================================================
62# main
63# ==================================================================
64# ------------------------------------------------------------------
65# randum number
66# ------------------------------------------------------------------
67rand_engine= Ranlux64Engine()
68HepRandom.setTheEngine(rand_engine)
69HepRandom.setTheSeed(20050830L)
70
71# setup...
74
75# ------------------------------------------------------------------
76# go...
77# ------------------------------------------------------------------
78gRunManager.Initialize()
79
80# visualization
81gControlExecute("vis.mac")
82
83# beamOn
84#gRunManager.BeamOn(3)
85
static G4Material * GetMaterial(const G4String &name, G4bool warning=true)
Definition: G4Material.cc:686
gControlExecute
Definition: __init__.py:157
def Configure()
Definition: test_voxel.py:18
def ConstructGeom()
Definition: test_voxel.py:46