Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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 TH2;
37
38class RooFitResult : public TNamed, public RooPrintable, public RooDirItem {
39public:
40
41 // Constructors, assignment etc.
42 RooFitResult(const char* name=nullptr, const char* title=nullptr) ;
44 TObject* Clone(const char* newname = nullptr) const override {
45 RooFitResult* r = new RooFitResult(*this) ;
46 if (newname && *newname) r->SetName(newname) ;
47 return r ;
48 }
49 virtual TObject* clone() const { return new RooFitResult(*this); }
50 ~RooFitResult() override ;
51
52 static RooFitResult *prefitResult(const RooArgList &paramList);
53
54 // Printing interface (human readable)
55 void printValue(std::ostream& os) const override ;
56 void printName(std::ostream& os) const override ;
57 void printTitle(std::ostream& os) const override ;
58 void printClassName(std::ostream& os) const override ;
59 void printArgs(std::ostream& os) const override ;
60 void printMultiline(std::ostream& os, Int_t contents, bool verbose=false, TString indent="") const override ;
61
62 inline void Print(Option_t *options= nullptr) const override {
63 // Printing interface
65 }
66
67 Int_t defaultPrintContents(Option_t* opt) const override ;
68 StyleOption defaultPrintStyle(Option_t* opt) const override ;
69
70 RooAbsPdf* createHessePdf(const RooArgSet& params) const ;
71
72 // Accessors
73 /// Return MINUIT status code
74 inline Int_t status() const {
75 return _status ;
76 }
77
78 inline UInt_t numStatusHistory() const { return _statusHistory.size() ; }
80 const char* statusLabelHistory(UInt_t icycle) const ;
81
82 /// Return MINUIT quality code of covariance matrix
83 inline Int_t covQual() const {
84 return _covQual ;
85 }
86 /// Return number of NLL evaluations with problems.
87 inline Int_t numInvalidNLL() const {
88 return _numBadNLL ;
89 }
90 /// Return estimated distance to minimum.
91 inline double edm() const {
92 return _edm ;
93 }
94 /// Return minimized -log(L) value.
95 inline double minNll() const {
96 return _minNLL ;
97 }
98 /// Return list of constant parameters.
99 inline const RooArgList& constPars() const {
100 return *_constPars ;
101 }
102 /// Return list of floating parameters before fit.
103 inline const RooArgList& floatParsInit() const {
104 return *_initPars ;
105 }
106 /// Return list of floating parameters after fit.
107 inline const RooArgList& floatParsFinal() const {
108 return *_finalPars ;
109 }
110
111 TH2* correlationHist(const char* name = "correlation_matrix") const ;
112
113 /// Return correlation between par1 and par2.
114 double correlation(const RooAbsArg& par1, const RooAbsArg& par2) const {
115 return correlation(par1.GetName(),par2.GetName()) ;
116 }
117 /// Return pointer to list of correlations of all parameters with par.
118 const RooArgList* correlation(const RooAbsArg& par) const {
119 return correlation(par.GetName()) ;
120 }
121
122 double correlation(const char* parname1, const char* parname2) const ;
123 const RooArgList* correlation(const char* parname) const ;
124
125
126 const TMatrixDSym& covarianceMatrix() const ;
127 const TMatrixDSym& correlationMatrix() const ;
128 TMatrixDSym reducedCovarianceMatrix(const RooArgList& params) const ;
130
131
132 // Global correlation accessors
133 double globalCorr(const RooAbsArg& par) { return globalCorr(par.GetName()) ; }
134 double globalCorr(const char* parname) ;
135 const RooArgList* globalCorr() ;
136
137
138 /// Add objects to a 2D plot.
139 /// Plot error ellipse in par1 and par2 on frame.
140 inline RooPlot *plotOn(RooPlot *frame, const RooAbsArg &par1, const RooAbsArg &par2,
141 const char *options= "ME") const {
142 return plotOn(frame,par1.GetName(),par2.GetName(),options);
143 }
144 RooPlot *plotOn(RooPlot *plot, const char *parName1, const char *parName2,
145 const char *options= "ME") const;
146
147 /// Generate random perturbations of the final parameters using the covariance matrix.
148 const RooArgList& randomizePars() const;
149
150 bool isIdenticalNoCov(const RooFitResult& other, double tol=1e-6, double tolErr=1e-3, bool verbose=true) const ;
151 bool isIdentical(const RooFitResult& other, double tol=1e-6, double tolCorr=1e-4, bool verbose=true) const ;
152
153 void SetName(const char *name) override ;
154 void SetNameTitle(const char *name, const char* title) override ;
155
156
157
159 void setConstParList(const RooArgList& list) ;
160 void setInitParList(const RooArgList& list) ;
161 void setFinalParList(const RooArgList& list) ;
162 inline void setMinNLL(double val) { _minNLL = val ; }
163 inline void setEDM(double val) { _edm = val ; }
164 inline void setStatus(Int_t val) { _status = val ; }
165 inline void setCovQual(Int_t val) { _covQual = val ; }
166 inline void setNumInvalidNLL(Int_t val) { _numBadNLL=val ; }
167 void setStatusHistory(std::vector<std::pair<std::string,int> >& hist) { _statusHistory = hist ; }
168 void fillCorrMatrix(const std::vector<double>& globalCC, const TMatrixDSym& corrs, const TMatrixDSym& covs) ;
169
170protected:
171
172 void fillLegacyCorrMatrix() const ;
174 double correlation(Int_t row, Int_t col) const;
175 double covariance(Int_t row, Int_t col) const;
176
177 Int_t _status ; ///< MINUIT status code
178 Int_t _covQual ; ///< MINUIT quality code of covariance matrix
179 Int_t _numBadNLL ; ///< Number calls with bad (zero,negative) likelihood
180 double _minNLL ; ///< NLL at minimum
181 double _edm ; ///< Estimated distance to minimum
182 RooArgList* _constPars = nullptr; ///< List of constant parameters
183 RooArgList* _initPars = nullptr; ///< List of floating parameters with initial values
184 RooArgList* _finalPars = nullptr; ///< List of floating parameters with final values
185
186 mutable std::unique_ptr<RooArgList> _globalCorr; ///<! List of global correlation coefficients
187 mutable TList _corrMatrix ; ///<! Correlation matrix (list of RooArgLists)
188
189 mutable std::unique_ptr<RooArgList>
190 _randomPars; ///<! List of floating parameters with most recent random perturbation applied
191 mutable std::unique_ptr<TMatrixF> _Lt; ///<! triangular matrix used for generate random perturbations
192
193 TMatrixDSym* _CM = nullptr; ///< Correlation matrix
194 TMatrixDSym* _VM = nullptr; ///< Covariance matrix
195 TVectorD* _GC = nullptr; ///< Global correlation coefficients
196
197 std::vector<std::pair<std::string,int> > _statusHistory ; ///< History of status codes
198
199 ClassDefOverride(RooFitResult,5) // Container class for fit result
200};
201
202#endif
#define e(i)
Definition RSha256.hxx:103
const char Option_t
Option string (const char)
Definition RtypesCore.h:80
#define ClassDefOverride(name, id)
Definition Rtypes.h:348
static void indent(ostringstream &buf, int indent_level)
winID h TVirtualViewer3D TVirtualGLPainter char TVirtualGLPainter plot
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t r
char name[80]
Definition TGX11.cxx:110
Common abstract base class for objects that represent a value and a "shape" in RooFit.
Definition RooAbsArg.h:76
Abstract interface for all probability density functions.
Definition RooAbsPdf.h:32
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:24
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.
TMatrixDSym conditionalCovarianceMatrix(const RooArgList &params) const
Return a reduced covariance matrix, which is calculated as.
void setCovQual(Int_t val)
void setMinNLL(double val)
double correlation(const RooAbsArg &par1, const RooAbsArg &par2) const
Return correlation between par1 and par2.
void setNumInvalidNLL(Int_t val)
std::unique_ptr< RooArgList > _randomPars
! List of floating parameters with most recent random perturbation applied
~RooFitResult() override
Destructor.
TList _corrMatrix
! Correlation matrix (list of RooArgLists)
std::vector< std::pair< std::string, int > > _statusHistory
History of status codes.
const TMatrixDSym & covarianceMatrix() const
Return covariance matrix.
void setStatus(Int_t val)
TMatrixDSym * _CM
Correlation matrix.
bool isIdentical(const RooFitResult &other, double tol=1e-6, double tolCorr=1e-4, bool verbose=true) const
Return true if this fit result is identical to other within tolerances.
void setConstParList(const RooArgList &list)
Fill the list of constant parameters.
Int_t statusCodeHistory(UInt_t icycle) const
void fillCorrMatrix(const std::vector< double > &globalCC, const TMatrixDSym &corrs, const TMatrixDSym &covs)
Function called by RooMinimizer.
double _minNLL
NLL at minimum.
Int_t _numBadNLL
Number calls with bad (zero,negative) likelihood.
TMatrixDSym * _VM
Covariance matrix.
void SetNameTitle(const char *name, const char *title) override
Change name and title of RooFitResult object.
Int_t defaultPrintContents(Option_t *opt) const override
Configure default contents to be printed.
void printClassName(std::ostream &os) const override
Print class name of fit result.
const RooArgList & floatParsInit() const
Return list of floating parameters before fit.
RooArgList * _initPars
List of floating parameters with initial values.
RooFitResult(const char *name=nullptr, const char *title=nullptr)
Constructor with name and title.
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...
Int_t _covQual
MINUIT quality code of covariance matrix.
void fillPrefitCorrMatrix()
RooArgList * _constPars
List of constant parameters.
const RooArgList * correlation(const RooAbsArg &par) const
Return pointer to list of correlations of all parameters with par.
const RooArgList & randomizePars() const
Generate random perturbations of the final parameters using the covariance matrix.
std::unique_ptr< TMatrixF > _Lt
! triangular matrix used for generate random perturbations
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 ;.
void setStatusHistory(std::vector< std::pair< std::string, int > > &hist)
RooArgList * _finalPars
List of floating parameters with final values.
double edm() const
Return estimated distance to minimum.
const RooArgList & constPars() const
Return list of constant parameters.
virtual TObject * clone() const
Int_t _status
MINUIT status code.
bool isIdenticalNoCov(const RooFitResult &other, double tol=1e-6, double tolErr=1e-3, bool verbose=true) const
Return true if this fit result is identical to other within tolerances, ignoring the correlation matr...
void SetName(const char *name) override
Change name of RooFitResult object.
std::unique_ptr< RooArgList > _globalCorr
! List of global correlation coefficients
const char * statusLabelHistory(UInt_t icycle) const
TObject * Clone(const char *newname=nullptr) const override
Make a clone of an object using the Streamer facility.
void Print(Option_t *options=nullptr) const override
This method must be overridden when a class wants to print itself.
void printValue(std::ostream &os) const override
Print the value of the fit result, i.e.g the status, minimized FCN, edm and covariance quality code.
Int_t numInvalidNLL() const
Return number of NLL evaluations with problems.
void printTitle(std::ostream &os) const override
Print title of fit result.
Int_t covQual() const
Return MINUIT quality code of covariance matrix.
double globalCorr(const RooAbsArg &par)
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.
StyleOption defaultPrintStyle(Option_t *opt) const override
Configure mapping of Print() arguments to RooPrintable print styles.
double covariance(Int_t row, Int_t col) const
Return the covariance matrix element addressed with numeric indices.
const RooArgList & floatParsFinal() const
Return list of floating parameters after fit.
Int_t status() const
Return MINUIT status code.
void setEDM(double val)
void printMultiline(std::ostream &os, Int_t contents, bool verbose=false, TString indent="") const override
Print fit result to stream 'os'.
TVectorD * _GC
Global correlation coefficients.
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...
double _edm
Estimated distance to minimum.
void setFinalParList(const RooArgList &list)
Fill the list of final values of the floating parameters.
void printArgs(std::ostream &os) const override
Print arguments of fit result, i.e. the parameters of the fit.
UInt_t numStatusHistory() const
void printName(std::ostream &os) const override
Print name of fit result.
const TMatrixDSym & correlationMatrix() const
Return correlation matrix ;.
double minNll() const
Return minimized -log(L) value.
Plot frame and a container for graphics objects within that frame.
Definition RooPlot.h:43
A 'mix-in' base class that define the standard RooFit plotting and printing methods.
static std::ostream & defaultPrintStream(std::ostream *os=nullptr)
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:38
The TNamed class is the base class for all named ROOT classes.
Definition TNamed.h:29
const char * GetName() const override
Returns name of object.
Definition TNamed.h:49
Mother of all ROOT objects.
Definition TObject.h:41
Basic string class.
Definition TString.h:138