Dear ROOTers,
I'm wondering whether the TLeaf name always coincides with the TLeaf title by the ROOT design. In a case if not, how can I make them different? The purpose is to save some additional information about every TLeaf in the file.
Regards,
Vassili.
P.S. Below is a macro which always shows the same name and title for every TLeaf.
////////////////////////////////////////////////////////////////////////read.C scans a file and print out some leaf attributes for all trees
//////////////////////////////////////////////////////////////////////void read(const char *file = "hsimple.root") {
//
TFile f(file);
TList *li = f.GetListOfKeys();
TKey *key;
TObject *obj = 0;
TClass *cl = 0;
TTree *tree = 0;
TIter next(li);
while ((key = (TKey*)next())) {
printf("name = %s;%d title = %s class = %s\n", key->GetName(), key->GetCycle(), key->GetTitle(), key->GetClassName()); cl = gROOT->GetClass(key->GetClassName()); if (!cl) { printf("unknown class %s\n", key->GetClassName()); continue;
}
// the case of tree if (cl->InheritsFrom(TTree::Class())) { tree = (TTree*)key->ReadObj(); // read tree TIterator *iter = tree->GetIteratorOnAllLeaves(); while ((obj = (*iter)())) { printf("\t name = %s title = %s class = %s\n", obj->GetName(), obj->GetTitle(), obj->ClassName()); }
}
This archive was generated by hypermail 2.2.0 : Mon Jan 01 2007 - 16:31:58 MET