I generate two TTree with simulation which are should be the same.
I would like to compare these equality.
In this question (21204), the function has been discussed and I found that the implemented solutions.
However, they are a little bit much and it is general for all TObject. My target is only TTree.
Can I compare them with handy way for example calculating their hash?
First suggestion is a bit trick. As you know, TTree::Scan() require user input. I guess I need to execute some ROOT script in the shell script like yes q | root -l -b -q 'dump.C etc. It isn’t closed in C++. Moreover, it Is hard to Scan all the entry for huge file because of performance issue.
Second one shows nice implementations. As I said, they are a little bit huge thus not match for my small project.
Actually, I cannot come up with anything else other than manually comparing the TTree schemas and the data stored in each branch. Maybe @pcanal can suggest something else here.
We do not calculate a hash for the content of a TTree (and extracting the non variable information would be more costly that you hope for). One thing you could do is to use the new TFile feature: ROOT: TFile Class Reference
as:
A bit TFile::kReproducible can be enabled specifying the "reproducible" url option when creating the file:
TFile *f = TFile::Open("name.root?reproducible","RECREATE","File title");
Unlike regular TFiles, the content of such file has reproducible binary content when writing exactly same data. This achieved by writing pre-defined values for creation and modification date of TKey/TDirectory objects and null value for TUUID objects inside TFile. As drawback, TRef objects stored in such file cannot be read correctly.
In case the name of the file is not reproducible either (in case of creating temporary filenames) a value can be passed to the reproducible option to replace the name stored in the file.
TFile *f = TFile::Open("tmpname.root?reproducible=fixedname","RECREATE","File title");