source: trunk/environments/g4py/examples/emplot/pplot.py @ 1354

Last change on this file since 1354 was 1337, checked in by garnier, 14 years ago

tag geant4.9.4 beta 1 + modifs locales

  • Property svn:executable set to *
File size: 1.6 KB
Line 
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
13EmPlot.Configure()
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
46myCanvas= EmPlot.init_root()
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
Note: See TracBrowser for help on using the repository browser.