Making selection on friend TTrees

Hi ROOT support,

Suppose I have two TTrees who are friends to each other. I want to make some selection using variables in both the friends. But how can I make the TTrees after the selection also friends to each other? I tried something like:

tree->AddFriend(friendtree);
TTree* sel_tree = (TTree*) tree->CopyTree(mycut);

friendtree->AddFriend(tree);
TTree* sel_friendtree = (TTree*) friendtree->CopyTree(mycut);

But sel_tree and sel_friendtree now have different orders of entries. How can I link them as friends? Alternatively, is there a way to merge them after the selection that doesn’t require setting all the branch names by hand?

Thanks,
Jia

[quote]Alternatively, is there a way to merge them after the selection that doesn’t require setting all the branch names by hand?[/quote]Not at the moment.

[quote]But sel_tree and sel_friendtree now have different orders of entries. [/quote]Why? The cut should be selecting the same entries in both cases …

Philippe.

Hi Philippe,

Thanks for the answer. I realized what happened was that, after selection, sel_tree still sees the original friendtree as its friend. Even if I add sel_friendtree as sel_tree’s friend, sel_tree is always displaying entries from the original friendtree. So I solved my problem by using RemoveFriend(friendtree) before I do AddFriend(sel_friendtree).