Apologies, in a first attempt I messed up the reply-to-all.
Hello,
2009/6/19 Salvatore Rappoccio <rappocc_at_fnal.gov>:
> Hi, All,
>
> I was wondering how easy it is for a TTree to access a "friend" TTree when
> the events of the first tree are a subset of the second? The application
> would be where the user filters events from one TTree and drops some
> branches, but then wants to access the original for debugging purposes.
>
> I've only used friend trees when there is an event-by-event match. Is this
> functionality possible directly with friend TTrees?
I am not sure if there is a builtin way of doing this in ROOT, a while ago I needed something similar and came up with the following:
def befriendtrees(pruned, unpruned, cut="1"): """Apply cut to the unpruned tree so that it has the same entries as the pruned
tree. """ # Make a copy of unprunedtree which has events removed copy = unpruned.CopyTree(cut) if copy.GetEntries() != pruned.GetEntries():msg = "Number of events differ after applying the cut" raise RuntimeError(msg)
# XXX maybe some work needs to be done with SetDirectory() for the copied tree
pruned.AddFriend(copy)
return pruned
It works quite well for me, not sure how well it does with _huge_ trees and whether or not you need to SetDirectory() for the copied tree or not. Trees that are not attached to a file seem to have some issues sometimes
HTH,
Tim
>
> Thanks,
> Sal Rappoccio
>
-- http://tim.jottit.com/ -- http://tim.jottit.com/Received on Sun Jun 21 2009 - 19:17:02 CEST
This archive was generated by hypermail 2.2.0 : Sun Jun 21 2009 - 23:50:01 CEST