[ROOT] problem with TTree

From: Nicolas Produit (Nicolas.Produit@obs.unige.ch)
Date: Fri Sep 05 2003 - 09:46:06 MEST


Hi,

I fall in a trap using TTree. I think it can be useful for other to know
about the trap and perhaps it could be documented (or discussed or changed...)
(My root: 3.04/02 on linux)

I was declaring a TTree in routine "a". Routine "a" was calling routine "b"
where all the branches of the tree where declared and filled.
Then routine "a" was making a tree->Print().
When declaring and filling the branch I had obviously to use 
variables known to the branch to hold the data before calling the Fill()
method.
Now the trap: I was using for that purpose a local variables of "b"!
This resulted in random crash in CINT and constant crash in compiled code.
Until I realised that perhaps Print() was needed the variables that where
destroyed going out of routine "b"!
Sure enough, when declaring those variables in "a" and passing them to "b" the problem disappear.

1- Can you confirm that the address passed in the second parameter of the Branch constructor
have to exist as long as the tree exist?
2- Is that not a sort of breach of data encapsulation? I mean, I declare a variable,
use it to fill the tree and then I have no more need of it in my user program so I destroy it.
Why do I have to care that the machinery has a need of it? Draw, Scan, and Print can, if they need
a variable to hold temporary results, redefine the Branch address and use their own local variables.
(and they reestablish the old address when done to be nice with other)

Thanks


-- 
Nicolas Produit                 
INTEGRAL Science Data Center    Phone:  +41 22 950 91 40
16, Chemin d'Ecogia             Fax:    +41 22 950 91 33
CH-1290 Versoix                 www:    http://isdc.unige.ch/



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