Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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"
21#include "Fit/FitResult.h"
22
23#include "RooAbsReal.h"
24#include "RooArgList.h"
25
26#include <fstream>
27#include <vector>
28
29class RooMinimizer;
30template<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
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;
105
106};
107
108#endif
109#endif
double Double_t
Definition RtypesCore.h:59
const Bool_t kTRUE
Definition RtypesCore.h:91
class containg the result of the fit and all the related information (fitted parameter values,...
Definition FitResult.h:47
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
RooMinimizerFcn is an interface to the ROOT::Math::IBaseFunctionMultiDim, a function that ROOT's mini...
RooArgList * _floatParamList
std::ofstream * _logfile
void SetPdfParamErr(Int_t index, Double_t value)
Modify PDF parameter error by ordinal index (needed by MINUIT)
RooArgList * _initFloatParamList
virtual double DoEval(const double *x) const
Evaluate function given the parameters in x.
RooArgList * GetInitFloatParamList()
virtual ROOT::Math::IBaseFunctionMultiDim * Clone() const
Clone a function.
Bool_t SetLogFile(const char *inLogfile)
Change the file name for logging of a RooMinimizer of all MINUIT steppings through the parameter spac...
void ApplyCovarianceMatrix(TMatrixDSym &V)
Apply results of given external covariance matrix.
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.
RooArgList * GetInitConstParamList()
RooArgList * _constParamList
Double_t & GetMaxFCN()
double getOffset() const
Return a possible offset that's applied to the function to separate invalid function values from vali...
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...
void BackProp(const ROOT::Fit::FitResult &results)
Transfer MINUIT fit results back into RooFit objects.
void SetPrintEvalErrors(Int_t numEvalErrors)
Int_t GetNumInvalidNLL() const
void printEvalErrors() const
Print information about why evaluation failed.
RooAbsReal * _funct
const RooMinimizer * _context
void ClearPdfParamAsymErr(Int_t index)
Modify PDF parameter error by ordinal index (needed by MINUIT)
RooArgList * GetFloatParamList()
void SetVerbose(Bool_t flag=kTRUE)
Bool_t SetPdfParamVal(int index, double value) const
Set value of parameter i.
RooArgList * _initConstParamList
double _recoverFromNaNStrength
RooArgList * GetConstParamList()
RooMinimizer is a wrapper class around ROOT::Fit:Fitter that provides a seamless interface between th...
TMatrixTSym.
Definition TMatrixTSym.h:34
Double_t x[n]
Definition legend1.C:17