Hi Alberto, On 8 Oct 2002, Alberto Pulvirenti wrote: > Dear all, > > I would like to perform the following operation. > > I read a TTree object from a file, but, in principle, I don't know WHAT > kind of objects are stored in it. The only thing I know is that it > should contain a unique branch, called "Points". > > Question 1: > I guess that I can check the existence of that branch by using > TTree::GetBranch("Points"), which should return a NULL pointer in case > that such branch does not exist. Am I right? > right > Question 2: > This branch should have been filled with objects if a given specified > class, say "point". How can I check if the entries stored into this > branch are of the correct type? You can do something like: const char* classname; TBranch *branch = tree.GetBranch(branchname); if (branch->InheritsFrom("TBranchObject")) { classname = ((TBranchObject*)branch)->GetClassName(); } else if (branch->InheritsFrom("TBranchElement")) { classname = ((TBranchElement*)branch)->GetClassName(); } else { classname = 0; //branch is not a class } This logic could be simplified by adding a GetClassName function in the base class TBranch. I will do it. Rene Brun > > Thanks > > alberto > > >
This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:51:13 MET