Geant4-11
Public Member Functions | Data Fields
Lesson1.App Class Reference
Inheritance diagram for Lesson1.App:

Public Member Functions

def __init__ (self, master=None)
 
def cmd_beamOn (self)
 
def cmd_down (self)
 
def cmd_energy (self, penergy)
 
def cmd_expand (self)
 
def cmd_g4command (self)
 
def cmd_left (self)
 
def cmd_particle (self, particle)
 
def cmd_right (self)
 
def cmd_shrink (self)
 
def cmd_up (self)
 
def init (self)
 

Data Fields

 energyVar
 
 eventVar
 
 materialVar
 
 particleVar
 
 solid
 
 thickVar
 

Detailed Description

Definition at line 100 of file Lesson1.py.

Constructor & Destructor Documentation

◆ __init__()

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

Definition at line 287 of file Lesson1.py.

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

References G4SimplexDownhill< G4ConvergenceTester >.init(), G4SimplexDownhill< T >.init(), G4LFission.init(), G4INCL::Config.init(), G4HepRepFileXMLWriter.init(), G4GIDI_target.init(), G4GIDI.init(), demo.App.init(), testem0.App.init(), Lesson1.App.init(), and ExN03.App.init().

Member Function Documentation

◆ cmd_beamOn()

def Lesson1.App.cmd_beamOn (   self)

Definition at line 209 of file Lesson1.py.

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

References demo.App.cmd_energy(), Lesson1.App.cmd_energy(), ExN03.App.cmd_energy(), demo.App.cmd_particle(), Lesson1.App.cmd_particle(), ExN03.App.cmd_particle(), demo.App.energyVar, Lesson1.App.energyVar, ExN03.App.energyVar, demo.App.eventVar, Lesson1.App.eventVar, ExN03.App.eventVar, source.gApplyUICommand, PTL.get(), demo.App.materialVar, Lesson1.App.materialVar, demo.App.particleVar, Lesson1.App.particleVar, ExN03.App.particleVar, demo.App.solid, Lesson1.App.solid, G4EzVolume.solid, G4MultiUnion::G4MultiUnionSurface.solid, G4VisAttributes.solid, Geant4_SoPolyhedron.solid, demo.App.thickVar, and Lesson1.App.thickVar.

◆ cmd_down()

def Lesson1.App.cmd_down (   self)

Definition at line 269 of file Lesson1.py.

269 def cmd_down(self):
270 gApplyUICommand("/vis/viewer/pan " + " 0. -10. mm")
271

References source.gApplyUICommand.

◆ cmd_energy()

def Lesson1.App.cmd_energy (   self,
  penergy 
)

Definition at line 259 of file Lesson1.py.

259 def cmd_energy(self, penergy):
260 gApplyUICommand("/gun/energy " + penergy + " MeV")
261
262

References source.gApplyUICommand.

Referenced by demo.App.cmd_beamOn(), Lesson1.App.cmd_beamOn(), and ExN03.App.cmd_beamOn().

◆ cmd_expand()

def Lesson1.App.cmd_expand (   self)

Definition at line 263 of file Lesson1.py.

263 def cmd_expand(self):
264 gApplyUICommand("/vis/viewer/zoom 1.2")
265

References source.gApplyUICommand.

◆ cmd_g4command()

def Lesson1.App.cmd_g4command (   self)

Definition at line 252 of file Lesson1.py.

252 def cmd_g4command(self):
253 gApplyUICommand(self.g4commandVar.get())
254

References demo.App.g4commandVar, ExN03.App.g4commandVar, source.gApplyUICommand, and PTL.get().

◆ cmd_left()

def Lesson1.App.cmd_left (   self)

Definition at line 275 of file Lesson1.py.

275 def cmd_left(self):
276 gApplyUICommand("/vis/viewer/pan " + " 1. 0. mm")
277
278

References source.gApplyUICommand.

◆ cmd_particle()

def Lesson1.App.cmd_particle (   self,
  particle 
)

Definition at line 255 of file Lesson1.py.

255 def cmd_particle(self, particle):
256 gApplyUICommand("/gun/particle " + particle)
257
258

References source.gApplyUICommand.

Referenced by demo.App.cmd_beamOn(), Lesson1.App.cmd_beamOn(), and ExN03.App.cmd_beamOn().

◆ cmd_right()

def Lesson1.App.cmd_right (   self)

Definition at line 272 of file Lesson1.py.

272 def cmd_right(self):
273 gApplyUICommand("/vis/viewer/pan " + " -1. 0. mm")
274

References source.gApplyUICommand.

◆ cmd_shrink()

def Lesson1.App.cmd_shrink (   self)

Definition at line 279 of file Lesson1.py.

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

References source.gApplyUICommand.

◆ cmd_up()

def Lesson1.App.cmd_up (   self)

Definition at line 266 of file Lesson1.py.

266 def cmd_up(self):
267 gApplyUICommand("/vis/viewer/pan " + " 0. 10. mm")
268

References source.gApplyUICommand.

◆ init()

def Lesson1.App.init (   self)

Definition at line 103 of file Lesson1.py.

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

Referenced by demo.App.__init__(), testem0.App.__init__(), Lesson1.App.__init__(), and ExN03.App.__init__().

Field Documentation

◆ energyVar

Lesson1.App.energyVar

Definition at line 149 of file Lesson1.py.

Referenced by demo.App.cmd_beamOn(), Lesson1.App.cmd_beamOn(), and ExN03.App.cmd_beamOn().

◆ eventVar

Lesson1.App.eventVar

Definition at line 157 of file Lesson1.py.

Referenced by demo.App.cmd_beamOn(), Lesson1.App.cmd_beamOn(), and ExN03.App.cmd_beamOn().

◆ materialVar

Lesson1.App.materialVar

Definition at line 114 of file Lesson1.py.

Referenced by demo.App.cmd_beamOn(), and Lesson1.App.cmd_beamOn().

◆ particleVar

Lesson1.App.particleVar

Definition at line 137 of file Lesson1.py.

Referenced by demo.App.cmd_beamOn(), Lesson1.App.cmd_beamOn(), and ExN03.App.cmd_beamOn().

◆ solid

Lesson1.App.solid

Definition at line 132 of file Lesson1.py.

Referenced by demo.App.cmd_beamOn(), and Lesson1.App.cmd_beamOn().

◆ thickVar

Lesson1.App.thickVar

Definition at line 125 of file Lesson1.py.

Referenced by demo.App.cmd_beamOn(), and Lesson1.App.cmd_beamOn().


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