TTree::Draw with friends and array branches

Hello,

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");
tree->Branch("channel",channel,"channel[2240]/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 : t95.channel","1")
(Long64_t)11152960
root [132] t96->Draw("channel : t95.channel","channel == t95.channel")
(Long64_t)11152960
root [133] t96->Draw("channel : t95.channel","run == t95.run")        
(Long64_t)9582720
root [134] t96->Draw("channel : t95.channel","run == t95.run && channel == t95.channel")
(Long64_t)8556

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.

Cheers,
~Ben

HI,

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

Will do. Cheers.

Hi Ben,

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

Cheers,
Philippe.

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 : tree2.channel”, “run == tree2.run”);