Help in Fiiting

Guys, I’m kind of new in ROOT and I’m trying to learn everything about it.
But there is one problem, me and me professor are trying to fit this histogram called “MuonMassInv” (in the .roo file) with a macro called Fit.C (or Fit1.C), but the problem is that we know that, for the signal, a breit wigner is the best, but for the background we have tried a lot of functions without any improvement. The problem is that if I try to fix some parameters int this function we have put into, that, until now, is the best, the error raises, even if the graph looks more “fitted”.
Does anyone have a clue about a function or some tip to help us.
Fit1.C (1.13 KB)
Fit.C (2.33 KB)
teste02.root (7.92 KB)

What do you mean by error? Are you talking about the chi^2/ndf or about the uncertainty on the yield? What the problem could be is that what you’re judging as more “fitted” corresponds to the fit function being visually closer to the points when you view it on the log plot. The problem with this is that the errors on the points above 100 or 120 are significantly larger than on the points over on the left (because there are orders of magnitude less entries in the bins on the right). They therefore contribute less significantly to constraining your fit function. It looks bad when you view it on a log plot but the chi^2 is being correctly minimized.

The issue is really that your background function doesn’t fully describe the background. You could improve the background fit a bit by increasing the lower range limit but I would really recommend experimenting with background functions and trying to improve the chi^2/ndf. If you add a few more terms in the background parameterization it will drop quite a bit.