ROOT  6.06/09
Reference Guide
TFitResult.cxx
Go to the documentation of this file.
1 // @(#)root/hist:$Id$
2 // Author: David Gonzalez Maline 12/11/09
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 #include "TFitResult.h"
13 #include "Math/WrappedMultiTF1.h"
14 
15 #include <iostream>
16 
17 /** \class TFitResult
18  \ingroup Hist
19 Extends the ROOT::Fit::Result class with a TNamed inheritance
20 providing easy possibility for I/O
21 */
22 
24 
25 ////////////////////////////////////////////////////////////////////////////////
26 /// Constructor from a ROOT::Fit::FitResult
27 /// copy the contained TF1 pointer function if it is
28 
30  TNamed("TFitResult","TFitResult"),
31  ROOT::Fit::FitResult(f)
32 {
33  ROOT::Math::WrappedMultiTF1 * wfunc = dynamic_cast<ROOT::Math::WrappedMultiTF1 *>(ModelFunction().get() );
34  if (wfunc) wfunc->SetAndCopyFunction();
35 }
36 
37 
38 ////////////////////////////////////////////////////////////////////////////////
39 /// Print result of the fit, by default chi2, parameter values and errors.
40 /// if option "V" is given print also error matrix and correlation
41 
42 void TFitResult::Print(Option_t *option) const
43 {
44  TString opt(option);
45  opt.ToUpper();
46  bool doCovMat = opt.Contains("V");
47  ROOT::Fit::FitResult::Print( std::cout, doCovMat);
48 }
49 
50 ////////////////////////////////////////////////////////////////////////////////
51 /// Return the covariance matrix from fit
52 ///
53 /// The matrix is a symmetric matrix with a size N equal to
54 /// the total number of parameters considered in the fit including the fixed ones
55 /// The matrix row and columns corresponding to the fixed parameters will contain only zero's
56 
58 {
59  if (CovMatrixStatus() == 0) {
60  Warning("GetCovarianceMatrix","covariance matrix is not available");
61  return TMatrixDSym();
62  }
63  TMatrixDSym mat(NPar());
64  ROOT::Fit::FitResult::GetCovarianceMatrix<TMatrixDSym>(mat);
65  return mat;
66 }
67 
68 ////////////////////////////////////////////////////////////////////////////////
69 /// Return the correlation matrix from fit.
70 ///
71 /// The matrix is a symmetric matrix with a size N equal to
72 /// the total number of parameters considered in the fit including the fixed ones
73 /// The matrix row and columns corresponding to the fixed parameters will contain only zero's
74 
76 {
77  if (CovMatrixStatus() == 0) {
78  Warning("GetCorrelationMatrix","correlation matrix is not available");
79  return TMatrixDSym();
80  }
81  TMatrixDSym mat(NPar());
82  ROOT::Fit::FitResult::GetCorrelationMatrix<TMatrixDSym>(mat);
83  return mat;
84 }
85 
86 
TMatrixDSym GetCorrelationMatrix() const
Return the correlation matrix from fit.
Definition: TFitResult.cxx:75
Namespace for new ROOT classes and functions.
Definition: ROOT.py:1
const char Option_t
Definition: RtypesCore.h:62
Class to Wrap a ROOT Function class (like TF1) in a IParamMultiFunction interface of multi-dimensions...
void ToUpper()
Change string to upper case.
Definition: TString.cxx:1101
Basic string class.
Definition: TString.h:137
ClassImp(TFitResult)
void SetAndCopyFunction(const TF1 *f=0)
method to set a new function pointer and copy it inside.
Definition: WrappedTF1.cxx:242
Extends the ROOT::Fit::Result class with a TNamed inheritance providing easy possibility for I/O...
Definition: TFitResult.h:36
The TNamed class is the base class for all named ROOT classes.
Definition: TNamed.h:33
TFitResult(int status=0)
Definition: TFitResult.h:41
std::shared_ptr< IModelFunction > ModelFunction()
Return pointer non const pointer to model (fit) function with fitted parameter values.
Definition: FitResult.h:333
unsigned int NPar() const
total number of parameters (abbreviation)
Definition: FitResult.h:136
TMatrixDSym GetCovarianceMatrix() const
Return the covariance matrix from fit.
Definition: TFitResult.cxx:57
class containg the result of the fit and all the related information (fitted parameter values...
Definition: FitResult.h:52
double f(double x)
TFitResultPtr Fit(FitObject *h1, TF1 *f1, Foption_t &option, const ROOT::Math::MinimizerOptions &moption, const char *goption, ROOT::Fit::DataRange &range)
Definition: HFitImpl.cxx:132
TMatrixTSym< Double_t > TMatrixDSym
void Print(std::ostream &os, bool covmat=false) const
print the result and optionaly covariance matrix and correlations
Definition: FitResult.cxx:446
virtual void Print(Option_t *option="") const
Print result of the fit, by default chi2, parameter values and errors.
Definition: TFitResult.cxx:42
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Definition: TString.h:567
int CovMatrixStatus() const
covariance matrix status code using Minuit convention : =0 not calculated, =1 approximated, =2 made pos def , =3 accurate
Definition: FitResult.h:147
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
Definition: TObject.cxx:904