Re: [ROOT] Histogram fitting with landau

From: Rene Brun (Rene.Brun@cern.ch)
Date: Wed Sep 19 2001 - 15:27:47 MEST


Hi Bob,

Thanks for reporting this problem. Now fixed in the CVS head.

Rene Brun

On Tue, 18 Sep 2001, Bob Schaefer wrote:

> Hello,
> 
>   I seemed to find 2 problems while using root to fit histograms. 1) Funny 
> behavior in fitting sums of functions when a landau function is involved, and 
> 2) Getting the SetOptFit to display the parameters as described.
> 
>   
> 1)  I tried fitting a sum ("total") of a landau function and an exponential 
> 
>     TH1F *hist;
> 
>     // fitting functions
>     TF1 *exp1, *land, *total;
>     // fitting parameters
>     Double_t par[5];    
>     
>     land = new TF1("land", "landau(0)",20,800);
>     hist->Fit(land,"WQ0","",300,800);
>     hist->Fit(exp1,"WQ0+","",20,200);
> 
>     exp1 = new TF1("exp1","expo(0)", 20, 800);
> 
>     land->GetParameters(&par[0]);
>     exp1->GetParameters(&par[3]);
> 
>     total->SetParameters(&par[0]);
> 
>     total = new TF1("total","expo(3)+landau(0)", 20, 800);
>     hist->Fit(total,"WR");
> 
> This works fine unless I try to do the fitting with the exponential parameters 
> FIRST in the parameter list, i.e., 
> 
>     land->GetParameters(&par[2]);
>     exp1->GetParameters(&par[0]);
> 
>     total->SetParameters(&par[0]);
>     total = new TF1("total","expo(0)+landau(2)", 20, 800);
>     hist->Fit(total,"WR");
>  
> In which case the fit fails, complaining that the ERROR MATRIX IS NOT POSITIVE 
> DEFINITE.  
> 
> 
> 2) Fit parameters not being displayed 
> 
>     According to the documentation: 
>     
>     gStyle->SetOptFit(0101);
>     
>     should print the names/values of the parameters AND the Chi-squared.  It 
> does not print the chi-squared, although it does print the parameters. 
> 
>     However, if I use 
> 
>     gStyle->SetOptFit(10101);
>     
>     it prints both chi sq and the parameters?!
>     
> Thanks,
>   Bob Schaefer
> 
>     
>     
>     
> 
> Root 3.1/02 on LinuxPPC2000 running on a Mac G4 dual processor.
>    
> 
> ----------------------------------------------------------
> Robert K. Schaefer       Email: bob@milkyway.gsfc.nasa.gov
> NASA/GSFC Code 664       Phone: 301-286-0878
> Greenbelt, MD 20771      FAX:   301-286-1629
> ----------------------------------------------------------
> 



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