Import Geant4 9.4.0 source tree
This commit is contained in:
+54
@@ -0,0 +1,54 @@
|
||||
#!/usr/bin/python3
|
||||
# ==================================================================
|
||||
# An example for reading a GDML file
|
||||
#
|
||||
# ==================================================================
|
||||
from Geant4 import *
|
||||
import g4py.ExN01pl, g4py.ParticleGun
|
||||
|
||||
# ==================================================================
|
||||
# user actions in python
|
||||
# ==================================================================
|
||||
class MyDetectorConstruction(G4VUserDetectorConstruction):
|
||||
"My Detector Construction"
|
||||
|
||||
def __init__(self):
|
||||
G4VUserDetectorConstruction.__init__(self)
|
||||
self.world= None
|
||||
self.gdml_parser= G4GDMLParser()
|
||||
|
||||
# -----------------------------------------------------------------
|
||||
def __del__(self):
|
||||
pass
|
||||
|
||||
# -----------------------------------------------------------------
|
||||
def Construct(self):
|
||||
self.gdml_parser.Read("qgeom.gdml")
|
||||
self.world= self.gdml_parser.GetWorldVolume()
|
||||
|
||||
return self.world
|
||||
|
||||
|
||||
# ==================================================================
|
||||
# main
|
||||
# ==================================================================
|
||||
# set geometry
|
||||
myDC= MyDetectorConstruction()
|
||||
gRunManager.SetUserInitialization(myDC)
|
||||
|
||||
# minimal physics list
|
||||
g4py.ExN01pl.Construct()
|
||||
|
||||
# set primary generator action
|
||||
g4py.ParticleGun.Construct()
|
||||
|
||||
# initialize
|
||||
gRunManager.Initialize()
|
||||
|
||||
# visualization
|
||||
gApplyUICommand("/vis/open OGLIX")
|
||||
gApplyUICommand("/vis/scene/create")
|
||||
gApplyUICommand("/vis/scene/add/volume")
|
||||
gApplyUICommand("/vis/sceneHandler/attach")
|
||||
gApplyUICommand("/vis/viewer/set/viewpointThetaPhi 90. -90.")
|
||||
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
#!/usr/bin/python3
|
||||
# ==================================================================
|
||||
# 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 OGLIX")
|
||||
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("qgeom.gdml", world_volume)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user