Re: [ROOT] Permanent histo overlay

From: Rene Brun (Rene.Brun@cern.ch)
Date: Tue Feb 13 2001 - 10:19:26 MET


Hi Andrea,
You can add as many objects as you want to the "list of functions"
of a TH1 or TGraph object. These objects are automatically saved with
the TH1 or TGraph on a file and then restored.
Example:
void demo()
{
   TH1F *h = new TH1F("h","h",100,-3,3);
   h->FillRandom("gaus",10000);
   TLine *l = new TLine(h->GetBinCenter(20),h->GetBinContent(20),
                        h->GetBinCenter(60),h->GetBinContent(60));
   h->GetListOfFunctions()->Add(l);
   h->Draw();
}

In the above example, you do not need to call h->Draw(). If you h->Write()
to a file, then in a new session, do:
   TFile f("xxx.root");
   TH1F *h = (TH1F*)f.Get("h");
   h->Draw();
you will get the line superimposed on top of the histogram.

Rene Brun

Andrea Fontana wrote:
> 
> Hello ROOTers,
>    I have a 2D histogram on top of which I want to superimpose a TEllipse
> and a TLine: everything works fine in interactive mode, as I simply do
> a Draw("same") and the overlay is correctly superimposed.
> 
> I now want to produce a bunch of these plots (TH2F + TEllipse + TLine) in
> batch mode, i.e. without drawing the histogram but only saving them
> into a file. Is there any way to superimpose the overlay only in memory
> without displaying it? In other terms, is it possible to attach (in some
>  sense) objects (like TLines and TEllipses) to an histogram?
> 
> Many thanks,
> Andrea Fontana (Athena Experiment)



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