Reading a branch with different types of variables

Hello:
I am trying to write a program that reads a ROOT tree from a file, determines the type of the variables contained on each brand, and creates an apropiate structure (arrays or class?) to hold the variables when readed.
For example, let’s suppose that I have a single branch on a tree saved on a given file. The structure

struct myStructA { Int_t one[10]; Float_t two[20]; };

can correctly hold the variables contained on the branch. But for some reason, I need to read another file, containing a related tree with a similar branch, in which the structure

struct myStructB { Int_t one[8]; Double_t two[25]; UShort_t tree; };
can correctly hold the data; and later I need to read another file, containing a related tree … and so on, making imposible to define every possible apropiate structure to hold the data. How can I write some code that checks the variables in a given branch, then creates something (structure, arrays, etc.) to hold the data and then reads this data correctly?

Thanks in advance and I hope I’ve been clear in what I am trying to do.

Hugo

Hi,

The information is available in various place in the TBranch and TLeaf object (depending a bit of the exact type).
For a complete example (which actually already does almost what you need) see TTree::MakeClass (which actually implemented at root.cern.ch/root/html/src/TTree … tml#T5qtnC)

Cheers,
Philippe