Re: Accesssing fit parameters and errors

From: Arthur E. Snyder <snyder_at_slac.stanford.edu>
Date: Mon, 5 Feb 2007 13:34:58 -0800 (PST)

To get full covariance you do one of the following:

    Example1:

         TH1F h("h","test",100,-2,2);
         h.FillRandom("gaus",1000);
         h.Fit("gaus");
         Double_t matrix[3][3];
         gMinuit->mnemat(&matrix[0][0],3);
      Example2:
         TH1F h("h","test",100,-2,2);
         h.FillRandom("gaus",1000);
         h.Fit("gaus");
         TVirtualFitter *fitter = TVirtualFitter::GetFitter();
         TMatrixD matrix(npar,npar,fitter->GetCovarianceMatrix());
         Double_t errorFirstPar = fitter->GetCovarianceMatrixElement(0,0);


from:http://root.cern.ch/root/html402/TH1.html

Generally you can find out how to do these things by looking at the headers though it's someway confusing sometimes, E.g., It never seems natural to me that to find the 'fitter' and hence covariance, I need to interogate the histogram rather than the function ...

Once you have pointer to TVirtualFitter or minuit you can extract whatever you want from the last fit done .. if you do another fit in the meanwhile, I think your fitter info from previous fits gets lost because TVirtualFitter is static and gMinuit is global.

-Art S.

A.E. Snyder, Group EC                        \!c*p?/
SLAC Mail Stop #95                          ((.   .))
Box 4349                                        |
Stanford, Ca, USA, 94309                      '\|/`
e-mail:snyder_at_slac.stanford.edu                 o
phone:650-926-2701                              _
http://www.slac.stanford.edu/~snyder          BaBar
FAX:650-926-2657                          Collaboration



On Mon, 5 Feb 2007, Roger Mason wrote:

> Hello Arthur,
>
> "Arthur E. Snyder" <snyder_at_slac.stanford.edu> writes:
>
> > It would be nice if root Print commands could take ostream as an argument
> > so one could print to a file, but that doesn't work. I use cut&paste
> > sometimes, but it I want to print a lot of 'em to files I have to use
> > GetParError or GetParErrors (returns an array [a]).
> >
> >
> >
> > [a] a pointer to the array fParErrors.
> > virtual Double_t *GetParErrors() const {return fParErrors;}
> >
>
> I don't understand what syntax one would use to fill an array from
> GetParErrors, but I can easily loop over GetParError.
>
> Thanks,
> Roger
>
>
Received on Mon Feb 05 2007 - 22:35:09 CET

This archive was generated by hypermail 2.2.0 : Tue Feb 06 2007 - 05:50:00 CET