Root-dump: dumping files and trees on screen, with Go-HEP

hi there,

I posted it here:
What is the most efficient way to compare the content of two entries in a TTree?

but just FYI, I have created a little tool to dump the content of ROOT files and their TTrees:

$> root-dump -h
Usage: root-dump [options] f0.root [f1.root [...]]

ex:
 $> root-dump ./testdata/small-flat-tree.root
 $> root-dump -deep=0 ./testdata/small-flat-tree.root

options:
  -deep
    	enable deep dumping of values (including Trees' entries) (default true)

i.e.:

$> root-dump ../testdata/simple.root ../testdata/small-flat-tree.root
>>> file[../testdata/simple.root]
key[000]: tree;1 "fake data" (TTree)
[000][one]: 1
[000][two]: 1.1
[000][three]: uno
[001][one]: 2
[001][two]: 2.2
[001][three]: dos
[002][one]: 3
[002][two]: 3.3
[002][three]: tres
[003][one]: 4
[003][two]: 4.4
[003][three]: quatro
>>> file[../testdata/small-flat-tree.root]
key[000]: tree;1 "my tree title" (TTree)
[000][Int32]: 0
[000][Int64]: 0
[000][UInt32]: 0
[000][UInt64]: 0
[000][Float32]: 0
[000][Float64]: 0
[000][Str]: evt-000
[000][ArrayInt32]: [0 0 0 0 0 0 0 0 0 0]
[000][ArrayInt64]: [0 0 0 0 0 0 0 0 0 0]
[000][ArrayInt32]: [0 0 0 0 0 0 0 0 0 0]
[000][ArrayInt64]: [0 0 0 0 0 0 0 0 0 0]
[000][ArrayFloat32]: [0 0 0 0 0 0 0 0 0 0]
[000][ArrayFloat64]: [0 0 0 0 0 0 0 0 0 0]
[000][N]: 0
[000][SliceInt32]: []
[000][SliceInt64]: []
[000][SliceInt32]: []
[000][SliceInt64]: []
[000][SliceFloat32]: []
[000][SliceFloat64]: []
[001][Int32]: 1
[001][Int64]: 1
[001][UInt32]: 1
[001][UInt64]: 1
[001][Float32]: 1
[001][Float64]: 1
[001][Str]: evt-001
[001][ArrayInt32]: [1 1 1 1 1 1 1 1 1 1]
[001][ArrayInt64]: [1 1 1 1 1 1 1 1 1 1]
[001][ArrayInt32]: [1 1 1 1 1 1 1 1 1 1]
[001][ArrayInt64]: [1 1 1 1 1 1 1 1 1 1]
[001][ArrayFloat32]: [1 1 1 1 1 1 1 1 1 1]
[001][ArrayFloat64]: [1 1 1 1 1 1 1 1 1 1]
[001][N]: 1
[001][SliceInt32]: [1]
[001][SliceInt64]: [1]
[...]

it’s (of course!) based on my Go-based ROOT reader: rootio.
you can install it like so:

$> go get go-hep.org/x/hep/rootio/cmd/root-dump

it doesn’t dump (yet) Trees with user-defined classes.
but it’s just a matter of coding and wiring the tools from go-hep.org/x/hep/rootio:slight_smile: (famous last words)

the idea being that, later on, it would be leveraged by another command root-diff, to compare the content of ROOT files, in a ROOT-aware manner ( e.g. ignoring ROOT TObject UUIDs that are uniquely generated, or objects that store gettimeofday(3) and prevent from just binary-diffing 2 files created with the same content)

hth,
-s

$root-dump dna.root
===
root-dump: error dumping file "dna.root": could not decode object "dna" from dir "dna.root": riofs: could not unmarshal key payload: rtree: tree [dna] with version [5] is not supported (too old)
===

If you provide me that ROOT file I could improve root-dump :slight_smile:

Also: the root-dump binary that’s linked above is quite old. Does the new/latest one choke on it too?
It can be retrieved with:

$> go get go-hep.org/x/hep/groot/cmd/root-dump

edit: I see from the error message it is indeed the latest version of root-dump.

The root-dump is the latest version.
This is a link for a dna.root - https://www.file-up.org/9ofsmxb1dmqn

dna.root is a result of Geant4-dna example dnaphysics - http://geant4-dna.in2p3.fr/styled-5/

forgot to go back here but Go-HEP v0.21.0 has gained support for ROOT-4 like files (the ones Geant4 write via inexlib).

please give it a try.

hth,
-s