Re: [ROOT] FPE in TMinuit

From: Rene Brun (Rene.Brun@cern.ch)
Date: Tue Jul 29 2003 - 15:51:50 MEST


Hi Jeff,

Thanks for reporting this interesting rare case.
Now protected in the CVS version.

Rene Brun

On 29 Jul 2003, Jeff 
Hartnell wrote:

> Hi,
> I have discovered that TMinuit will cause a Floating Point Exception
> (FPE) with a rare combination of numbers.
> 
> I am using root 3.05/05 on SuSE 8.2 Linux but I believe it is a generic
> problem.
> 
> In order to see this FPE you have to set the flag (sigfpe?) that causes
> a program to crash when it happens (the safest option!).
> 
> Once you have turned on FPE trapping then the macro pasted below will
> crash.
> 
> Here is the trace from gdb:
> 
> Program received signal SIGFPE, Arithmetic exception.
> [Switching to Thread 16384 (LWP 22186)]
> 0x428cdbb4 in TMinuit::mnmigr() () from
> /usr/local/root_3_05_05/root/lib/libMinuit.so
> (gdb) up
> #1  0x428c5c44 in TMinuit::mnexcm(char const*, double*, int, int&) ()
>    from /usr/local/root_3_05_05/root/lib/libMinuit.so
> (gdb) up
> #2  0x428bc5cf in TFitter::ExecuteCommand(char const*, double*, int) ()
>    from /usr/local/root_3_05_05/root/lib/libMinuit.so
> (gdb)
> #3  0x41cb8f94 in TGraph::Fit(TF1*, char const*, char const*, double,
> double) ()
>    from /usr/local/root_3_05_05/root/lib/libGraf.so
> (gdb)
> 
> Hope you can fix it!
> 
> Thanks,
> Jeff.
> 
> Here is the macro:
> {
> 
> //there are two steps to this
> //1.) slightly modify the values used to make fit not fpe
> //2.) use the values that cause the fpe
> 
>   float oddplanes[30] = {0};  
>   float oddstrips[30] = {0};
>   int oddcnt = 0;
> 
>   //set up a particular senario
>   oddcnt=4;
>   oddplanes[0]=15;
>   oddplanes[1]=17;
>   oddplanes[2]=19;
>   oddplanes[3]=21;
> 
>   oddstrips[0]=1;
>   oddstrips[1]=3;
>   oddstrips[2]=6;
>   oddstrips[3]=9;
> 
>   TF1* form=new TF1("form","pol1",0,60);
> 
>   for (Int_t i=0;i<oddcnt;i++){
>     cout<<"oddcnt="<<oddcnt
> 	<<", plane="<<oddplanes[i]
> 	<<", strip="<<oddstrips[i]<<endl;
> 
>     //hack to make it work
>     oddplanes[i]+=0.00001;
>     oddstrips[i]+=0.00001;
>     cout<<"After hack: oddcnt="<<oddcnt
> 	<<", plane="<<oddplanes[i]
> 	<<", strip="<<oddstrips[i]<<endl; 
>   }
>   TGraph* oddgr=new TGraph(oddcnt,oddplanes,oddstrips);
>   cout<<"Created graph"<<endl;
>   oddgr->Fit(form);  
>   cout<<"Fitted graph"<<endl<<endl;
> 
>   //set up the particular senario again
>   oddcnt=4;
>   oddplanes[0]=15;
>   oddplanes[1]=17;
>   oddplanes[2]=19;
>   oddplanes[3]=21;
> 
>   oddstrips[0]=1;
>   oddstrips[1]=3;
>   oddstrips[2]=6;
>   oddstrips[3]=9;
> 
>   for (Int_t i=0;i<oddcnt;i++){
>     cout<<"oddcnt="<<oddcnt
> 	<<", plane="<<oddplanes[i]
> 	<<", strip="<<oddstrips[i]<<endl;
>     //oddplanes[i]+=0.0001;
>     //oddstrips[i]+=0.0001;
>     cout<<"oddcnt="<<oddcnt
> 	<<", plane="<<oddplanes[i]
> 	<<", strip="<<oddstrips[i]<<endl; 
>   }
> 
>   TGraph* oddgr=new TGraph(oddcnt,oddplanes,oddstrips);
>   cout<<"Created graph"<<endl;
> 
>   cout<<"I will FPE here..."<<endl;
> 
>   oddgr->Fit(form);  
>   cout<<"Fitted graph"<<endl;
> 
>   cout<<"Finished macro"<<endl;
> }
> 
> 



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