Re: Fitting problem

From: Lorenzo Moneta <Lorenzo.Moneta_at_cern.ch>
Date: Fri, 22 Jan 2010 16:14:36 +0100


Hello Parada,

 Thank you for sending me your code example. In your code you need to verify first if the fit was completed successfully. If this is not the case the covariance matrix is not available. (I need to add also a protection in the code to avoid the crash).

You can do that by doing:

int iret = gr->Fit("f1");
if (iret == 0) {

        // get covariance matrix
}

Note also that the fit did not converge because it exceeded the call limit. You can increase it by doing TVirtualFitter::SetMaxIterations( maxcalls ) and you can use for example maxcalls = 10000

Note also that If you are using ROOT version 5.26 you can also get the covariance matrix as following:

  TFitResultPtr r = gr->Fit("f1","S");
   if ( int(r) == 0) {
    TMatrixTSym<double> matrix = r->GetCovarianceMatrix();     matrix.Print();
  }

 Best Regards

 Lorenzo  

On Jan 21, 2010, at 2:25 PM, Jiri Kvita wrote:

> Hello, Lorenzo!
> 
> Could you provide the full .C macro as attach so that one could run it and try to reproduce your problem?
> 
> Still, one would simply guess that nOrder should be equal to the number of fit parameters, did you make sure? If the error matrix is 5x5 (which implies 5 fit params), why would you go for 9?
> 
> Jiri
> 
> On 01/21/2010 02:12 PM, Glasgow wrote:

