-
Notifications
You must be signed in to change notification settings - Fork 1
/
createGDMLsolid.py
executable file
·41 lines (32 loc) · 1.1 KB
/
createGDMLsolid.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/python
# ==================================================================
# An example of writing a GDML file
#
# ==================================================================
from Geant4 import *
import g4py.Qmaterials, g4py.Qgeom
import g4py.ExN01pl, g4py.ParticleGun
# ==================================================================
# main
# ==================================================================
# set geometry
g4py.Qmaterials.Construct()
g4py.Qgeom.Construct()
# minimal physics list
g4py.ExN01pl.Construct()
# set primary generator action
g4py.ParticleGun.Construct()
# initialize
gRunManager.Initialize()
# visualization
gApplyUICommand("/vis/open OGLSX")
gApplyUICommand("/vis/scene/create")
gApplyUICommand("/vis/scene/add/volume")
gApplyUICommand("/vis/sceneHandler/attach")
gApplyUICommand("/vis/viewer/set/viewpointThetaPhi 90. -90.")
# write to a GDML file
print "\n*** write to a GDML file..."
navigator= gTransportationManager.GetNavigatorForTracking()
world_volume= navigator.GetWorldVolume()
gdml_parser = G4GDMLParser()
gdml_parser.Write("output.gdml", world_volume)