Using a branch from another tree


I have two root files having different trees name but a common branch “totWeight”.
I am running the event loop on 1st root file and fill some histograms with some selections etc.
But there is this branch “totWeight” which I want to use from 2nd root file, while filling these histograms from 1st root file. Both the root files having same number of entries and each entry of 1st tree correspond to the entry of 2nd tree. Or you can say they are “friend” trees.

Is there a way to do this?

Thanks and regards,

You can use AddFriend to connect two trees.
For example treeA->AddFriend(treeB), then you can do treeA->Draw(“weight:treeB.weight”), something like that.
Not sure this is what you want or not.