Fitting histograms

From: <monika_at_rcf.rhic.bnl.gov>
Date: Sun, 7 Aug 2005 08:24:21 -0400 (EDT)

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.

After reading all of them from the root file I am saying :

  c1->SetBorderMode(1);
  c1->SetFillColor(kWhite);
  gStyle->SetOptFit(0);
  gStyle->SetOptStat("");

  c1->SetLogy();
  h1->SetMaximum(500);
  h1->SetMinimum(0);
  h1->SetLineColor(2);
  h1->SetLineWidth(2);
  h1->GetXaxis()->SetRange(0,150);
  h1->Draw();
  h2->SetLineColor(4);
  h2->SetLineWidth(2);
  h2->Draw("same");
  h3->Fit("gaus");
  h3->SetMarkerColor(8);
  h3->SetMarkerStyle(22);
  h3->SetMarkerSize(0.6);
  h3->Draw("pSame");
  h4->SetMarkerColor(6);
  h4->SetMarkerStyle(29);
  h4->SetMarkerSize(0.6);
  h4->Fit("gaus");
  h4->Draw("pSame");
  h5->SetMarkerColor(50);
  h5->SetMarkerStyle(28);
  h5->SetMarkerSize(0.6);
  h5->Fit("gaus");
  h5->Draw("pSame");
  h6->SetMarkerColor(1);
  h6->SetMarkerStyle(30);
  h6->SetMarkerSize(0.6);
  h6->Fit("gaus");
  h6->Draw("pSame");
  h7->SetMarkerColor(3);
  h7->SetMarkerStyle(23);
  h7->SetMarkerSize(0.6);
  h7->Fit("gaus");
  h7->Draw("pSame");
  h8->SetMarkerColor(3);
  h8->SetMarkerStyle(23);
  h8->SetMarkerSize(0.6);
  h8->Fit("gaus");
  h8->Draw("pSame");

Thanks very much for any help.

Monika Received on Sun Aug 07 2005 - 14:24:33 MEST

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