Re: Fitting histograms

From: Andrey Stepin <kaon_at_inbox.ru>
Date: Sun, 7 Aug 2005 19:24:12 +0400


Hi, Monika!

> Hi everybody,

> I have a root file which has 8 histograms. The aim is to draw all of them
> in one histogram. Out of these 8 histograms, I want to fit 6 of them with
> "gaus". But when I use the following script, it just draws the last
> histogram and fits it with "gaus". What am I missing here.
> Thanks very much for any help.

> Monika

You have to set the graphic options to Fit function of histogram.

like : h1->Fit("gaus","","pSame")

There is no need to Draw it before Fit.

Try this script:

TH1F *h1=new TH1F("h1","1",100,-5,5);
TH1F *h2=new TH1F("h2","2",100,-5,5);
h1->FillRandom("gaus",10000);
h2->FillRandom("pol1",10000);

h1->Fit("gaus");
h2->Fit("pol1","","pSame");

Regards,

 Andrey                          mailto:kaon_at_inbox.ru
Received on Sun Aug 07 2005 - 17:24:07 MEST

This archive was generated by hypermail 2.2.0 : Tue Jan 02 2007 - 14:45:11 MET