Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Data Structures | Functions
demo Namespace Reference

Data Structures

class  MyEventAction
 
class  MyPrimaryGeneratorAction
 
class  MyRunAction
 
class  MySteppingAction
 
class  ScoreSD
 

Functions

def init_root
 
def hini
 
def hshow
 
def posXZ
 

Function Documentation

def demo.hini ( )

Definition at line 35 of file demo.py.

Referenced by posXZ().

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

Definition at line 66 of file demo.py.

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

Definition at line 18 of file demo.py.

Referenced by posXZ().

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

Definition at line 140 of file demo.py.

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

Referenced by demo.ScoreSD.ProcessHits().

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