[ROOT] Strange interaction between friend tree and CopyTree

From: Boris Tuchming (tuchming@hep.saclay.cea.fr)
Date: Fri Aug 02 2002 - 14:13:07 MEST


Hello,
I see something strange using Friend and CopyTree :
I have a big file "myfile.root" and a smaller file "friend.root" with 
the same number of events and which contains the variable Ngoodmu. I 
want to use this variable to make a selection and extract a small sample 
from myfile.root.

Here is the way I proceed :

TFile *file = TFile::Open("myfile.root");
TTree * t=gDirectory->Get("Global")
t->AddFriend("GlobalFriend","friend.root");
TFile * newfile=new TFile("Copied.root","recreate")
TTree * newtree = t->CopyTree("Ngoodmu>1"); //Selection using a variable 
from friend.root
 newtree->Write();
delete t
delete newfile
.q

The problem is that the output Copied.root cannot live without the file 
friend.root.
If friend.root is deleted, this is what I get

TFile * f =  TFile::Open("Copied.root")
TTree * t=gDirectory->Get("Global")           
t->Draw("OneVariable")
Error in <TFile::TFile>: file friend.root does not exist

 *** Break *** segmentation violation


So it seems that root wants to open this file even if it is not needed.
It is confirmed by the fact that if friend.root is present in the 
directory it will automatically  appear in a TBrowser window after the 
instruction t->Draw("OneVariable")

Is this a bug, or a  limitation or a mistake of mine.

Thanks
Boris



This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:51:03 MET