Classes | Functions
emcalc_gui Namespace Reference

Classes

class  MainWindow
 
class  TextView
 

Functions

def g4_configure ()
 
def plot_charged (material, pname)
 
def plot_gamma (material)
 
def main ()
 MAIN FUNCTION. More...
 

Function Documentation

def emcalc_gui.g4_configure ( )

Definition at line 20 of file emcalc_gui.py.

References EmPlot.Configure().

Referenced by main().

20 def g4_configure() :
22  g4py.EMSTDpl.Construct()
23 
24 # -------------------------------------------------------------------
25 # plot for chaged particles
26 # -------------------------------------------------------------------
def Configure()
Definition: EmPlot.py:18
def g4_configure()
Definition: emcalc_gui.py:20
def emcalc_gui.main ( )

MAIN FUNCTION.

1D plots hits vs w //

Definition at line 342 of file emcalc_gui.py.

References g4_configure(), and python.gTerminate().

342 def main() :
343  SetG4PyCoutDestination()
344 
345  default_stdout = sys.stdout
346  global mycout
347  sys.stdout = mycout = StringIO()
348 
349  # G4 setup
350  g4_configure()
351 
352  # start GUI
353  application = MainWindow()
354  gtk.main()
355 
356  gTerminate()
357  sys.stdout = default_stdout
358 
359 
def g4_configure()
Definition: emcalc_gui.py:20
def main()
MAIN FUNCTION.
Definition: emcalc_gui.py:342
def gTerminate()
Definition: __init__.py:221
def emcalc_gui.plot_charged (   material,
  pname 
)

Definition at line 27 of file emcalc_gui.py.

References EmPlot.init_root(), EmPlot.make_plot(), PandAna.Demos.demo1.range, and EmPlot.SetMaterial().

Referenced by emcalc_gui.MainWindow.cb_show_plot().

27 def plot_charged(material, pname) :
28  EmPlot.SetMaterial(material)
29 
30  # initialize G4 kernel
31  gRunManager.Initialize()
32  gRunManagerKernel.RunInitialization()
33 
34  # energy
35  elist= []
36  for n in range(-3, 3):
37  for i in range(10,99):
38  elist.append(i/10.*10.**n *MeV)
39 
40  # calculate stopping power
41  global mycout
42  mycout.close()
43  sys.stdout = mycout = StringIO()
44  dedx_list= g4py.emcalculator.CalculateDEDX(pname, material, elist, 1)
45  xlist_tot=[]
46  xlist_ioni=[]
47  xlist_brems=[]
48 
49  for x in dedx_list:
50  xlist_tot.append((x[0], x[1]["tot"]/(MeV*cm2/g)))
51  xlist_ioni.append((x[0], x[1]["ioni"]/(MeV*cm2/g)))
52  xlist_brems.append((x[0], x[1]["brems"]/(MeV*cm2/g)))
53 
54  # make plot
55  global myCanvas, aplot, bplot, cplot
56  myCanvas = EmPlot.init_root()
57  aplot = EmPlot.make_plot(xlist_tot, pname+" Stopping Power ("+material+")",
58  "dE/dX (MeV cm^{2}/g)")
59  bplot = EmPlot.make_plot(xlist_ioni, "Stopping Power ("+material+")",
60  "dE/dX (MeV cm^{2}/g)", 1)
61  cplot = EmPlot.make_plot(xlist_brems, "Stopping Power ("+material+")",
62  "dE/dX (MeV cm^{2}/g)", 3)
63  myCanvas.SaveAs("/tmp/sp.png")
64 
65 
66 # -------------------------------------------------------------------
67 # plot for gamma
68 # -------------------------------------------------------------------
def plot_charged(material, pname)
Definition: emcalc_gui.py:27
def SetMaterial(material_name)
Definition: EmPlot.py:25
def init_root()
Definition: EmPlot.py:58
def make_plot(xlist, user_title, axis_titile, q_super_impose=0)
Definition: EmPlot.py:84
def emcalc_gui.plot_gamma (   material)

Definition at line 69 of file emcalc_gui.py.

References EmPlot.init_root(), EmPlot.make_plot(), PandAna.Demos.demo1.range, and EmPlot.SetMaterial().

Referenced by emcalc_gui.MainWindow.cb_show_plot().

69 def plot_gamma(material) :
70  EmPlot.SetMaterial(material)
71 
72  # initialize G4 kernel
73  gRunManager.Initialize()
74  gRunManagerKernel.RunInitialization()
75 
76  # energy
77  elist= []
78  for n in range(-3, 4):
79  for i in range(10,99):
80  elist.append(i/10.*10.**n *MeV)
81 
82  # calculate cross sections
83  global mycout
84  mycout.close()
85  sys.stdout = mycout = StringIO()
86  xsection_list= g4py.emcalculator.CalculatePhotonCrossSection(material,
87  elist, 1)
88  xlist_tot=[]
89  xlist_comp=[]
90  xlist_pe=[]
91  xlist_conv=[]
92  for x in xsection_list:
93  xlist_tot.append((x[0]/MeV, x[1]["tot"]/(cm2/g)))
94  xlist_comp.append((x[0]/MeV, x[1]["compt"]/(cm2/g)))
95  xlist_pe.append((x[0]/MeV, x[1]["phot"]/(cm2/g)))
96  xlist_conv.append((x[0]/MeV, x[1]["conv"]/(cm2/g)))
97 
98  # make plots
99  global myCanvas, aplot, bplot, cplot, dplot
100  myCanvas = EmPlot.init_root()
101  aplot = EmPlot.make_plot(xlist_tot, "Photon Cross Section ("+material+")",
102  "Cross Section (cm^{2}/g)")
103  bplo = EmPlot.make_plot(xlist_comp, "Photon Cross Section ("+material+")",
104  "Cross Section (cm^{2}/g)", 1)
105  cplot = EmPlot.make_plot(xlist_pe, "Photon Cross Section ("+material+")",
106  "Cross Section (cm^{2}/g)", 7)
107  dplot = EmPlot.make_plot(xlist_conv, "Photon Cross Section ("+material+")",
108  "Cross Section (cm^{2}/g)", 3)
109  myCanvas.SaveAs("/tmp/cs.png")
110 
111 
112 # ==================================================================
113 # GUI
114 # ==================================================================
def SetMaterial(material_name)
Definition: EmPlot.py:25
def init_root()
Definition: EmPlot.py:58
def make_plot(xlist, user_title, axis_titile, q_super_impose=0)
Definition: EmPlot.py:84
def plot_gamma(material)
Definition: emcalc_gui.py:69