Geant4  10.03.p03
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
mcscorerootio Namespace Reference

Classes

class  MCScoreROOTIO
 

Functions

def loop_tree
 
def test_t2root
 
def test_loop
 

Variables

list __all__ = [ 'MCScoreROOTIO', 'loop_tree' ]
 

Detailed Description

Python module

This module provides ROOT IO interface for MCScore data

  [C] MCScoreROOTIO
  [f] loop_tree(tfile, analyze_vertex):

                                        Q, 2006

Function Documentation

def mcscorerootio.loop_tree (   tfile,
  analyze_vertex 
)
loop ROOT tree in a ROOT file.
  * analyze_vertex: user function : analyze_vertex(MCVertex)

Definition at line 112 of file mcscorerootio.py.

113 def loop_tree(tfile, analyze_vertex):
114  """
115  loop ROOT tree in a ROOT file.
116  * analyze_vertex: user function : analyze_vertex(MCVertex)
117  """
118  avtree = tfile.Get("vertex")
119  aptree = tfile.Get("particle")
120 
121  # reading vertex...
122  n_vertex = avtree.GetEntries()
123  for ivtx in xrange(n_vertex):
124  avtree.GetEntry(ivtx)
125  aptree.GetEntry(ivtx)
126 
127  # vertex
128  vertex = MCScore.MCVertex(avtree.x, avtree.y, avtree.z)
129 
130  # reading secondary particles...
131  nsec = aptree.np
132  namelist = aptree.namelist
133  pname = namelist.split()
134  for ip in xrange(nsec):
135  particle = MCScore.MCParticle(pname[ip], aptree.Z[ip], aptree.A[ip],
136  aptree.kE[ip], aptree.px[ip],
137  aptree.py[ip], aptree.pz[ip])
138  vertex.append_particle(particle)
139 
140  analyze_vertex(vertex)
141 
142  return n_vertex
143 
144 
145 # ==================================================================
146 # test
# ==================================================================

Here is the caller graph for this function:

def mcscorerootio.test_loop ( )

Definition at line 174 of file mcscorerootio.py.

175 def test_loop():
176  def my_analysis(vertex):
177  vertex.printout()
178 
179  f = ROOT.TFile("reaction.root", 'read')
180  nv = loop_tree(f, my_analysis)
181  print "*** # of vertex= ", nv
182 
183 
184 # ==================================================================
185 # main
# ==================================================================

Here is the call graph for this function:

def mcscorerootio.test_t2root ( )

Definition at line 147 of file mcscorerootio.py.

148 def test_t2root():
149  g = ROOT.TFile("reaction.root", 'recreate')
150 
151  rootio = MCScoreROOTIO()
152  rootio.define_tree()
153 
154  f = open("reaction.dat")
155  f.seek(0)
156 
157  while(1):
158  vertex = MCScore.read_next_vertex(f)
159  if vertex == 0:
160  break
161 
162  # filling ...
163  rootio.fill_tree(vertex)
164 
165  del vertex
166 
167  print ">>> EOF"
168  f.close()
169 
170  # closing ROOT file
171  g.Write()
172  g.Close()
173 
# ------------------------------------------------------------------

Here is the caller graph for this function:

Variable Documentation

list mcscorerootio.__all__ = [ 'MCScoreROOTIO', 'loop_tree' ]

Definition at line 20 of file mcscorerootio.py.