Logo ROOT  
Reference Guide
RooFitResult.h
Go to the documentation of this file.
1/*****************************************************************************
2 * Project: RooFit *
3 * Package: RooFitCore *
4 * File: $Id: RooFitResult.h,v 1.28 2007/05/11 09:11:30 verkerke Exp $
5 * Authors: *
6 * WV, Wouter Verkerke, UC Santa Barbara, verkerke@slac.stanford.edu *
7 * DK, David Kirkby, UC Irvine, dkirkby@uci.edu *
8 * *
9 * Copyright (c) 2000-2005, Regents of the University of California *
10 * and Stanford University. All rights reserved. *
11 * *
12 * Redistribution and use in source and binary forms, *
13 * with or without modification, are permitted according to the terms *
14 * listed in LICENSE (http://roofit.sourceforge.net/license.txt) *
15 *****************************************************************************/
16#ifndef ROO_FIT_RESULT
17#define ROO_FIT_RESULT
18
19#include "RooAbsArg.h"
20#include "RooPrintable.h"
21#include "RooDirItem.h"
22#include "RooArgList.h"
23
24#include "RVersion.h"
25#include "TMatrixFfwd.h"
26#include "TMatrixDSym.h"
27#include "TList.h"
28
29#include <vector>
30#include <string>
31#include <utility>
32
33class RooArgSet ;
34class RooAbsPdf ;
35class RooPlot;
36class TObject ;
37class TH2 ;
39
40class RooFitResult : public TNamed, public RooPrintable, public RooDirItem {
41public:
42
43 // Constructors, assignment etc.
44 RooFitResult(const char* name=0, const char* title=0) ;
45 RooFitResult(const RooFitResult& other) ;
46 virtual TObject* Clone(const char* newname = 0) const {
47 RooFitResult* r = new RooFitResult(*this) ;
48 if (newname && *newname) r->SetName(newname) ;
49 return r ;
50 }
51 virtual TObject* clone() const { return new RooFitResult(*this); }
52 virtual ~RooFitResult() ;
53
54 static RooFitResult* lastMinuitFit(const RooArgList& varList=RooArgList()) ;
55
56 static RooFitResult *prefitResult(const RooArgList &paramList);
57
58 // Printing interface (human readable)
59 virtual void printValue(std::ostream& os) const ;
60 virtual void printName(std::ostream& os) const ;
61 virtual void printTitle(std::ostream& os) const ;
62 virtual void printClassName(std::ostream& os) const ;
63 virtual void printArgs(std::ostream& os) const ;
64 void printMultiline(std::ostream& os, Int_t contents, Bool_t verbose=kFALSE, TString indent="") const ;
65
66 inline virtual void Print(Option_t *options= 0) const {
67 // Printing interface
69 }
70
71 virtual Int_t defaultPrintContents(Option_t* opt) const ;
72 virtual StyleOption defaultPrintStyle(Option_t* opt) const ;
73
74 RooAbsPdf* createHessePdf(const RooArgSet& params) const ;
75
76 // Accessors
77 /// Return MINUIT status code
78 inline Int_t status() const {
79 return _status ;
80 }
81
82 inline UInt_t numStatusHistory() const { return _statusHistory.size() ; }
83 Int_t statusCodeHistory(UInt_t icycle) const ;
84 const char* statusLabelHistory(UInt_t icycle) const ;
85
86 /// Return MINUIT quality code of covariance matrix
87 inline Int_t covQual() const {
88 return _covQual ;
89 }
90 /// Return number of NLL evaluations with problems.
91 inline Int_t numInvalidNLL() const {
92 return _numBadNLL ;
93 }
94 /// Return estimated distance to minimum.
95 inline Double_t edm() const {
96 return _edm ;
97 }
98 /// Return minimized -log(L) value.
99 inline Double_t minNll() const {
100 return _minNLL ;
101 }
102 /// Return list of constant parameters.
103 inline const RooArgList& constPars() const {
104 return *_constPars ;
105 }
106 //. Return list of floating parameters before fit.
107 inline const RooArgList& floatParsInit() const {
108 return *_initPars ;
109 }
110 /// Return list of floarting parameters after fit.
111 inline const RooArgList& floatParsFinal() const {
112 return *_finalPars ;
113 }
114
115 TH2* correlationHist(const char* name = "correlation_matrix") const ;
116
117 /// Return correlation between par1 and par2.
118 Double_t correlation(const RooAbsArg& par1, const RooAbsArg& par2) const {
119 return correlation(par1.GetName(),par2.GetName()) ;
120 }
121 /// Return pointer to list of correlations of all parameters with par.
122 const RooArgList* correlation(const RooAbsArg& par) const {
123 return correlation(par.GetName()) ;
124 }
125
126 Double_t correlation(const char* parname1, const char* parname2) const ;
127 const RooArgList* correlation(const char* parname) const ;
128
129
130 const TMatrixDSym& covarianceMatrix() const ;
131 const TMatrixDSym& correlationMatrix() const ;
132 TMatrixDSym reducedCovarianceMatrix(const RooArgList& params) const ;
134
135
136 // Global correlation accessors
137 Double_t globalCorr(const RooAbsArg& par) { return globalCorr(par.GetName()) ; }
138 Double_t globalCorr(const char* parname) ;
139 const RooArgList* globalCorr() ;
140
141
142 /// Add objects to a 2D plot.
143 /// Plot error ellipse in par1 and par2 on frame.
144 inline RooPlot *plotOn(RooPlot *frame, const RooAbsArg &par1, const RooAbsArg &par2,
145 const char *options= "ME") const {
146 return plotOn(frame,par1.GetName(),par2.GetName(),options);
147 }
148 RooPlot *plotOn(RooPlot *plot, const char *parName1, const char *parName2,
149 const char *options= "ME") const;
150
151 /// Generate random perturbations of the final parameters using the covariance matrix.
152 const RooArgList& randomizePars() const;
153
154 Bool_t isIdentical(const RooFitResult& other, Double_t tol=1e-6, Double_t tolCorr=1e-4, Bool_t verbose=kTRUE) const ;
155
156 void SetName(const char *name) ;
157 void SetNameTitle(const char *name, const char* title) ;
158
159protected:
160
161 friend class RooAbsPdf ;
162 friend class RooMinuit ;
163 friend class RooMinimizer ;
165 void setConstParList(const RooArgList& list) ;
166 void setInitParList(const RooArgList& list) ;
167 void setFinalParList(const RooArgList& list) ;
168 inline void setMinNLL(Double_t val) { _minNLL = val ; }
169 inline void setEDM(Double_t val) { _edm = val ; }
170 inline void setStatus(Int_t val) { _status = val ; }
171 inline void setCovQual(Int_t val) { _covQual = val ; }
172 inline void setNumInvalidNLL(Int_t val) { _numBadNLL=val ; }
173 void fillCorrMatrix() ;
174 void fillCorrMatrix(const std::vector<double>& globalCC, const TMatrixDSym& corrs, const TMatrixDSym& covs) ;
175 void fillLegacyCorrMatrix() const ;
177 void setStatusHistory(std::vector<std::pair<std::string,int> >& hist) { _statusHistory = hist ; }
178
179 Double_t correlation(Int_t row, Int_t col) const;
180 Double_t covariance(Int_t row, Int_t col) const;
181
182 Int_t _status ; // MINUIT status code
183 Int_t _covQual ; // MINUIT quality code of covariance matrix
184 Int_t _numBadNLL ; // Number calls with bad (zero,negative) likelihood
185 Double_t _minNLL ; // NLL at minimum
186 Double_t _edm ; // Estimated distance to minimum
187 RooArgList* _constPars ; // List of constant parameters
188 RooArgList* _initPars ; // List of floating parameters with initial values
189 RooArgList* _finalPars ; // List of floating parameters with final values
190
191 mutable RooArgList* _globalCorr ; //! List of global correlation coefficients
192 mutable TList _corrMatrix ; //! Correlation matrix (list of RooArgLists)
193
194 mutable RooArgList *_randomPars; //! List of floating parameters with most recent random perturbation applied
195 mutable TMatrixF* _Lt; //! triangular matrix used for generate random perturbations
196
197 TMatrixDSym* _CM ; // Correlation matrix
198 TMatrixDSym* _VM ; // Covariance matrix
199 TVectorD* _GC ; // Global correlation coefficients
200
201 std::vector<std::pair<std::string,int> > _statusHistory ; // History of status codes
202
203 ClassDef(RooFitResult,5) // Container class for fit result
204};
205
206#endif
ROOT::R::TRInterface & r
Definition: Object.C:4
#define e(i)
Definition: RSha256.hxx:103
RooArgSet * pRooArgSet
Definition: RooFitResult.h:37
int Int_t
Definition: RtypesCore.h:45
unsigned int UInt_t
Definition: RtypesCore.h:46
const Bool_t kFALSE
Definition: RtypesCore.h:101
bool Bool_t
Definition: RtypesCore.h:63
double Double_t
Definition: RtypesCore.h:59
const Bool_t kTRUE
Definition: RtypesCore.h:100
const char Option_t
Definition: RtypesCore.h:66
#define ClassDef(name, id)
Definition: Rtypes.h:325
static void indent(ostringstream &buf, int indent_level)
char name[80]
Definition: TGX11.cxx:110
RooAbsArg is the common abstract base class for objects that represent a value and a "shape" in RooFi...
Definition: RooAbsArg.h:72
RooArgList is a container object that can hold multiple RooAbsArg objects.
Definition: RooArgList.h:22
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition: RooArgSet.h:35
RooDirItem is a utility base class for RooFit objects that are to be attached to ROOT directories.
Definition: RooDirItem.h:22
RooFitResult is a container class to hold the input and output of a PDF fit to a dataset.
Definition: RooFitResult.h:40
TMatrixDSym conditionalCovarianceMatrix(const RooArgList &params) const
Return a reduced covariance matrix, which is calculated as.
void fillCorrMatrix()
Internal utility method to extract the correlation matrix and the global correlation coefficients fro...
void setCovQual(Int_t val)
Definition: RooFitResult.h:171
void setMinNLL(Double_t val)
Definition: RooFitResult.h:168
virtual void Print(Option_t *options=0) const
Print TNamed name and title.
Definition: RooFitResult.h:66
void setNumInvalidNLL(Int_t val)
Definition: RooFitResult.h:172
TList _corrMatrix
List of global correlation coefficients.
Definition: RooFitResult.h:192
std::vector< std::pair< std::string, int > > _statusHistory
Definition: RooFitResult.h:201
const TMatrixDSym & covarianceMatrix() const
Return covariance matrix.
RooFitResult(const char *name=0, const char *title=0)
Constructor with name and title.
void setStatus(Int_t val)
Definition: RooFitResult.h:170
TMatrixDSym * _CM
triangular matrix used for generate random perturbations
Definition: RooFitResult.h:197
void setConstParList(const RooArgList &list)
Fill the list of constant parameters.
Int_t statusCodeHistory(UInt_t icycle) const
virtual ~RooFitResult()
Destructor.
virtual Int_t defaultPrintContents(Option_t *opt) const
Configure default contents to be printed.
virtual void printTitle(std::ostream &os) const
Print title of fit result.
Int_t _numBadNLL
Definition: RooFitResult.h:184
TMatrixDSym * _VM
Definition: RooFitResult.h:198
Double_t correlation(const RooAbsArg &par1, const RooAbsArg &par2) const
Return correlation between par1 and par2.
Definition: RooFitResult.h:118
const RooArgList & floatParsInit() const
Definition: RooFitResult.h:107
RooArgList * _initPars
Definition: RooFitResult.h:188
TMatrixDSym reducedCovarianceMatrix(const RooArgList &params) const
Return a reduced covariance matrix (Note that Vred is a simple sub-matrix of V, row/columns are order...
void fillPrefitCorrMatrix()
RooArgList * _constPars
Definition: RooFitResult.h:187
void SetNameTitle(const char *name, const char *title)
Change name and title of RooFitResult object.
const RooArgList * correlation(const RooAbsArg &par) const
Return pointer to list of correlations of all parameters with par.
Definition: RooFitResult.h:122
RooArgList * _globalCorr
Definition: RooFitResult.h:191
Double_t edm() const
Return estimated distance to minimum.
Definition: RooFitResult.h:95
const RooArgList & randomizePars() const
Generate random perturbations of the final parameters using the covariance matrix.
const RooArgList * globalCorr()
Return the list of all global correlations.
static RooFitResult * prefitResult(const RooArgList &paramList)
Import the results of the last fit performed by gMinuit, interpreting the fit parameters as the given...
void setCovarianceMatrix(TMatrixDSym &V)
Store externally provided correlation matrix in this RooFitResult ;.
virtual StyleOption defaultPrintStyle(Option_t *opt) const
Configure mapping of Print() arguments to RooPrintable print styles.
void setEDM(Double_t val)
Definition: RooFitResult.h:169
void setStatusHistory(std::vector< std::pair< std::string, int > > &hist)
Definition: RooFitResult.h:177
RooArgList * _finalPars
Definition: RooFitResult.h:189
const RooArgList & constPars() const
Return list of constant parameters.
Definition: RooFitResult.h:103
virtual TObject * clone() const
Definition: RooFitResult.h:51
void SetName(const char *name)
Change name of RooFitResult object.
virtual TObject * Clone(const char *newname=0) const
Make a clone of an object using the Streamer facility.
Definition: RooFitResult.h:46
Double_t covariance(Int_t row, Int_t col) const
Return the covariance matrix element addressed with numeric indices.
virtual void printClassName(std::ostream &os) const
Print class name of fit result.
Bool_t isIdentical(const RooFitResult &other, Double_t tol=1e-6, Double_t tolCorr=1e-4, Bool_t verbose=kTRUE) const
Return true if this fit result is identical to other within tolerances.
const char * statusLabelHistory(UInt_t icycle) const
Double_t _edm
Definition: RooFitResult.h:186
Double_t _minNLL
Definition: RooFitResult.h:185
Int_t numInvalidNLL() const
Return number of NLL evaluations with problems.
Definition: RooFitResult.h:91
Int_t covQual() const
Return MINUIT quality code of covariance matrix.
Definition: RooFitResult.h:87
void printMultiline(std::ostream &os, Int_t contents, Bool_t verbose=kFALSE, TString indent="") const
Print fit result to stream 'os'.
Double_t minNll() const
Return minimized -log(L) value.
Definition: RooFitResult.h:99
virtual void printArgs(std::ostream &os) const
Print arguments of fit result, i.e. the parameters of the fit.
TH2 * correlationHist(const char *name="correlation_matrix") const
Return TH2D of correlation matrix.
void fillLegacyCorrMatrix() const
Sanity check.
void setInitParList(const RooArgList &list)
Fill the list of initial values of the floating parameters.
RooPlot * plotOn(RooPlot *frame, const RooAbsArg &par1, const RooAbsArg &par2, const char *options="ME") const
Add objects to a 2D plot.
Definition: RooFitResult.h:144
TMatrixF * _Lt
List of floating parameters with most recent random perturbation applied.
Definition: RooFitResult.h:195
virtual void printName(std::ostream &os) const
Print name of fit result.
const RooArgList & floatParsFinal() const
Return list of floarting parameters after fit.
Definition: RooFitResult.h:111
Int_t status() const
Return MINUIT status code.
Definition: RooFitResult.h:78
RooArgList * _randomPars
Correlation matrix (list of RooArgLists)
Definition: RooFitResult.h:194
static RooFitResult * lastMinuitFit(const RooArgList &varList=RooArgList())
Import the results of the last fit performed by gMinuit, interpreting the fit parameters as the given...
Double_t globalCorr(const RooAbsArg &par)
Definition: RooFitResult.h:137
virtual void printValue(std::ostream &os) const
Print the value of the fit result, i.e.g the status, minimized FCN, edm and covariance quality code.
TVectorD * _GC
Definition: RooFitResult.h:199
RooAbsPdf * createHessePdf(const RooArgSet &params) const
Return a p.d.f that represents the fit result as a multi-variate probability densisty function on the...
void setFinalParList(const RooArgList &list)
Fill the list of final values of the floating parameters.
UInt_t numStatusHistory() const
Definition: RooFitResult.h:82
const TMatrixDSym & correlationMatrix() const
Return correlation matrix ;.
RooMinimizer is a wrapper class around ROOT::Fit:Fitter that provides a seamless interface between th...
Definition: RooMinimizer.h:55
RooMinuit is a wrapper class around TFitter/TMinuit that provides a seamless interface between the MI...
Definition: RooMinuit.h:41
A RooPlot is a plot frame and a container for graphics objects within that frame.
Definition: RooPlot.h:44
RooPlotable is a 'mix-in' base class that define the standard RooFit plotting and printing methods.
Definition: RooPrintable.h:25
static std::ostream & defaultPrintStream(std::ostream *os=0)
Return a reference to the current default stream to use in Print().
virtual void printStream(std::ostream &os, Int_t contents, StyleOption style, TString indent="") const
Print description of object on ostream, printing contents set by contents integer,...
Service class for 2-D histogram classes.
Definition: TH2.h:30
A doubly linked list.
Definition: TList.h:44
TMatrixT.
Definition: TMatrixT.h:39
The TNamed class is the base class for all named ROOT classes.
Definition: TNamed.h:29
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:47
Mother of all ROOT objects.
Definition: TObject.h:37
Basic string class.
Definition: TString.h:136