Re: [ROOT] Performance issue in GraphFitChiSquare

From: Rene Brun (Rene.Brun@cern.ch)
Date: Thu May 15 2003 - 16:24:34 MEST


Hi Matt,

I agree with your proposed patch. Now in CVS.
Thanks for the suggestion.

Rene Brun

Matt Palmer wrote:
> 
> Hi,
> I'm trying to optimize some of my fitting code and I noticed the
> following issue with the function GraphFitChiSquare in graf/src/TGraph.cxx:
> 
> The code is:
> 
>        if (ex < 0) ex = 0;
>        if (ey < 0) ey = 0;
>        if (ex >= 0) {
>          xm = x[0] - ex; if (xm < fxmin) xm = fxmin;
>          xp = x[0] + ex; if (xp > fxmax) xp = fxmax;
>          xx[0] = xm; fm = grF1->EvalPar(xx,u);
>          xx[0] = xp; fp = grF1->EvalPar(xx,u);
>          eux = 0.5*(fp-fm);
>        } else
>          eux = 0.;
> 
> ex, ey hold the error on the current point.
> The test on the third line above is unnecessary given the previous 2
> lines, however, I think that test should be changed to:
>         if (ex > 0) {
> 
> This would mean only 1 evaluation of TF1::EvalPar rather than 3 when
> fitting TGraphs (rather than TGraphErrors) or when the errors are 0.
> (And would thus give a factor of 3 performance increase in this case).
> 
> Thanks
> Matt



This archive was generated by hypermail 2b29 : Thu Jan 01 2004 - 17:50:11 MET