_ROOT Version: 6.20/02
_Platform: MAC OS Catalina on MacBook Air
_Compiler: version 10.15.4
I have in my code:
#include “TH1.h”
#include “TF1.h”
…
TF1 *f1 = new TF1(“f1”,"[0]exp(-0.5((x-[1])/[2])**2)",12., 14.5);
…
NewInf->Fit(“f1”,r);
and get an error:
error: use of undeclared identifier ‘r’
although in the documentation it is written on https://root.cern.ch/how-use-histograms-classes
By default,TH1::Fit will fit the function on the defined histogram range. You can specify the option " r " in the second parameter to restrict the fit to the range specified in the TF1object.
BTW f1->Draw(""); works fine
BTW in the above documentation the link to A simple fitting example and Fitting histogram sub-ranges doesn’t exist.
Thanks for telling me how can one fit a function on a histogram in a range specified in the function, and if possible, give me a working example.
Elemer