Geant4-11
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Data Fields | Static Public Attributes
ExN03.App Class Reference
Inheritance diagram for ExN03.App:

Public Member Functions

def __init__ (self, master=None)
 
def cmd_beamOn (self)
 
def cmd_energy (self, penergy)
 
def cmd_expand (self)
 
def cmd_g4command (self)
 
def cmd_pan (self)
 
def cmd_particle (self, particle)
 
def cmd_setProcess (self)
 
def cmd_shrink (self)
 
def cmd_viewer (self)
 
def init (self)
 

Data Fields

 absorbermaterialVar
 
 absorberthickVar
 
 calorsizeYZVar
 
 cutVar
 
 energyVar
 
 eventVar
 
 g4commandVar
 
 g4pipe
 
 gapmaterialVar
 
 gapthickVar
 
 layerVar
 
 magVar
 
 particleVar
 
 processList
 
 processVar
 
 viewerVar
 

Static Public Attributes

int g4pipe = 0
 

Detailed Description

Definition at line 141 of file ExN03.py.

Constructor & Destructor Documentation

◆ __init__()

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

Definition at line 419 of file ExN03.py.

419 def __init__(self, master=None):
420 Frame.__init__(self, master)
421 self.init()
422 self.grid()
423
424

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 ExN03.App.cmd_beamOn (   self)

Definition at line 327 of file ExN03.py.

327 def cmd_beamOn(self):
328 exN03geom.SetNbOfLayers(self.layerVar.get())
329 exN03geom.SetAbsorberMaterial(self.absorbermaterialVar.get())
330 exN03geom.SetAbsorberThickness(self.absorberthickVar.get() * mm/2.0)
331 exN03geom.SetGapMaterial(self.gapmaterialVar.get())
332 exN03geom.SetGapThickness(self.gapthickVar.get() * mm/2.0)
333 exN03geom.SetCalorSizeYZ(self.calorsizeYZVar.get() * mm)
334 position = -self.layerVar.get()*(self.absorberthickVar.get() + self.gapthickVar.get())*1.2
335
336 exN03geom.UpdateGeometry()
337 exN03PL.SetDefaultCutValue(self.cutVar.get() * mm)
338 exN03PL.SetCutsWithDefault()
339 exN03geom.SetMagField(self.magVar.get() * tesla)
340
341 print("Now geometry updated")
342
343
344 self.cmd_particle(self.particleVar.get())
345 self.cmd_energy(self.energyVar.get())
346
347 print(position)
348
349 eventNum = self.eventVar.get()
350 for i in range(eventNum):
351
352 pg.SetParticlePosition(G4ThreeVector(position*mm, (i-eventNum/2)*5.*mm, 0.*cm))
353 gRunManager.BeamOn(1)
354 sleep(0.01)
355 gApplyUICommand("/vis/viewer/update")
356
void print(G4double elem)
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.absorbermaterialVar, ExN03.App.absorbermaterialVar, demo.App.absorberthickVar, ExN03.App.absorberthickVar, demo.App.calorsizeYZVar, ExN03.App.calorsizeYZVar, 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.cutVar, ExN03.App.cutVar, demo.App.energyVar, Lesson1.App.energyVar, ExN03.App.energyVar, demo.App.eventVar, Lesson1.App.eventVar, ExN03.App.eventVar, demo.App.gapmaterialVar, ExN03.App.gapmaterialVar, source.gApplyUICommand, demo.App.gapthickVar, ExN03.App.gapthickVar, PTL.get(), demo.App.layerVar, ExN03.App.layerVar, demo.App.magVar, ExN03.App.magVar, demo.App.particleVar, Lesson1.App.particleVar, ExN03.App.particleVar, and print().

◆ cmd_energy()

def ExN03.App.cmd_energy (   self,
  penergy 
)

Definition at line 373 of file ExN03.py.

373 def cmd_energy(self, penergy):
374 gApplyUICommand("/gun/energy " + penergy + " MeV")
375
376

