Re: TLeaf name and title

From: Rene Brun <Rene.Brun_at_cern.ch>
Date: Fri, 31 Mar 2006 14:28:04 +0200 (MEST)


The result of your script is correct. If you want more information about a TLeaf, you must get a pointer to a TLeaf object and use the TLeaf functions.

    TLeaf *leaf1 = mytree->GetLeaf("leafname");     leaf1->GetTitle(); etc

In case you would like to store additional information per leaf, you can create an object with the meta information that you need and add this object to

    tree->GetUserInfo()->add(myobject);

Rene Brun

On Fri, 31 Mar 2006, Vassili Maroussov wrote:

> 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());
> }
> }
> }
> }
>
Received on Fri Mar 31 2006 - 14:28:09 MEST

This archive was generated by hypermail 2.2.0 : Mon Jan 01 2007 - 16:31:58 MET