Automatic file content list


is it possible to generate a list of all the variable (with their types) of e.g. TTree of a ROOT file to some stdout? I would need to get a list of the variables and automatically edit/copy them to some other header file.

I know about the tree->MakeClass(“mytreeclass”) function but what I would need is just to get a list of the variables with their types. Is there a (maybe PyROOT) function already doing this or I would need to write some sed/awk script that takes the info out of e.g. a MakeClass() generated header file?

Thank you,

see example below:


void ll() { //list list of leaf names in a Tree TFile f("Event1.root"); TTree *T = (TTree*)f.Get("T"); TObjArray *leaves = T->GetListOfLeaves(); Int_t nleaves = leaves->GetEntries(); for (Int_t i=0;i<nleaves;i++) { TLeaf *leaf = leaves->At(i); printf("leaf %d = %s\n",i,leaf->GetName()); } }

Hi Rene,

thank you that helps. But I still don’t understand that if I call


I get e.g. “vector” as the type of myleaf, while if I make a


I get “vector * myleaf” in the generated header file.

Why doesn’t the “GetTypeName()” gives also a pointer as a type for the same leaf than what the MakeClass() generates?

Thank you,


The result of MakeClass does not represent an exact copy of your original class design. Instead this is a variation thereof, tuned to allow reading of each of the leaf independently. In the case you mention this means that rather than having an embedded object, the access to your vector is done indirectly (via the pointer).