Restrict the fit range on x-axis

Hi all,

I have a question about fitting TH1D histograms to the user-defined function “gaus”
As I mentioned, I fit the histogram hist_am[k]->Fit(“gaus”); but now I want to restrict the fit range on the right side to 2.
Could someone please give me some advice on how to do this? Thanks.

Check out the use of the “R” option:
https://root.cern/doc/master/multifit_8C.html

1 Like

hist_am[k]->Fit("gaus", "", "", some_xmin, some_xmax);

1 Like

Thanks very much for your help!
I says however that there is no matching member function for call to 'Fit’, and I also get these mistakes :

/usr/local/Cellar/root/6.26.06_1/include/root/TH1.h:232:29: note: candidate function not viable: no known conversion from ‘Double_t’
(aka ‘double’) to ‘Option_t *’ (aka ‘const char *’) for 3rd argument
virtual TFitResultPtr Fit(const char *formula ,Option_t *option=“…
^
/usr/local/Cellar/root/6.26.06_1/include/root/TH1.h:233:29: note: candidate function not viable: no known conversion from ‘const char [5]’ to
‘TF1 *’ for 1st argument
virtual TFitResultPtr Fit(TF1 *f1 ,Option_t *option=”" ,Option_t *…

Thanks again. It all works now.