Geant4  10.03.p03
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Lesson1.App Class Reference
Inheritance diagram for Lesson1.App:
Collaboration diagram for Lesson1.App:

Public Member Functions

def init
 
def cmd_beamOn
 
def cmd_g4command
 
def cmd_particle
 
def cmd_energy
 
def cmd_expand
 
def cmd_up
 
def cmd_down
 
def cmd_right
 
def cmd_left
 
def cmd_shrink
 
def __init__
 

Public Attributes

 materialVar
 
 thickVar
 
 solid
 
 particleVar
 
 energyVar
 
 eventVar
 

Detailed Description

Definition at line 100 of file Lesson1.py.

Constructor & Destructor Documentation

def Lesson1.App.__init__ (   self,
  master = None 
)

Definition at line 287 of file Lesson1.py.

288  def __init__(self, master=None):
289  Frame.__init__(self, master)
290  self.init()
291  self.grid()
292 
def __init__
Definition: Lesson1.py:287
def init
Definition: Lesson1.py:103

Here is the call graph for this function:

Member Function Documentation

def Lesson1.App.cmd_beamOn (   self)

Definition at line 209 of file Lesson1.py.

210  def cmd_beamOn(self):
211  materialChosen = self.materialVar.get()
212  water_phantom.SetMaterial(absorber[materialChosen])
213 
214  if materialChosen == "water":
215  water_phantom.SetColor(0., 0.9, 1.0)
216 
217  if materialChosen == "air":
218  water_phantom.SetColor(0.9, 0.9, 1.0)
219 
220  if materialChosen == "lead":
221  water_phantom.SetColor(0.2, 0.2, 0.2)
222 
223  if materialChosen == "iron":
224  water_phantom.SetColor(0.7, 0.5, 0.7)
225 
226  if materialChosen == "aluminum":
227  water_phantom.SetColor(.7, 0.9, 1.0)
228 
229  if materialChosen == "gold":
230  water_phantom.SetColor(1., 0.9, .0)
231 
232  self.solid.SetZHalfLength(self.thickVar.get() * mm/2.0)
233 # gControlExecute("oglx.mac") #draw for each run
234  gApplyUICommand("/vis/viewer/flush")
235 
236  self.cmd_particle(self.particleVar.get())
237  self.cmd_energy(self.energyVar.get())
238 # TODO later to reflesh text
239  gApplyUICommand("/vis/scene/add/text 0 610 610 mm 20 0 0 " + " ")
240  gApplyUICommand("/vis/scene/add/text 0 610 610 mm 20 0 0 " + self.materialVar.get() + " = " + str(self.thickVar.get()) + "mm " + self.particleVar.get() + " = "+self.energyVar.get() + "MeV")
241 
242  eventNum = self.eventVar.get()
243  for i in range(eventNum):
244  gunYZpos = str(i-eventNum/2) + ". -20. cm"
245  gApplyUICommand("/gun/position 0. " + gunYZpos)
246  gRunManager.BeamOn(1)
247  sleep(0.01)
248 # self.cmd_expand() #Zoom in to the last diaplayed OGLSX
249 # self.cmd_shrink()
250 
251 
const G4ParticleDefinition const G4Material *G4double range
gApplyUICommand
Definition: __init__.py:165
def cmd_energy
Definition: Lesson1.py:259
def cmd_particle
Definition: Lesson1.py:255
def cmd_beamOn
Definition: Lesson1.py:209

Here is the call graph for this function:

def Lesson1.App.cmd_down (   self)

Definition at line 269 of file Lesson1.py.

270  def cmd_down(self):
271  gApplyUICommand("/vis/viewer/pan " + " 0. -10. mm")
def cmd_down
Definition: Lesson1.py:269
gApplyUICommand
Definition: __init__.py:165
def Lesson1.App.cmd_energy (   self,
  penergy 
)

Definition at line 259 of file Lesson1.py.

260  def cmd_energy(self, penergy):
261  gApplyUICommand("/gun/energy " + penergy + " MeV")
262 
gApplyUICommand
Definition: __init__.py:165
def cmd_energy
Definition: Lesson1.py:259

Here is the caller graph for this function:

def Lesson1.App.cmd_expand (   self)

Definition at line 263 of file Lesson1.py.

264  def cmd_expand(self):
265  gApplyUICommand("/vis/viewer/zoom 1.2")
def cmd_expand
Definition: Lesson1.py:263
gApplyUICommand
Definition: __init__.py:165
def Lesson1.App.cmd_g4command (   self)

