Hi Brant,
What you tried should work. Could you send a small script/tar file
reproducing this problem?
Thanks,
Philippe.
-----Original Message-----
From: owner-roottalk@pcroot.cern.ch
[mailto:owner-roottalk@pcroot.cern.ch]On Behalf Of Brant C.
Sent: Friday, August 15, 2003 8:25 PM
To: roottalk@pcroot.cern.ch
Subject: [ROOT] TTree use without TFile
Hi All,
I'm confused about how TTree is working.
I have a function that reads a text file, creates objects, fills a TTree
with them, and returns a pointer to the TTree it created.
The TTree is created with a single explicitly-created branch to hold the
main object, call it a1, with splitting set to maximum. This main branch
contains a bunch of pointers to TObject-derived objects, which also contain
pointers and TRefs to other objects:
(classes called A, B, and C. a1 instance of A, b1 and b2 instances of B, c1
instance of C.)
a1 has a pointer to b1. b1 has a TRef to a1.
a1 has a pointer to c1. c1 has a TRef to a1.
c1 has a TRef to b1.
c1 has a pointer to b2.
where pointers are used so the objects will be written, and TRefs used where
necessary to prevent multiple instances being created.
(Philippe; much thanks for the help, it works now. no more memory leaks :)
A subsequent call to Draw() for a property of a1 works properly.
Calling Draw(...) causes a segfault if i try to draw a property of b1 by
accessing it through a1's pointer to b1.
However, if I call SetBranchAddress(...):
A *pa1=0;
ptree->SetBranchAddress("Abranch",&a);
on the main branch of the tree giving it a null A* pointer before i call
Draw(...), it works properly.
It also works properly if I first save the tree in a TFile and then read the
tree from the file.
Is there a reason for this behavior, or is there something I'm doing wrong
that would cause this?
or am I just confused?
Thanks in advance,
Brant Carlson
This archive was generated by hypermail 2b29 : Thu Jan 01 2004 - 17:50:14 MET