TGraphErrors problem in TMinuit in pyROOT

Hi everyone,

I have a pyROOT code fitting a 2D plot. I want to add uncertainty along y-axis to every data point. When I add the line for errors, TMinuit stops giving me the parts “Covariance Matrix”, “Correlation Matrix” and most importantly “Minimizer is Minuit / MigradImproved” – which shows the Chi2 as well-- at the end of the output. This happens even if the fit has a successful status. Some portion of the code is below.

Cheers,
M

        opt.SetDefaultMinimizer("Minuit2"); # I don't see MigradImproved option in TMinuit2 in the manuel but it works somehow when I don't add the line marked below
        opt.SetPrintLevel(3);
        opt.SetMinimizerAlgorithm("Simplex");

...
        d = ROOT.TCanvas("d","d",800,800)
        d.SetLeftMargin(0.2) #was 0.12
        periodData = 25e-9*s_to_ns
        gr_data = ROOT.TGraphErrors(len(data))
        pedestal = 0
        for x,y in enumerate(data):
                if x == 0: pedestal = y
                gr_data.SetPoint(x,x*periodData,y)
                gr_data.SetPointError(x,0,y_err) #<------ this is the part that I am talking
        gr_data.Draw("AP")
...

        fitfunction = ROOT.TF1("myFunction",myFunction,0,1500,5)
	fitfunction.SetParName(0,'rise')
	fitfunction.SetParName(1,'width')
	fitfunction.SetParName(2,'amplitude')
	fitfunction.SetParName(3,'start')
	fitfunction.SetParName(4,'pedestal')

	fitfunction.SetParLimits(0,50,600)
	fitfunction.SetParLimits(1,100,800)
	fitfunction.SetParLimits(2,4000,100000)
	fitfunction.SetParameter(4,pedestal)

        gr_data.Fit('myFunction', 'RSEMVN') 
...

I actually have this for my parameters. I have updated the code above by adding those line. The code is long so I am trying to minimize it here.
Thanks

How about:

(gr_data.Fit('myFunction', 'RSEMN')).Print('V')
1 Like

Yes, that worked. However, it closes the detailed output which was working before. So I tried

(gr_data.Fit(‘myFunction’, ‘RSEMVN’)).Print(‘V’)

and that also worked perfectly.

Thank you!

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