Re: Fit problem

From: Vassili Maroussov <Vassili.Maroussov_at_cern.ch>
Date: Wed, 06 Sep 2006 05:37:26 +0200


Dear Rene,

does it mean fit1->SetParLimits(2,0.1,100) does not prevent the parameter 2 from going down to zero?

Regards,

Vassili.

Rene Brun wrote:
> You must protect your function shift_Poiss against division by 0.
>
> Rene Brun
>
>
> Vassili Maroussov wrote:
>> Dear ROOTers,
>>
>> for some reason fitting macros which were perfectly working with
>> ROOT4.03 do not work with ROOT5.11 When I execute a short sample
>> macro test_fit_0.C I get the 2 long series of error messages:
>>
>> ----------------------------------------------------------------------
>> [pcmspur5] ~/Preselection > root -l
>>
>> Welcome to the ROOT tutorials
>>
>>
>> Type ".x demos.C" to get a toolbar from which to execute the demos
>>
>> Type ".x demoshelp.C" to see the help window
>>
>> ==> Many tutorials use the file hsimple.root produced by hsimple.C
>> ==> It is recommended to execute hsimple.C before any other script
>>
>> root [0] .x test_fit_0.C
>> Error: operator '/' divided by zero test_fit_0.C:3:
>> Error: operator '/' divided by zero test_fit_0.C:3:
>> Error: operator '/' divided by zero test_fit_0.C:3:
>>
>> ****
>>
>> Error: G__CallFunc::SetArgArray() must be initialized with
>> 'G__CallFunc::SetFunc(G__ClassInfo* cls,char* fname,char* args,long*
>> poffset)' first
>> Error: G__CallFunc::SetArgArray() must be initialized with
>> 'G__CallFunc::SetFunc(G__ClassInfo* cls,char* fname,char* args,long*
>> poffset)' first
>> Error: G__CallFunc::SetArgArray() must be initialized with
>> 'G__CallFunc::SetFunc(G__ClassInfo* cls,char* fname,char* args,long*
>> poffset)' first
>>
>> ****
>> .q
>>
>> This is the end of ROOT -- Goodbye
>>
>> [pcmspur5] ~/Preselection >
>> ----------------------------------------------------------------------
>>
>> What is wrong with the macro?
>>
>> Regards,
>>
>> Vassili.
>>
>>
>> ------------------------------------------------------------------------
>>
>> Double_t shift_Poiss(Double_t *x, Double_t *par)
>> {
>> Double_t var = x[0]/par[2] - par[1];
>> return par[0] * TMath::Exp(var *
>> TMath::Log(par[3])-par[3])/TMath::Gamma(var+1.0);
>> }
>>
>> void test_fit_0()
>> {
>> TFile *f = new TFile("Test_Fit.root", "READ");
>> TCanvas *c1 = new TCanvas("c1","Multiplicity distribution");
>> TH1F *h1f_ntrk_S = (TH1F*)f->Get("h1f_ntrk_S");
>>
>> // Creates a ROOT function TF1 to fit
>> TF1 *fit1 = new TF1("fit1",shift_Poiss,6,60,4);
>>
>> // Sets initial values, limits and parameter names
>> fit1->SetParameters(300000,0,1.5,5);
>>
>> fit1->SetParLimits(0,1,100000000);
>> fit1->SetParLimits(1,0,100);
>> fit1->SetParLimits(2,0.1,100);
>> fit1->SetParLimits(3,1,100);
>>
>> fit1->SetParNames("Ampl","Shift","Scale","Mean");
>>
>> // Fit histogram in range defined by function
>> h1f_ntrk_S->Fit("fit1","r");
>> }
>>
>
Received on Wed Sep 06 2006 - 05:37:34 MEST

This archive was generated by hypermail 2.2.0 : Mon Jan 01 2007 - 16:32:00 MET