Re: reading TTree from a TDirectory

From: Paul Russo <russo_at_fnal.gov>
Date: Wed, 17 Aug 2005 01:09:19 -0500


An example:

// Prove to ourselves that the current directory
// is gROOT.

gROOT
gDirectory
.ls

// Make a new directory, which will be a subdirectory
// of gROOT.

d = new TDirectory("mydir", "for my stuff")

// See that it is in gROOT.

.ls

// Prove to ourselves that current directory is still
// gROOT and not our new directory.

d
gROOT
gDirectory
.ls

// Make our new directory the current directory.
d->cd()

// Verify that we have changed current directory.
d
gROOT
gDirectory
.ls

// Make a tree in our subdirectory

tree1 = new TTree("mytree", "for testing") .ls

// Go back to top level directory

gROOT->cd()
.ls

// Fetch tree from subdirectory and prove that
// fetched tree is the one we created above.

tree1_fetched = (TTree*)((TDirectory*)gROOT->Get("mydir"))->Get("mytree") tree1
tree1_fetched

// This is all documented in Chapter 11, Input/Output, of the User Guide
// and in the reference documentation for TDirectory.

Tulun Ergin wrote:

> Hi,
> 
> Could somebody tell me the way to read a tree, 
> which is saved in a TDirectory. I could not find 
> any answer in the Root manual and tutorials...
> 
> Thanx,
> 
> Tulun Ergin
> 

Received on Wed Aug 17 2005 - 08:10:19 MEST

This archive was generated by hypermail 2.2.0 : Tue Jan 02 2007 - 14:45:11 MET