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,
This archive was generated by hypermail 2.2.0 : Mon Nov 22 2010 - 17:50:01 CET