Geant4-11
write_gdml.py
Go to the documentation of this file.
1#!/usr/bin/python
2# ==================================================================
3# An example of writing a GDML file
4#
5# ==================================================================
6from Geant4 import *
7import g4py.Qmaterials, g4py.Qgeom
8import g4py.ExN01pl, g4py.ParticleGun
9
10# ==================================================================
11# main
12# ==================================================================
13# set geometry
14g4py.Qmaterials.Construct()
15g4py.Qgeom.Construct()
16
17# minimal physics list
18g4py.ExN01pl.Construct()
19
20# set primary generator action
21g4py.ParticleGun.Construct()
22
23# initialize
24gRunManager.Initialize()
25
26# visualization
27gApplyUICommand("/vis/open OGLSX")
28gApplyUICommand("/vis/scene/create")
29gApplyUICommand("/vis/scene/add/volume")
30gApplyUICommand("/vis/sceneHandler/attach")
31gApplyUICommand("/vis/viewer/set/viewpointThetaPhi 90. -90.")
32
33# write to a GDML file
34print "\n*** write to a GDML file..."
35navigator= gTransportationManager.GetNavigatorForTracking()
36world_volume= navigator.GetWorldVolume()
37
38gdml_parser = G4GDMLParser()
39gdml_parser.Write("qgeom_out.gdml", world_volume)
40
41
gApplyUICommand
Definition: __init__.py:158