Classes and Pointers


I have a small issue with something in the ROOT manual. On page 211 we are dealing with a TTree that has CERN staff data. At this point we’ve done a TFile f(“staff.root”) so the file is in memory.

My question is about objects and calling a method. We see inthe manual T->Show(10) which shows us the 10th record. Where did the “T” come from? I would have expected f->Show(10) to work or tree->Show(10) (the object tree is defined in the macro)

More confusing, a few lines later we are asked t type in tree->Print() which does NOT work. However f->Print() DOES work! and, not surprisingly, T->Print() DOES work but I still don’t know where the “T” comes from.


Hi Harry,

Indeed there are typos in the provided example on pages 210-211 of the User’s Guide which I am going to fix for the next edition.

The macro $ROOTSYS/tutorials/staff.C is used to create the file staff.root. When you run it, you will see what is provided in the attached file trreeexam.txt, i.e. a TTree 'T ’ is created that contains the data from an ascii file (NOT a TTree ‘tree’ how it is written in the example provided on the page 210). So the correct way for running this example should be as it is included in the attached file. The command f->ls() show you all objects written in the file.

Thank you for reporting this case.

Best regards, Ilka
treeexam.txt (4.73 KB)

Neat, now I also see to look more closely at the output of .x staff.C (and other commands). I tried it out in a root window and got the same output as your txt file, the answer was always there.

thanks again, Ilka