Re: [ROOT] how do I load objects from RootFile without searching

From: Rene Brun (Rene.Brun@cern.ch)
Date: Wed Jan 22 2003 - 20:58:30 MET


Hi HP,

This functionality exists (just look inside TDirectory::Get).

If you have the key (Tkey), then do
  MyClass *object = (MyClass*)key->ReadObj();

Rene Brun

On Wed, 22 
Jan 2003, HP Wei wrote:

> 
> Question:
>    TDirectory::Get("ObjName");
>    first searches for the object named "ObjName" in a given RootFile
>    and then loads the object into memory.
>    
>    I want to eliminate the process of searching.
>    i.e. I want to find a function that does the second part of Get()
>         --> to load the object in memory given an offset.
>    
>    Since we can get the info of the offset (seekKey) of 
>    the object stored in a rootfile and we can know the offset beforehand,
>    we could have a function like:
>    (TObject *) Load(offset)
>    which just goes to the offset in the file and load the object into memory.
>    This presumably will be somewhat faster than Get("ObjName").
>    
>    Is there something in the class library to allow me to do this ???
>    
>    GetListOfKeys() can provide SeekKey for the object, which we can 
>    store in a hash table such as 
>    STL::map(string(objName), unsigned_int(offset)).
>    But in TDirectory, I could not find any function that does:
>    (TObject *) Load(seekKey).
> 
> thanks,
> HP
> 



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