Logo ROOT  
Reference Guide
RooMinimizerFcn.h
Go to the documentation of this file.
1 /*****************************************************************************
2  * Project: RooFit *
3  * Package: RooFitCore *
4  * @(#)root/roofitcore:$Id$
5  * Authors: *
6  * AL, Alfio Lazzaro, INFN Milan, alfio.lazzaro@mi.infn.it *
7  * *
8  * *
9  * Redistribution and use in source and binary forms, *
10  * with or without modification, are permitted according to the terms *
11  * listed in LICENSE (http://roofit.sourceforge.net/license.txt) *
12  *****************************************************************************/
13 
14 #ifndef __ROOFIT_NOROOMINIMIZER
15 
16 #ifndef ROO_MINIMIZER_FCN
17 #define ROO_MINIMIZER_FCN
18 
19 #include "Math/IFunction.h"
20 #include "Fit/ParameterSettings.h"
21 #include "Fit/FitResult.h"
22 
23 #include "RooAbsReal.h"
24 #include "RooArgList.h"
25 
26 #include <fstream>
27 #include <vector>
28 
29 class RooMinimizer;
30 template<typename T> class TMatrixTSym;
32 
34 
35  public:
36 
37  RooMinimizerFcn(RooAbsReal *funct, RooMinimizer *context,
38  bool verbose = false);
39  RooMinimizerFcn(const RooMinimizerFcn& other);
40  virtual ~RooMinimizerFcn();
41 
43  virtual unsigned int NDim() const { return _nDim; }
44 
49 
50  void SetEvalErrorWall(Bool_t flag) { _doEvalErrorWall = flag ; }
51  /// Try to recover from invalid function values. When invalid function values are encountered,
52  /// a penalty term is returned to the minimiser to make it back off. This sets the strength of this penalty.
53  /// \note A strength of zero is equivalent to a constant penalty (= the gradient vanishes, ROOT < 6.24).
54  /// Positive values lead to a gradient pointing away from the undefined regions. Use ~10 to force the minimiser
55  /// away from invalid function values.
56  void SetRecoverFromNaNStrength(double strength) { _recoverFromNaNStrength = strength; }
57  void SetPrintEvalErrors(Int_t numEvalErrors) { _printEvalErrors = numEvalErrors ; }
58  Bool_t SetLogFile(const char* inLogfile);
59  std::ofstream* GetLogFile() { return _logfile; }
60  void SetVerbose(Bool_t flag=kTRUE) { _verbose = flag ; }
61 
62  Double_t& GetMaxFCN() { return _maxFCN; }
63  Int_t GetNumInvalidNLL() const { return _numBadNLL; }
64 
65  Bool_t Synchronize(std::vector<ROOT::Fit::ParameterSettings>& parameters,
66  Bool_t optConst, Bool_t verbose);
67  void BackProp(const ROOT::Fit::FitResult &results);
69 
70  Int_t evalCounter() const { return _evalCounter ; }
71  void zeroEvalCount() { _evalCounter = 0 ; }
72  /// Return a possible offset that's applied to the function to separate invalid function values from valid ones.
73  double getOffset() const { return _funcOffset; }
74 
75  private:
76  void SetPdfParamErr(Int_t index, Double_t value);
77  void ClearPdfParamAsymErr(Int_t index);
78  void SetPdfParamErr(Int_t index, Double_t loVal, Double_t hiVal);
79 
80  Bool_t SetPdfParamVal(int index, double value) const;
81  void printEvalErrors() const;
82 
83  virtual double DoEval(const double * x) const;
84 
85 
88 
89  mutable double _maxFCN;
90  mutable double _funcOffset{0.};
92  mutable int _numBadNLL;
93  mutable int _printEvalErrors;
94  mutable int _evalCounter{0};
95  int _nDim;
96 
101 
102  std::ofstream *_logfile;
103  bool _doEvalErrorWall{true};
104  bool _verbose;
105 
106 };
107 
108 #endif
109 #endif
RooMinimizerFcn::SetPrintEvalErrors
void SetPrintEvalErrors(Int_t numEvalErrors)
Definition: RooMinimizerFcn.h:57
RooMinimizerFcn::_constParamList
RooArgList * _constParamList
Definition: RooMinimizerFcn.h:98
kTRUE
const Bool_t kTRUE
Definition: RtypesCore.h:91
RooAbsReal.h
RooMinimizerFcn::_doEvalErrorWall
bool _doEvalErrorWall
Definition: RooMinimizerFcn.h:103
RooMinimizerFcn::RooMinimizerFcn
RooMinimizerFcn(RooAbsReal *funct, RooMinimizer *context, bool verbose=false)
Definition: RooMinimizerFcn.cxx:41
IFunction.h
RooMinimizerFcn::_evalCounter
int _evalCounter
Definition: RooMinimizerFcn.h:94
RooMinimizerFcn::_recoverFromNaNStrength
double _recoverFromNaNStrength
Definition: RooMinimizerFcn.h:91
RooMinimizerFcn::SetLogFile
Bool_t SetLogFile(const char *inLogfile)
Change the file name for logging of a RooMinimizer of all MINUIT steppings through the parameter spac...
Definition: RooMinimizerFcn.cxx:414
RooMinimizerFcn::printEvalErrors
void printEvalErrors() const
Print information about why evaluation failed.
Definition: RooMinimizerFcn.cxx:467
RooMinimizerFcn::GetLogFile
std::ofstream * GetLogFile()
Definition: RooMinimizerFcn.h:59
RooArgList
RooArgList is a container object that can hold multiple RooAbsArg objects.
Definition: RooArgList.h:21
RooMinimizerFcn::GetFloatParamList
RooArgList * GetFloatParamList()
Definition: RooMinimizerFcn.h:45
RooMinimizerFcn::SetPdfParamErr
void SetPdfParamErr(Int_t index, Double_t value)
Modify PDF parameter error by ordinal index (needed by MINUIT)
Definition: RooMinimizerFcn.cxx:370
RooMinimizerFcn::_context
const RooMinimizer * _context
Definition: RooMinimizerFcn.h:87
x
Double_t x[n]
Definition: legend1.C:17
RooMinimizerFcn::_numBadNLL
int _numBadNLL
Definition: RooMinimizerFcn.h:92
RooAbsReal
RooAbsReal is the common abstract base class for objects that represent a real value and implements f...
Definition: RooAbsReal.h:61
RooMinimizerFcn::_initFloatParamList
RooArgList * _initFloatParamList
Definition: RooMinimizerFcn.h:99
TMatrixTSym
TMatrixTSym.
Definition: TMatrixTSym.h:34
RooMinimizerFcn::_nDim
int _nDim
Definition: RooMinimizerFcn.h:95
RooMinimizerFcn::~RooMinimizerFcn
virtual ~RooMinimizerFcn()
Definition: RooMinimizerFcn.cxx:111
RooMinimizerFcn::GetMaxFCN
Double_t & GetMaxFCN()
Definition: RooMinimizerFcn.h:62
RooMinimizerFcn::SetPdfParamVal
Bool_t SetPdfParamVal(int index, double value) const
Set value of parameter i.
Definition: RooMinimizerFcn.cxx:449
RooMinimizerFcn::BackProp
void BackProp(const ROOT::Fit::FitResult &results)
Transfer MINUIT fit results back into RooFit objects.
Definition: RooMinimizerFcn.cxx:388
RooMinimizerFcn::_maxFCN
double _maxFCN
Definition: RooMinimizerFcn.h:89
RooMinimizerFcn::_funcOffset
double _funcOffset
Definition: RooMinimizerFcn.h:90
bool
RooMinimizerFcn::GetInitFloatParamList
RooArgList * GetInitFloatParamList()
Definition: RooMinimizerFcn.h:47
RooMinimizerFcn
RooMinimizerFcn is an interface to the ROOT::Math::IBaseFunctionMultiDim, a function that ROOT's mini...
Definition: RooMinimizerFcn.h:33
RooMinimizerFcn::ApplyCovarianceMatrix
void ApplyCovarianceMatrix(TMatrixDSym &V)
Apply results of given external covariance matrix.
Definition: RooMinimizerFcn.cxx:436
RooMinimizerFcn::SetRecoverFromNaNStrength
void SetRecoverFromNaNStrength(double strength)
Try to recover from invalid function values.
Definition: RooMinimizerFcn.h:56
RooMinimizerFcn::Clone
virtual ROOT::Math::IBaseFunctionMultiDim * Clone() const
Clone a function.
Definition: RooMinimizerFcn.cxx:120
RooMinimizerFcn::getOffset
double getOffset() const
Return a possible offset that's applied to the function to separate invalid function values from vali...
Definition: RooMinimizerFcn.h:73
RooMinimizerFcn::_floatParamList
RooArgList * _floatParamList
Definition: RooMinimizerFcn.h:97
RooMinimizerFcn::_logfile
std::ofstream * _logfile
Definition: RooMinimizerFcn.h:102
RooMinimizerFcn::GetNumInvalidNLL
Int_t GetNumInvalidNLL() const
Definition: RooMinimizerFcn.h:63
RooMinimizerFcn::_funct
RooAbsReal * _funct
Definition: RooMinimizerFcn.h:86
RooMinimizerFcn::evalCounter
Int_t evalCounter() const
Definition: RooMinimizerFcn.h:70
ROOT::Fit::FitResult
class containg the result of the fit and all the related information (fitted parameter values,...
Definition: FitResult.h:47
RooMinimizerFcn::_initConstParamList
RooArgList * _initConstParamList
Definition: RooMinimizerFcn.h:100
RooMinimizerFcn::SetEvalErrorWall
void SetEvalErrorWall(Bool_t flag)
Definition: RooMinimizerFcn.h:50
RooMinimizerFcn::GetInitConstParamList
RooArgList * GetInitConstParamList()
Definition: RooMinimizerFcn.h:48
RooMinimizerFcn::ClearPdfParamAsymErr
void ClearPdfParamAsymErr(Int_t index)
Modify PDF parameter error by ordinal index (needed by MINUIT)
Definition: RooMinimizerFcn.cxx:376
RooMinimizerFcn::zeroEvalCount
void zeroEvalCount()
Definition: RooMinimizerFcn.h:71
RooMinimizerFcn::_verbose
bool _verbose
Definition: RooMinimizerFcn.h:104
RooMinimizerFcn::GetConstParamList
RooArgList * GetConstParamList()
Definition: RooMinimizerFcn.h:46
Double_t
double Double_t
Definition: RtypesCore.h:59
RooMinimizerFcn::Synchronize
Bool_t Synchronize(std::vector< ROOT::Fit::ParameterSettings > &parameters, Bool_t optConst, Bool_t verbose)
Internal function to synchronize TMinimizer with current information in RooAbsReal function parameter...
Definition: RooMinimizerFcn.cxx:128
RooMinimizerFcn::DoEval
virtual double DoEval(const double *x) const
Evaluate function given the parameters in x.
Definition: RooMinimizerFcn.cxx:493
RooMinimizerFcn::NDim
virtual unsigned int NDim() const
Retrieve the dimension of the function.
Definition: RooMinimizerFcn.h:43
genreflex::verbose
bool verbose
Definition: rootcling_impl.cxx:133
ParameterSettings.h
FitResult.h
ROOT::Math::IBaseFunctionMultiDimTempl
Documentation for the abstract class IBaseFunctionMultiDim.
Definition: IFunction.h:62
RooArgList.h
RooMinimizer
RooMinimizer is a wrapper class around ROOT::Fit:Fitter that provides a seamless interface between th...
Definition: RooMinimizer.h:40
RooMinimizerFcn::_printEvalErrors
int _printEvalErrors
Definition: RooMinimizerFcn.h:93
int
RooMinimizerFcn::SetVerbose
void SetVerbose(Bool_t flag=kTRUE)
Definition: RooMinimizerFcn.h:60