References source.gApplyUICommand.

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

◆ cmd_expand()

def ExN03.App.cmd_expand (   self)

Definition at line 407 of file ExN03.py.

407 def cmd_expand(self):
408 gApplyUICommand("/vis/viewer/zoom 1.2")
409

References source.gApplyUICommand.

◆ cmd_g4command()

def ExN03.App.cmd_g4command (   self)

Definition at line 366 of file ExN03.py.

366 def cmd_g4command(self):
367 gApplyUICommand(self.g4commandVar.get())
368

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

◆ cmd_pan()

def ExN03.App.cmd_pan (   self)

Definition at line 410 of file ExN03.py.

410 def cmd_pan(self):
411 gApplyUICommand("/vis/viewer/pan " + self.panXYVar.get() + " " + " mm")
412
413

References source.gApplyUICommand, and PTL.get().

◆ cmd_particle()

def ExN03.App.cmd_particle (   self,
  particle 
)

Definition at line 369 of file ExN03.py.

369 def cmd_particle(self, particle):
370 gApplyUICommand("/gun/particle " + particle)
371
372

References source.gApplyUICommand.

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

◆ cmd_setProcess()

def ExN03.App.cmd_setProcess (   self)

Definition at line 357 of file ExN03.py.

357 def cmd_setProcess(self):
358 for i in self.processList:
359 if self.processVar[i].get() == 0:
360 gProcessTable.SetProcessActivation(i, 0)
361 print("Process " + i + " inactivated")
362 else:
363 gProcessTable.SetProcessActivation(i, 1)
364 print("Process " + i + " activated")
365

References PTL.get(), print(), demo.App.processList, ExN03.App.processList, demo.App.processVar, and ExN03.App.processVar.

◆ cmd_shrink()

def ExN03.App.cmd_shrink (   self)

Definition at line 414 of file ExN03.py.

414 def cmd_shrink(self):
415 gApplyUICommand("/vis/viewer/zoom 0.8")
416
417
418

References source.gApplyUICommand.

◆ cmd_viewer()

def ExN03.App.cmd_viewer (   self)

Definition at line 377 of file ExN03.py.

377 def cmd_viewer(self):
378 if self.viewerVar.get() == "OpenGL":
379 gApplyUICommand("/vis/viewer/select oglsxviewer")
380 gApplyUICommand("/vis/scene/add/trajectories")
381
382 gApplyUICommand("/tracking/storeTrajectory 1")
383 gApplyUICommand("/vis/scene/endOfEventAction accumulate")
384 gApplyUICommand("/vis/scene/endOfRunAction accumulate")
385
386 if self.viewerVar.get() == "VRML":
387 gApplyUICommand("/vis/viewer/select vrmlviewer")
388 gApplyUICommand("/vis/scene/add/trajectories")
389
390 gApplyUICommand("/tracking/storeTrajectory 1")
391 gApplyUICommand("/vis/scene/endOfEventAction accumulate")
392 gApplyUICommand("/vis/scene/endOfRunAction accumulate")
393
394 if self.viewerVar.get() == "Wired":
395 gApplyUICommand("/vis/viewer/select wired")
396 gApplyUICommand("/vis/scene/add/trajectories")
397
398 gApplyUICommand("/tracking/storeTrajectory 1")
399 gApplyUICommand("/vis/scene/endOfEventAction accumulate")
400 gApplyUICommand("/vis/scene/endOfRunAction accumulate")
401
402 if self.g4pipe == 0:
403 Popen(heprepViewer + " -file " + heprepDir + "/" + heprepName +".heprep", shell=True)
404 self.g4pipe = 1
405
406

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

◆ init()

def ExN03.App.init (   self)

Definition at line 145 of file ExN03.py.

