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

**URL:** <https://root-forum.cern.ch/t/tfractionfitter-how-can-i-print-status-and-edm-want-to-save-them-in-arrays/43612>\
**Category:** Newbie\
**Created:** [February 19, 2021, 11:55am UTC](https://root-forum.cern.ch/t/tfractionfitter-how-can-i-print-status-and-edm-want-to-save-them-in-arrays/43612 "2021-02-19T11:55:50Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ahmedabdelmotteleb](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/a/d2c977/32.png) [@ahmedabdelmotteleb](https://root-forum.cern.ch/u/ahmedabdelmotteleb)\
**Post date:** [February 19, 2021, 11:55am UTC](https://root-forum.cern.ch/t/tfractionfitter-how-can-i-print-status-and-edm-want-to-save-them-in-arrays/43612/1 "2021-02-19T11:55:50Z")

</div>

Hi. I’m using TFractionFitter on PyROOT.

This is the relevant part of my code:

```python

        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!

---

<div class="post-metadata">

**Author:** ![couet](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/couet/32/12037_2.png) [@couet](https://root-forum.cern.ch/u/couet)\
**Post date:** [February 23, 2021, 12:55pm UTC](https://root-forum.cern.ch/t/tfractionfitter-how-can-i-print-status-and-edm-want-to-save-them-in-arrays/43612/2 "2021-02-23T12:55:39Z")

</div>

The list of all getters is given [here](https://root.cern/doc/master/classTFractionFitter.html)

---

<div class="post-metadata">

**Author:** ![ahmedabdelmotteleb](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/a/d2c977/32.png) [@ahmedabdelmotteleb](https://root-forum.cern.ch/u/ahmedabdelmotteleb)\
**Post date:** [February 23, 2021, 2:22pm UTC](https://root-forum.cern.ch/t/tfractionfitter-how-can-i-print-status-and-edm-want-to-save-them-in-arrays/43612/3 "2021-02-23T14:22:58Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![couet](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/couet/32/12037_2.png) [@couet](https://root-forum.cern.ch/u/couet)\
**Post date:** [February 23, 2021, 3:06pm UTC](https://root-forum.cern.ch/t/tfractionfitter-how-can-i-print-status-and-edm-want-to-save-them-in-arrays/43612/4 "2021-02-23T15:06:46Z")

</div>

> [@ahmedabdelmotteleb](#):
>
> Does that mean that there is no way to automatically get the EDM and fit status

I guess @moneta has the answer.

---

<div class="post-metadata">

**Author:** ![moneta](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/moneta/32/19423_2.png) [@moneta](https://root-forum.cern.ch/u/moneta)\
**Post date:** [February 23, 2021, 5:45pm UTC](https://root-forum.cern.ch/t/tfractionfitter-how-can-i-print-status-and-edm-want-to-save-them-in-arrays/43612/5 "2021-02-23T17:45:54Z")

</div>

All the fit information is in the `ROOT::Fit::Result` class. See [ROOT: ROOT::Fit::FitResult Class Reference](https://root.cern.ch/doc/v606/classROOT_1_1Fit_1_1FitResult.html).  
It can be obtained using option ‘S’ when fitting. You should be able to do:

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

```

Lorenzo
