Geant4-11
Data Structures | Functions | Variables
demo Namespace Reference

Data Structures

class  App
 
class  MyEventAction
 
class  MyPrimaryGeneratorAction
 
class  MyRunAction
 
class  MySteppingAction
 
class  ScoreSD
 

Functions

def Configure ()
 
def ConstructGeom ()
 
def hini ()
 
def hshow ()
 
def init_root ()
 
def posXZ (copyN)
 

Variables

 app = App()
 
list cutsList = ["um", "mm" , "cm", "m", "km"]
 
list enrgyList = ["eV","keV","MeV","GeV","TeV","PeV"]
 
 exN03geom = g4py.ExN03geom.ExN03DetectorConstruction()
 
 exN03PL = g4py.EMSTDpl.PhysicsListEMstd()
 
 heprepDir = os.environ.get("G4HEPREPFILE_DIR")
 
 heprepName = os.environ.get("G4HEPREPFILE_NAME")
 
 heprepViewer = os.environ.get("G4HEPREPFILE_VIEWER")
 
 materialList = testem0.getMaterialTable();
 
 myDC = testem0.DetectorConstruction()
 
 myPGA = testem0.PrimaryGeneratorAction(myDC)
 
 myPL = testem0.PhysicsList()
 
 myRA = testem0.RunAction(myDC,myPGA)
 
 particleList = testem0.getParticleTable()
 
 pg = g4.G4ParticleGun()
 
 rand_engine = Ranlux64Engine()
 
 vrmlDir = os.environ.get("G4VRML_DEST_DIR")
 
 vrmlViewer = os.environ.get("G4VRMLFILE_VIEWER")
 

Function Documentation

◆ Configure()

def demo.Configure ( )

Definition at line 20 of file demo.py.

20def Configure():
21 # ------------------------------------------------------------------
22 # setup for materials
23 # ------------------------------------------------------------------
24 # simple materials for Qgeom
25 g4py.NISTmaterials.Construct()
26
27 # ------------------------------------------------------------------
28 # setup for geometry
29 # ------------------------------------------------------------------
30 #g4py.Qgeom.Construct()
31 g4py.ezgeom.Construct() # initialize
32
33 # ------------------------------------------------------------------
34 # setup for physics list
35 # ------------------------------------------------------------------
36 g4py.EMSTDpl.Construct()
37
38 # ------------------------------------------------------------------
39 # setup for primary generator action
40 # ------------------------------------------------------------------
41 g4py.ParticleGun.Construct()
42 gControlExecute("gun.mac")
43
44# ==================================================================
45# constructing geometry
46# ==================================================================
def Configure()
Definition: demo.py:20
gControlExecute
Definition: __init__.py:157

References source.gControlExecute.

Referenced by G4BiasingProcessInterface.BuildPhysicsTable().

◆ ConstructGeom()

def demo.ConstructGeom ( )

Definition at line 47 of file demo.py.

47def ConstructGeom():
48 print "* Constructing geometry..."
49 # reset world material
50 global absorber
51 air= G4Material.GetMaterial("G4_AIR", 1)
52 galactic = G4Material.GetMaterial("G4_Galactic", 1)
53 absorber = {} # material's dictionary to be used by a radiobutton
54 aluminum = G4Material.GetMaterial("G4_Al", 1)
55 iron = G4Material.GetMaterial("G4_Fe", 1)
56 silver = G4Material.GetMaterial("G4_Ag", 1)
57 gold = G4Material.GetMaterial("G4_Au", 1)
58 lead = G4Material.GetMaterial("G4_Pb", 1)
59 water = G4Material.GetMaterial("G4_WATER", 1)
60 absorber = {"air":air, "aluminum":aluminum, "iron":iron, "lead":lead, "water":water, "gold":gold}
61 g4py.ezgeom.SetWorldMaterial(galactic)
62 g4py.ezgeom.ResizeWorld(120.*cm, 120.*cm, 100.*cm)
63 # water phantom
64 global water_phantom, water_phantom_pv
65
66 water_phantom= G4EzVolume("WaterPhantom")
67 water_phantom.CreateBoxVolume(water, 110.*cm, 110.*cm, 10.*cm)
68
69 water_phantom_pv = water_phantom.PlaceIt(G4ThreeVector(0.,0.,0.*cm))
70
71# ==================================================================
72# main
73# ==================================================================
74# ------------------------------------------------------------------
75# randum number
76# ------------------------------------------------------------------
static G4Material * GetMaterial(const G4String &name, G4bool warning=true)
Definition: G4Material.cc:686
def ConstructGeom()
Definition: demo.py:47

