Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
pplot.py
Go to the documentation of this file.
1 #!/usr/bin/python
2 # ==================================================================
3 # An example of ploting by EmCalculator
4 #
5 # Plotting photon cross sections and stopping power
6 # ==================================================================
7 from Geant4 import *
8 import g4py.ExN03pl
9 import g4py.emcalculator
10 import EmPlot
11 
12 # initialize
14 
15 # user physics list
16 g4py.ExN03pl.Construct()
17 
18 # target material
19 material= "G4_Pb"
20 EmPlot.SetMaterial(material)
21 
22 # initialize G4 kernel
23 gRunManager.Initialize()
24 gRunManagerKernel.RunInitialization()
25 
26 # energy
27 elist= []
28 for n in range(-3, 4):
29  for i in range(10,99):
30  elist.append(i/10.*10.**n *MeV)
31 
32 
33 # calculate cross sections
34 xsection_list= g4py.emcalculator.CalculatePhotonCrossSection(material, elist, 1)
35 xlist_tot=[]
36 xlist_comp=[]
37 xlist_pe=[]
38 xlist_conv=[]
39 for x in xsection_list:
40  xlist_tot.append((x[0]/MeV, x[1]["tot"]/(cm2/g)))
41  xlist_comp.append((x[0]/MeV, x[1]["compt"]/(cm2/g)))
42  xlist_pe.append((x[0]/MeV, x[1]["phot"]/(cm2/g)))
43  xlist_conv.append((x[0]/MeV, x[1]["conv"]/(cm2/g)))
44 
45 # make a plot
46 myCanvas= EmPlot.init_root()
47 aplot= EmPlot.make_plot(xlist_tot, "Photon Cross Section ("+material+")",
48  "Cross Section (cm^{2}/g)")
49 bplot= EmPlot.make_plot(xlist_comp, "Photon Cross Section ("+material+")",
50  "Cross Section (cm^{2}/g)", 1)
51 cplot= EmPlot.make_plot(xlist_pe, "Photon Cross Section ("+material+")",
52  "Cross Section (cm^{2}/g)", 7)
53 dplot= EmPlot.make_plot(xlist_conv, "Photon Cross Section ("+material+")",
54  "Cross Section (cm^{2}/g)", 3)
55 
def init_root
Definition: EmPlot.py:58
def Configure
Definition: EmPlot.py:18
def make_plot
Definition: EmPlot.py:84
def SetMaterial
Definition: EmPlot.py:25