Geant4-11
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# ==================================================================
7from Geant4 import *
8import g4py.ExN03pl
9import g4py.emcalculator
10import EmPlot
11
12# initialize
14
15# user physics list
16g4py.ExN03pl.Construct()
17
18# target material
19material= "G4_Pb"
20EmPlot.SetMaterial(material)
21
22# initialize G4 kernel
23gRunManager.Initialize()
24gRunManagerKernel.RunInitialization()
25
26# energy
27elist= []
28for 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
34xsection_list= g4py.emcalculator.CalculatePhotonCrossSection(material, elist, 1)
35xlist_tot=[]
36xlist_comp=[]
37xlist_pe=[]
38xlist_conv=[]
39for 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
47aplot= EmPlot.make_plot(xlist_tot, "Photon Cross Section ("+material+")",
48 "Cross Section (cm^{2}/g)")
49bplot= EmPlot.make_plot(xlist_comp, "Photon Cross Section ("+material+")",
50 "Cross Section (cm^{2}/g)", 1)
51cplot= EmPlot.make_plot(xlist_pe, "Photon Cross Section ("+material+")",
52 "Cross Section (cm^{2}/g)", 7)
53dplot= EmPlot.make_plot(xlist_conv, "Photon Cross Section ("+material+")",
54 "Cross Section (cm^{2}/g)", 3)
55
def Configure()
Definition: EmPlot.py:18
def init_root()
Definition: EmPlot.py:58
def make_plot(xlist, user_title, axis_titile, q_super_impose=0)
Definition: EmPlot.py:84
def SetMaterial(material_name)
Definition: EmPlot.py:25