Re: [ROOT] how do I find the number of trees in a file?

From: Rene Brun (Rene.Brun@cern.ch)
Date: Thu Aug 21 2003 - 18:49:19 MEST


Hi Chris,

You can get the number of objects written as keys in a file via
TDirectory::GetNkeys(). When opening your file in update mode
  TFile f("myfile.root","update");
  int nkeys = f.GetNkeys();

If you have written only Trees to the file, nkeys should be 
the number of Trees.

I have some difficulty understanding what you want to do.
Why do you want to create a friend Tree of the first Tree
with each run ?
Why don't you store each run/Tree in a separate file?

Rene Brun

On Thu, 21 
Aug 2003, Chris Hayward wrote:

> Hello ROOTers,
> 
> I am running ROOT 3.05/07 on lxplus.
> 
> I would like to create a new tree on each run of my program
> and add it as a friend to the first tree. I would like to name them tree0,
> tree1, tree2, etc. Is there a simple way to keep a running count of trees
> in the file, i.e. some command that returns the number of trees stored?
> 
> Thanks,
> Chris
> 
> 



This archive was generated by hypermail 2b29 : Thu Jan 01 2004 - 17:50:15 MET