ROOT  6.06/09
Reference Guide
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 "TMatrixDSymfwd.h"
25 
26 
27 #include "Fit/Fitter.h"
28 #include "RooMinimizerFcn.h"
29 
30 class RooAbsReal ;
31 class RooFitResult ;
32 class RooArgList ;
33 class RooRealVar ;
34 class RooArgSet ;
35 class TH2F ;
36 class RooPlot ;
37 
38 class RooMinimizer : public TObject {
39 public:
40 
41  RooMinimizer(RooAbsReal& function) ;
42  virtual ~RooMinimizer() ;
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) ;
51  void setOffsetting(Bool_t flag) ;
52  void setMaxIterations(Int_t n) ;
53  void setMaxFunctionCalls(Int_t n) ;
54 
55  RooFitResult* fit(const char* options) ;
56 
57  Int_t migrad() ;
58  Int_t hesse() ;
59  Int_t minos() ;
60  Int_t minos(const RooArgSet& minosParamList) ;
61  Int_t seek() ;
62  Int_t simplex() ;
63  Int_t improve() ;
64 
65  Int_t minimize(const char* type, const char* alg=0) ;
66 
67  RooFitResult* save(const char* name=0, const char* title=0) ;
68  RooPlot* contour(RooRealVar& var1, RooRealVar& var2,
69  Double_t n1=1, Double_t n2=2, Double_t n3=0,
70  Double_t n4=0, Double_t n5=0, Double_t n6=0) ;
71 
72  Int_t setPrintLevel(Int_t newLevel) ;
73  void setPrintEvalErrors(Int_t numEvalErrors) { fitterFcn()->SetPrintEvalErrors(numEvalErrors); }
74  void setVerbose(Bool_t flag=kTRUE) { _verbose = flag ; fitterFcn()->SetVerbose(flag); }
75  void setProfile(Bool_t flag=kTRUE) { _profile = flag ; }
76  Bool_t setLogFile(const char* logf=0) { return fitterFcn()->SetLogFile(logf); }
77 
78  void setMinimizerType(const char* type) ;
79 
80  static void cleanup() ;
81  static RooFitResult* lastMinuitFit(const RooArgList& varList=RooArgList()) ;
82 
83  void saveStatus(const char* label, Int_t status) { _statusHistory.push_back(std::pair<std::string,int>(label,status)) ; }
84 
85  Int_t evalCounter() const { return fitterFcn()->evalCounter() ; }
87 
89  const ROOT::Fit::Fitter* fitter() const ;
90 
91 protected:
92 
93  friend class RooAbsPdf ;
95 
96  void profileStart() ;
97  void profileStop() ;
98 
99  inline Int_t getNPar() const { return fitterFcn()->NDim() ; }
100  inline std::ofstream* logfile() { return fitterFcn()->GetLogFile(); }
101  inline Double_t& maxFCN() { return fitterFcn()->GetMaxFCN() ; }
102 
103  const RooMinimizerFcn* fitterFcn() const { return ( fitter()->GetFCN() ? ((RooMinimizerFcn*) fitter()->GetFCN()) : _fcn ) ; }
104  RooMinimizerFcn* fitterFcn() { return ( fitter()->GetFCN() ? ((RooMinimizerFcn*) fitter()->GetFCN()) : _fcn ) ; }
105 
106 private:
107 
113 
118 
120 
122  std::string _minimizerType;
123 
125 
126  std::vector<std::pair<std::string,int> > _statusHistory ;
127 
128  RooMinimizer(const RooMinimizer&) ;
129 
130  ClassDef(RooMinimizer,0) // RooFit interface to ROOT::Fit::Fitter
131 } ;
132 
133 
134 #endif
135 
136 #endif
std::string _minimizerType
Definition: RooMinimizer.h:122
Bool_t _verbose
Definition: RooMinimizer.h:114
TMatrixDSym * _extV
Definition: RooMinimizer.h:119
void optimizeConst(Int_t flag)
If flag is true, perform constant term optimization on function being minimized.
Int_t seek()
Execute SEEK.
void applyCovarianceMatrix(TMatrixDSym &V)
Apply results of given external covariance matrix.
virtual ~RooMinimizer()
Destructor.
std::ofstream * GetLogFile()
Bool_t SetLogFile(const char *inLogfile)
Int_t improve()
Execute IMPROVE.
TStopwatch _timer
Definition: RooMinimizer.h:115
TAlienJobStatus * status
Definition: TAlienJob.cxx:51
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
Int_t evalCounter() const
ROOT::Fit::Fitter * fitter()
Return underlying ROOT fitter object.
std::ofstream * logfile()
Definition: RooMinimizer.h:100
void setMinimizerType(const char *type)
Choose the minimzer algorithm.
void setEps(Double_t eps)
Change MINUIT epsilon.
void setStrategy(Int_t strat)
Change MINUIT strategy to istrat.
virtual unsigned int NDim() const
Retrieve the dimension of the function.
void setVerbose(Bool_t flag=kTRUE)
Definition: RooMinimizer.h:74
Int_t simplex()
Execute SIMPLEX.
Int_t getNPar() const
Definition: RooMinimizer.h:99
#define ClassDef(name, id)
Definition: Rtypes.h:254
void SetVerbose(Bool_t flag=kTRUE)
void zeroEvalCount()
Definition: RooMinimizer.h:86
RooMinimizer(RooAbsReal &function)
Construct MINUIT interface to given function.
void SetEvalErrorWall(Bool_t flag)
Bool_t setLogFile(const char *logf=0)
Definition: RooMinimizer.h:76
void setMaxIterations(Int_t n)
Change maximum number of MINUIT iterations (RooMinimizer default 500 * #parameters) ...
Int_t _printLevel
Definition: RooMinimizer.h:108
void saveStatus(const char *label, Int_t status)
Definition: RooMinimizer.h:83
void setMaxFunctionCalls(Int_t n)
Change maximum number of likelihood function calss from MINUIT (RooMinimizer default 500 * #parameter...
Bool_t _profile
Definition: RooMinimizer.h:111
Int_t evalCounter() const
Definition: RooMinimizer.h:85
RooFitResult * save(const char *name=0, const char *title=0)
Save and return a RooFitResult snaphot of current minimizer status.
Bool_t _optConst
Definition: RooMinimizer.h:110
Fitter class, entry point for performing all type of fits.
Definition: Fitter.h:94
2-D histogram with a float per channel (see TH1 documentation)}
Definition: TH2.h:256
Int_t migrad()
Execute MIGRAD.
RooMinimizerFcn * _fcn
Definition: RooMinimizer.h:121
std::vector< std::pair< std::string, int > > _statusHistory
Definition: RooMinimizer.h:126
void setPrintEvalErrors(Int_t numEvalErrors)
Definition: RooMinimizer.h:73
void SetPrintEvalErrors(Int_t numEvalErrors)
void setEvalErrorWall(Bool_t flag)
Definition: RooMinimizer.h:50
double Double_t
Definition: RtypesCore.h:55
RooAbsReal is the common abstract base class for objects that represent a real value and implements f...
Definition: RooAbsReal.h:53
const RooMinimizerFcn * fitterFcn() const
Definition: RooMinimizer.h:103
Int_t minos()
Execute MINOS.
RooAbsReal * _func
Definition: RooMinimizer.h:112
void setErrorLevel(Double_t level)
Set the level for MINUIT error analysis to the given value.
int type
Definition: TGX11.cxx:120
Double_t & GetMaxFCN()
Int_t minimize(const char *type, const char *alg=0)
#define name(a, b)
Definition: linkTestLib0.cpp:5
void profileStop()
Stop profiling timer and report results of last session.
Mother of all ROOT objects.
Definition: TObject.h:58
Int_t setPrintLevel(Int_t newLevel)
Change the MINUIT internal printing level.
TStopwatch _cumulTimer
Definition: RooMinimizer.h:116
Int_t hesse()
Execute HESSE.
void setProfile(Bool_t flag=kTRUE)
Definition: RooMinimizer.h:75
RooAbsPdf is the abstract interface for all probability density functions The class provides hybrid a...
Definition: RooAbsPdf.h:41
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 'sigma' settings w...
static void cleanup()
Cleanup method called by atexit handler installed by RooSentinel to delete all global heap objects wh...
static ROOT::Fit::Fitter * _theFitter
Definition: RooMinimizer.h:124
RooMinimizerFcn * fitterFcn()
Definition: RooMinimizer.h:104
void setOffsetting(Bool_t flag)
Enable internal likelihood offsetting for enhanced numeric precision.
const Bool_t kTRUE
Definition: Rtypes.h:91
RooFitResult * fit(const char *options)
Parse traditional RooAbsPdf::fitTo driver options.
static RooFitResult * lastMinuitFit(const RooArgList &varList=RooArgList())
void profileStart()
Start profiling timer.
const Int_t n
Definition: legend1.C:16
Bool_t _profileStart
Definition: RooMinimizer.h:117
Double_t & maxFCN()
Definition: RooMinimizer.h:101
Stopwatch class.
Definition: TStopwatch.h:30