Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Functions
EmPlot Namespace Reference

Functions

def Configure
 
def SetMaterial
 
def plot_range
 
def init_root
 
def make_plot
 

Function Documentation

def EmPlot.Configure ( )

Definition at line 18 of file EmPlot.py.

Referenced by emcalc_gui.g4_configure().

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

Definition at line 58 of file EmPlot.py.

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

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

Definition at line 84 of file EmPlot.py.

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

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

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

Definition at line 40 of file EmPlot.py.

Referenced by make_plot().

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

Definition at line 25 of file EmPlot.py.

Referenced by emcalc_gui.plot_charged(), emcalc_gui.plot_gamma(), B2aDetectorConstruction.SetChamberMaterial(), IORTDetectorConstruction.SetDiscoMaterialIORT(), IORTDetectorConstruction.SetDiscoMaterialIORT1(), BrachyDetectorConstruction.SetPhantomMaterial(), HadrontherapyDetectorConstruction.SetPhantomMaterial(), IORTDetectorConstruction.SetPhantomMaterial(), and PassiveProtonBeamLine.SetRSMaterial().

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