Hi,
I have a TTree containing several arrays of size 1600. I would like to compare all the values of the branches between two different entries of the TTree and print out the differences.
I have a class (ReadTree), created by TTree::MakeClass(), that loads a TTree from a given TFile and provides me with all the variables to read the values of the TBranches.
What would be the most efficient way to do the comparison within that context ?
My bet is something like :
// Write a function within ReadTree.
ReadTree::Compare( entry1, entry2 ){
// get another instance of ReadTree, loading the same TTree in the same TFile
ReadTree t2();
// Read entry1 in this TTree
fChain->GetEntry( entry1 );
// Read entry2 in t2
t2.fChain->GetEntry( entry2 );
// Perform comparison between members
// Loop on all arrays to check for differences
for( int i=0; i<1600; i++){
if( array1[i] != t2.array1[i] ){
// print out
}
... so on for all arrays
}
Does it sound like a good strategy ? Thanks for your opinion.
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… (famous last words)
Comparing of data in two different files is a little project we would love to have a little help on! The idea is to
compare all data members of a TKey's value, recursively, with a given precision (for flowing point values)
if the object is a TTree, compare all leaves of the TTree, with a given precision (for flowing point values)
That should be wrapped into a command line tool, rootcmp --rel-precision=1E5 file1.root file2.root file3.root that returns 1 in case there are differences and 0 for equality, and that dumps the differences onto stdout.
So far the idea! If nobody picks this up by next spring it will likely become a summer student project.
Thanks for your comments.
I am only interested into comparing the TTree leaves between 2 specific entries, not from different TTrees.
Well, I went on with the above mentioned proposition - a Compare function in my ReadTree class - as it is very specific to the tree. Precision and print out must be adapted for every leaf.
(you’ll have to trust me I am not doing anything bizarre with my binaries, and mark them executable :P)
but, of course, once Go is installed, it’s as easy as:
$> go get go-hep.org/x/hep/rootio/cmd/root-diff
$> export PATH=$GOPATH/bin:$PATH
$> root-diff -h
Usage: root-diff [options] a.root b.root
ex:
$> root-diff ./testdata/small-flat-tree.root ./testdata/small-flat-tree.root
options:
-k string
comma-separated list of keys to inspect and compare (default=all common keys)