Geant4-11
Functions
EmPlot Namespace Reference

Functions

def Configure ()
 
def init_root ()
 
def make_plot (xlist, user_title, axis_titile, q_super_impose=0)
 
def plot_range (xmin, xmax, xmargin=0.)
 
def SetMaterial (material_name)
 

Function Documentation

◆ Configure()

def EmPlot.Configure ( )

Definition at line 18 of file EmPlot.py.

18def Configure():
19 g4py.NISTmaterials.Construct()
20 g4py.ezgeom.Construct()
21
22# ------------------------------------------------------------------
23# constructing geometry
24# ------------------------------------------------------------------
def Configure()
Definition: EmPlot.py:18

Referenced by emcalc_gui.g4_configure().

◆ init_root()

def EmPlot.init_root ( )

Definition at line 58 of file EmPlot.py.

58def init_root():
59 ROOT.gROOT.Reset()
60
61 # plot style
62 ROOT.gStyle.SetTextFont(82)
63
64 ROOT.gStyle.SetTitleFont(82, "X")
65 ROOT.gStyle.SetTitleFontSize(0.04)
66 ROOT.gStyle.SetLabelFont(82, "X")
67 ROOT.gStyle.SetTitleFont(82, "Y")
68 ROOT.gStyle.SetLabelFont(82, "Y")
69
70 #ROOT.gStyle.SetOptTitle(0)
71 ROOT.gStyle.SetErrorX(0)
72
73 canvas= ROOT.TCanvas("g4plot", "g4plot", 620, 30, 600, 600)
74
75 canvas.SetLogy()
76 canvas.SetLogx()
77 canvas.SetGrid()
78
79 return canvas
80
81# ------------------------------------------------------------------
82# do a plot
83# ------------------------------------------------------------------
def init_root()
Definition: EmPlot.py:58

Referenced by emcalc_gui.plot_charged(), and emcalc_gui.plot_gamma().

◆ make_plot()

def EmPlot.make_plot (   xlist,
  user_title,
  axis_titile,
  q_super_impose = 0 
)

Definition at line 84 of file EmPlot.py.

84def make_plot(xlist, user_title, axis_titile, q_super_impose=0):
85
86 ekin_array, y_array = array('d'), array('d')
87
88 for x in xlist:
89 ekin_array.append(x[0])
90 y_array.append(x[1])
91
92 # plot range
93 xmin= min(ekin_array)
94 xmax= max(ekin_array)
95 xrange= plot_range(xmin, xmax)
96
97 ymin= min(y_array)
98 ymax= max(y_array)
99 yrange= plot_range(ymin, ymax, 2)
100
101 if(q_super_impose==0):
102 htit= user_title
103 global frame
104 frame= ROOT.TH1F("dumy", htit, 1, xrange[0], xrange[1]);
105 frame.SetMinimum(yrange[0]);
106 frame.SetMaximum(yrange[1]);
107 frame.SetXTitle("Kinetic Energy (MeV)")
108 frame.GetXaxis().SetLabelSize(0.025)
109 frame.GetXaxis().SetTitleSize(0.03)
110 frame.SetYTitle(axis_titile)
111 frame.GetYaxis().SetLabelSize(0.025)
112 frame.GetYaxis().SetTitleSize(0.03)
113 frame.SetStats(0)
114 frame.Draw()
115
116 plot= ROOT.TGraph(len(ekin_array), ekin_array, y_array)
117 plot.Draw("L")
118 plot.SetLineColor(q_super_impose+1)
119
120 return plot
121
def make_plot(xlist, user_title, axis_titile, q_super_impose=0)
Definition: EmPlot.py:84
def plot_range(xmin, xmax, xmargin=0.)
Definition: EmPlot.py:40
T max(const T t1, const T t2)
brief Return the largest of the two arguments
T min(const T t1, const T t2)
brief Return the smallest of the two arguments

References G4INCL::Math.max(), G4INCL::Math.min(), and plot_range().

Referenced by emcalc_gui.plot_charged(), and emcalc_gui.plot_gamma().

◆ plot_range()

def EmPlot.plot_range (   xmin,
  xmax,
  xmargin = 0. 
)

Definition at line 40 of file EmPlot.py.

40def plot_range(xmin, xmax, xmargin=0.):
41 xmaxlog= 10
42 xminlog= -10
43
44 if(xmax!=0.):
45 xmaxlog= log10(xmax)
46
47 if(xmin!=0):
48 xminlog= log10(xmin)
49
50 ixmaxlog= xmaxlog+0.5
51 ixminlog= xminlog-0.5-xmargin
52
53 return [10**ixminlog, 10**ixmaxlog]
54
55# ------------------------------------------------------------------
56# ROOT init
57# ------------------------------------------------------------------

Referenced by make_plot().

◆ SetMaterial()

def EmPlot.SetMaterial (   material_name)

Definition at line 25 of file EmPlot.py.

25def SetMaterial(material_name):
26 material= gNistManager.FindOrBuildMaterial(material_name)
27 g4py.ezgeom.SetWorldMaterial(material)
28
29
30# ==================================================================
31# plot by ROOT
32# ==================================================================
def SetMaterial(material_name)
Definition: EmPlot.py:25

Referenced by emcalc_gui.plot_charged(), emcalc_gui.plot_gamma(), and G4ScoringMessenger.SetNewValue().