Re: Fit options in ROOT

From: Jordi Nadal Serrano <jnadal_at_ifae.es>
Date: Fri, 6 Nov 2009 12:50:13 +0100


Thanks for your answer, Lorezo! I think I will write my own chi2 function is easy to see what's the fit doing.

Cheers,

Jordi

On Nov 6, 2009, at 12:12 PM, Lorenzo Moneta wrote:

> Hi,
>
> you cannot change with a simple option the errors in the chi2
> calculations. You would need to write yourself the chi2 function and
> pass to the fit,
> using for example the option "U".
> You can however use the option "L" to perform a binned likelihood
> fit. In this case you will have the correct treatment of the bins
> statistics in particular if you have empty bins
>
> Best Regards
>
> Lorenzo
> On Nov 5, 2009, at 5:20 PM, Jordi Nadal Serrano wrote:
>
>> Hello guys,
>>
>> I am trying to fit a function to a histogram. Like this:
>>
>> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
>>
>> Double_t myfunction (Double_t *x, Double_t *par){
>> int bin = data_8175->GetXaxis()->FindBin(x[0]);
>> Double_t f = 0;
>> f= par[0] * ttbar->GetBinContent(bin) + par[1] * h_w_jets-
>> >GetBinContent(bin) + par[2] * h_others->GetBinContent(bin);
>> return f;
>>
>> }
>>
>>
>> void myfunc(){
>>
>> TF1 *f1 = new TF1("myfunc",myfunction,minBin_fit,maxBin_fit,3);
>>
>> f1->SetParLimits(0,0,2);
>> f1->SetParLimits(1,0,2);
>> f1->FixParameter(2,1);
>> f1->Draw();
>> }
>> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
>>
>> Once my histograms are filled. I do the fit this way:
>>
>> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
>> myfunc();
>> TF1 *f1= (TF1*)gROOT->GetFunction("myfunc");
>> data_8175->Fit("myfunc","ER0");
>> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
>>
>>
>> I wonder what are the errors that are entered in the chi square. I
>> believe that the errors are the sqrt( number of entries in a bin )
>>
>> Can I change these errors to be the theoretical ones, i.e, the sqrt
>> of the value of myfunction per bin .
>>
>>
>> Many thanks in advance,
>>
>> Jordi
>>
>
Received on Fri Nov 06 2009 - 12:50:20 CET

This archive was generated by hypermail 2.2.0 : Fri Nov 06 2009 - 17:50:03 CET