References G4Material.GetMaterial().

◆ hini()

def demo.hini ( )

Definition at line 35 of file demo.py.

35def hini():
36# ------------------------------------------------------------------
37 global gPad1
38 gPad1= ROOT.TPad("2D", "2D", 0.02, 0.5, 0.98, 1.)
39 gPad1.Draw()
40 gPad1.cd()
41
42 ROOT.gStyle.SetPalette(1);
43
44 global hist_dose2d
45 hist_dose2d= ROOT.TH2D("2D Dose", "Dose Distribution",
46 200, 0., 400.,
47 81, -81., 81.)
48 hist_dose2d.SetXTitle("Z (mm)")
49 hist_dose2d.SetYTitle("X (mm)")
50 hist_dose2d.SetStats(0)
51 hist_dose2d.Draw("colz")
52
53 gCanvas.cd()
54 global gPad2
55 gPad2= ROOT.TPad("Z", "Z", 0.02, 0., 0.98, 0.5)
56 gPad2.Draw()
57 gPad2.cd()
58
59 global hist_dosez
60 hist_dosez= ROOT.TH1D("Z Dose", "Depth Dose", 200, 0., 400.)
61 hist_dosez.SetXTitle("(mm)")
62 hist_dosez.SetYTitle("Accumulated Dose (MeV)")
63 hist_dosez.Draw()
64
65# ------------------------------------------------------------------
def hini()
Definition: demo.py:35

Referenced by posXZ().

◆ hshow()

def demo.hshow ( )

Definition at line 66 of file demo.py.

66def hshow():
67# ------------------------------------------------------------------
68 gPad1.cd()
69 hist_dose2d.Draw("colz")
70 gPad2.cd()
71 hist_dosez.Draw()
72
73
74# ==================================================================
75# Geant4 PART #
76# ==================================================================
77
78# ==================================================================
79# user actions in python
80# ==================================================================
def hshow()
Definition: demo.py:66

◆ init_root()

def demo.init_root ( )

Definition at line 18 of file demo.py.

18def init_root():
19# ------------------------------------------------------------------
20 ROOT.gROOT.Reset()
21
22 # plot style
23 ROOT.gStyle.SetTextFont(42)
24 ROOT.gStyle.SetTitleFont(42, "X")
25 ROOT.gStyle.SetLabelFont(42, "X")
26 ROOT.gStyle.SetTitleFont(42, "Y")
27 ROOT.gStyle.SetLabelFont(42, "Y")
28
29 global gCanvas
30 gCanvas= ROOT.TCanvas("water_phantom_plots",
31 "Water Phantom Demo Plots",
32 620, 30, 800, 800)
33
34# ------------------------------------------------------------------
def init_root()
Definition: demo.py:18

Referenced by posXZ().

◆ posXZ()

def demo.posXZ (   copyN)

Definition at line 140 of file demo.py.

