37 """dump the content of a ROOT file into an ASCII format.
40 import PyUtils.RootUtils
as ru
41 root = ru.import_root()
43 _inspect = root.RootUtils.PyROOTInspector.pyroot_inspect2
45 import PyUtils.Logging
as L
46 msg = L.logging.getLogger(
'dump-root')
47 msg.setLevel(L.logging.INFO)
49 msg.info(
'fname: [%s]', args.fname)
50 root_file = root.TFile.Open(args.fname)
51 if (root_file
is None or
52 not isinstance(root_file, root.TFile)
or not root_file.IsOpen()):
53 msg.error(
'could not open [%s]', args.fname)
58 tree_names = args.tree_name.split(
',')
61 keys = [k.GetName()
for k
in root_file.GetListOfKeys()]
64 if isinstance(o, root.TTree):
67 msg.info(
'dumping trees: %s', tree_names)
69 for tree_name
in tree_names:
70 f = ru.RootFileDumper(args.fname, tree_name)
71 nentries = f.tree.GetEntries()
73 nentries = args.entries
74 for d
in f.dump(tree_name, nentries):
75 tree_name, ientry, name, data = d
76 n =
'.'.
join(map(str, [tree_name,
"%03i"%ientry]+name))
77 print (
'%s %r' %(n, data))