Hi
I’m trying to fit two gaussians to my dataset in pyROOT but I’m facing some problems… The code I’m using right now is as follows:
func_1 = TF1(‘func_1’, ‘[0]*TMath::Gaus(x,[1],[2])’, np.min(x), 567)
func_1.SetParameters(-500,557,0.09)
fit_1 = g1.Fit(‘func_1’, ‘SR’)
graphs.append(fit_1)
fit_1.Draw(“L” “Same”)
ROOT.SetOwnership(fit_1, False)
func_2 = TF1(‘func_2’, ‘[0]*TMath::Gaus(x,[1],[2])’, 565, np.max(x))
func_2.SetParameters(-580,570,0.1)
fit_2 = g1.Fit(‘func_2’, ‘SR’)
graphs.append(fit_2)
fit_2.Draw(“L” “Same”)
The main problem is that I never see a fit for the first peak and sometimes it also doesn’t preform a fit on the second peak (they are both negative fyi). I first tried to use 1 function for the complete data set which was a sum of two gaussians, but this didn’t do the thing I wanted either. As you can see I’m now trying to fit the two peaks separatly by giving them their own range… anybody any ideas?