RMF
rmf_decorator.py

The example shows how to use the decorators by printing the coordates and radius of every node that has them.

1 ## \example rmf_decorator.py
2 # The example shows how to use the decorators by printing the
3 # coordates and radius of every node that has them.
4 from __future__ import print_function
5 import RMF
6 
7 
8 def traverse(nh, pf):
9  # check if the current node has coordinates and radius
10  if pf.get_is(nh):
11  # create a decorator for the current node
12  d = pf.get(nh)
13  print(nh.get_name(), d.get_coordinates())
14  # recurse on the children
15  children = nh.get_children()
16  for c in children:
17  traverse(c, pf)
18 
19 fch = RMF.open_rmf_file_read_only(RMF.get_example_path("simple.rmf3"))
20 pf = RMF.ParticleFactory(fch)
21 fch.set_current_frame(RMF.FrameID(0))
22 traverse(fch.get_root_node(), pf)