Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Data Fields
Lesson1withN03.App Class Reference
Inheritance diagram for Lesson1withN03.App:

Public Member Functions

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

Data Fields

 materialVar
 
 thickVar
 
 solid
 
 particleVar
 
 energyVar
 
 eventVar
 
 processList
 
 processVar
 

Detailed Description

Definition at line 101 of file Lesson1withN03.py.

Constructor & Destructor Documentation

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

Definition at line 312 of file Lesson1withN03.py.

References testem0.App.init(), Lesson1.App.init(), Lesson1withN03.App.init(), ccdpm25dprin.init, and c2_cached_function_p< float_type >.init.

313  def __init__(self, master=None):
314  Frame.__init__(self, master)
315  self.init()
316  self.grid()
317 

Member Function Documentation

def Lesson1withN03.App.cmd_beamOn (   self)

Definition at line 228 of file Lesson1withN03.py.

References Lesson1.App.cmd_energy(), Lesson1withN03.App.cmd_energy(), Lesson1.App.cmd_particle(), Lesson1withN03.App.cmd_particle(), and python.gApplyUICommand.

Referenced by ExN03.App.init().

229  def cmd_beamOn(self):
230  materialChosen = self.materialVar.get()
231  water_phantom.SetMaterial(absorber[materialChosen])
232 
233  if materialChosen == "water":
234  water_phantom.SetColor(0., 0.9, 1.0)
235 
236  if materialChosen == "air":
237  water_phantom.SetColor(0.9, 0.9, 1.0)
238 
239  if materialChosen == "lead":
240  water_phantom.SetColor(0.2, 0.2, 0.2)
241 
242  if materialChosen == "iron":
243  water_phantom.SetColor(0.7, 0.5, 0.7)
244 
245  if materialChosen == "aluminum":
246  water_phantom.SetColor(.7, 0.9, 1.0)
247 
248  if materialChosen == "gold":
249  water_phantom.SetColor(1., 0.9, .0)
250 
251  self.solid.SetZHalfLength(self.thickVar.get() * mm/2.0)
252 # gControlExecute("oglx.mac") #draw for each run
253  gApplyUICommand("/vis/viewer/flush")
254 
255  self.cmd_particle(self.particleVar.get())
256  self.cmd_energy(self.energyVar.get())
257 # TODO later to reflesh text
258  gApplyUICommand("/vis/scene/add/text 0 610 610 mm 20 0 0 " + " ")
259  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")
260 
261  eventNum = self.eventVar.get()
262  for i in range(eventNum):
263  gunYZpos = str(i-eventNum/2) + ". -20. cm"
264  gApplyUICommand("/gun/position 0. " + gunYZpos)
265  gRunManager.BeamOn(1)
266  sleep(0.01)
267 # self.cmd_expand() #Zoom in to the last diaplayed OGLSX
268 # self.cmd_shrink()
269 
270 
def Lesson1withN03.App.cmd_down (   self)

Definition at line 294 of file Lesson1withN03.py.

References python.gApplyUICommand.

295  def cmd_down(self):
296  gApplyUICommand("/vis/viewer/pan " + " 0. -10. mm")
def Lesson1withN03.App.cmd_energy (   self,
  penergy 
)

Definition at line 284 of file Lesson1withN03.py.

References python.gApplyUICommand.

Referenced by Lesson1withN03.App.cmd_beamOn(), and ExN03.App.cmd_beamOn().

285  def cmd_energy(self, penergy):
286  gApplyUICommand("/gun/energy " + penergy + " MeV")
287 
def Lesson1withN03.App.cmd_expand (   self)

Definition at line 288 of file Lesson1withN03.py.

References python.gApplyUICommand.

289  def cmd_expand(self):
290  gApplyUICommand("/vis/viewer/zoom 1.2")
def Lesson1withN03.App.cmd_g4command (   self)

Definition at line 271 of file Lesson1withN03.py.

References python.gApplyUICommand.

Referenced by ExN03.App.init().

272  def cmd_g4command(self):
273  gApplyUICommand(self.g4commandVar.get())
def Lesson1withN03.App.cmd_left (   self)

Definition at line 300 of file Lesson1withN03.py.

References python.gApplyUICommand.

301  def cmd_left(self):
302  gApplyUICommand("/vis/viewer/pan " + " 1. 0. mm")
303 
def Lesson1withN03.App.cmd_particle (   self,
  particle 
)

Definition at line 274 of file Lesson1withN03.py.

References python.gApplyUICommand.

Referenced by Lesson1withN03.App.cmd_beamOn(), and ExN03.App.cmd_beamOn().

275  def cmd_particle(self, particle):
276  gApplyUICommand("/gun/particle " + particle)
def Lesson1withN03.App.cmd_right (   self)

Definition at line 297 of file Lesson1withN03.py.

References python.gApplyUICommand.

298  def cmd_right(self):
299  gApplyUICommand("/vis/viewer/pan " + " -1. 0. mm")
def Lesson1withN03.App.cmd_setProcess (   self)

Definition at line 277 of file Lesson1withN03.py.

References Lesson1withN03.App.processList, and Lesson1withN03.App.processVar.

Referenced by ExN03.App.init().

278  def cmd_setProcess(self):
279  for i in self.processList:
280  if self.processVar[i].get() == 0:
281  gProcessTable.SetProcessActivation(i, 0)
282  else:
283  gProcessTable.SetProcessActivation(i, 1)
def Lesson1withN03.App.cmd_shrink (   self)

Definition at line 304 of file Lesson1withN03.py.

References python.gApplyUICommand.

305  def cmd_shrink(self):
306  gApplyUICommand("/vis/viewer/zoom 0.8")
307 
308 
309 # def cmd_reset(self):
310 # gApplyUICommand("/vis/viewer/pan " + " 0. 0. mm")
311 
def Lesson1withN03.App.cmd_up (   self)

Definition at line 291 of file Lesson1withN03.py.

References python.gApplyUICommand.

292  def cmd_up(self):
293  gApplyUICommand("/vis/viewer/pan " + " 0. 10. mm")
def Lesson1withN03.App.init (   self)

Definition at line 105 of file Lesson1withN03.py.

Referenced by Lesson1withN03.App.__init__(), and ExN03.App.__init__().

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

Field Documentation

Lesson1withN03.App.energyVar

Definition at line 151 of file Lesson1withN03.py.

Referenced by ExN03.App.init().

Lesson1withN03.App.eventVar

Definition at line 159 of file Lesson1withN03.py.

Referenced by ExN03.App.init().

Lesson1withN03.App.materialVar

Definition at line 116 of file Lesson1withN03.py.

Lesson1withN03.App.particleVar

Definition at line 139 of file Lesson1withN03.py.

Referenced by ExN03.App.init().

Lesson1withN03.App.processList

Definition at line 174 of file Lesson1withN03.py.

Referenced by Lesson1withN03.App.cmd_setProcess(), ExN03.App.cmd_setProcess(), ExN03.App.init(), and Lesson1Wx.MyApp.RunStart().

Lesson1withN03.App.processVar

Definition at line 175 of file Lesson1withN03.py.

Referenced by Lesson1withN03.App.cmd_setProcess(), ExN03.App.cmd_setProcess(), and ExN03.App.init().

Lesson1withN03.App.solid

Definition at line 134 of file Lesson1withN03.py.

Lesson1withN03.App.thickVar

Definition at line 127 of file Lesson1withN03.py.


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