Hi Volodja,
When you implement your fit function, you must protect your function for all
possible values of the parameters. In your case, it could be that par[2] be
called with a value 0 or a value that makes your exp function infinite.
Rene Brun
babintsev@mx.ihep.su wrote:
>
> babintsev@mx.ihep.su, 20-FEB-2001
>
> Hello rooters.
>
> Some times ago I asked about strange behaviour of the ROOT
> for the script from tutorials: (Alpha server 8200 (4 cpu), OSF1)
> (Root Version 2.25/03)
>
> root [0] .L fitexample.C
> root [1] fitexample()
>
> *** Break *** floating point exception
> Root > Function fitf() busy flag cleared
> Function fitexample() busy flag cleared
>
> AT the same time the script works at Linux.
> Using iteration I found the place where the system is stopped
> (commented in the script below).
>
> Please, your comments.
>
> /_____________________macro fitexample.C___________________________
> Double_t fitf(Double_t *x, Double_t *par)
> {
> Double_t arg = 0;
> //.....!!! this operator does not work at OSF1, but works at Linux !!!!
> // if (par[2]) arg = (x[0] - par[1])/par[2];
> Float_t pp= par[2]; if (pp) arg = (x[0] - par[1])/par[2];
>
> Double_t fitval = par[0]*TMath::Exp(-0.5*arg*arg);
> return fitval;
> }
> void fitexample()
> {
> TFile *f = new TFile("hsimple.root");
>
> TH1F *hpx = (TH1F*)f->Get("hpx");
>
> TF1 *func = new TF1("fit",fitf,-3,3,3);
> func->SetParameters(500,hpx->GetMean(),hpx->GetRMS());
> func->SetParNames("Constant","Mean_value","Sigma");
> hpx->Fit("fit");
> }
> //------------------ end--------------
>
> Volodja Babintsev
This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:50:37 MET