Tfractionfitter how can I print status and EDM? (want to save them in arrays)

Hi. I’m using TFractionFitter on PyROOT.

This is the relevant part of my code:


        list_of_histos = ROOT.TObjArray()
        list_of_histos.Add(mc_hist) #param 1
        list_of_histos.Add(bkg_hist) #param 2
        fit = ROOT.TFractionFitter(data_hist, list_of_histos)
        fit.Fit()

        fit_plot = fit.GetPlot()

        signal_fit_fraction = ROOT.Double(0)
        signal_fit_fraction_error = ROOT.Double(0)
        bkg_fit_fraction = ROOT.Double(0)
        bkg_fit_fraction_error = ROOT.Double(0)

        fit.GetResult(0,signal_fit_fraction,signal_fit_fraction_error)
        fit.GetResult(1,bkg_fit_fraction,bkg_fit_fraction_error)


        print('********************************************')
        print(signal_fit_fraction,signal_fit_fraction_error)
        print(bkg_fit_fraction,bkg_fit_fraction_error)
        print('********************************************')

As you can see, I’m able to extract the fitting fractions and their errors using the “GetResult” function. Is there another way to extract the status of the fit (converged or failed) as well as the EDM value (Expected Distance from Minimum)? When I run my script, it gets printed on my terminal but I want to save the values automatically to be able to flag when the fitter fails, for example.

Thanks!

The list of all getters is given here

1 Like

Thank you for your reply. I checked out the documentation but I still cannot find what I’m looking for. Does that mean that there is no way to automatically get the EDM and fit status, or did I miss something?

I guess @moneta has the answer.

All the fit information is in the ROOT::Fit::Result class. See ROOT: ROOT::Fit::FitResult Class Reference.
It can be obtained using option ‘S’ when fitting. You should be able to do:

result = fit.Fit("S")
edm = result.Edm()

Lorenzo

1 Like