Geant4  10.02.p03
demo Namespace Reference

Classes

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

Functions

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

Variables

 myDC = testem0.DetectorConstruction()
 
 myPL = testem0.PhysicsList()
 
 myPGA = testem0.PrimaryGeneratorAction(myDC)
 
 myRA = testem0.RunAction(myDC,myPGA)
 
 pg = g4.G4ParticleGun()
 
 materialList = testem0.getMaterialTable();
 
 particleList = testem0.getParticleTable()
 
list enrgyList = ["eV","keV","MeV","GeV","TeV","PeV"]
 
list cutsList = ["um", "mm" , "cm", "m", "km"]
 
 app = App()
 
 rand_engine = Ranlux64Engine()
 
 exN03geom = g4py.ExN03geom.ExN03DetectorConstruction()
 
 exN03PL = g4py.ExN03pl.PhysicsList()
 
 heprepViewer = os.environ.get("G4HEPREPFILE_VIEWER")
 
 heprepDir = os.environ.get("G4HEPREPFILE_DIR")
 
 heprepName = os.environ.get("G4HEPREPFILE_NAME")
 
 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 education/lesson1/demo.py.

20 def 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 # ==================================================================
Here is the caller graph for this function:

◆ ConstructGeom()

def demo.ConstructGeom ( )

Definition at line 47 of file education/lesson1/demo.py.

47 def 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:604
def ConstructGeom()
Here is the call graph for this function:

◆ hini()

def demo.hini ( )

Definition at line 35 of file demos/water_phantom/demo.py.

35 def 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 # ------------------------------------------------------------------
Here is the caller graph for this function:

◆ hshow()

def demo.hshow ( )

Definition at line 66 of file demos/water_phantom/demo.py.

66 def 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 # ==================================================================

◆ init_root()

def demo.init_root ( )

Definition at line 18 of file demos/water_phantom/demo.py.

18 def 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 # ------------------------------------------------------------------
Here is the caller graph for this function:

◆ posXZ()

def demo.posXZ (   copyN)

Definition at line 140 of file demos/water_phantom/demo.py.

140 def 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...
156 init_root()
157 hini()
158 
159 # configure application
160 #app= demo_wp.MyApplication()
161 #app.Configure()
162 
163 myMaterials= demo_wp.MyMaterials()
164 myMaterials.Construct()
165 
166 myDC= demo_wp.MyDetectorConstruction()
167 gRunManager.SetUserInitialization(myDC)
168 
169 myPL= FTFP_BERT()
170 gRunManager.SetUserInitialization(myPL)
171 
172 # set user actions...
173 myPGA= MyPrimaryGeneratorAction()
174 gRunManager.SetUserAction(myPGA)
175 
176 myRA= MyRunAction()
177 gRunManager.SetUserAction(myRA)
178 
179 myEA= MyEventAction()
180 gRunManager.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
193 beam= g4py.MedicalBeam.Construct()
194 beam.particle= "proton"
195 beam.kineticE= 230.*MeV
196 #beam.particle= "gamma"
197 #beam.kineticE= 1.77*MeV
198 beam.sourcePosition= G4ThreeVector(0.,0.,-100.*cm)
199 beam.SSD= 100.*cm
200 beam.fieldXY= [5.*cm, 5.*cm]
201 
202 # initialize
203 gRunManager.Initialize()
204 
205 # set SD (A SD should be set after geometry construction)
206 scoreSD= ScoreSD()
207 myDC.SetSDtoScoreVoxel(scoreSD)
208 
209 # visualization
210 gApplyUICommand("/control/execute vis.mac")
211 
212 # beamOn
213 gRunManager.BeamOn(100)
214 
215 #ROOT.gSystem.Run()
216 
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ app

demo.app = App()

Definition at line 189 of file demos/TestEm0/demo.py.

◆ cutsList

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

Definition at line 45 of file demos/TestEm0/demo.py.

◆ enrgyList

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

Definition at line 43 of file demos/TestEm0/demo.py.

◆ exN03geom

demo.exN03geom = g4py.ExN03geom.ExN03DetectorConstruction()

Definition at line 41 of file education/lesson2/demo.py.

◆ exN03PL

demo.exN03PL = g4py.ExN03pl.PhysicsList()

Definition at line 56 of file education/lesson2/demo.py.

◆ heprepDir

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

Definition at line 121 of file education/lesson2/demo.py.

◆ heprepName

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

Definition at line 122 of file education/lesson2/demo.py.

◆ heprepViewer

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

Definition at line 120 of file education/lesson2/demo.py.

◆ materialList

demo.materialList = testem0.getMaterialTable();

Definition at line 39 of file demos/TestEm0/demo.py.

◆ myDC

demo.myDC = testem0.DetectorConstruction()

Definition at line 18 of file demos/TestEm0/demo.py.

◆ myPGA

demo.myPGA = testem0.PrimaryGeneratorAction(myDC)

Definition at line 25 of file demos/TestEm0/demo.py.

◆ myPL

demo.myPL = testem0.PhysicsList()

Definition at line 21 of file demos/TestEm0/demo.py.

◆ myRA

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

Definition at line 28 of file demos/TestEm0/demo.py.

◆ particleList

demo.particleList = testem0.getParticleTable()

Definition at line 41 of file demos/TestEm0/demo.py.

◆ pg

demo.pg = g4.G4ParticleGun()

Definition at line 37 of file demos/TestEm0/demo.py.

◆ rand_engine

demo.rand_engine = Ranlux64Engine()

Definition at line 78 of file education/lesson1/demo.py.

◆ vrmlDir

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

Definition at line 128 of file education/lesson2/demo.py.

◆ vrmlViewer

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

Definition at line 129 of file education/lesson2/demo.py.