Hi Reinhardt,
The doc of TH1::Fit says:
Associated functions
====================
One or more object (typically a TF1*) can be added to the list
of functions (fFunctions) associated to each histogram.
When TH1::Fit is invoked, the fitted function is added to this list.
Given an histogram h, one can retrieve an associated function
with: TF1 *myfunc = h->GetFunction("myfunc");
Access to the fit results
=========================
If the histogram is made persistent, the list of
associated functions is also persistent. Given a pointer (see above)
to an associated function myfunc, one can retrieve the function/fit
parameters with calls such as:
Double_t chi2 = myfunc->GetChisquare();
Double_t par0 = myfunc->GetParameter(0); //value of 1st parameter
Double_t err0 = myfunc->GetParError(0); //error on first parameter
In your case, do:
TF1 *myfunc = myhisto->GetFunction("gaus");
Double_t par0 = myfunc->GetParameter(0); //value of 1st parameter
etc..
Rene Brun
On Mon, 6 Jan 2003, Reinhardt Chamonal wrote:
> Hi,
> First happy new year to everbody.
> I shall start this new year with a root question.
>
> I have a file in which I have a histogram. This histogram has been saved
> with its fit. I would like to access the fit in order to read the
> parameters. So far I have:
> TFile f("data/root/run5345.root");
> TH1F *myhisto =(TH1F*)f->Get(Form("boundary;1"); //I have several of them
> So from here I have a pointer to boudary;1
> inside it there is "boundary" (the histogram) and "gaus" (the fit)
> no problem to retrieve the parameters of the histogram directly like
> that:
> Double_t mean=myhisto->GetMean();
> But How to I get the fit parameters ?
>
> Cheers
>
> --
> ------------------------------------------------------------
> Reinhardt CHAMONAL The University of Edinburgh
> School of Physics
> email: chamonal@ph.ed.ac.uk King's Buildings, JCMB, 5301
> Mayfield Road
> phone: +44-131-650 5307 Edinburgh, EH9 3JZ
>
> web: http://www.ph.ed.ac.uk/~chamonal/
> http://www.reuh.fr.st
> ------------------------------------------------------------
>
This archive was generated by hypermail 2b29 : Thu Jan 01 2004 - 17:50:08 MET