140def posXZ(copyN):
141 dd= 2.*mm
142 nx= 81
143
144 iz= copyN/nx
145 ix= copyN-iz*nx-nx/2
146
147 x0= ix*dd
148 z0= (iz+0.5)*dd
149 return (x0,z0)
150
151
152# ==================================================================
153# main
154# ==================================================================
155# init ROOT...
156init_root()
157hini()
158
159# configure application
160#app= demo_wp.MyApplication()
161#app.Configure()
162
163myMaterials= demo_wp.MyMaterials()
164myMaterials.Construct()
165
166myDC= demo_wp.MyDetectorConstruction()
167gRunManager.SetUserInitialization(myDC)
168
169myPL= FTFP_BERT()
170gRunManager.SetUserInitialization(myPL)
171
172# set user actions...
173myPGA= MyPrimaryGeneratorAction()
174gRunManager.SetUserAction(myPGA)
175
176myRA= MyRunAction()
177gRunManager.SetUserAction(myRA)
178
179myEA= MyEventAction()
180gRunManager.SetUserAction(myEA)
181
182#mySA= MySteppingAction()
183#gRunManager.SetUserAction(mySA)
184
185# set particle gun
186#pg= myPGA.particleGun
187#pg.SetParticleByName("proton")
188#pg.SetParticleEnergy(230.*MeV)
189#pg.SetParticleMomentumDirection(G4ThreeVector(0., 0., 1.))
190#pg.SetParticlePosition(G4ThreeVector(0.,0.,-50.)*cm)
191
192# medical beam
193beam= g4py.MedicalBeam.Construct()
194beam.particle= "proton"
195beam.kineticE= 230.*MeV
196#beam.particle= "gamma"
197#beam.kineticE= 1.77*MeV
198beam.sourcePosition= G4ThreeVector(0.,0.,-100.*cm)
199beam.SSD= 100.*cm
200beam.fieldXY= [5.*cm, 5.*cm]
201
202# initialize
203gRunManager.Initialize()
204
205# set SD (A SD should be set after geometry construction)
206scoreSD= ScoreSD()
207myDC.SetSDtoScoreVoxel(scoreSD)
208
209# visualization
210gApplyUICommand("/control/execute vis.mac")
211
212# beamOn
213gRunManager.BeamOn(100)
214
215#ROOT.gSystem.Run()
216
def posXZ(copyN)
Definition: demo.py:140
gApplyUICommand
Definition: __init__.py:158

References source.gApplyUICommand, hini(), and init_root().

Referenced by demo.ScoreSD.ProcessHits().

Variable Documentation

◆ app

demo.app = App()

◆ cutsList

list demo.cutsList = ["um", "mm" , "cm", "m", "km"]

Definition at line 45 of file demo.py.

◆ enrgyList

list demo.enrgyList = ["eV","keV","MeV","GeV","TeV","PeV"]

Definition at line 43 of file demo.py.

◆ exN03geom

demo.exN03geom = g4py.ExN03geom.ExN03DetectorConstruction()

Definition at line 41 of file demo.py.

◆ exN03PL

demo.exN03PL = g4py.EMSTDpl.PhysicsListEMstd()

Definition at line 56 of file demo.py.

◆ heprepDir

demo.heprepDir = os.environ.get("G4HEPREPFILE_DIR")

Definition at line 121 of file demo.py.

◆ heprepName

demo.heprepName = os.environ.get("G4HEPREPFILE_NAME")

Definition at line 122 of file demo.py.

◆ heprepViewer

demo.heprepViewer = os.environ.get("G4HEPREPFILE_VIEWER")

Definition at line 120 of file demo.py.

◆ materialList

demo.materialList = testem0.getMaterialTable();

Definition at line 39 of file demo.py.

Referenced by getMaterialTable().

◆ myDC

demo.myDC = testem0.DetectorConstruction()

Definition at line 18 of file demo.py.

◆ myPGA

demo.myPGA = testem0.PrimaryGeneratorAction(myDC)

Definition at line 25 of file demo.py.

◆ myPL

demo.myPL = testem0.PhysicsList()

Definition at line 21 of file demo.py.

◆ myRA

demo.myRA = testem0.RunAction(myDC,myPGA)

Definition at line 28 of file demo.py.

◆ particleList

demo.particleList = testem0.getParticleTable()

Definition at line 41 of file demo.py.

◆ pg

demo.pg = g4.G4ParticleGun()

Definition at line 37 of file demo.py.

Referenced by G4ParticleHPPartial.InitData(), and G4hhElastic.SetRB().

◆ rand_engine

demo.rand_engine = Ranlux64Engine()

Definition at line 78 of file demo.py.

◆ vrmlDir

demo.vrmlDir = os.environ.get("G4VRML_DEST_DIR")

Definition at line 128 of file demo.py.

◆ vrmlViewer

demo.vrmlViewer = os.environ.get("G4VRMLFILE_VIEWER")

Definition at line 129 of file demo.py.