AddFriend

Hallo,

gSystem->Load("$ROOTSYS/test/libEvent.so"); file = TFile::Open("$ROOTSYS/test/Event.root"); // 400 events T->AddFriend("wrong_tree_name", "or_wrong_file_name"); // ooooops my mistake, now trying correct names T->AddFriend("t1", "$ROOTSYS/tutorials/tree1.root"); // tree1.C, but only 400 events T->Draw("px"); [quote] *** Break *** segmentation violation
Generating stack trace…
0x013584f8 in TTree::LoadTree(long long) + 0xf2 from /cern/root/lib/libTree.so
0x074e34a3 in TTreePlayer::Process(TSelector*, char const*, long long, long long) + 0x37f from /cern/root/lib/libTreePlayer.so[/quote]
Why within TTree::AddFriend(const char* treename, const char* filename) is not any mechanism which is able to check if adding the tree(or file) is correct ? or it is on the user yourself ?
Eeven though ROOT announces: Error in : file or_wrong_file does not exist, is this “wrong” FriendElement adding in ListOfFriends, why ?
Sorry to my poor english.

Thanks, Jan

Jan,

Could you send the exact script that you execute?
In your example, thw two lines:

T->AddFriend("wrong_tree_name", "or_wrong_file_name"); T->AddFriend("t1", "$ROOTSYS/tutorials/tree1.root"); // tree1.C, but only 400 are invalid (See TTree::AddFriend calling sequence)

Rene

tree1.root is file from $ROOTSYS/tutorials/tree1.C (but only 400 events, same as Event.root from $ROOTSYS/test)

are invalid ? why ? TFriendElement* TTree::AddFriend(const char* treename, const char* filename)

T->AddFriend("wrong_tree_name", "or_wrong_file_name"); // or T->AddFriend("wrongName", "tree1.root");in this case I tried to add tree with “wrongName” (by my mistake I put incorrect name), I am adding tree with the correct name:

T->AddFriend("t1", "tree1.root"); and now

T->Draw("px"); dont working ?! and ListOfFriends contains “wrongName”, why ?

[quote]
root [7] T->GetListOfFriends()->ls();
Friend Tree: t0 in file: tree1.root
Friend Tree: t1 in file: tree1.root
root [8] T->Draw(“px”);

*** Break *** segmentation violation
Generating stack trace…
0x04db3b9d in TTree::GetFriendAlias(TTree*) const + 0xab from /cern/root/lib/libTree.so[/quote]
FC6, root 5.13/04a

Thanks, Jan

{ gROOT->LoadMacro("$ROOTSYS/tutorials/tree1.C"); tree1w(); // but only 400 events gSystem->Load("$ROOTSYS/test/libEvent.so"); TFile *file = TFile::Open("$ROOTSYS/test/Event.root"); TTree *T = (TTree*)file->Get("T"); T->AddFriend("t0", "tree1.root"); // by my mistake I put incorrect name "t0" T->AddFriend("t1", "tree1.root"); T->GetListOfFriends()->ls(); T->Draw("px"); }