Hello,
You did not sent a running macro showing the problem so I can only guess what could be wrong.
It could be the following: histograms are not drawn from Min to Max of their content. There
is a margin on top, added to the maximum. It could be that this margin provokes the difference
in Z. To suppress it do: gStyle->SetHistTopMargin(0);
Cheers,
O.Couet
-----Original Message-----
From: owner-roottalk_at_root.cern.ch [mailto:owner-roottalk_at_root.cern.ch] On Behalf Of nguler_at_jlab.org
Sent: Wednesday, November 17, 2010 1:08 AM
To: roottalk (Mailing list discussing all aspects of the ROOT system.)
Subject: [ROOT] TF2 SetRange
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 : Tue Nov 23 2010 - 11:50:01 CET