91187
1
Hi, relatively new user here:
I have two root files, both of which contain the same tree ‘A’.
Is it possible that I can load both root files in one ROOT session, and then compare branches of ‘A’ between the two root files?
E.g. tree ‘A’ has branch “momentum”, I would like to scan that branch for both root files in a single session and compare the values side by side.
Thanks so much for any advice!
ksmith
2
I believe you want the TTree::AddFriend(TTree * tree, const char* alias)
method: https://root.cern.ch/doc/master/classTTree.html#a321f2684de145cfcb01cabfce69ea910.
An example:
TFile file1("file1.root");
TTree *tree1 = (TTree*) file1->Get("A");
TFile file2("file2.root");
TTree *tree2 = (TTree*) file2->Get("A");
tree1->AddFriend(tree2, "tree2");
tree1->Scan("A.momentum:tree2.momentum");
(I haven’t tested this.)
1 Like
91187
3
Thanks so much! That was really helpful.
system
Closed
4
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.