1 #include "../interface/RooMinimizerOpt.h"
4 #include <RooRealVar.h>
6 #include <RooMsgService.h>
8 #include <Math/MinimizerOptions.h>
15 setEps(ROOT::Math::MinimizerOptions::DefaultTolerance());
21 if (_theFitter == 0)
throw std::logic_error(
"Must have done a fit before calling edm()");
22 return _theFitter->Result().Edm();
29 RooMinimizerFcn(funct, context, verbose)
31 _vars.resize(_floatParamList->getSize());
32 std::vector<RooRealVar *>::iterator itv =
_vars.begin();
33 RooLinkedListIter iter = _floatParamList->iterator();
34 for (TObject *
a = iter.Next();
a != 0;
a = iter.Next(), ++itv) {
35 RooRealVar *rrv =
dynamic_cast<RooRealVar *
>(
a);
36 if (rrv == 0)
throw std::logic_error(Form(
"Float param not a RooRealVar but a %s",
a->ClassName()));
41 ROOT::Math::IBaseFunctionMultiDim*
52 if (_logfile) (*_logfile) << x[
index] <<
" " ;
54 if (par->getVal()!=x[
index]) {
55 if (_verbose)
cout << par->GetName() <<
"=" << x[
index] <<
", " ;
56 par->setVal(x[
index]);
61 double fvalue = _funct->getVal();
62 if (RooAbsPdf::evalError() || RooAbsReal::numEvalErrors()>0) {
64 if (_printEvalErrors>=0) {
66 if (_doEvalErrorWall) {
67 oocoutW(_context,Minimization) <<
"RooMinimizerFcn: Minimized function has error status." << endl
68 <<
"Returning maximum FCN so far (" << _maxFCN
69 <<
") to force MIGRAD to back out of this region. Error log follows" << endl ;
71 oocoutW(_context,Minimization) <<
"RooMinimizerFcn: Minimized function has error status but is ignored" << endl ;
74 TIterator* iter = _floatParamList->createIterator() ;
77 ooccoutW(_context,Minimization) <<
"Parameter values: " ;
78 while((var=(RooRealVar*)iter->Next())) {
79 if (first) { first = kFALSE ; }
else ooccoutW(_context,Minimization) <<
", " ;
80 ooccoutW(_context,Minimization) << var->GetName() <<
"=" << var->getVal() ;
83 ooccoutW(_context,Minimization) << endl ;
85 RooAbsReal::printEvalErrors(ooccoutW(_context,Minimization),_printEvalErrors) ;
86 ooccoutW(_context,Minimization) << endl ;
89 if (_doEvalErrorWall) {
93 RooAbsPdf::clearEvalError() ;
94 RooAbsReal::clearEvalErrorLog() ;
96 }
else if (fvalue>_maxFCN) {
102 (*_logfile) << setprecision(15) << fvalue << setprecision(4) << endl;
104 cout <<
"\nprevFCN = " << setprecision(10)
105 << fvalue << setprecision(4) <<
" " ;
std::vector< RooRealVar * > _vars
RooMinimizerOpt(RooAbsReal &function)
virtual ROOT::Math::IBaseFunctionMultiDim * Clone() const
RooMinimizerFcnOpt(RooAbsReal *funct, RooMinimizer *context, bool verbose=false)
virtual double DoEval(const double *x) const