Re: [ROOT] Persisting Histogram Attributes in TFiles...

From: Frankland John (frankland@ganil.fr)
Date: Wed May 28 2003 - 00:08:51 MEST


Hi Steve

I just pasted your two bits of code into two files, stevewrite.C
and steveread.C
I executed the first (.x stevewrite.C), then exited ROOT,
and then executed the second (.x steveread.C).
In both cases I was left with a canvas showing a red, shaded
histogram!
I can't see anything wrong with what you're doing, and it
works fine for me (with ROOT v3.05/05). There must be
something else somewhere...

???
John

Steve Sekula wrote:

>Hi John,
>
>A simple example where I've had no success would be as follows:
>
>
>{
>TH1F* hist = new TH1F("hist","",20,-10,10);
>hist->FillRandom("gaus",1000);
>hist->SetFillColor(kRed);
>hist->SetFillStyle(3001);
>hist->Draw();
>
>TFile f("test.root","RECREATE");
>f.cd();
>hist->Write();
>f.Close();
>}
>
>Now exit ROOT (just for good measure) and restart it. Then open the
>test.root file and plot the histogram:
>
>{
> TFile f("test.root");
> f.cd();
> TH1F* hist = (TH1F*)f.Get("hist");
> hist->Draw();
>
>}
>
>You'll see that the fill style and color are no longer set to 3001 and
>kRed, respectively. I take it persisting attributes is more
>complicated than just calling hist->Write()?
>
>I have tried this with two versions of ROOT, 3.05/05 and 3.03/09. Both
>behave identically.
>
>
>Cheers,
>Steve
>
>
>  
>

-- 
John D. Frankland
Beam Coordinator
GANIL
B.P. 55027
14076 CAEN Cedex 05

tel: +33 (0)231454628
fax: +33 (0)231454665



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