9 import g4py.NISTmaterials
11 from g4py.ezgeom
import G4EzVolume
13 import g4py.ParticleGun
25 g4py.NISTmaterials.Construct()
31 g4py.ezgeom.Construct()
36 g4py.ExN03pl.Construct()
41 g4py.ParticleGun.Construct()
48 print "* Constructing geometry..."
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)
64 global water_phantom, water_phantom_pv
66 water_phantom= G4EzVolume(
"WaterPhantom")
67 water_phantom.CreateBoxVolume(water, 110.*cm, 110.*cm, 10.*cm)
69 water_phantom_pv = water_phantom.PlaceIt(
G4ThreeVector(0.,0.,0.*cm))
77 print "Random numbers..."
78 rand_engine= Ranlux64Engine()
79 HepRandom.setTheEngine(rand_engine)
80 HepRandom.setTheSeed(20050830L)
91 gRunManager.Initialize()
108 title = Label(self, text=
"Geant4Py for Education @ H. Yoshida Naruto Univ. of Education")
109 title.grid(row=0, column=1, columnspan=5)
110 header = Label(self, text=
"Measurement of Mass Attenuation Coefficient")
111 header.grid(row=1, column=1, columnspan=5)
114 materialLabel = Label(self, bg=
"green", text=
"Material")
115 materialLabel.grid(row=2, column=0, sticky=W)
117 self.materialVar.set(
"water")
120 for i
in absorber.keys():
121 ra1[i] = Radiobutton(self, text=i, variable=self.
materialVar, value=i)
122 ra1[i].grid(row=2, column=pos, sticky=W)
126 thickLabel = Label(self, bg=
"green", text=
"Thickness (mm)")
128 self.thickVar.set(100.0)
129 thick =
Scale(self, orient=HORIZONTAL, length=400, from_=0., to=100., resolution=0.05, tickinterval=10.0, digits=4, variable=self.
thickVar)
130 thickLabel.grid(row=3, column=0, sticky=W)
131 thick.grid(row=3, column=1, columnspan=5, sticky=W)
134 self.
solid = g4py.ezgeom.G4EzVolume.GetSold(water_phantom)
137 particleLabel = Label(self, bg=
"green", text=
"Particle")
138 particleLabel.grid(row=4, column=0, sticky=W)
140 self.particleVar.set(
"gamma")
143 for i
in (
"gamma",
"e-",
"proton"):
144 ra1[i] = Radiobutton(self, text=i, variable=self.
particleVar, value=i)
145 ra1[i].grid(row=4, column=pos1, sticky=W)
149 energyLabel = Label(self, bg=
"green", text=
"Energy (MeV)")
152 self.energyVar.set(1)
153 energy =
Scale(self, orient=HORIZONTAL, length=400, from_=0., to=100., tickinterval=10.0, resolution=0.1, variable=self.
energyVar, digits=4 )
154 energyLabel.grid(row=5, column=0, sticky=W)
155 energy.grid(row=5, column=1, columnspan=5, sticky=W)
158 eventLabel = Label(self, bg=
"green", text=
"Events")
160 event =
Scale(self, orient=HORIZONTAL, length=400, from_=1, to=100, tickinterval=10, resolution=1, variable=self.
eventVar )
161 eventLabel.grid(row=6, column=0, sticky=W)
162 event.grid(row=6, column=1, columnspan=5, sticky=W)
165 startBut = Button(self, bg=
"orange", text=
"Start a run", command=self.
cmd_beamOn)
166 startBut.grid(row=0, column=0, sticky=W)
171 processLabel = Label(self, text=
"Process On/Off", bg=
"green")
172 processLabel.grid(row=8, column=0, sticky=W)
174 self.
processList = [
"phot",
"compt",
"msc",
"conv",
"eIoni",
"eBrem",
"hIoni"]
180 procTab[i].grid(row=8, column=pos, sticky=W)
186 visLabel = Label(self, text=
"viewer", bg=
"orange")
187 expandBut = Button(self, text=
"Zoom in", command=self.
cmd_expand)
188 shrinkBut = Button(self, text=
"Zoom out", command=self.
cmd_shrink)
189 visLabel.grid(row=9, column=0, sticky=W)
190 expandBut.grid(row=9, column=1, sticky=W)
191 shrinkBut.grid(row=9, column=2, sticky=W)
193 upBut = Button(self, text=
"Up", command=self.
cmd_up)
194 downBut = Button(self, text=
"Down", command=self.
cmd_down)
195 upBut.grid(row=9, column=3, sticky=W)
196 downBut.grid(row=9, column=4, sticky=W)
198 leftBut = Button(self, text=
"Left", command=self.
cmd_left)
199 rightBut = Button(self, text=
"Right", command=self.
cmd_right)
200 leftBut.grid(row=9, column=5, sticky=W)
201 rightBut.grid(row=9, column=6, sticky=W)
224 exitBut = Button(self, bg=
"red", text=
"End all", command=sys.exit)
225 exitBut.grid(row=0, column=6, sticky=W)
229 materialChosen = self.materialVar.get()
230 water_phantom.SetMaterial(absorber[materialChosen])
232 if materialChosen ==
"water":
233 water_phantom.SetColor(0., 0.9, 1.0)
235 if materialChosen ==
"air":
236 water_phantom.SetColor(0.9, 0.9, 1.0)
238 if materialChosen ==
"lead":
239 water_phantom.SetColor(0.2, 0.2, 0.2)
241 if materialChosen ==
"iron":
242 water_phantom.SetColor(0.7, 0.5, 0.7)
244 if materialChosen ==
"aluminum":
245 water_phantom.SetColor(.7, 0.9, 1.0)
247 if materialChosen ==
"gold":
248 water_phantom.SetColor(1., 0.9, .0)
250 self.solid.SetZHalfLength(self.thickVar.get() * mm/2.0)
258 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 eventNum = self.eventVar.get()
261 for i
in range(eventNum):
262 gunYZpos = str(i-eventNum/2) +
". -20. cm"
264 gRunManager.BeamOn(1)
280 gProcessTable.SetProcessActivation(i, 0)
282 gProcessTable.SetProcessActivation(i, 1)
313 Frame.__init__(self, master)