Hi roottalk, I have a question about how to best synchronize entries across two friend trees (trees read in parallel) by a key value. Through a search of the root talk digest, I've found that similar questions have been asked in the past, for example: http://root.cern.ch/root/roottalk/roottalk01/2135.html but I'm still unsure of the best way to go about what I want to do. In particular, I currently have 2 friend trees read in parallel in a script such as: { ... TFile* mcfile = new TFile("mctruth.root","READ"); TTree* mctree = (TTree*)(mcfile -> Get("mctree")); TFile* recfile = new TFile("reconstructiondata.root","READ"); TTree* rectree = (TTree*)(recfile -> Get("rectree")); // Make the reconstruction data tree a friend of the mc truth tree mctree -> AddFriend(rectree); // Use TTree::Draw to draw members of either tree // In this case, draw reconstructed versus monte carlo event vertex z position mctree -> Draw("mctree.evt.vtx.z:rectree.evt.vtx.z"); } This works fine if there is a 1:1 match between the entries in the mctree and the rectree. But in some cases, mctree might contain a subset of entries stored in rectree, or vice-versa. In this case, I don't want to rely on tree indexing to provide the match between entries in the two trees but use key data (for example run & event #) to provide the match between two tree entries. I'm wondering what is the best way to handle this situation that preserves the ease of the relationship between the two trees that is provided by AddFriend? For example, I see that I can use BuildIndex, as described in: http://root.cern.ch/root/roottalk/roottalk03/0445.html to synchronize trees with mismatched index numbers by run,event number, but this doesn't allow the user to Draw members of the two trees against each other as illustrated in the example above, or use other methods of TTree (e.g. TTree::Scan) as transparently as TTree::AddFriend allows the user to, does it? A tool to sequence entries by key value, if available, has very general application beyond the simple example I've given here. Thanks for any advice you can give me, -Sue Kasahara
This archive was generated by hypermail 2b29 : Thu Jan 01 2004 - 17:50:15 MET