Newbie tree question

Sorry to ask such a newbie question, but just starting to learn root and I am having a really hard time with this macro. My problem is the following:

Given a tree with several histograms in it, I am trying to print the names and titles of each of the histograms in the tree. Also, given the name of a histogram file, I would like to be able to retrieve the object from a tree that is holding it.

I tried:
TObjArray* myArray = myTree->GetListOfLeaves();

then traversing the array and printing the names and titles of the objects in the array.

leaf = tree->FindLeaf(obj->GetName());

But this did not seem to be what I wanted :frowning:

Could somebody give me some direction with this seemingly simple task?

Could you give more info?
-how you wrote your histograms to the Tree
-a short example of your reader + a small input file is welcome


well… i dont know much about the structure of the trees I will be working with because I won’t have written them and they won’t all be of similar structure.


What I do know is the following (and I know I might need more to go by or to handle this in cases…):

I will be given the name of a file containing several TObjectes - some of which will be TH1F or TH2F histograms, some of which will be TDirectories, and some of which will be TTrees. The macro will (hopefully) output html that generates and links to a gif file upon encountering a histogram, links to a list of histograms in a TDirectory, and links to a list of histograms in a TTree. The program currently works for TDirectories and histogram objects. Is there any way to generally, given a TTree, produce a list of histograms found anywhere in the tree or will I have to get more information about how the trees are structured?

Thanks again,

I can only repeat my original question: How do you put your histograms in the Tree?
A TTree supports any C++ object.
It is up to the class designer to know how to access other objects (like histograms)
inside the mother object.