TF1 linear fit (pol1): Fitted line is not smooth

Hi all, I’m trying to perform a linear fit over a selected region in my plot. The macro is running successfully and giving desirable output;
used something like this to FIT:

TF1 *fit2 = new TF1("fit2", "pol1");
hist2->Fit("fit2","","",0.036,0.041);

However, the fitted line in the plot is not smooth instead it’s some sort of step line chart. Wanna know what is the reason for this and how to make it a smooth straight line? Attached is the plot for the same in case you wanna look at the fit.

Thanks!!

Try to increase the number of points using TF1::SetNpx().

Add after the fit2 declaration the line

fit2->SetNpx(500);

Stefano

1 Like