Geant4-11
read_gdml.py
Go to the documentation of this file.
1#!/usr/bin/python
2# ==================================================================
3# An example for reading a GDML file
4#
5# ==================================================================
6from Geant4 import *
7import g4py.ExN01pl, g4py.ParticleGun
8
9# ==================================================================
10# user actions in python
11# ==================================================================
13 "My Detector Construction"
14
15 def __init__(self):
16 G4VUserDetectorConstruction.__init__(self)
17 self.world= None
19
20 # -----------------------------------------------------------------
21 def __del__(self):
22 pass
23
24 # -----------------------------------------------------------------
25 def Construct(self):
26 self.gdml_parser.Read("qgeom.gdml")
27 self.world= self.gdml_parser.GetWorldVolume()
28
29 return self.world
30
31
32# ==================================================================
33# main
34# ==================================================================
35# set geometry
37gRunManager.SetUserInitialization(myDC)
38
39# minimal physics list
40g4py.ExN01pl.Construct()
41
42# set primary generator action
43g4py.ParticleGun.Construct()
44
45# initialize
46gRunManager.Initialize()
47
48# visualization
49gApplyUICommand("/vis/open OGLSX")
50gApplyUICommand("/vis/scene/create")
51gApplyUICommand("/vis/scene/add/volume")
52gApplyUICommand("/vis/sceneHandler/attach")
53gApplyUICommand("/vis/viewer/set/viewpointThetaPhi 90. -90.")
54
virtual G4VPhysicalVolume * Construct()=0
gApplyUICommand
Definition: __init__.py:158