ATLAS Offline Software
Loading...
Searching...
No Matches
python.scripts.dump_root_file Namespace Reference

Functions

 main (args)

Variables

str __doc__ = "ASCII-fy a ROOT file"
str __author__ = "Sebastien Binet"

Function Documentation

◆ main()

python.scripts.dump_root_file.main ( args)
dump the content of a ROOT file into an ASCII format.

Definition at line 34 of file dump_root_file.py.

34def main(args):
35 """dump the content of a ROOT file into an ASCII format.
36 """
37
38 import PyUtils.RootUtils as ru
39 root = ru.import_root()
40
41 _inspect = root.RootUtils.PyROOTInspector.pyroot_inspect2 # noqa: F841
42
43 import PyUtils.Logging as L
44 msg = L.logging.getLogger('dump-root')
45 msg.setLevel(L.logging.INFO)
46
47 msg.info('fname: [%s]', args.fname)
48 root_file = root.TFile.Open(args.fname)
49 if (root_file is None or
50 not isinstance(root_file, root.TFile) or not root_file.IsOpen()):
51 msg.error('could not open [%s]', args.fname)
52 return 1
53
54 tree_names = []
55 if args.tree_name:
56 tree_names = args.tree_name.split(',')
57 else:
58 tree_names = []
59 keys = [k.GetName() for k in root_file.GetListOfKeys()]
60 for k in keys:
61 o = root_file.Get(k)
62 if isinstance(o, root.TTree):
63 tree_names.append(k)
64
65 msg.info('dumping trees: %s', tree_names)
66
67 for tree_name in tree_names:
68 f = ru.RootFileDumper(args.fname, tree_name)
69 nentries = f.tree.GetEntries()
70 if args.entries:
71 nentries = args.entries
72 for d in f.dump(tree_name, nentries):
73 tree_name, ientry, name, data = d
74 n = '.'.join(map(str, [tree_name,"%03i"%ientry]+name))
75 print ('%s %r' %(n, data))
76 return 0
STL class.
int main()
Definition hello.cxx:18

Variable Documentation

◆ __author__

str python.scripts.dump_root_file.__author__ = "Sebastien Binet"
private

Definition at line 9 of file dump_root_file.py.

◆ __doc__

str python.scripts.dump_root_file.__doc__ = "ASCII-fy a ROOT file"
private

Definition at line 8 of file dump_root_file.py.