>> Hi All,
>>
>> Sorry I think there is no problem with the fit. The problem came up when
>> I try to get matrix determinant using TVirtualfitter. You can see my
>> macro below :
>>
>> TVirtualFitter *fit = TVirtualFitter::GetFitter();
>> TMatrixT<double>matrix(nOrder,nOrder);
>> for (int lines=0 ; lines<nOrder ; lines++ ) {
>> for (int coulomn=0 ; coulomn<nOrder ; coulomn++ ) {
>> matrix(lines,coulomn)=
>> fit->GetCovarianceMatrixElement(lines,coulomn);
>> }
>> }
>> matrix.Print();
>>
>> When I set the nOrder=5, it works but when I set the nOrder=9, the error
>> message which I posted in my previous email emerged.Does anyone guide me
>> to the right way?
>>
>> Regards,
>> Parada
>>
>>
>>
>>
>>
>>
>> On Thu, 2010-01-21 at 11:01 +0000, Glasgow wrote:
>>> Dear All,
>>> 
>>> I had a problem when I do a fitting. You can see the error message
>>> below. Could you or anyone help me to solve the problem?
>>> -------------------------------------------------------------
>>> 5x5 matrix is as follows
>>> 
>>>      |      0    |      1    |      2    |      3    |      4    |
>>> ----------------------------------------------------------------------
>>>    0 |   0.004898     -0.0332  -1.629e-05    -0.01088    -0.01906
>>>    1 |    -0.0332      0.2847   7.292e-05       0.124      0.1669
>>>    2 | -1.629e-05   7.292e-05   2.257e-07   5.117e-05  -2.766e-05
>>>    3 |   -0.01088       0.124   5.117e-05      0.1021     0.04538
>>>    4 |   -0.01906      0.1669  -2.766e-05     0.04538      0.1436
>>> 
>>> nOrder = 5	Chisquared = 1.28133
>>> p0 = 2.15045
>>> 5	1.28133	0.526941	1.18024e-09
>>> 5
>>> 1.28133
>>> 0.526941
>>> 1.18024e-09
>>> Warning in<Fit>: Abnormal termination of minimization.
>>>  FCN=1.2813 FROM MIGRAD    STATUS=CALL LIMIT   1792 CALLS        1793
>>> TOTAL
>>>                      EDM=1.41512e-05    STRATEGY= 1  ERROR MATRIX
>>> UNCERTAINTY  24.0 per cent
>>>   EXT PARAMETER                APPROXIMATE        STEP         FIRST
>>>   NO.   NAME      VALUE            ERROR          SIZE      DERIVATIVE
>>>    1  p0           2.04980e+00   1.36174e+00   1.41786e-04   8.31491e-02
>>>    2  p1          -8.61968e+00   1.08995e+01  -1.20473e-03  -5.29401e-02
>>>    3  p2           9.41483e+00   1.89758e+01   2.17245e-03  -2.73666e-02
>>>    4  p3          -5.98405e+00   5.45302e+00  -4.53394e-04   1.05655e-01
>>>    5  p4           2.49567e+00   2.91305e+00   2.10207e-04   1.55638e-01
>>>    6  p5           1.11878e-01   1.37352e+00   2.68535e-05  -4.89362e-02
>>> Warning in<TBackCompFitter::GetCovarianceMatrix>: Invalid fit result
>>> 
>>>  *** Break *** segmentation violation
>>> (no debugging symbols found)
>>> Attaching to program: /proc/4155/exe, process 4155
>>> (no debugging symbols found)...done.
>>> (no debugging symbols found)...done.
>>> [Thread debugging using libthread_db enabled]
>>> [New Thread 0xb76de6d0 (LWP 4155)]
>>> (no debugging symbols found)...done.
>>> (no debugging symbols found)...done.
>>> (no debugging symbols found)...done.
>>> (no debugging symbols found)...done.
>>> (no debugging symbols found)...done.
>>> (no debugging symbols found)...done.
>>> (no debugging symbols found)...done.
>>> (no debugging symbols found)...done.
>>> (no debugging symbols found)...done.
>>> (no debugging symbols found)...done.
>>> (no debugging symbols found)...done.
>>> (no debugging symbols found)...done.
>>> (no debugging symbols found)...done.
>>> (no debugging symbols found)...done.
>>> (no debugging symbols found)
>>> 0x0063e416 in __kernel_vsyscall ()
>>> Missing separate debuginfos, use: debuginfo-install
>>> expat-2.0.1-8.fc10.i386 fontconfig-2.6.0-3.fc10.i386
>>> freetype-2.3.7-3.fc10.i386 glibc-2.9-3.i686 gsl-1.11-4.fc10.i386
>>> libX11-1.1.5-4.fc10.i386 libXau-1.0.4-1.fc10.i386
>>> libXcursor-1.1.9-3.fc10.i386 libXdmcp-1.0.2-6.fc10.i386
>>> libXext-1.0.4-1.fc9.i386 libXfixes-4.0.3-4.fc10.i386
>>> libXft-2.1.13-1.fc10.i386 libXpm-3.5.7-4.fc9.i386
>>> libXrender-0.9.4-3.fc9.i386 libgcc-4.3.2-7.i386 libjpeg-6b-43.fc10.i386
>>> libpng-1.2.37-1.fc10.i386 libstdc++-4.3.2-7.i386
>>> libtiff-3.8.2-14.fc10.i386 libxcb-1.1.91-8.fc10.i386
>>> zlib-1.2.3-18.fc9.i386
>>> #1  0x003cdf53 in __waitpid_nocancel () from /lib/libc.so.6
>>> #2  0x0036833b in do_system () from /lib/libc.so.6
>>> #3  0x0032359d in system () from /lib/libpthread.so.0
>>> #4  0x008bf17d in TUnixSystem::Exec ()
>>> from /usr/local/root/lib/libCore.so
>>> #5  0x008c456b in TUnixSystem::StackTrace ()
>>> from /usr/local/root/lib/libCore.so
>>> #6  0x008c530d in TUnixSystem::DispatchSignals ()
>>> from /usr/local/root/lib/libCore.so
>>> #7  0x008c540d in SigHandler () from /usr/local/root/lib/libCore.so
>>> #8  0x008bbd12 in sighandler () from /usr/local/root/lib/libCore.so
>>> #9<signal handler called>
>>> #10 0x05e7e4f4 in TBackCompFitter::GetCovarianceMatrixElement ()
>>> from /usr/local/root/lib/libHist.so
>>> #11 0x00212ca5 in G__G__MathCore_117_0_11 ()
>>> from /usr/local/root/lib/libMathCore.so
>>> #12 0x00e2dd56 in Cint::G__ExceptionWrapper ()
>>> from /usr/local/root/lib/libCint.so
>>> #13 0x00e41187 in G__exec_asm () from /usr/local/root/lib/libCint.so
>>> #14 0x00f16546 in G__exec_loop () from /usr/local/root/lib/libCint.so
>>> #15 0x00f14dd6 in G__exec_statement ()
>>> from /usr/local/root/lib/libCint.so
>>> #16 0x00f15eef in G__exec_loop () from /usr/local/root/lib/libCint.so
>>> #17 0x00f14dd6 in G__exec_statement ()
>>> from /usr/local/root/lib/libCint.so
>>> #18 0x00ebc7ad in G__interpret_func ()
>>> from /usr/local/root/lib/libCint.so
>>> #19 0x00eaa747 in G__getfunction () from /usr/local/root/lib/libCint.so
>>> #20 0x00e7cf98 in G__getitem () from /usr/local/root/lib/libCint.so
>>> #21 0x00e82ac3 in G__getexpr () from /usr/local/root/lib/libCint.so
>>> #22 0x00e90b78 in G__calc_internal ()
>>> from /usr/local/root/lib/libCint.so
>>> #23 0x00f1db02 in G__process_cmd () from /usr/local/root/lib/libCint.so
>>> #24 0x008ae674 in TCint::ProcessLine ()
>>> from /usr/local/root/lib/libCore.so
>>> #25 0x008aad3f in TCint::ProcessLineSynch ()
>>> from /usr/local/root/lib/libCore.so
>>> #26 0x007d3f9e in TApplication::ExecuteFile ()
>>> from /usr/local/root/lib/libCore.so
>>> #27 0x007d42b4 in TApplication::ProcessFile ()
>>> from /usr/local/root/lib/libCore.so
>>> #28 0x007d2903 in TApplication::ProcessLine ()
>>> from /usr/local/root/lib/libCore.so
>>> #29 0x002c59de in TRint::HandleTermInput ()
>>> from /usr/local/root/lib/libRint.so
>>> #30 0x002c5495 in TTermInputHandler::Notify ()
>>> from /usr/local/root/lib/libRint.so
>>> #31 0x002c7c34 in TTermInputHandler::ReadNotify ()
>>> from /usr/local/root/lib/libRint.so
>>> #32 0x008c26f9 in TUnixSystem::CheckDescriptors ()
>>> from /usr/local/root/lib/libCore.so
>>> #33 0x008c2a59 in TUnixSystem::DispatchOneEvent ()
>>> from /usr/local/root/lib/libCore.so
>>> #34 0x00835ae1 in TSystem::InnerLoop ()
>>> from /usr/local/root/lib/libCore.so
>>> #35 0x0083887b in TSystem::Run () from /usr/local/root/lib/libCore.so
>>> #36 0x007d0507 in TApplication::Run ()
>>> from /usr/local/root/lib/libCore.so
>>> #37 0x002c7714 in TRint::Run () from /usr/local/root/lib/libRint.so
>>> #38 0x08048d75 in main ()
>>> The program is running.  Quit anyway (and detach it)? (y or n) [answered
>>> Y; input not from terminal]
>>> Detaching from program: /proc/4155/exe, process 4155
>>> Root>  Function posterior2() busy flag cleared
>>> 
>>> Thank for your help.
>>> 
>>> Regards,
>>> Parada
>>> 
>>> 

>>
> 
> -- 
> ------------------------------------------------------------------------
> Office   : 40-3D-06, Tel. (+41 2276) 73436, Cell +41 76 239 5696
> ------------------------------------------------------------------------
>     Jiri.Kvita@cern.ch, A1 Rh+,  http://www.matfyz.cz/qitek
>   Charles University, Prague, Faculty of Mathematics and Physics
>  Institute of Particle and Nuclear Physics, Czech Republic / CERN
> ------------------------------------------------------------------------
> 
Received on Fri Jan 22 2010 - 16:14:45 CET

This archive was generated by hypermail 2.2.0 : Sun Jan 24 2010 - 05:50:02 CET