Logo ROOT   master
Reference Guide
RooMinuit.h
Go to the documentation of this file.
1 /*****************************************************************************
2  * Project: RooFit *
3  * Package: RooFitCore *
4  * File: $Id: RooMinuit.h,v 1.15 2007/07/12 20:30:28 wouter 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_MINUIT
17 #define ROO_MINUIT
18 
19 #include "TObject.h"
20 #include "TStopwatch.h"
21 #include <fstream>
22 #include "TMatrixDSymfwd.h"
23 #include <vector>
24 #include <string>
25 
26 class RooAbsReal ;
27 class RooFitResult ;
28 class RooArgList ;
29 class RooRealVar ;
30 class RooArgSet ;
31 class RooAbsArg ;
32 class TVirtualFitter ;
33 class TH2F ;
34 class RooPlot ;
35 
36 void RooMinuitGlue(Int_t& /*np*/, Double_t* /*gin*/, Double_t &f, Double_t *par, Int_t /*flag*/) ;
37 
38 class RooMinuit : public TObject {
39 public:
40 
41  RooMinuit(RooAbsReal& function) ;
42  virtual ~RooMinuit() ;
43 
44  enum Strategy { Speed=0, Balance=1, Robustness=2 } ;
46  void setStrategy(Int_t strat) ;
47  void setErrorLevel(Double_t level) ;
48  void setEps(Double_t eps) ;
49  void optimizeConst(Int_t flag) ;
50  void setEvalErrorWall(Bool_t flag) { _doEvalErrorWall = flag ; }
51  void setOffsetting(Bool_t flag) ;
52 
53  RooFitResult* fit(const char* options) ;
54 
55  Int_t migrad() ;
56  Int_t hesse() ;
57  Int_t minos() ;
58  Int_t minos(const RooArgSet& minosParamList) ; // added FMV, 08/18/03
59  Int_t seek() ;
60  Int_t simplex() ;
61  Int_t improve() ;
62 
63  RooFitResult* save(const char* name=0, const char* title=0) ;
64  RooPlot* contour(RooRealVar& var1, RooRealVar& var2,
65  Double_t n1=1, Double_t n2=2, Double_t n3=0,
66  Double_t n4=0, Double_t n5=0, Double_t n6=0) ;
67 
68  Int_t setPrintLevel(Int_t newLevel) ;
69  void setNoWarn() ;
70  Int_t setWarnLevel(Int_t newLevel) ;
71  void setPrintEvalErrors(Int_t numEvalErrors) { _printEvalErrors = numEvalErrors ; }
72  void setVerbose(Bool_t flag=kTRUE) { _verbose = flag ; }
73  void setProfile(Bool_t flag=kTRUE) { _profile = flag ; }
75  Bool_t setLogFile(const char* logfile=0) ;
76 
77  static void cleanup() ;
78 
79  Int_t evalCounter() const { return _evalCounter ; }
80  void zeroEvalCount() { _evalCounter = 0 ; }
81 
82 protected:
83 
84  friend class RooAbsPdf ;
86 
87  friend void RooMinuitGlue(Int_t &np, Double_t *gin, Double_t &f, Double_t *par, Int_t flag) ;
88 
89  void profileStart() ;
90  void profileStop() ;
91 
93  void backProp() ;
94 
95  inline Int_t getNPar() const { return _nPar ; }
96  inline std::ofstream* logfile() const { return _logfile ; }
97  inline Double_t& maxFCN() { return _maxFCN ; }
98 
100  Double_t getPdfParamErr(Int_t index) ;
101  virtual Bool_t setPdfParamVal(Int_t index, Double_t value, Bool_t verbose=kFALSE) ;
102  void setPdfParamErr(Int_t index, Double_t value) ;
103  void setPdfParamErr(Int_t index, Double_t loVal, Double_t hiVal) ;
104  void clearPdfParamAsymErr(Int_t index) ;
105 
106  void saveStatus(const char* label, Int_t status) { _statusHistory.push_back(std::pair<std::string,int>(label,status)) ; }
107 
108  void updateFloatVec() ;
109 
110 private:
111 
125  std::vector<RooAbsArg*> _floatParamVec ;
130 
132  std::ofstream* _logfile ;
136 
138 
140 
141  std::vector<std::pair<std::string,int> > _statusHistory ;
142 
143  RooMinuit(const RooMinuit&) ;
144 
145  ClassDef(RooMinuit,0) // RooFit minimizer based on MINUIT
146 } ;
147 
148 
149 #endif
150 
static TVirtualFitter * _theFitter
Definition: RooMinuit.h:139
Int_t seek()
Execute SEEK.
Definition: RooMinuit.cxx:468
Bool_t _verbose
Definition: RooMinuit.h:133
void setPrintEvalErrors(Int_t numEvalErrors)
Definition: RooMinuit.h:71
RooPlot * contour(RooRealVar &var1, RooRealVar &var2, Double_t n1=1, Double_t n2=2, Double_t n3=0, Double_t n4=0, Double_t n5=0, Double_t n6=0)
Create and draw a TH2 with the error contours in parameters var1 and v2 at up to 6 &#39;sigma&#39; settings w...
Definition: RooMinuit.cxx:939
void setVerbose(Bool_t flag=kTRUE)
Definition: RooMinuit.h:72
Int_t simplex()
Execute SIMPLEX.
Definition: RooMinuit.cxx:501
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition: RooArgSet.h:28
Int_t hesse()
Execute HESSE.
Definition: RooMinuit.cxx:339
Int_t _printLevel
Definition: RooMinuit.h:113
Bool_t synchronize(Bool_t verbose)
Internal function to synchronize TMinuit with current information in RooAbsReal function parameters...
Definition: RooMinuit.cxx:617
Int_t evalCounter() const
Definition: RooMinuit.h:79
Int_t minos()
Execute MINOS.
Definition: RooMinuit.cxx:372
RooArgList * _initFloatParamList
Definition: RooMinuit.h:126
RooFitResult is a container class to hold the input and output of a PDF fit to a dataset.
Definition: RooFitResult.h:40
#define f(i)
Definition: RSha256.hxx:104
int Int_t
Definition: RtypesCore.h:43
bool Bool_t
Definition: RtypesCore.h:61
std::vector< std::pair< std::string, int > > _statusHistory
Definition: RooMinuit.h:141
void setEps(Double_t eps)
Change MINUIT epsilon.
Definition: RooMinuit.cxx:241
Int_t migrad()
Execute MIGRAD.
Definition: RooMinuit.cxx:305
void setStrategy(Int_t strat)
Change MINUIT strategy to istrat.
Definition: RooMinuit.cxx:217
std::vector< RooAbsArg * > _floatParamVec
Definition: RooMinuit.h:125
Double_t getPdfParamVal(Int_t index)
Access PDF parameter value by ordinal index (needed by MINUIT)
Definition: RooMinuit.cxx:1034
void profileStop()
Stop profiling timer and report results of last session.
Definition: RooMinuit.cxx:1116
RooAbsReal * _func
Definition: RooMinuit.h:129
void setEvalErrorWall(Bool_t flag)
Definition: RooMinuit.h:50
void updateFloatVec()
Definition: RooMinuit.cxx:1159
TStopwatch _timer
Definition: RooMinuit.h:134
void setErrorLevel(Double_t level)
Set the level for MINUIT error analysis to the given value.
Definition: RooMinuit.cxx:231
Int_t _numBadNLL
Definition: RooMinuit.h:119
Int_t _optConst
Definition: RooMinuit.h:116
RooArgList * _initConstParamList
Definition: RooMinuit.h:128
TStopwatch _cumulTimer
Definition: RooMinuit.h:135
void applyCovarianceMatrix(TMatrixDSym &V)
Apply results of given external covariance matrix.
Definition: RooMinuit.cxx:1178
#define ClassDef(name, id)
Definition: Rtypes.h:322
void setMaxEvalMultiplier(Int_t n)
Definition: RooMinuit.h:74
virtual Bool_t setPdfParamVal(Int_t index, Double_t value, Bool_t verbose=kFALSE)
Modify PDF parameter value by ordinal index (needed by MINUIT)
Definition: RooMinuit.cxx:1054
Int_t setPrintLevel(Int_t newLevel)
Change the MINUIT internal printing level.
Definition: RooMinuit.cxx:565
RooRealVar represents a variable that can be changed from the outside.
Definition: RooRealVar.h:35
Double_t getPdfParamErr(Int_t index)
Access PDF parameter error by ordinal index (needed by MINUIT)
Definition: RooMinuit.cxx:1044
Bool_t _doEvalErrorWall
Definition: RooMinuit.h:122
void setOffsetting(Bool_t flag)
Enable internal likelihood offsetting for enhanced numeric precision.
Definition: RooMinuit.cxx:251
Double_t _maxFCN
Definition: RooMinuit.h:131
void setProfile(Bool_t flag=kTRUE)
Definition: RooMinuit.h:73
2-D histogram with a float per channel (see TH1 documentation)}
Definition: TH2.h:251
Int_t _nPar
Definition: RooMinuit.h:120
void zeroEvalCount()
Definition: RooMinuit.h:80
static void cleanup()
Cleanup method called by atexit handler installed by RooSentinel to delete all global heap objects wh...
Definition: RooMinuit.cxx:83
RooArgList * _floatParamList
Definition: RooMinuit.h:124
virtual ~RooMinuit()
Destructor.
Definition: RooMinuit.cxx:198
Int_t setWarnLevel(Int_t newLevel)
Set MINUIT warning level to given level.
Definition: RooMinuit.cxx:591
RooMinuit(RooAbsReal &function)
Construct MINUIT interface to given function.
Definition: RooMinuit.cxx:105
Int_t getNPar() const
Definition: RooMinuit.h:95
void RooMinuitGlue(Int_t &, Double_t *, Double_t &f, Double_t *par, Int_t)
Definition: RooMinuit.cxx:1198
Int_t _evalCounter
Definition: RooMinuit.h:112
A RooPlot is a plot frame and a container for graphics objects within that frame. ...
Definition: RooPlot.h:44
const Bool_t kFALSE
Definition: RtypesCore.h:90
double Double_t
Definition: RtypesCore.h:57
Bool_t _profile
Definition: RooMinuit.h:117
RooAbsReal is the common abstract base class for objects that represent a real value and implements f...
Definition: RooAbsReal.h:60
TMatrixDSym * _extV
Definition: RooMinuit.h:137
RooFitResult * save(const char *name=0, const char *title=0)
Save and return a RooFitResult snaphot of current minimizer status.
Definition: RooMinuit.cxx:873
Int_t _maxEvalMult
Definition: RooMinuit.h:123
void clearPdfParamAsymErr(Int_t index)
Modify PDF parameter error by ordinal index (needed by MINUIT)
Definition: RooMinuit.cxx:1083
friend void RooMinuitGlue(Int_t &np, Double_t *gin, Double_t &f, Double_t *par, Int_t flag)
Definition: RooMinuit.cxx:1198
Int_t _status
Definition: RooMinuit.h:115
Double_t & maxFCN()
Definition: RooMinuit.h:97
Abstract Base Class for Fitting.
Int_t _warnLevel
Definition: RooMinuit.h:114
Mother of all ROOT objects.
Definition: TObject.h:37
RooFitResult * fit(const char *options)
Parse traditional RooAbsPdf::fitTo driver options.
Definition: RooMinuit.cxx:269
void profileStart()
Start profiling timer.
Definition: RooMinuit.cxx:1102
Int_t _printEvalErrors
Definition: RooMinuit.h:121
RooAbsPdf, the base class of all PDFs
Definition: RooAbsPdf.h:40
void setPdfParamErr(Int_t index, Double_t value)
Modify PDF parameter error by ordinal index (needed by MINUIT)
Definition: RooMinuit.cxx:1073
void saveStatus(const char *label, Int_t status)
Definition: RooMinuit.h:106
RooArgList is a container object that can hold multiple RooAbsArg objects.
Definition: RooArgList.h:21
Bool_t setLogFile(const char *logfile=0)
Change the file name for logging of a RooMinuit of all MINUIT steppings through the parameter space...
Definition: RooMinuit.cxx:1011
void setNoWarn()
Instruct MINUIT to suppress warnings.
Definition: RooMinuit.cxx:579
RooAbsArg is the common abstract base class for objects that represent a value (of arbitrary type) an...
Definition: RooAbsArg.h:73
void backProp()
Transfer MINUIT fit results back into RooFit objects.
Definition: RooMinuit.cxx:1133
std::ofstream * _logfile
Definition: RooMinuit.h:132
Int_t improve()
Execute IMPROVE.
Definition: RooMinuit.cxx:535
const Bool_t kTRUE
Definition: RtypesCore.h:89
Bool_t _handleLocalErrors
Definition: RooMinuit.h:118
const Int_t n
Definition: legend1.C:16
char name[80]
Definition: TGX11.cxx:109
RooArgList * _constParamList
Definition: RooMinuit.h:127
std::ofstream * logfile() const
Definition: RooMinuit.h:96
RooMinuit is a wrapper class around TFitter/TMinuit that provides a seamless interface between the MI...
Definition: RooMinuit.h:38
void optimizeConst(Int_t flag)
If flag is true, perform constant term optimization on function being minimized.
Definition: RooMinuit.cxx:841
Stopwatch class.
Definition: TStopwatch.h:28