Re: [ROOT] ROOT hangs while fitting histograms

From: Rene Brun (Rene.Brun@cern.ch)
Date: Thu Sep 27 2001 - 21:13:09 MEST


Hi Robert,

A few weeks ago, I fixed a problem in TF1 (version 3.02) when
storing a copy of the fitted function. 
Your test works with this version.
I do not see any way to circumvent the problem in 3.01.

Rene Brun

On Thu, 27 Sep 2001, Robert Feuerbach wrote:

> 
> Hi,
> 
> I'm using ROOT version 3.01/06 on a LinuxRH7.1 machine, and am having
> problems using TH1::Fit when using a user-defined function. We were able
> to create a short program that has the same problems:
> 
> /*---------------------------------------------------------*/
> #include <TF1.h>
> #include <TMath.h>
> #include <TH1.h>
> // #include <TROOT.h>     /* needed for ROOT 2.25 */
> 
> Double_t fitf(Double_t *x, Double_t *par) {
>   Double_t arg=0;
>   Double_t result=0.;
>   arg = (x[0]-par[1])/par[2];
>   result = par[0]*TMath::Exp(-0.5*arg*arg)+par[3];
>   return result;
> }
> 
> void main(int argc, char *argv[]) {
>   
>   //  TROOT root("myroot","stuff"); /* needed for ROOT 2.25 */
>   TF1 *myfunc = new TF1("myfunc",fitf,-2.,2.,4);
>   //TF1 *myfunc = new TF1("myfunc","gaus",-2.,2.); /* doesn't hang up */
>   myfunc->SetParameters(1000.,0.,.4,10.);
>   
>   TH1F *hist = new TH1F("hist1","test",100,-4.,4.);
>   hist->FillRandom("myfunc",1000);
> 
>   myfunc->SetParameters(200.,-1.,.5,100.);
>   hist->Fit("myfunc","R0");
>   //  hist->Fit("myfunc","R0N");  /* doesn't seg-fault/hang up */
> 
> }
> /*---------------------------------------------------------*/
> 
> After the actual fit is done (and the results printed to the screen), the
> program just hangs, and never exits from the hist->Fit line. If we tell
> ROOT NOT to store the function (with the 'N' option), it exits just
> fine. This works if we use a pre-defined function (such as "gaus") or
> run it under ROOT 2.25.
> 
> Would you please look into this?
> 
> Thank you,
> Rob Feuerbach
> 
> -- 
> /***************************************************
>  * Robert Feuerbach   feuerbac@ernest.phys.cmu.edu *
>  * CMU Physics Department           (412) 268-2772 *
>  * Pittsburgh, PA 15213        FAX: (412) 681-0648 *
>  ***************************************************/
> 



This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:51:00 MET