Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RooMinimizer.h
Go to the documentation of this file.
1/*****************************************************************************
2 * Project: RooFit *
3 * Package: RooFitCore *
4 * File: $Id$
5 * Authors: *
6 * WV, Wouter Verkerke, UC Santa Barbara, verkerke@slac.stanford.edu *
7 * DK, David Kirkby, UC Irvine, dkirkby@uci.edu *
8 * AL, Alfio Lazzaro, INFN Milan, alfio.lazzaro@mi.infn.it *
9 * *
10 * *
11 * Redistribution and use in source and binary forms, *
12 * with or without modification, are permitted according to the terms *
13 * listed in LICENSE (http://roofit.sourceforge.net/license.txt) *
14 *****************************************************************************/
15
16#ifndef __ROOFIT_NOROOMINIMIZER
17
18#ifndef ROO_MINIMIZER
19#define ROO_MINIMIZER
20
21#include "TObject.h"
22#include "TStopwatch.h"
23#include <fstream>
24#include <vector>
25#include <string>
26#include <utility>
27#include "TMatrixDSymfwd.h"
28
29#include "Fit/Fitter.h"
30#include "RooMinimizerFcn.h"
31
32class RooAbsReal ;
33class RooFitResult ;
34class RooArgList ;
35class RooRealVar ;
36class RooArgSet ;
37class TH2F ;
38class RooPlot ;
39
40class RooMinimizer : public TObject {
41public:
42
43 RooMinimizer(RooAbsReal& function) ;
44 virtual ~RooMinimizer() ;
45
46 enum Strategy { Speed=0, Balance=1, Robustness=2 } ;
48 void setStrategy(Int_t strat) ;
49 void setErrorLevel(Double_t level) ;
50 void setEps(Double_t eps) ;
51 void optimizeConst(Int_t flag) ;
53 /// \copydoc RooMinimizerFcn::SetRecoverFromNaNStrength()
54 void setRecoverFromNaNStrength(double strength) { fitterFcn()->SetRecoverFromNaNStrength(strength); }
55 void setOffsetting(Bool_t flag) ;
58
59 RooFitResult* fit(const char* options) ;
60
61 Int_t migrad() ;
62 Int_t hesse() ;
63 Int_t minos() ;
64 Int_t minos(const RooArgSet& minosParamList) ;
65 Int_t seek() ;
66 Int_t simplex() ;
67 Int_t improve() ;
68
69 Int_t minimize(const char* type, const char* alg=0) ;
70
71 RooFitResult* save(const char* name=0, const char* title=0) ;
72 RooPlot* contour(RooRealVar& var1, RooRealVar& var2,
73 Double_t n1=1, Double_t n2=2, Double_t n3=0,
74 Double_t n4=0, Double_t n5=0, Double_t n6=0, unsigned int npoints = 50) ;
75
76 Int_t setPrintLevel(Int_t newLevel) ;
77 void setPrintEvalErrors(Int_t numEvalErrors) { fitterFcn()->SetPrintEvalErrors(numEvalErrors); }
78 void setVerbose(Bool_t flag=kTRUE) { _verbose = flag ; fitterFcn()->SetVerbose(flag); }
79 void setProfile(Bool_t flag=kTRUE) { _profile = flag ; }
80 Bool_t setLogFile(const char* logf=0) { return fitterFcn()->SetLogFile(logf); }
81
82 void setMinimizerType(const char* type) ;
83
84 static void cleanup() ;
85 static RooFitResult* lastMinuitFit(const RooArgList& varList=RooArgList()) ;
86
87 void saveStatus(const char* label, Int_t status) { _statusHistory.push_back(std::pair<std::string,int>(label,status)) ; }
88
89 Int_t evalCounter() const { return fitterFcn()->evalCounter() ; }
91
93 const ROOT::Fit::Fitter* fitter() const ;
94
95protected:
96
97 friend class RooAbsPdf ;
99
100 void profileStart() ;
101 void profileStop() ;
102
103 inline Int_t getNPar() const { return fitterFcn()->NDim() ; }
104 inline std::ofstream* logfile() { return fitterFcn()->GetLogFile(); }
105 inline Double_t& maxFCN() { return fitterFcn()->GetMaxFCN() ; }
106
107 const RooMinimizerFcn* fitterFcn() const { return ( fitter()->GetFCN() ? ((RooMinimizerFcn*) fitter()->GetFCN()) : _fcn ) ; }
108 RooMinimizerFcn* fitterFcn() { return ( fitter()->GetFCN() ? ((RooMinimizerFcn*) fitter()->GetFCN()) : _fcn ) ; }
109
110private:
111
117
122
124
126 std::string _minimizerType;
127
129
130 std::vector<std::pair<std::string,int> > _statusHistory ;
131
133
134 ClassDef(RooMinimizer,0) // RooFit interface to ROOT::Fit::Fitter
135} ;
136
137
138#endif
139
140#endif
double Double_t
Definition RtypesCore.h:59
const Bool_t kTRUE
Definition RtypesCore.h:91
#define ClassDef(name, id)
Definition Rtypes.h:325
char name[80]
Definition TGX11.cxx:110
int type
Definition TGX11.cxx:121
Fitter class, entry point for performing all type of fits.
Definition Fitter.h:77
RooAbsReal is the common abstract base class for objects that represent a real value and implements f...
Definition RooAbsReal.h:61
RooArgList is a container object that can hold multiple RooAbsArg objects.
Definition RooArgList.h:21
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition RooArgSet.h:29
RooFitResult is a container class to hold the input and output of a PDF fit to a dataset.
RooMinimizerFcn is an interface to the ROOT::Math::IBaseFunctionMultiDim, a function that ROOT's mini...
Bool_t SetLogFile(const char *inLogfile)
Change the file name for logging of a RooMinimizer of all MINUIT steppings through the parameter spac...
virtual unsigned int NDim() const
Retrieve the dimension of the function.
std::ofstream * GetLogFile()
Int_t evalCounter() const
void SetEvalErrorWall(Bool_t flag)
void SetRecoverFromNaNStrength(double strength)
Try to recover from invalid function values.
Double_t & GetMaxFCN()
void SetPrintEvalErrors(Int_t numEvalErrors)
void SetVerbose(Bool_t flag=kTRUE)
RooMinimizer is a wrapper class around ROOT::Fit:Fitter that provides a seamless interface between th...
void setRecoverFromNaNStrength(double strength)
Try to recover from invalid function values.
RooMinimizerFcn * _fcn
std::vector< std::pair< std::string, int > > _statusHistory
std::ofstream * logfile()
Int_t hesse()
Execute HESSE.
Double_t & maxFCN()
void setEvalErrorWall(Bool_t flag)
void setMaxIterations(Int_t n)
Change maximum number of MINUIT iterations (RooMinimizer default 500 * #parameters)
void zeroEvalCount()
RooFitResult * save(const char *name=0, const char *title=0)
Save and return a RooFitResult snapshot of current minimizer status.
void setMinimizerType(const char *type)
Choose the minimiser algorithm.
void saveStatus(const char *label, Int_t status)
Int_t improve()
Execute IMPROVE.
void profileStart()
Start profiling timer.
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, unsigned int npoints=50)
Create and draw a TH2 with the error contours in the parameters var1 and var2.
Int_t migrad()
Execute MIGRAD.
Int_t minimize(const char *type, const char *alg=0)
Minimise the function passed in the constructor.
void profileStop()
Stop profiling timer and report results of last session.
static RooFitResult * lastMinuitFit(const RooArgList &varList=RooArgList())
RooFitResult * fit(const char *options)
Parse traditional RooAbsPdf::fitTo driver options.
RooMinimizerFcn * fitterFcn()
void setOffsetting(Bool_t flag)
Enable internal likelihood offsetting for enhanced numeric precision.
TMatrixDSym * _extV
Int_t seek()
Execute SEEK.
Bool_t setLogFile(const char *logf=0)
void setProfile(Bool_t flag=kTRUE)
void setEps(Double_t eps)
Change MINUIT epsilon.
void setErrorLevel(Double_t level)
Set the level for MINUIT error analysis to the given value.
RooMinimizer(const RooMinimizer &)
static ROOT::Fit::Fitter * _theFitter
static void cleanup()
Cleanup method called by atexit handler installed by RooSentinel to delete all global heap objects wh...
Int_t setPrintLevel(Int_t newLevel)
Change the MINUIT internal printing level.
TStopwatch _timer
void setMaxFunctionCalls(Int_t n)
Change maximum number of likelihood function calss from MINUIT (RooMinimizer default 500 * #parameter...
Int_t evalCounter() const
Int_t minos()
Execute MINOS.
RooAbsReal * _func
void applyCovarianceMatrix(TMatrixDSym &V)
Apply results of given external covariance matrix.
void optimizeConst(Int_t flag)
If flag is true, perform constant term optimization on function being minimized.
Int_t simplex()
Execute SIMPLEX.
Bool_t _profileStart
const RooMinimizerFcn * fitterFcn() const
ROOT::Fit::Fitter * fitter()
Return underlying ROOT fitter object.
void setStrategy(Int_t strat)
Change MINUIT strategy to istrat.
std::string _minimizerType
void setPrintEvalErrors(Int_t numEvalErrors)
TStopwatch _cumulTimer
void setVerbose(Bool_t flag=kTRUE)
virtual ~RooMinimizer()
Destructor.
Int_t getNPar() const
A RooPlot is a plot frame and a container for graphics objects within that frame.
Definition RooPlot.h:44
RooRealVar represents a variable that can be changed from the outside.
Definition RooRealVar.h:39
2-D histogram with a float per channel (see TH1 documentation)}
Definition TH2.h:251
Mother of all ROOT objects.
Definition TObject.h:37
Stopwatch class.
Definition TStopwatch.h:28
const Int_t n
Definition legend1.C:16