source: trunk/environments/g4py/examples/emplot/eplot.py @ 1337

Last change on this file since 1337 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.4 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_Cu"
20EmPlot.SetMaterial(material)
21
22# initialize G4 kernel
23gRunManager.Initialize()
24gRunManagerKernel.RunInitialization()
25
26# energy
27elist= []
28for n in range(-3, 3):
29  for i in range(10,99):
30    elist.append(i/10.*10.**n *MeV)
31
32# calculate stopping power
33pname= "e-"
34dedx_list= g4py.emcalculator.CalculateDEDX(pname, material, elist, 1)
35xlist_tot=[]
36xlist_ioni=[]
37xlist_brems=[]
38
39for x in dedx_list:
40  xlist_tot.append((x[0], x[1]["tot"]/(MeV*cm2/g)))
41  xlist_ioni.append((x[0], x[1]["ioni"]/(MeV*cm2/g)))
42  xlist_brems.append((x[0], x[1]["brems"]/(MeV*cm2/g)))
43
44# make plot
45myCanvas= EmPlot.init_root()
46aplot= EmPlot.make_plot(xlist_tot, pname+" Stopping Power ("+material+")",
47                        "dE/dX (MeV cm^{2}/g)")
48bplot= EmPlot.make_plot(xlist_ioni, "Stopping Power ("+material+")",
49                        "dE/dX (MeV cm^{2}/g)", 1)
50cplot= EmPlot.make_plot(xlist_brems, "Stopping Power ("+material+")",
51                        "dE/dX (MeV cm^{2}/g)", 3)
52
Note: See TracBrowser for help on using the repository browser.