Reading Trees for coincidences based on event number branch

Hello,

I want to read two trees with 5 branches, the first branch is event number and the other branches contain corresponding energies in different detectors for both trees. The first tree has many events where event number exists but energies are 0. Another tree has only events when there are some energies in corresponding channels.
I would like to count the number of events that occur in both trees. For instance, if event number 35 of tree1 has some energy in any column then look for the same event number in the tree2 and check if there is also some energy deposited. If yes, then count as 1.

It seems very simple but somehow I am puzzled to loop over trees and branches.
Any help would be much appreciated.

Thanks very much in advance,

You can “Draw” the trees without producing graphics (option “goff”) . The returned value of this command will be the number of event satisfying the selection:

   int n = yourtree->Draw("variables","selection","goff");

try something like

tree1->AddFriend(tree2);
tree2->BuildIndex("eventnumber");
tree1->GetEntries("(tree1.det1 != 0 || tree1.det2 != 0 || tree1.det3 != 0) && (tree2.det1 != 0 | tree2.det2 != 0 || tree2.det3 != 0")

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.