Re: [ROOT] reading / writing object to disk

From: Rene Brun (Rene.Brun@cern.ch)
Date: Sun Nov 25 2001 - 19:35:32 MET


Hi Joe,

To write an object of class Myclass to a file, do:
  TFile f("joe.root","recreate");
  Myclass *obj = new Myclass;
  obj->Write("aname");
  f.Close();

To read an object from a file:
  TFile f("joe.root");
  Myclass *obj = (Myclass*)f.Get("aname");

Rene Brun


On Sun, 25 Nov 2001, joe robe wrote:

> Hi rooters,
> 
> just try to understand TFILE.
> 
> I created a small testclass (with ClassImp etc macros
> and creating dict. file and are able to write this to
> disk.
> 
> All I see is the only data member the class has.
> 
> I just dont understand yet how to save and retrieve my
> WHOLE class to/from disk. Is that not possible ?? I
> have classes with huge data arrays which are filled
> after doing some calculations. I just want to save and
> later retrieve this COMPLETE state of the object with
> all its datamebers, objects etc.
> 
> Is there a simple way to do that ??
> 
> Thanks
> 
> Joe
> 
> 
> 
> 
> __________________________________________________
> Do You Yahoo!?
> Yahoo! GeoCities - quick and easy web site hosting, just $8.95/month.
> http://geocities.yahoo.com/ps/info1
> 



This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:51:09 MET