I wonder if there is a way to obtain the number of signal events after fitting.
The Stat window only shows mean, sigma and constant etc.
It does not show the area under the fit function.
For example, when a histogram is fitted with a Gaussian or a Gaussian signal + polynomial background,
the number of background subtracted signal is an important parameter.
The error on the number of signal after fit is also necessary.
See the example below showing how to add one or more lines to the TPaveStats.
TCanvas *c1 = new TCanvas("c1");
TH1F *h = new TH1F("h","test",100,-4,4);
TF1 *f1 = (TF1*)h->GetFunction("gaus");
Double_t integ = f1->Integral(-4,4);
integ /= h->GetXaxis()->GetBinWidth(1);
c1->Update(); //force the creation of the TPaveStats
TPaveStats *ps = (TPaveStats*)h->GetFunction("stats");
ps->SetName("mystats"); //name must be changed, otherwise "stats" is regenerated
ps->AddText(Form("Integral = %g",integ));
h->SetStats(0); //to avoid a new "stats" to be drawn
That seems working.
How can I get the error on the Integral similar to the error on the Sigma, for example?
see tutorial $ROOTSYS/tutorials/fit/ErrorIntegral.C (also in attachment)
ErrorIntegral.C (3.67 KB)
Thanks a lot, Rene.