Reiterating TGraphError fitting with PyROOT

Hello, I was given some code in PyROOT that, after filling a TGraphError with data and creating a TF1 function named ff, does this:

for j in range(5):
    fit = graph.Fit("ff","SQ")
    if fit.CovMatrixStatus()==3 and fit.Chi2()/fit.Ndf() < 2: break

Which seems redundant to me, unless ROOT saves something (new starting values for parameters, eg) in the function or the graph, but I see no reason for that to happen, and furthermore - looking at minuit output, it doesn’t seem to affect fit parameter values or errors, it only changes the first derivative and the EDM values:

 FCN=32.4185 FROM MIGRAD    STATUS=CONVERGED      83 CALLS          84 TOTAL
                     EDM=1.18671e-08    STRATEGY= 1      ERROR MATRIX ACCURATE 
  EXT PARAMETER                                   STEP         FIRST   
  NO.   NAME      VALUE            ERROR          SIZE      DERIVATIVE 
   1  #Sigma       2.18672e-02   2.50746e-05   4.90368e-08   4.99878e+00
   2  Mean        -4.20064e-04   3.10162e-05   7.46396e-08  -2.12784e+00
   3  peak         1.30361e-01   2.23531e-04   4.59588e-07   9.35870e-01
 FCN=32.4185 FROM MIGRAD    STATUS=CONVERGED      36 CALLS          37 TOTAL
                     EDM=2.90524e-09    STRATEGY= 1      ERROR MATRIX ACCURATE 
  EXT PARAMETER                                   STEP         FIRST   
  NO.   NAME      VALUE            ERROR          SIZE      DERIVATIVE 
   1  #Sigma       2.18672e-02   2.50746e-05   4.90358e-08  -1.66095e+00
   2  Mean        -4.20063e-04   3.10162e-05   7.46378e-08   1.18549e+00
   3  peak         1.30361e-01   2.23530e-04   4.59590e-07   1.72107e-01
 FCN=32.4185 FROM MIGRAD    STATUS=CONVERGED      36 CALLS          37 TOTAL
                     EDM=8.87068e-10    STRATEGY= 1      ERROR MATRIX ACCURATE 
  EXT PARAMETER                                   STEP         FIRST   
  NO.   NAME      VALUE            ERROR          SIZE      DERIVATIVE 
   1  #Sigma       2.18672e-02   2.50746e-05   4.90358e-08   6.51478e-01
   2  Mean        -4.20064e-04   3.10162e-05   7.46378e-08  -8.18195e-01
   3  peak         1.30361e-01   2.23531e-04   4.59590e-07   2.19542e-01
 FCN=32.4185 FROM MIGRAD    STATUS=CONVERGED      36 CALLS          37 TOTAL
                     EDM=3.60568e-10    STRATEGY= 1      ERROR MATRIX ACCURATE 
  EXT PARAMETER                                   STEP         FIRST   
  NO.   NAME      VALUE            ERROR          SIZE      DERIVATIVE 
   1  #Sigma       2.18672e-02   2.50746e-05   4.90358e-08  -8.56438e-01
   2  Mean        -4.20064e-04   3.10162e-05   7.46378e-08   8.93334e-02
   3  peak         1.30361e-01   2.23531e-04   4.59590e-07   3.77525e-02
 FCN=32.4185 FROM MIGRAD    STATUS=CONVERGED      36 CALLS          37 TOTAL
                     EDM=1.46972e-10    STRATEGY= 1      ERROR MATRIX ACCURATE 
  EXT PARAMETER                                   STEP         FIRST   
  NO.   NAME      VALUE            ERROR          SIZE      DERIVATIVE 
   1  #Sigma       2.18672e-02   2.50746e-05   4.90358e-08   2.46610e-01
   2  Mean        -4.20064e-04   3.10162e-05   7.46378e-08  -3.56546e-01
   3  peak         1.30361e-01   2.23530e-04   4.59590e-07   8.67452e-02

I can’t find any suggestion anywhere that this reiterating of the fit makes sense, but I wonder why the original author (who’s no longer with the project) did it? And since SOMETHING changes, I guess under certain conditions (which I am yet to find) it might affect fit parameters too… Any help with this would be appreciated

The fit function identified with ‘ff’ retains state from the fit result. Get a hold of it with gROOT.FindObject(“ff”) and check the output of its GetParameters().

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