Hi Vladimir, In your fitFunction, replace the line: return &par[0]*TMath::Landau(xx,.02,.005); by return par[0]*TMath::Landau(xx,.02,.005); Rene Brun On Sun, 17 Mar 2002, Vladimir Morozov wrote: > I'm having trouble fitting a histogram to Landau distribution in a > limited variable range. > Here's a macro, which will build a histogram, fill it and try to fit it > to Landau. The fit always fails (cannot find an appropriate value for > fit parameters), and I don't know what's wrong. I've tried helping the > fitter by providing a reasonable starting point for the fit, but it > still doesn't work. Any idea what I might be doing wrong? I'm running > Root4STAR 3.02/07 > > Thanx, > Vladimir. > > _______________________________________- > > #include <TMath.h> > > Double_t fitFunction(Double_t *x, Double_t *par) { > Double_t xx = x[0]; > return &par[0]*TMath::Landau(xx,.02,.005); > } > > void macro() { > > TH1 *histo = new TH1F("histo","pPt",19,-0.002,0.19); > histo->SetEntries(174); > histo->SetDirectory(0); > histo->SetBinContent(1,12); > histo->SetBinContent(2,22); > histo->SetBinContent(3,18); > histo->SetBinContent(4,10); > histo->SetBinContent(5,8); > histo->SetBinContent(6,8); > histo->SetBinContent(7,3); > histo->SetBinContent(8,3); > histo->SetBinContent(9,2); > histo->SetBinContent(10,3); > histo->SetBinContent(11,1); > histo->SetBinContent(12,1); > histo->SetBinContent(13,1); > histo->SetBinContent(14,1); > histo->SetBinContent(15,7); > histo->SetBinContent(16,3); > histo->SetBinContent(17,8); > histo->SetBinContent(19,4); > > histo->SetMarkerStyle(20); > histo->Draw(""); > > TF1 *fun = new TF1("fun",fitFunction,0.03,.12,1); > fun->SetParameter(0,140.0); > histo->Fit("fun","R"); > } > > > > >
This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:50:46 MET