Re: Pointer to TH1F in TCanvas

From: Rene Brun (Rene.Brun@cern.ch)
Date: Fri Dec 10 1999 - 08:38:36 MET


Hi Alexey,
To get a pointer to any primitive in a pad/canvas, use
TPad::GetPrimitive.
Example:

Root > bgoadc.Draw("a0","lay==0");
Root > TH1F *htemp = (TH1F*)can->GetPrimitive("htemp");

the above will work in all cases (recommended).

In an interactive session, you can also use the shortcut:

Root > bgoadc.Draw("a0","lay==0");
Root > htemp->Fit("gaus");

By default, Root look for named objects in the current directory
and in the current pad/canvas

Rene Brun


Alexey Toptygin wrote:
> 
> Here's what I'm doing:
> 
> {
> ...
> TFile file("ntuple.root");
> TCanvas *can = new TCanvas("filename", "Histogram");
> bgoadc.Draw("a0","lay==0"); //bgoadc is a TNtuple in ntiple.root
> ...
> TH1F::htemp->Fit("gaus"); //kludge
> ...
> can->Print();
> ...
> }
> 
> Now, the line using TH1F::htemp is a kludge. I shoid really be using a
> pointer to htemp in *can, but I don't know how to get one.
> Any suggestions?
>                                 Alexey



This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:43:44 MET