Re: [ROOT] TDirectory::Get() with objects in memory

From: Pierre-Luc Drouin (pldrouin@physics.carleton.ca)
Date: Wed Aug 13 2003 - 16:16:20 MEST


HI,

Here is an example.

root [0] TObjString *mystr=new TObjString("mystr")
root [1] gDirectory->Add(mystr)                   
root [2] TMatrixD *mymatrix=new TMatrixD(1,1)     
root [3] gDirectory->Add(mymatrix)                
root [4] gDirectory->ls()                         
TROOT*          Rint    The ROOT of EVERYTHING
 OBJ: TObjString        mystr   Collectable string class : 0 at: 0x8e5ac60
 OBJ: TMatrixD  TMatrixD        Matrix class (double precision) : 0 at: 0x8ba8e00
root [5] mystr->GetName()
(const char* 0x8e5ac8c)"mystr"
root [6] gDirectory->Get("mystr")
(class TObject*)0x8e5ac60
root [7] mymatrix->GetName()     
(const char* 0x8e5ae4c)"TMatrixD"
root [8] gDirectory->Get("TMatrix")
(class TObject*)0x0

Thank you!

Pierre-Luc Drouin

On Wed, 13 Aug 2003, Rene Brun wrote:

> Pierre-Luc,
> 
> I cannot reproduce this problem. Please send a short script.
> 
> Rene Brun
> 
> Pierre-Luc Drouin wrote:
> > 
> > Hi,
> > 
> > There is something I don't understand with TDirectory::Get(). Suppose I've
> > a
> > TNamed object and a object from a class that I've derived from
> > TNamed. Both objects have been added in gDirectory using
> > gDirectory->Add(). The object names are respectively "tnamed" and
> > "tnamedd". Why do I get this result:
> > 
> > gDirectory->Get("tnamed") returns a pointer to the TNamed object
> > gDirectory->Get("tnamedd") returns a NULL pointer (not a pointer to the
> > TNamed derived object)
> > 
> > If both objects are written a TKey into gDirectory, I get valid pointers
> > with the 2 lines
> > 
> > I get also this problem with ROOT classes. With a TObjString object, I get
> > a valid pointer. With a TMatrixD object, I get a NULL
> > pointer.
> > 
> > TDirectory::FindObject() behaves the same way (with objects in memory of
> > course)
> > 
> > Thank you!
> > 
> > Pierre-Luc Drouin
> 



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