Definition at line 252 of file Lesson1.py.

253  def cmd_g4command(self):
254  gApplyUICommand(self.g4commandVar.get())
def cmd_g4command
Definition: Lesson1.py:252
gApplyUICommand
Definition: __init__.py:165
def Lesson1.App.cmd_left (   self)

Definition at line 275 of file Lesson1.py.

276  def cmd_left(self):
277  gApplyUICommand("/vis/viewer/pan " + " 1. 0. mm")
278 
def cmd_left
Definition: Lesson1.py:275
gApplyUICommand
Definition: __init__.py:165
def Lesson1.App.cmd_particle (   self,
  particle 
)

Definition at line 255 of file Lesson1.py.

256  def cmd_particle(self, particle):
257  gApplyUICommand("/gun/particle " + particle)
258 
gApplyUICommand
Definition: __init__.py:165
def cmd_particle
Definition: Lesson1.py:255

Here is the caller graph for this function:

def Lesson1.App.cmd_right (   self)

Definition at line 272 of file Lesson1.py.

273  def cmd_right(self):
274  gApplyUICommand("/vis/viewer/pan " + " -1. 0. mm")
def cmd_right
Definition: Lesson1.py:272
gApplyUICommand
Definition: __init__.py:165
def Lesson1.App.cmd_shrink (   self)

Definition at line 279 of file Lesson1.py.

280  def cmd_shrink(self):
281  gApplyUICommand("/vis/viewer/zoom 0.8")
282 
283 
284 # def cmd_reset(self):
285 # gApplyUICommand("/vis/viewer/pan " + " 0. 0. mm")
286 
gApplyUICommand
Definition: __init__.py:165
def cmd_shrink
Definition: Lesson1.py:279
def Lesson1.App.cmd_up (   self)

Definition at line 266 of file Lesson1.py.

267  def cmd_up(self):
268  gApplyUICommand("/vis/viewer/pan " + " 0. 10. mm")
gApplyUICommand
Definition: __init__.py:165
def cmd_up
Definition: Lesson1.py:266
def Lesson1.App.init (   self)

Definition at line 103 of file Lesson1.py.

