TTree::Draw with friends and array branches


Either I have a very deep misunderstanding of the way draw selections work in this case or there is a bug here.

My (simplified) situation is this:
I have two trees, each with multiple branches, some simple, some vectors of length 2240, one for each channel:

tree->Branch("run", &run, "run/I");

where channel[i] = i+1
The two trees are filled out of order, so that entry 15 might be run 5123 on tree1 and 9014 on tree2. The trees also have different numbers of entries.

So now I want to compare things with the runs matched up, so I call BuildIndex(“run”) on both of them, and then tree1->AddFriend(“tree2”). As I understand, this will match the trees up by their index values - and I had thought only draw entries where there is a match.

Now here’s where it gets really weird:

root [131] t96->Draw("channel :","1")
root [132] t96->Draw("channel :","channel ==")
root [133] t96->Draw("channel :","run ==")        
root [134] t96->Draw("channel :","run == && channel ==")

As we can see, the channels are lined up, as expected. But when I make explicit the idea that the runs must be equal, I get a reduction in entries. What am I not seeing here?

Even worse, when I add the cut that the channels must be equal, which above had no effect, suddenly I cut away almost everything. The plot, which formerly went from 1 to 2241, now only has channels 1 and 2 on it. This especially feels very much like a bug to me.

I am running root v5.22 on OS 10.5.



Indeed this looks weird. Can you file a report under savannah and attach a running example? Thanks,

Will do. Cheers.

Hi Ben,

The problem is finally fixed in the svn trunk. Thanks for your patience.


A work around is

tree1->GetEntry(100); // Need an entry that will ‘not’ load the entry of tree2 associated with the 1st entry of tree1 that has a corresponding entry in tree2 (in your example this is any entry greater than or equal to 22)
int n3 = tree1->Draw(“channel :”, “run ==”);