00001 // @(#)root/hist:$Id: TFitResult.cxx 31604 2009-12-07 19:04:33Z moneta $ 00002 // Author: David Gonzalez Maline 12/11/09 00003 00004 /************************************************************************* 00005 * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. * 00006 * All rights reserved. * 00007 * * 00008 * For the licensing terms see $ROOTSYS/LICENSE. * 00009 * For the list of contributors see $ROOTSYS/README/CREDITS. * 00010 *************************************************************************/ 00011 00012 #include "TFitResult.h" 00013 00014 #include <iostream> 00015 00016 /** 00017 TFitResult extends the ROOT::Fit::Result class with a TNamed inheritance 00018 providing easy possibility for I/O 00019 00020 */ 00021 00022 ClassImp(TFitResult) 00023 00024 void TFitResult::Print(Option_t *option) const 00025 { 00026 // print result of the fit, by default chi2, parameter values and errors 00027 // if option "V" is given print also error matrix and correlation 00028 00029 TString opt(option); 00030 opt.ToUpper(); 00031 bool doCovMat = opt.Contains("V"); 00032 ROOT::Fit::FitResult::Print( std::cout, doCovMat); 00033 } 00034 00035 TMatrixDSym TFitResult::GetCovarianceMatrix() const 00036 { 00037 // Return the covariance matrix from fit 00038 // The matrix is a symmetric matrix with a size N equal to 00039 // the total number of parameters considered in the fit including the fixed ones 00040 // The matrix row and columns corresponding to the fixed parameters will contain only zero's 00041 00042 if (CovMatrixStatus() == 0) { 00043 Warning("GetCovarianceMatrix","covariance matrix is not available"); 00044 return TMatrixDSym(); 00045 } 00046 TMatrixDSym mat(NPar()); 00047 ROOT::Fit::FitResult::GetCovarianceMatrix<TMatrixDSym>(mat); 00048 return mat; 00049 } 00050 00051 TMatrixDSym TFitResult::GetCorrelationMatrix() const 00052 { 00053 // Return the correlation matrix from fit. 00054 // The matrix is a symmetric matrix with a size N equal to 00055 // the total number of parameters considered in the fit including the fixed ones 00056 // The matrix row and columns corresponding to the fixed parameters will contain only zero's 00057 if (CovMatrixStatus() == 0) { 00058 Warning("GetCorrelationMatrix","correlation matrix is not available"); 00059 return TMatrixDSym(); 00060 } 00061 TMatrixDSym mat(NPar()); 00062 ROOT::Fit::FitResult::GetCorrelationMatrix<TMatrixDSym>(mat); 00063 return mat; 00064 } 00065 00066