Re: [ROOT] Fit param shown for superimposed fit

From: Rene Brun (Rene.Brun@cern.ch)
Date: Sat Jun 01 2002 - 01:10:50 MEST


Hi Stefano,

Use the option "sames" instead of "same". For more details see:
http://root.cern.ch/root/htmldoc/THistPainter.html#THistPainter:Paint

Also see the example below

Rene Brun

void sames() {
   TH1F *HPtJ1 = new TH1F("HPtJ1","Pt of 1st jet",20,0,20);
   TH1F *HPtJ2 = new TH1F("HPtJ2","Pt of 2nd jet",20,0,20);

   HPtJ1->Fill(10,0.5); HPtJ1->Fill(12,0.6);
   HPtJ2->Fill(2,1);HPtJ2->Fill(4,2);HPtJ2->Fill(7,3);

   HPtJ1->SetLineColor(4);
   HPtJ2->SetLineColor(2);

   TCanvas *c1 = new TCanvas("c1");

   //HPtJ2->Draw();
   gStyle->SetOptFit();
   HPtJ2->Fit("pol1");
   
   c1->Modified(); c1->Update();
   TPaveStats *stats =(TPaveStats*)c1->GetPrimitive("stats");
   stats->SetName("h1stats");
   stats->SetY1NDC(.4);
   stats->SetY2NDC(.6);
   stats->SetTextColor(2);

   //HPtJ1->Draw("sames");
   HPtJ1->Fit("pol0","","sames");
   c1->Update();
   TPaveStats *stats2 = (TPaveStats*)c1->GetPrimitive("stats");
   stats2->SetName("h1stats2");
   stats2->SetY1NDC(.1);
   stats2->SetY2NDC(.3);
   stats2->SetTextColor(4);
}


On Thu, 30 May 2002, Stefano Lacaprara wrote:

> Hi!
>   I have the following situation:
> I draw a 2d histogram, then I FitSlicesY it and draw the result on the same
> plot. Then I fit the sliced histos and I want to draw the fitted funcion on
> top of the two other histos.
> I do this way:
> 
> DTvsBnorm->FitSlicesY();
> DTvsBnorm->Draw();
> DTvsBnorm_1->Draw("same");
> DTvsBnorm_1->Fit("pol2","","same");
> 
> I want to have on the plot the parameters of the fit, while I have the
> statistic of the first histo I draw (I have set SetOptFit(111111) and
> SetOptStat(111111) ). Is it possible to have the fit parameter shown and not
> (only) the histo stat box?
> 
> Cheers,
>   Stefano Lacaprara
> 
> 
> -- 
> Stefano Lacaprara Ph.D Lacaprara@pd.infn.it   \\\|///
> I.N.F.N. & Universita' di Padova            \\  - -  //
> http://www.pd.infn.it/~lacaprar              (  0 0  )
> PHONE +39-049-8277100 FAX +39-049-8756233 -oOOo-(_)-oOOo-
> 



This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:50:54 MET