# Contents of statistics box

Hello,
Is there a way to add calculated quantities to the statistics box for a fit? In other words, If I integrate to determine the number of events under a gaussian peak, and various other quantities, how might I add them to a box?
Also, is there a way to print only particular fit parameters of interest? Say I have a gaussian plus a polynomial background, but am only interested in the fit parameters of the gaussian, how to I code for this?

thanks!

see example below

Rene

[code]void mycoeff() {
TCanvas *c1 = new TCanvas;
TH1F *h = new TH1F(“h”,“test”,100,-3,3);
h->FillRandom(“gaus”,3000);
gStyle->SetOptFit();
h->Fit(“gaus”);
TF1 *f1 = h->GetFunction(“gaus”);
c1->Update();
TPaveStats ps = (TPaveStats)c1->GetPrimitive(“stats”);
ps->SetName(“mystats”);
TList *list = ps->GetListOfLines();
TText *tconst = ps->GetLineWith(“Constant”);
printf(“tconst=%x\n”,tconst);
list->Remove(tconst);
Double_t integral = f1->Integral(-3,3)*100/6;
TLatex *myt = new TLatex(0,0,Form(“Integral %g”,integral) );
h->SetStats(0);
c1->Modified();

}
[/code]

Rene,

in you example, the stats box is something like the top stats box of the attachment. I would like to know if it is possible to align the parameter name on the left and the values on the right, just like the bottom stats box of the attachment.

I did this alignment replacing

``   TLatex *myt = new TLatex(0,0,Form("Integral %g",integral) ); ``

by

``   TLatex *myt = new TLatex(0,0,Form("Integral %g",integral) ); ``

Just another question, is there a way to set the same font for the added line and the stats box. I tried to add the line

``ps->SetTextFont(62);``

but it didn’t work.

Best regards

Hi,

I found out how to put a parameter inside stats box and keep it aligns (the name on the left and the value on the right).

```TPaveStats *st = (TPaveStats*)h->GetListOfFunctions()->FindObject("stats"); char tmp_text; sprintf(tmp_text, "NAME = %3.1f ", value); TString text_line = TString(tmp_text); st->AddText(text_line.Data());```

cheers