source: trunk/environments/g4py/examples/gdml/read_gdml.py @ 1337

Last change on this file since 1337 was 1337, checked in by garnier, 14 years ago

tag geant4.9.4 beta 1 + modifs locales

  • Property svn:executable set to *
File size: 1.5 KB
Line 
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# ==================================================================
12class MyDetectorConstruction(G4VUserDetectorConstruction):
13  "My Detector Construction"
14
15  def __init__(self):
16    G4VUserDetectorConstruction.__init__(self)
17    self.world= None
18    self.gdml_parser= G4GDMLParser()
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
36myDC= MyDetectorConstruction()
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 OGLIX")
50gApplyUICommand("/vis/scene/create")
51gApplyUICommand("/vis/scene/add/volume")
52gApplyUICommand("/vis/sceneHandler/attach")
53gApplyUICommand("/vis/viewer/set/viewpointThetaPhi 90. -90.")
54
Note: See TracBrowser for help on using the repository browser.