Hello,
I use this command to get the name of a tree if I do not know its name.
TTree Tree_Data = (TTree)root_file->Get(root_file->GetListOfKeys()->At(0)->GetName());
where root_file is the name of object TFile
I would like to know if there is another method to get a tree name and if my command works always
Thanks.
[quote]I would like to know if there is another method to get a tree name and if my command works always[/quote]What do you mean? Do you mean Tree_Data->GetName() ?
Philippe.
My root files contain often a tree. My problem is that I do not know always the name of the tree. So, I would like to know a command which give me the name of the tree contained in a root file.
Now, I use command above but I am not sure this works always.
Inspired from $ROOTSYS/tutorials/hadd.C:
[code] TIter nextkey( root_file->GetListOfKeys() );
TKey *key, oldkey=0;
while ( (key = (TKey)nextkey())) {
TObject *obj = key->ReadObj();
if ( obj->IsA()->InheritsFrom( TTree::Class() ) ) {
Tree_data = (TTree*)obj;
break;
}
}
[/code]
Philippe.