104  def init(self):
105 
106 #title and header row=0, 1
107  title = Label(self, text="Geant4Py for Education @ H. Yoshida Naruto Univ. of Education")
108  title.grid(row=0, column=1, columnspan=5)
109  header = Label(self, text="Measurement of Mass Attenuation Coefficient")
110  header.grid(row=1, column=1, columnspan=5)
111 
112 #material selection row=2
113  materialLabel = Label(self, bg="green", text="Material")
114  materialLabel.grid(row=2, column=0, sticky=W)
115  self.materialVar = StringVar()
116  self.materialVar.set("water")
117  ra1 = { }
118  pos=1
119  for i in absorber.keys():
120  ra1[i] = Radiobutton(self, text=i, variable=self.materialVar, value=i)
121  ra1[i].grid(row=2, column=pos, sticky=W)
122  pos=pos+1
123 
124 #absorber thickness row=3
125  thickLabel = Label(self, bg="green", text="Thickness (mm)")
126  self.thickVar = DoubleVar()
127  self.thickVar.set(100.0)
128  thick = Scale(self, orient=HORIZONTAL, length=400, from_=0., to=100., resolution=0.05, tickinterval=10.0, digits=4, variable=self.thickVar)
129  thickLabel.grid(row=3, column=0, sticky=W)
130  thick.grid(row=3, column=1, columnspan=5, sticky=W)
131 
132 #get logical volume and set its half length
133  self.solid = g4py.ezgeom.G4EzVolume.GetSold(water_phantom)
134 
135 #particle row=4
136  particleLabel = Label(self, bg="green", text="Particle")
137  particleLabel.grid(row=4, column=0, sticky=W)
138  self.particleVar = StringVar()
139  self.particleVar.set("gamma")
140  ra1 = { }
141  pos1=1
142  for i in ("gamma", "e-"):
143  ra1[i] = Radiobutton(self, text=i, variable=self.particleVar, value=i)
144  ra1[i].grid(row=4, column=pos1, sticky=W)
145  pos1=pos1+1
146 
147 #energy row=5
148  energyLabel = Label(self, bg="green", text="Energy (MeV)")
150  self.energyVar=StringVar()
151  self.energyVar.set(1)
152  energy = Scale(self, orient=HORIZONTAL, length=400, from_=0., to=100., tickinterval=10.0, resolution=0.1, variable=self.energyVar, digits=4 )
153  energyLabel.grid(row=5, column=0, sticky=W)
154  energy.grid(row=5, column=1, columnspan=5, sticky=W)
155 
156 #number of event row=6
157  eventLabel = Label(self, bg="green", text="Events")
158  self.eventVar=IntVar()
159  event = Scale(self, orient=HORIZONTAL, length=400, from_=1, to=100, tickinterval=10, resolution=1, variable=self.eventVar )
160  eventLabel.grid(row=6, column=0, sticky=W)
161  event.grid(row=6, column=1, columnspan=5, sticky=W)
162 
163 #start a run button row=7
164  startBut = Button(self, bg="orange", text="Start a run", command=self.cmd_beamOn)
165  startBut.grid(row=0, column=0, sticky=W)
166 
167 #Zoom in/out Pan X Y row=8
168  visLabel = Label(self, text="viewer", bg="orange")
169  expandBut = Button(self, text="Zoom in", command=self.cmd_expand)
170  shrinkBut = Button(self, text="Zoom out", command=self.cmd_shrink)
171  visLabel.grid(row=8, column=0, sticky=W)
172  expandBut.grid(row=8, column=1, sticky=W)
173  shrinkBut.grid(row=8, column=2, sticky=W)
174 
175  upBut = Button(self, text="Up", command=self.cmd_up)
176  downBut = Button(self, text="Down", command=self.cmd_down)
177  upBut.grid(row=8, column=3, sticky=W)
178  downBut.grid(row=8, column=4, sticky=W)
179 
180  leftBut = Button(self, text="Left", command=self.cmd_left)
181  rightBut = Button(self, text="Right", command=self.cmd_right)
182  leftBut.grid(row=8, column=5, sticky=W)
183  rightBut.grid(row=8, column=6, sticky=W)
184 # later
185 # resetBut = Button(self, text="Reset", command=self.cmd_reset)
186 # resetBut.grid(row=8, column=7, sticky=W)
187 
188 
189 # panLabel = Label(self, text="Pan X Y (mm)")
190 # self.panXYVar = StringVar()
191 # panXYEnt = Entry(self, textvariable=self.panXYVar)
192 # panBut = Button(self, bg="orange", text="OK", command=self.cmd_pan)
193 # panLabel.grid(row=8, column=3, sticky=W)
194 # panXYEnt.grid(row=8, column=4)
195 # panBut.grid(row=8, column=5)
196 #Geant4 command entry row = 9
197 # g4comLabel = Label(self, text="Geant4 command")
198 # self.g4commandVar = StringVar()
199 # commandEntry = Entry(self, textvariable=self.g4commandVar)
200 # comBut = Button(self, bg="orange", text="Execute", command=self.cmd_g4command)
201 # g4comLabel.grid(row=9, column=0, sticky=W)
202 # commandEntry.grid(row=9, column=1, columnspan=4, sticky=E+W)
203 # comBut.grid(row=9, column=5)
204 
205 #exit row = 10
206  exitBut = Button(self, bg="red", text="End all", command=sys.exit)
207  exitBut.grid(row=0, column=6, sticky=W)
208 
#on Run butto do...
def cmd_right
Definition: Lesson1.py:272
def cmd_expand
Definition: Lesson1.py:263
def cmd_left
Definition: Lesson1.py:275
def cmd_down
Definition: Lesson1.py:269
def init
Definition: Lesson1.py:103
def cmd_beamOn
Definition: Lesson1.py:209
def cmd_shrink
Definition: Lesson1.py:279
def cmd_up
Definition: Lesson1.py:266

Here is the caller graph for this function:

Member Data Documentation

Lesson1.App.energyVar

Definition at line 149 of file Lesson1.py.

Lesson1.App.eventVar

Definition at line 157 of file Lesson1.py.

Lesson1.App.materialVar

Definition at line 114 of file Lesson1.py.

Lesson1.App.particleVar

Definition at line 137 of file Lesson1.py.

Lesson1.App.solid

Definition at line 132 of file Lesson1.py.

Lesson1.App.thickVar

Definition at line 125 of file Lesson1.py.


The documentation for this class was generated from the following file: