I’m trying to get my stats box to show the resolution of the fit on my histogram, but I can only get it to show by also showing the Std. Dev of the histogram instead of the Sigma of the fit.
This:
Which is almost what I want, but doesn’t have the Resolution at the end. Adding h1->SetStats(0); after l1->Add(t1); gives the following, which has Std Dev where I want Sigma to be and doesn’t show the results of the fit.
{
// Create and plot a test histogram with stats
TCanvas *se = new TCanvas;
TH1F *h = new TH1F("h","test",100,-3,3);
h->FillRandom("gaus",3000);
gStyle->SetOptFit();
gStyle->SetOptStat(0);
h->Fit("gaus");
se->Update();
// Retrieve the stat box
TPaveStats *ps = (TPaveStats*)se->GetPrimitive("stats");
ps->SetName("mystats");
TList *listOfLines = ps->GetListOfLines();
// Add a new line in the stat box.
// Note that "=" is a control character
TLatex *myt = new TLatex(0,0,"Test = 10");
myt ->SetTextFont(42);
myt ->SetTextSize(0.04);
myt ->SetTextColor(kRed);
listOfLines->Add(myt);
// the following line is needed to avoid that the automatic redrawing of stats
h->SetStats(0);
se->Modified();
}
Yes that’s what I started from but as I say, either I can get the stats box drawn with the resolution at the end, or I can get the fit characteristics drawn, I can’t get the fit parameters with the resolution on the end