9 import g4py.NISTmaterials
 
   11 from g4py.ezgeom 
import G4EzVolume
 
   13 import g4py.ParticleGun
 
   25   g4py.NISTmaterials.Construct()
 
   31   g4py.ezgeom.Construct()  
 
   36   g4py.EMSTDpl.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)
 
   90 gRunManager.Initialize()
 
  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)
 
  112     materialLabel = Label(self, bg=
"green", text=
"Material")
 
  113     materialLabel.grid(row=2, column=0, sticky=W)
 
  115     self.materialVar.set(
"water")
 
  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)
 
  124     thickLabel = Label(self, bg=
"green", text=
"Thickness (mm)")
 
  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)
 
  132     self.
solid = g4py.ezgeom.G4EzVolume.GetSold(water_phantom)
 
  135     particleLabel = Label(self, bg=
"green",  text=
"Particle")
 
  136     particleLabel.grid(row=4, column=0, sticky=W)
 
  138     self.particleVar.set(
"gamma")
 
  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)
 
  147     energyLabel = Label(self, bg=
"green",  text=
"Energy (MeV)")
 
  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)
 
  156     eventLabel = Label(self, bg=
"green",  text=
"Events")
 
  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)
 
  163     startBut = Button(self, bg=
"orange", text=
"Start a run", command=self.
cmd_beamOn)
 
  164     startBut.grid(row=0, column=0, sticky=W)
 
  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)
 
  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)
 
  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)
 
  205     exitBut = Button(self, bg=
"red", text=
"End all", command=sys.exit)
 
  206     exitBut.grid(row=0, column=6, sticky=W)
 
  210       materialChosen = self.materialVar.get()
 
  211       water_phantom.SetMaterial(absorber[materialChosen])
 
  213       if materialChosen == 
"water":
 
  214           water_phantom.SetColor(0., 0.9, 1.0)
 
  216       if materialChosen == 
"air":
 
  217           water_phantom.SetColor(0.9, 0.9, 1.0)
 
  219       if materialChosen == 
"lead":
 
  220           water_phantom.SetColor(0.2, 0.2, 0.2)
 
  222       if materialChosen == 
"iron":
 
  223           water_phantom.SetColor(0.7, 0.5, 0.7)
 
  225       if materialChosen == 
"aluminum":
 
  226           water_phantom.SetColor(.7, 0.9, 1.0)
 
  228       if materialChosen == 
"gold":
 
  229           water_phantom.SetColor(1., 0.9, .0)
 
  231       self.solid.SetZHalfLength(self.thickVar.get() * mm/2.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")
 
  241       eventNum = self.eventVar.get()
 
  242       for i 
in range(eventNum):
 
  243         gunYZpos = str(i-eventNum/2) + 
". -20. cm" 
  245         gRunManager.BeamOn(1)
 
  288     Frame.__init__(self, master)
 
static G4Material * GetMaterial(const G4String &name, G4bool warning=true)
 
const G4ParticleDefinition const G4Material *G4double range
 
simulatedPeak Scale(1/simulationNormalisationFactor)