Re: TF2 SetRange

From: John Idarraga <idarraga_at_cern.ch>
Date: Mon, 22 Nov 2010 14:17:26 +0100


Hello Nevzat,

Instead of defining your TF2 objects in that range. Do a broader range in the TF2 constructor and limit your fit when doing the Fit call. Use this member instead

TFitResultPtr Fit(const char* formula, Option_t* option = "", Option_t* goption = "", Double_t xmin = 0, Double_t xmax = 0)

cheers,

John Idarraga

nguler_at_jlab.org wrote:
> Hello All,
> I have 2D histograms with various peaks in each. I perform a gaussian fit on
> the peaks. For the fit to be successful, I have to set x,y ranges around the
> peaks while defining my TF2 object. Therefore, the range of my TF2 is
> different than the range of my TH2F. This becomes problem later when I plot
> the histogram and the fit results together on the same canvas. So, I rescale
> the histogram by using SetRange. To be more clear, I define TH2F:
> TH2F *histsim = new TH2F(histsimName,histsimName,256,0,256,256,0,256);
> Then define TF2:
> TF2 *fitsim = new TF2("fitsim",Gaus2D,0,80,75,125,5);
> And I fit and plot:
> histsim->Fit("fitsim","RN");
> histsim->Draw("surf4");
> fitsim->Draw("cont1, same");
> But the fitsim is plotted on a different scale and does not overlap with the
> peak anymore even if the fit is successful. So, instead I do the following:
> histsim->Fit("fitsim","RN");
> histsim->Draw("surf4");
> fitsim->SetRange(0,0,256,256); //// necessary to rescale to the histogram
> range
> fitsim->Draw("cont1, same");
> This plots the fitsim on correct x and y positions. However, the z height of
> the fit is still off-scale. How can I rescale the fit height so that it is the
> same as the peak height? I tried following:
> fitsim->SetRange(0,0,0, 256,256, fitsim->GetParameter(0));
> But it did not have any visible effect, the z range of the fit is still very
> different than the z range of the histogram.
>
> I appreciate your suggestions. Thank you,
>
> - Nevzat Guler
>
>
>
>
>
Received on Mon Nov 22 2010 - 14:21:44 CET

This archive was generated by hypermail 2.2.0 : Mon Nov 22 2010 - 23:50:01 CET