Re: [ROOT] write doesn't write

From: Rene Brun (Rene.Brun@cern.ch)
Date: Thu Jun 06 2002 - 23:27:02 MEST


Hi Michael,

If you want to write all objects (histograms) in the default directory
"Rint" in memory to the file f, do:
//assuming you are already in "Rint:/" where you have histograms
TDirectory *dir = gDirectory; //save pointer to Rint dir
TFile *f = new TFile("Hmu.root","recreate");
dir->GetList()->Write();
f->ls();
delete f;

Rene Brun


On Thu, 6 Jun 2002, Michael Gold wrote:

> Dear Rooters:
> 
> when I execute this, the histograms are there in
> the local memory, but the f->ls() shows the file
> is empty.  
> 
> what is wrong here?
> 
> thanks, Michael
> 
> void save() 
> {
>   TFile *f = new TFile("Hmu.root","recreate");
>   //gDirectory->pwd();
>   gDirectory->cd("Rint:/");
>   gDirectory->ls("-m");
>   //  gDirectory->GetList()->ls();
>   f->Write();
>   f->ls();
>   // automatic upon deletion  f->Close();
>   delete f;
> }
> 



This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:50:55 MET