ROOT  6.07/01
Reference Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 "Riosfwd.h"
20 #include "RooAbsArg.h"
21 #include "RooPrintable.h"
22 #include "RooDirItem.h"
23 #include "RooArgList.h"
24 
25 #include "RVersion.h"
26 #include "TMatrixFfwd.h"
27 #include "TMatrixDSym.h"
28 #include "TRootIOCtor.h"
29 
30 #include <vector>
31 #include <string>
32 #include <map>
33 
34 class RooArgSet ;
35 class RooAbsPdf ;
36 class RooPlot;
37 class TObject ;
38 class TH2 ;
39 typedef RooArgSet* pRooArgSet ;
40 
41 class RooFitResult : public TNamed, public RooPrintable, public RooDirItem {
42 public:
43 
44  // Constructors, assignment etc.
45  RooFitResult(const char* name=0, const char* title=0) ;
46  RooFitResult(const RooFitResult& other) ;
47  virtual TObject* Clone(const char* newname = 0) const {
48  RooFitResult* r = new RooFitResult(*this) ;
49  if (newname && *newname) r->SetName(newname) ;
50  return r ;
51  }
52  virtual TObject* clone() const { return new RooFitResult(*this); }
53  virtual ~RooFitResult() ;
54 
55  static RooFitResult* lastMinuitFit(const RooArgList& varList=RooArgList()) ;
56 
57  // Printing interface (human readable)
58  virtual void printValue(std::ostream& os) const ;
59  virtual void printName(std::ostream& os) const ;
60  virtual void printTitle(std::ostream& os) const ;
61  virtual void printClassName(std::ostream& os) const ;
62  virtual void printArgs(std::ostream& os) const ;
63  void printMultiline(std::ostream& os, Int_t contents, Bool_t verbose=kFALSE, TString indent="") const ;
64 
65  inline virtual void Print(Option_t *options= 0) const {
66  // Printing interface
68  }
69 
70  virtual Int_t defaultPrintContents(Option_t* opt) const ;
71  virtual StyleOption defaultPrintStyle(Option_t* opt) const ;
72 
73  RooAbsPdf* createHessePdf(const RooArgSet& params) const ;
74 
75  // Accessors
76  inline Int_t status() const {
77  // Return MINUIT status code
78  return _status ;
79  }
80 
81  inline UInt_t numStatusHistory() const { return _statusHistory.size() ; }
82  Int_t statusCodeHistory(UInt_t icycle) const ;
83  const char* statusLabelHistory(UInt_t icycle) const ;
84 
85  inline Int_t covQual() const {
86  // Return MINUIT quality code of covariance matrix
87  return _covQual ;
88  }
89  inline Int_t numInvalidNLL() const {
90  // Return number of NLL evaluations with problems
91  return _numBadNLL ;
92  }
93  inline Double_t edm() const {
94  // Return estimated distance to minimum
95  return _edm ;
96  }
97  inline Double_t minNll() const {
98  // Return minimized -log(L) value
99  return _minNLL ;
100  }
101  inline const RooArgList& constPars() const {
102  // Return list of constant parameters
103  return *_constPars ;
104  }
105  inline const RooArgList& floatParsInit() const {
106  // Return list of floating parameters before fit
107  return *_initPars ;
108  }
109  inline const RooArgList& floatParsFinal() const {
110  // Return list of floarting parameters after fit
111  return *_finalPars ;
112  }
113 
114  TH2* correlationHist(const char* name = "correlation_matrix") const ;
115 
117  // Return correlation between par1 and par2
118  return correlation(par1.GetName(),par2.GetName()) ;
119  }
120  const RooArgList* correlation(const RooAbsArg& par) const {
121  // Return pointer to list of correlations of all parameters with par
122  return correlation(par.GetName()) ;
123  }
124 
125  Double_t correlation(const char* parname1, const char* parname2) const ;
126  const RooArgList* correlation(const char* parname) const ;
127 
128 
129  const TMatrixDSym& covarianceMatrix() const ;
130  const TMatrixDSym& correlationMatrix() const ;
131  TMatrixDSym reducedCovarianceMatrix(const RooArgList& params) const ;
132  TMatrixDSym conditionalCovarianceMatrix(const RooArgList& params) const ;
133 
134 
135  // Global correlation accessors
136  Double_t globalCorr(const RooAbsArg& par) { return globalCorr(par.GetName()) ; }
137  Double_t globalCorr(const char* parname) ;
138  const RooArgList* globalCorr() ;
139 
140 
141  // Add objects to a 2D plot
142  inline RooPlot *plotOn(RooPlot *frame, const RooAbsArg &par1, const RooAbsArg &par2,
143  const char *options= "ME") const {
144  // Plot error ellipse in par1 and par2 on frame
145  return plotOn(frame,par1.GetName(),par2.GetName(),options);
146  }
147  RooPlot *plotOn(RooPlot *plot, const char *parName1, const char *parName2,
148  const char *options= "ME") const;
149 
150  // Generate random perturbations of the final parameters using the covariance matrix
151  const RooArgList& randomizePars() const;
152 
153  Bool_t isIdentical(const RooFitResult& other, Double_t tol=5e-5, Double_t tolCorr=1e-4, Bool_t verbose=kTRUE) const ;
154 
155  void SetName(const char *name) ;
156  void SetNameTitle(const char *name, const char* title) ;
157 
158 protected:
159 
160  friend class RooMinuit ;
161  friend class RooMinimizer ;
162  void setCovarianceMatrix(TMatrixDSym& V) ;
163  void setConstParList(const RooArgList& list) ;
164  void setInitParList(const RooArgList& list) ;
165  void setFinalParList(const RooArgList& list) ;
166  inline void setMinNLL(Double_t val) { _minNLL = val ; }
167  inline void setEDM(Double_t val) { _edm = val ; }
168  inline void setStatus(Int_t val) { _status = val ; }
169  inline void setCovQual(Int_t val) { _covQual = val ; }
170  inline void setNumInvalidNLL(Int_t val) { _numBadNLL=val ; }
171  void fillCorrMatrix() ;
172  void fillCorrMatrix(const std::vector<double>& globalCC, const TMatrixDSym& corrs, const TMatrixDSym& covs) ;
173  void fillLegacyCorrMatrix() const ;
174  void setStatusHistory(std::vector<std::pair<std::string,int> >& hist) { _statusHistory = hist ; }
175 
176  Double_t correlation(Int_t row, Int_t col) const;
177  Double_t covariance(Int_t row, Int_t col) const;
178 
179  Int_t _status ; // MINUIT status code
180  Int_t _covQual ; // MINUIT quality code of covariance matrix
181  Int_t _numBadNLL ; // Number calls with bad (zero,negative) likelihood
182  Double_t _minNLL ; // NLL at minimum
183  Double_t _edm ; // Estimated distance to minimum
184  RooArgList* _constPars ; // List of constant parameters
185  RooArgList* _initPars ; // List of floating parameters with initial values
186  RooArgList* _finalPars ; // List of floating parameters with final values
187 
188  mutable RooArgList* _globalCorr ; //! List of global correlation coefficients
189  mutable TList _corrMatrix ; //! Correlation matrix (list of RooArgLists)
190 
191  mutable RooArgList *_randomPars; //! List of floating parameters with most recent random perturbation applied
192  mutable TMatrixF* _Lt; //! triangular matrix used for generate random perturbations
193 
194  TMatrixDSym* _CM ; // Correlation matrix
195  TMatrixDSym* _VM ; // Covariance matrix
196  TVectorD* _GC ; // Global correlation coefficients
197 
198  std::vector<std::pair<std::string,int> > _statusHistory ; // History of status codes
199 
200  ClassDef(RooFitResult,5) // Container class for fit result
201 };
202 
203 #endif
Double_t globalCorr(const RooAbsArg &par)
Definition: RooFitResult.h:136
virtual void printArgs(std::ostream &os) const
Print arguments of fit result, i.e. the parameters of the fit.
virtual void Print(Option_t *options=0) const
Print TNamed name and title.
Definition: RooFitResult.h:65
tuple row
Definition: mrt.py:26
tuple par1
Definition: multifit.py:48
double par[1]
Definition: unuranDistr.cxx:38
Double_t covariance(Int_t row, Int_t col) const
Return the covariance matrix element addressed with numeric indices.
Double_t _minNLL
Definition: RooFitResult.h:182
RooPlot * plotOn(RooPlot *frame, const RooAbsArg &par1, const RooAbsArg &par2, const char *options="ME") const
Definition: RooFitResult.h:142
virtual TObject * Clone(const char *newname=0) const
Make a clone of an object using the Streamer facility.
Definition: RooFitResult.h:47
const RooArgList & floatParsFinal() const
Definition: RooFitResult.h:109
const RooArgList & constPars() const
Definition: RooFitResult.h:101
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, which is interpreted as an OR of 'enum ContentsOptions' values and in the style given by 'enum StyleOption'.
void setStatusHistory(std::vector< std::pair< std::string, int > > &hist)
Definition: RooFitResult.h:174
const char Option_t
Definition: RtypesCore.h:62
Double_t _edm
Definition: RooFitResult.h:183
TMatrixDSym * _VM
Definition: RooFitResult.h:195
virtual void printTitle(std::ostream &os) const
Print title of fit result.
void SetNameTitle(const char *name, const char *title)
Change name and title of RooFitResult object.
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 setNumInvalidNLL(Int_t val)
Definition: RooFitResult.h:170
void setStatus(Int_t val)
Definition: RooFitResult.h:168
TMatrixDSym conditionalCovarianceMatrix(const RooArgList &params) const
Return a reduced covariance matrix, which is calculated as ___ -1 Vred = V22 = V11 - V12 * V22 * V21...
TH2 * correlationHist(const char *name="correlation_matrix") const
Return TH2D of correlation matrix.
Basic string class.
Definition: TString.h:137
RooArgList * _globalCorr
Definition: RooFitResult.h:188
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
const Bool_t kFALSE
Definition: Rtypes.h:92
const RooArgList * correlation(const RooAbsArg &par) const
Definition: RooFitResult.h:120
void setInitParList(const RooArgList &list)
Fill the list of initial values of the floating parameters.
TVectorD * _GC
Definition: RooFitResult.h:196
void setEDM(Double_t val)
Definition: RooFitResult.h:167
void plot(TString fname="data.root", TString var0="var0", TString var1="var1")
Definition: createData.C:17
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...
#define ClassDef(name, id)
Definition: Rtypes.h:254
RooPlotable is a 'mix-in' base class that define the standard RooFit plotting and printing methods...
Definition: RooPrintable.h:26
The TNamed class is the base class for all named ROOT classes.
Definition: TNamed.h:33
const RooArgList & randomizePars() const
Return a list of floating parameter values that are perturbed from the final fit values by random amo...
Bool_t isIdentical(const RooFitResult &other, Double_t tol=5e-5, Double_t tolCorr=1e-4, Bool_t verbose=kTRUE) const
Return true if this fit result is identical to other within tolerance 'tol' on fitted values and tole...
void printMultiline(std::ostream &os, Int_t contents, Bool_t verbose=kFALSE, TString indent="") const
Print fit result to stream 'os'.
RooArgList * _finalPars
Definition: RooFitResult.h:186
Double_t correlation(const RooAbsArg &par1, const RooAbsArg &par2) const
Definition: RooFitResult.h:116
A doubly linked list.
Definition: TList.h:47
void setMinNLL(Double_t val)
Definition: RooFitResult.h:166
TList _corrMatrix
List of global correlation coefficients.
Definition: RooFitResult.h:189
TMatrixDSym * _CM
triangular matrix used for generate random perturbations
Definition: RooFitResult.h:194
const double tol
Int_t statusCodeHistory(UInt_t icycle) const
ROOT::R::TRInterface & r
Definition: Object.C:4
Service class for 2-Dim histogram classes.
Definition: TH2.h:36
TPaveLabel title(3, 27.1, 15, 28.7,"ROOT Environment and Tools")
static RooFitResult * lastMinuitFit(const RooArgList &varList=RooArgList())
Import the results of the last fit performed by gMinuit, interpreting the fit parameters as the given...
unsigned int UInt_t
Definition: RtypesCore.h:42
bool verbose
virtual ~RooFitResult()
Destructor.
void setFinalParList(const RooArgList &list)
Fill the list of final values of the floating parameters.
virtual TObject * clone() const
Definition: RooFitResult.h:52
const TMatrixDSym & covarianceMatrix() const
Return covariance matrix.
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:51
RooFitResult(const char *name=0, const char *title=0)
Constructor with name and title coverity[UNINIT_CTOR].
static void indent(ostringstream &buf, int indent_level)
TMatrixF * _Lt
List of floating parameters with most recent random perturbation applied.
Definition: RooFitResult.h:192
void SetName(const char *name)
Change name of RooFitResult object.
RooArgList * _initPars
Definition: RooFitResult.h:185
A RooPlot is a plot frame and a container for graphics objects within that frame. ...
Definition: RooPlot.h:41
Int_t numInvalidNLL() const
Definition: RooFitResult.h:89
static std::ostream & defaultPrintStream(std::ostream *os=0)
Return a reference to the current default stream to use in Print().
RooArgList * _randomPars
Correlation matrix (list of RooArgLists)
Definition: RooFitResult.h:191
void setConstParList(const RooArgList &list)
Fill the list of constant parameters.
Int_t status() const
Definition: RooFitResult.h:76
double Double_t
Definition: RtypesCore.h:55
Double_t minNll() const
Definition: RooFitResult.h:97
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...
const RooArgList & floatParsInit() const
Definition: RooFitResult.h:105
RooDirItem is a utility base class for RooFit objects that are to be attached to ROOT directories...
Definition: RooDirItem.h:22
virtual void printName(std::ostream &os) const
Print name of fit result.
const char * statusLabelHistory(UInt_t icycle) const
tuple par2
Definition: multifit.py:49
virtual StyleOption defaultPrintStyle(Option_t *opt) const
Configure mapping of Print() arguments to RooPrintable print styles.
UInt_t numStatusHistory() const
Definition: RooFitResult.h:81
#define name(a, b)
Definition: linkTestLib0.cpp:5
Int_t covQual() const
Definition: RooFitResult.h:85
Mother of all ROOT objects.
Definition: TObject.h:58
RooAbsPdf is the abstract interface for all probability density functions The class provides hybrid a...
Definition: RooAbsPdf.h:41
RooArgList * _constPars
Definition: RooFitResult.h:184
RooMinimizer is a wrapper class around ROOT::Fit:Fitter that provides a seamless interface between th...
Definition: RooMinimizer.h:38
const RooArgList * globalCorr()
Return the list of all global correlations.
void setCovQual(Int_t val)
Definition: RooFitResult.h:169
RooArgSet * pRooArgSet
Definition: RooFitResult.h:38
RooAbsArg is the common abstract base class for objects that represent a value (of arbitrary type) an...
Definition: RooAbsArg.h:66
const TMatrixDSym & correlationMatrix() const
Return correlation matrix ;.
void fillCorrMatrix()
Internal utility method to extract the correlation matrix and the global correlation coefficients fro...
virtual void printClassName(std::ostream &os) const
Print class name of fit result.
Double_t edm() const
Definition: RooFitResult.h:93
const Bool_t kTRUE
Definition: Rtypes.h:91
Int_t _numBadNLL
Definition: RooFitResult.h:181
virtual Int_t defaultPrintContents(Option_t *opt) const
Configure default contents to be printed.
void setCovarianceMatrix(TMatrixDSym &V)
Store externally provided correlation matrix in this RooFitResult ;.
void fillLegacyCorrMatrix() const
Sanity check.
RooMinuit is a wrapper class around TFitter/TMinuit that provides a seamless interface between the MI...
Definition: RooMinuit.h:39
std::vector< std::pair< std::string, int > > _statusHistory
Definition: RooFitResult.h:198