145 def init(self):
146
147#title and header row=0, 1
148 title = Label(self, text="exampleN03")
149 title.grid(row=0, column=1, columnspan=3)
150 header = Label(self, text="empowered by \n Geant4Py")
151 header.grid(row=1, column=1, columnspan=3)
152# number of layers
153 layerLabel = Label(self, bg="green", text="No of layers")
154 self.layerVar=IntVar()
155 self.layerVar.set(10)
156 layer = Scale(self, orient=HORIZONTAL, length=400, from_=0, to=10, tickinterval=1, resolution=1, variable=self.layerVar )
157 layerLabel.grid(row=2, column=0, sticky=W)
158 layer.grid(row=2, column=1, columnspan=5, sticky=W)
159
160#absorber material selection row=3
161 absorbermaterialLabel = Label(self, bg="green", text="Absorber Material")
162 absorbermaterialLabel.grid(row=3, column=0, sticky=W)
163 self.absorbermaterialVar = StringVar()
164 self.absorbermaterialVar.set("Lead")
165 ra1 = { }
166 pos=1
167 for i in ("Aluminium", "Lead"):
168 ra1[i] = Radiobutton(self, text=i, variable=self.absorbermaterialVar, value=i)
169 ra1[i].grid(row=3, column=pos, sticky=W)
170 pos=pos+1
171
172#absorber thickness row=4
173 absorberthickLabel = Label(self, bg="green", text="Thickness (mm)")
174 self.absorberthickVar = DoubleVar()
175 self.absorberthickVar.set(10.0)
176 absorberthick = Scale(self, orient=HORIZONTAL, length=400, from_=0., to=100., resolution=0.05, tickinterval=10.0, digits=4, variable=self.absorberthickVar)
177 absorberthickLabel.grid(row=4, column=0, sticky=W)
178 absorberthick.grid(row=4, column=1, columnspan=5, sticky=W)
179
180
181#gap material selection row=5
182 gapmaterialLabel = Label(self, bg="green", text="Gap Material")
183 gapmaterialLabel.grid(row=5, column=0, sticky=W)
184 self.gapmaterialVar = StringVar()
185 self.gapmaterialVar.set("liquidArgon")
186 ra2 = { }
187 pos=1
188 for i in ("liquidArgon","Scintillator", "Air", "Aerogel", "Galactic" ):
189 ra2[i] = Radiobutton(self, text=i, variable=self.gapmaterialVar, value=i)
190 ra2[i].grid(row=5, column=pos, sticky=W)
191 pos=pos+1
192
193#gap thickness row=6
194 gapthickLabel = Label(self, bg="green", text="Thickness (mm)")
195 self.gapthickVar = DoubleVar()
196 self.gapthickVar.set(5.0)
197 gapthick = Scale(self, orient=HORIZONTAL, length=400, from_=0., to=100., resolution=0.05, tickinterval=10.0, digits=4, variable=self.gapthickVar)
198 gapthickLabel.grid(row=6, column=0, sticky=W)
199 gapthick.grid(row=6, column=1, columnspan=5, sticky=W)
200
201#calorSizeYZ row=7
202 calorsizeYZLabel = Label(self, bg="green", text="SizeYZ (mm)")
203 self.calorsizeYZVar = DoubleVar()
204 self.calorsizeYZVar.set(100.0)
205 calorsizeYZ = Scale(self, orient=HORIZONTAL, length=400, from_=0., to=200., resolution=0.05, tickinterval=20.0, digits=4, variable=self.calorsizeYZVar)
206 calorsizeYZLabel.grid(row=7, column=0, sticky=W)
207 calorsizeYZ.grid(row=7, column=1, columnspan=5, sticky=W)
208
209
210#particle row=8
211 particleLabel = Label(self, bg="green", text="Particle")
212 particleLabel.grid(row=8, column=0, sticky=W)
213 self.particleVar = StringVar()
214 self.particleVar.set("e-")
215 ra1 = { }
216 pos1=1
217 for i in ("proton", "gamma", "e-", "e+", "mu-", "mu+"):
218 ra1[i] = Radiobutton(self, text=i, variable=self.particleVar, value=i)
219 ra1[i].grid(row=8, column=pos1, sticky=W)
220 pos1=pos1+1
221
222#energy row=9
223 energyLabel = Label(self, bg="green", text="Energy (MeV)")
224
225 self.energyVar=StringVar()
226 self.energyVar.set(50)
227 energy = Scale(self, orient=HORIZONTAL, length=400, from_=0., to=1000., tickinterval=100.0, resolution=0.1, variable=self.energyVar, digits=5 )
228 energyLabel.grid(row=9, column=0, sticky=W)
229 energy.grid(row=9, column=1, columnspan=5, sticky=W)
230
231#number of event row=10
232 eventLabel = Label(self, bg="green", text="Events")
233 self.eventVar=IntVar()
234 self.eventVar.set(3)
235 event = Scale(self, orient=HORIZONTAL, length=400, from_=0, to=100, tickinterval=10, resolution=1, variable=self.eventVar )
236 eventLabel.grid(row=10, column=0, sticky=W)
237 event.grid(row=10, column=1, columnspan=5, sticky=W)
238
239#start a run button row=0
240 startBut = Button(self, bg="orange", text="Start a run", command=self.cmd_beamOn)
241 startBut.grid(row=0, column=0, sticky=W)
242
243#Zoom in/out Pan X Y row=13
244# visLabel = Label(self, text="viewer", bg="orange")
245# expandBut = Button(self, text="Zoom in", command=self.cmd_expand)
246# shrinkBut = Button(self, text="Zoom out", command=self.cmd_shrink)
247# visLabel.grid(row=13, column=0, sticky=W)
248# expandBut.grid(row=13, column=1, sticky=W)
249# shrinkBut.grid(row=13, column=2, sticky=W)
250# panLabel = Label(self, text="Pan X Y(mm)")
251# self.panXYVar = StringVar()
252# panXYEnt = Entry(self, textvariable=self.panXYVar, width=6)
253# panBut = Button(self, bg="orange", text="OK", command=self.cmd_pan)
254# panLabel.grid(row=13, column=3, sticky=W)
255# panXYEnt.grid(row=13, column=4)
256# panBut.grid(row=13, column=5)
257
258# process activate row 11 - 13
259 processLabel=Label(self, text="Process on/off", bg="green")
260 processLabel.grid(row=11, column=0, sticky=W)
261 procTab = {}
262
263 self.processList = ["phot", "compt", "conv", "msc", "eIoni", "eBrem", "annihil","muIoni", "muBrems", "hIoni"]
264 pos=1
265 self.processVar = {}
266 for i in self.processList:
267 self.processVar[i] = IntVar()
268 procTab[i] = Checkbutton(self, text=i, variable=self.processVar[i], command=self.cmd_setProcess)
269 if pos <= 3:
270 procTab[i].grid(row=11, column=pos, sticky=W)
271 if 4<= pos <= 7:
272 procTab[i].grid(row=12, column=pos-3, sticky=W)
273 if pos >= 8:
274 procTab[i].grid(row=13, column=pos-7, sticky=W)
275 pos=pos+1
276 procTab[i].select()
277# set cuts row 14
278 cutLabel = Label(self, bg="green", text="Cut (mm)")
279
280 self.cutVar=DoubleVar()
281 self.cutVar.set(1.)
282 cut = Scale(self, orient=HORIZONTAL, length=400, from_=0., to=10., tickinterval=1., resolution=0.005, variable=self.cutVar, digits=5 )
283 cutLabel.grid(row=14, column=0, sticky=W)
284 cut.grid(row=14, column=1, columnspan=5, sticky=W)
285
286# set mag field row 15
287 magLabel = Label(self, bg="green", text="Magnetic (T)")
288
289 self.magVar=DoubleVar()
290 self.magVar.set(0.)
291 mag = Scale(self, orient=HORIZONTAL, length=400, from_=0., to=5., tickinterval=1., resolution=0.1, variable=self.magVar, digits=3 )
292 magLabel.grid(row=15, column=0, sticky=W)
293 mag.grid(row=15, column=1, columnspan=5, sticky=W)
294
295
296# viewer selection row=16
297 viewerLabel = Label(self, bg="green", text="Viewer")
298 viewerLabel.grid(row=16, column=0, sticky=W)
299 self.viewerVar = StringVar()
300 self.viewerVar.set("")
301 stateOfViewer = {"OpenGL":"normal", "VRML":"normal", "Wired":"normal"}
302 if vrmlViewer is None: stateOfViewer["VRML"] = "disabled"
303 if heprepViewer is None: stateOfViewer["Wired"] = "disabled"
304 viewers = { }
305 pos=1
306 for i in ("OpenGL", "VRML", "Wired"):
307 viewers[i] = Radiobutton(self, text=i, variable=self.viewerVar, value=i, command=self.cmd_viewer, state=stateOfViewer[i])
308 viewers[i].grid(row=16, column=pos, sticky=W)
309 pos=pos+1
310
311
312#Geant4 command entry row = 17
313 g4comLabel = Label(self, text="Geant4 command", bg="orange")
314 self.g4commandVar = StringVar()
315 commandEntry = Entry(self, textvariable=self.g4commandVar, width=15)
316 self.g4commandVar.set("/vis/viewer/zoom 1.2")
317 comBut = Button(self, bg="orange", text="Execute", command=self.cmd_g4command)
318 g4comLabel.grid(row=17, column=0, sticky=W)
319 commandEntry.grid(row=17, column=1, columnspan=3, sticky=E+W)
320 comBut.grid(row=17, column=5)
321
322#exit row = 0
323 exitBut = Button(self, bg="red", text="End all", command=sys.exit)
324 exitBut.grid(row=0, column=5, sticky=W)
325
326#on Run butto do...

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

