Classes | Functions | Variables
mcscorerootio Namespace Reference

Classes

class  MCScoreROOTIO
 

Functions

def loop_tree (tfile, analyze_vertex)
 
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.

Referenced by test_loop().

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

Definition at line 174 of file mcscorerootio.py.

References loop_tree(), and test_t2root().

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

Definition at line 147 of file mcscorerootio.py.

References open(), and while().

Referenced by test_loop().

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

Variable Documentation

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

Definition at line 20 of file mcscorerootio.py.