Logo ROOT   6.16/01
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"
14
15#include <iostream>
16
17/** \class TFitResult
18 \ingroup Hist
19Extends the ROOT::Fit::Result class with a TNamed inheritance
20providing 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{
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
42void 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////////////////////////////////////////////////////////////////////////////////
87/// Print the TFitResult.
88
89std::string cling::printValue(const TFitResult* val) {
90 std::stringstream outs;
91 val->ROOT::Fit::FitResult::Print(outs, false /*doCovMat*/);
92 return outs.str();
93}
#define f(i)
Definition: RSha256.hxx:104
const char Option_t
Definition: RtypesCore.h:62
#define ClassImp(name)
Definition: Rtypes.h:363
TMatrixTSym< Double_t > TMatrixDSym
class containg the result of the fit and all the related information (fitted parameter values,...
Definition: FitResult.h:48
void Print(std::ostream &os, bool covmat=false) const
print the result and optionaly covariance matrix and correlations
Definition: FitResult.cxx:446
std::shared_ptr< IModelFunction > ModelFunction()
Return pointer non const pointer to model (fit) function with fitted parameter values.
Definition: FitResult.h:330
unsigned int NPar() const
total number of parameters (abbreviation)
Definition: FitResult.h:132
int CovMatrixStatus() const
covariance matrix status code using Minuit convention : =0 not calculated, =1 approximated,...
Definition: FitResult.h:143
Class to Wrap a ROOT Function class (like TF1) in a IParamMultiFunction interface of multi-dimensions...
void SetAndCopyFunction(const TF1 *f=0)
method to set a new function pointer and copy it inside.
Extends the ROOT::Fit::Result class with a TNamed inheritance providing easy possibility for I/O.
Definition: TFitResult.h:30
TFitResult(int status=0)
Definition: TFitResult.h:35
TMatrixDSym GetCorrelationMatrix() const
Return the correlation matrix from fit.
Definition: TFitResult.cxx:75
TMatrixDSym GetCovarianceMatrix() const
Return the covariance matrix from fit.
Definition: TFitResult.cxx:57
virtual void Print(Option_t *option="") const
Print result of the fit, by default chi2, parameter values and errors.
Definition: TFitResult.cxx:42
The TNamed class is the base class for all named ROOT classes.
Definition: TNamed.h:29
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
Definition: TObject.cxx:866
Basic string class.
Definition: TString.h:131
void ToUpper()
Change string to upper case.
Definition: TString.cxx:1113
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Definition: TString.h:619
TFitResultPtr Fit(FitObject *h1, TF1 *f1, Foption_t &option, const ROOT::Math::MinimizerOptions &moption, const char *goption, ROOT::Fit::DataRange &range)
Definition: HFitImpl.cxx:134
Namespace for new ROOT classes and functions.
Definition: StringConv.hxx:21
std::string printValue(const TDatime *val)
Print a TDatime at the prompt.
Definition: TDatime.cxx:514