Re: Write histogram to a specific file

From: Rene Brun (Rene.Brun@cern.ch)
Date: Wed Jan 26 2000 - 18:25:21 MET


Hi Stefan,
You must write back the modified and new objects to the file.
The file mmust be opened in update mode.
To write back the modified/new objects, two possibilities
 1- write each of them individually to the file, eg
pt_sig_teamlt18.Write();
 2 -write all objects to the file with file->Write();

In your case, option 2 is probably the best.

Rene Brun

Stefan Stonjek wrote:
> 
> Hello Root Users,
> 
> I have a problem with writing a histogram to a specific file.
> 
> It is no problem to read the allready existig histos in this program. They
> are already filled in the same program and the "print" command clearly
> indicated that the new histogram contains usefull date. But these data
> does not end up in the file.
> 
> Here is the code in question. It is just an excerpt from a much longer
> program with many subroutines.
> 
>   TH1F *pt_gcc_sig_etamlt18 = (TH1F*)hfile->Get("pt_gcc_sig_etamlt18");
>   TH1F *pt_wcc_sig_etamlt18 = (TH1F*)hfile->Get("pt_wcc_sig_etamlt18");
>   hfile->cd();
>   TH1F pt_sig_etamlt18 = ( *pt_gcc_sig_etamlt18 - *pt_wcc_sig_etamlt18);
>   pt_sig_etamlt18.SetName("pt_sig_etamlt18");
>   pt_sig_etamlt18.SetDirectory(hfile);
>   pt_sig_etamlt18.Print("all");
> 
> Mayby it is just a stupid mistake but I hope someone is able to help me.
> 
> Tschuess
>         Stefan
> 
> *********      Stefan  Stonjek     *********
> *****            DESY / ZEUS           *****
> *****      Stefan.Stonjek@desy.de      *****
> *********  Tel.: +49-40-8998-3159  *********



This archive was generated by hypermail 2b29 : Tue Jan 02 2001 - 11:50:17 MET