Area under a fit

Hi all,
I have a gaussian peak in the range 79 GeV-101 GeV and I want to calculate the area under this peak. But th eanswer I am getting is zero. I want to do the same for a polynomial fit of order 2 in this same range.

TF1 *fit1 = new TF1(“nfit1”,“gaus(0)”,79,101);
hist1->Fit(“nfit1”,“R”);
fit1->Integral(159,203);//bin no 159 corresponds to 79 GeV and 203 corresponds to 101 GeV

What is wrong here?

hist1->Integral(159,203)
fit1->Integral(79,101)

Hey Thanks,
I have a question, Aren’t bin numbers the arguments in the Integral function ? Then why is it written fit1->Integral(79,101)??

No, the bin numbers are for TH1::Integral. There are no real bins in TF1 so the arguments of TH1::Integral are the real x values.
See https://root.cern.ch/doc/master/classTF1.html#a596e02742b00f1e265cc2dbe4daf20fe

Lorenzo

Thanks a lot. It helps!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.