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