Saving a tree with a friend to a file

When I do this

[code]
TTree *intree = 0;

intree = chainele;

TFile *f = new TFile(“tmpfile.root”,“recreate”);

TTree * electron1_tree = (TTree*)intree->CloneTree(1000);

TTree * friend_tree = new TTree;
electron1_tree->AddFriend(friend_tree);

f->Write();
f->Close();[/code]
and then open tmpfile.root and then do root and then do “new TBrowser” and click on one of the branches, root crashes due to segmentation fault. I attached the stack trace. Any ideas how to fix this?
stack_trace.txt (5.15 KB)

Hi,

In order for a TTree to be saved and properly retrieve, it must have a name. Using: TTree * friend_tree = new TTree("friendtree","");solves the problem.

Cheers,
Philippe.

PS. The missing protection avoid the segmentation fault in that case has been added to the trunk and v5.34 patch branch.

thanks, giving the tree a name did indeed solve the problem