RE: [ROOT] Strange interaction between friend tree and CopyTree

From: Philippe Canal (pcanal@fnal.gov)
Date: Mon Aug 05 2002 - 18:32:14 MEST


Hi Boris,

There is 2 issues.

The friendship relation is a persistent relation.  This relation is also
copied over by CopyTree.

You can 'detach' a friend by calling (do it before saving the new tree).

	TList * l = newtree->GetListOfFriends();
	l->Remove(l->FindObject("GlobalFriend");

Also even if the friend file does not exist, it should not core dump.  We
will fix the problem.

Cheers,
Philippe

-----Original Message-----
From: owner-roottalk@pcroot.cern.ch
[mailto:owner-roottalk@pcroot.cern.ch]On Behalf Of Boris Tuchming
Sent: Friday, August 02, 2002 7:13 AM
To: roottalk@pcroot.cern.ch
Subject: [ROOT] Strange interaction between friend tree and CopyTree


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