Field Documentation

◆ absorbermaterialVar

ExN03.App.absorbermaterialVar

Definition at line 163 of file ExN03.py.

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

◆ absorberthickVar

ExN03.App.absorberthickVar

Definition at line 174 of file ExN03.py.

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

◆ calorsizeYZVar

ExN03.App.calorsizeYZVar

Definition at line 203 of file ExN03.py.

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

◆ cutVar

ExN03.App.cutVar

Definition at line 280 of file ExN03.py.

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

◆ energyVar

ExN03.App.energyVar

Definition at line 225 of file ExN03.py.

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

◆ eventVar

ExN03.App.eventVar

Definition at line 233 of file ExN03.py.

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

◆ g4commandVar

ExN03.App.g4commandVar

◆ g4pipe [1/2]

int ExN03.App.g4pipe = 0
static

Definition at line 143 of file ExN03.py.

◆ g4pipe [2/2]

ExN03.App.g4pipe

Definition at line 402 of file ExN03.py.

◆ gapmaterialVar

ExN03.App.gapmaterialVar

Definition at line 184 of file ExN03.py.

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

◆ gapthickVar

ExN03.App.gapthickVar

Definition at line 195 of file ExN03.py.

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

◆ layerVar

ExN03.App.layerVar

Definition at line 154 of file ExN03.py.

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

◆ magVar

ExN03.App.magVar

Definition at line 289 of file ExN03.py.

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

◆ particleVar

ExN03.App.particleVar

Definition at line 213 of file ExN03.py.

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

◆ processList

ExN03.App.processList

Definition at line 263 of file ExN03.py.

Referenced by demo.App.cmd_setProcess(), and ExN03.App.cmd_setProcess().

◆ processVar

ExN03.App.processVar

Definition at line 265 of file ExN03.py.

Referenced by demo.App.cmd_setProcess(), and ExN03.App.cmd_setProcess().

◆ viewerVar

ExN03.App.viewerVar

Definition at line 299 of file ExN03.py.

Referenced by demo.App.cmd_viewer(), and ExN03.App.cmd_viewer().


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