[ROOT] Re: TTrees question

From: Rene Brun (Rene.Brun@cern.ch)
Date: Mon Jan 27 2003 - 08:14:34 MET


Hi,

If you have a class ThreeVector, create your Tree with

ThreeVector *trivec=0;
TFile *f = new TFile("test.root","recreate");
TTree *T = new TTree("T","test");
T->Branch("xx","ThreeVector",&trivec);

for (...
   fill your trivec object
   T->Fill();
}
T->Write();
delete f;

see Users Guide and examples in $ROOTSYS/tutorials/tree0.C, etc

Rene Brun

On Sun, 26 
Jan 2003, 
Siva Subramania wrote:

> Hi, 
> Can anybody help me out with this...
> I have a Class ThreeVector, which has x, y, z as its private members and 
> whole lot of constructors and functions as public....
> Now I define a tree, then create a branch like this 
> T->Branch("ThreeVector", &trivec, "x:y:z");
> and then I fill the tree with 10 values each for x, y, z with a 
> constructor of ThreeVector. 
> Now I write another program to read the tree and I set the branch address 
> to the threevector in the tree, and I try to read back x, y, z.  I 
> couldn't, it gives all wrong values.   Can you give an example code to 
> read x, y, z and cout << the values.  The ThreeVector class has x(), y(), 
> z() as the getters. 
> I guess, I have tried to explain what I want, please lemme know if I am 
> not clear... Expecting a reply soon. Thanq
> 
> Siva.
> 



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