Please document TTree::SetMakeClass()

It recently took me many many hours to figure out that my code could not read out a branch because TTree::SetMakeClass() was not set. As far as I can tell this is neither explained in the ROOT manual, nor the TTree documentation page. I found a old RootTalk message (http://root.cern.ch/root/roottalk/roottalk03/1853.html) regarding it, but only post mortem because one has to search for SetMakeClass, and at least this one had no clue that SetMakeClass was the problem to begin with.

Some explanation and warning about this feature in the TTree documentation would be very much appreciated.

Sue Ann Koay
sakoay@cern.ch

Seconded.

I used MakeClass() to make a class to read my TTree. The Tree contains 3 branches with custom classes in, so the generated template didn’t set the branch addresses (not something mentioned in the method documentation). I set the branch addresses as I would do normally (presumably the ‘hand crafting’ suggested here SetMakeClass problem), but it Segfaults on GetEntry.
Using MyClass *myobjp; tree->SetBranch("toplevel",&myobjp); as suggested here
How to use SetBranchAddres() ? Role of SetMakeClass()? simply results in error: no member named 'SetBranch' in 'TTree'. The answer also seems to say ‘if you don’t have a library, the method you suggested is correct’ - despite the fact that OP shows it doesn’t work…!

Essentially my understanding at this point is

With SetMakeClass enabled, ROOT will not read anything that inherits from TObject from your file.

if that’s the message, it’s a simple one, please include in the documentation.

Try:

TBranch *bp = 0;
MyClass *op = 0;
tree->SetBranchAddress("MyClass_object_top_level_branch_name", &op, bp);
// ...
delete tree; // cleanup (automatically deals with "bp")
delete op; // cleanup