GetFunction returns null after Fit converges

ROOT Version: 6.26/06
Platform: Scientific Linux 7.3 (Nitrogen)
Compiler: g++ (GCC) 12.1.0

Hi ROOTers, I have what I think is a real head-scratcher. I have the following lines in a compiled file:

hcalout_eta[i]->Fit("myexpo", "N", "", fitmin, fitmax);
std::cout << hcalout_eta[i]->GetFunction("myexpo") << std::endl;
f2f = (TF1 *) hcalout_eta[i]->GetFunction("myexpo");
std::cout << f2f << std::endl;

Where myexpo is a user defined function.

The output is:

 FCN=921.949 FROM MIGRAD    STATUS=CONVERGED      67 CALLS          68 TOTAL
                     EDM=2.66807e-09    STRATEGY= 1      ERROR MATRIX ACCURATE 
  EXT PARAMETER                                   STEP         FIRST   
  NO.   NAME      VALUE            ERROR          SIZE      DERIVATIVE 
   1  p0           2.99920e-01   4.98635e-04   5.44379e-06   1.92797e-01
   2  p1           1.06291e+00   7.12072e-04   7.77442e-06  -6.58834e-02
0
0

Where the two 0s are from printint out the return value of GetFunction. Later, I call GetParameter on f2f, and the code segfaults.

This doesn’t make any sense to me - the fit converges, and in the very next line I try to access the result of the fit, but it doesn’t seem to work - I just get back a null pointer. Why would this happen? Am I missing something obvious? Thanks!

A quick update: removing the "N" option resolves this issue. I thought N was there to ignore saving graphics, but maybe I don’t understand what it actually does. Can anyone explain?

Hi,

Thanks for the post and for also sharing the solution. The “N” option is described as follows Does not store the graphics function, does not draw the histogram with the function after fitting. ( see here)

If the function is not stored, it cannot be retrieved.

Cheers,
D

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