#include <Minimiser.h>
|
| Minimiser (IMinimisable *fitFunction=0, const double errdef=1.) |
|
virtual | ~Minimiser () |
|
bool | attachFunction (IMinimisable *fcn) |
|
IMinimisable * | theFunction () |
|
const IMinimisable * | theFunction () const |
|
const MinuitParameterSet * | parSet () const |
|
MinuitParameterSet * | parSet () |
|
unsigned int | nPars () const |
|
IMinuitParameter * | getParPtr (unsigned int i) |
|
const IMinuitParameter * | getParPtr (unsigned int i) const |
|
bool | OK () const |
|
bool | parsOK () const |
|
bool | fcnOK () const |
|
double | getFCNVal () |
|
void | FCNGradient (std::vector< double > &grad) |
|
bool | initialiseVariables () |
|
bool | setPrintLevel (int level=-1) |
|
bool | temporarilyQuiet () |
|
bool | resetPrintLevel () |
|
bool | SetSomeMinuitOptions () |
|
bool | CallMigrad () |
|
bool | CallMinos () |
|
bool | CallSeek (int maxCalls=100, int devs=5) |
|
bool | CallSimplex (int maxCalls=300, double tolerance=1.) |
|
bool | CallImprove (int maxCalls=1500, int searches=5) |
|
bool | prepFit () |
|
bool | doFit () |
|
bool | doMinosFit () |
|
bool | doSeekFit (int maxCalls=100, int devs=5) |
|
bool | doSimplexFit (int maxCalls=300, double tolerance=1.) |
|
bool | scanMarked () |
|
bool | scanAll () |
|
TGraph * | scan (int i, double from=0, double to=0) |
|
TGraph * | scan (IMinuitParameter &fp, double from=0, double to=0) |
|
void | setMaxCalls (int maxCalls) |
|
int | getMaxCalls () const |
|
void | printResultVsInput (std::ostream &os=std::cout) const |
|
TMatrixTSym< double > | covMatrix () |
|
TMatrixTSym< double > | covMatrixFull () |
|
int | status () |
|
bool | isStatus (Minimiser::FitStatus) |
|
bool | isStatusAtLeast (Minimiser::FitStatus) |
|
int | printStatus () |
|
bool | isConverged () |
|
TGraph * | contour (unsigned, unsigned, float nsigma=1., unsigned npoints=40) |
|
Definition at line 22 of file Minimiser.h.
◆ FitStatus
Fit status enumerators.
Enumerator |
---|
NOTCALCULATED | FAILED: Covariance matrix not calculated at all.
|
NOTACCURATE | FAILED: Covariance matrix approximation only, not accurate.
|
NOTPOSDEF | FAILED: Full covariance matrix, but forced positive-definite.
|
CONVERGED | CONVERGED: Full accurate covariance matrix.
|
Definition at line 121 of file Minimiser.h.
FAILED: Covariance matrix approximation only, not accurate.
FAILED: Full covariance matrix, but forced positive-definite.
CONVERGED: Full accurate covariance matrix.
FAILED: Covariance matrix not calculated at all.
◆ Minimiser()
Minimiser::Minimiser |
( |
IMinimisable * |
fitFunction = 0 , |
|
|
const double |
errdef = 1. |
|
) |
| |
Definition at line 32 of file Minimiser.cpp.
IMinimisable * _theFunction
bool _useAnalyticGradient
IMinimisable * theFunction()
static int _defaultMaxCalls
◆ ~Minimiser()
Minimiser::~Minimiser |
( |
| ) |
|
|
virtual |
◆ attachFunction()
Definition at line 139 of file Minimiser.cpp.
140 if(0==fcn)
return false;
IMinimisable * _theFunction
◆ CallImprove()
bool Minimiser::CallImprove |
( |
int |
maxCalls = 1500 , |
|
|
int |
searches = 5 |
|
) |
| |
Definition at line 367 of file Minimiser.cpp.
373 if(dbThis) cout <<
"calling IMPROVE" << endl;
375 if(dbThis) cout <<
"did that. How did I do? ierflg=" <<
ierflg << endl;
bool _useAnalyticGradient
◆ CallMigrad()
bool Minimiser::CallMigrad |
( |
| ) |
|
Definition at line 317 of file Minimiser.cpp.
321 if(dbThis) cout <<
"calling MIGRAD" << endl;
323 if(dbThis) cout <<
"did that. How did I do? ierflg=" <<
ierflg << endl;
◆ CallMinos()
bool Minimiser::CallMinos |
( |
| ) |
|
Definition at line 327 of file Minimiser.cpp.
332 if(dbThis) cout <<
"calling MINOS" << endl;
334 if(dbThis) cout <<
"did that. How did I do? ierflg=" <<
ierflg << endl;
◆ CallSeek()
bool Minimiser::CallSeek |
( |
int |
maxCalls = 100 , |
|
|
int |
devs = 5 |
|
) |
| |
Definition at line 353 of file Minimiser.cpp.
359 if(dbThis) cout <<
"calling SEEK" << endl;
361 if(dbThis) cout <<
"did that. How did I do? ierflg=" <<
ierflg << endl;
bool _useAnalyticGradient
◆ CallSimplex()
bool Minimiser::CallSimplex |
( |
int |
maxCalls = 300 , |
|
|
double |
tolerance = 1. |
|
) |
| |
Definition at line 339 of file Minimiser.cpp.
345 if(dbThis) cout <<
"calling SIMPLEX" << endl;
347 if(dbThis) cout <<
"did that. How did I do? ierflg=" <<
ierflg << endl;
bool _useAnalyticGradient
◆ contour()
TGraph * Minimiser::contour |
( |
unsigned |
iparx, |
|
|
unsigned |
ipary, |
|
|
float |
nsigma = 1. , |
|
|
unsigned |
npoints = 40 |
|
) |
| |
Make the nsigma contour plot for the given parameters - note that parameter numbers run from 0-N.
Definition at line 596 of file Minimiser.cpp.
598 deque<deque<double> > initvals ;
599 for(
unsigned i = 0 ; i <
parSet()->
size() ; ++i){
601 initvals.push_back(deque<double>()) ;
602 deque<double>& parvals = initvals.back() ;
603 parvals.push_back(par->
mean()) ;
604 parvals.push_back(par->
err()) ;
605 parvals.push_back(par->
errPos()) ;
606 parvals.push_back(par->
errNeg()) ;
612 float errdef =
_errdef * nsigma * nsigma ;
613 SetErrorDef(errdef) ;
614 TGraph* graph = (TGraph*)Contour(npoints, iparx, ipary) ;
616 ostringstream title ;
617 title << pary->
name() <<
"_vs_" << parx->
name() <<
"_" << nsigma <<
"_sigma_contour" ;
618 string titlestr(title.str()) ;
619 graph->SetName(titlestr.c_str()) ;
622 for(
unsigned i = 0 ; i <
parSet()->
size() ; ++i)
623 getParPtr(i)->
setResult(initvals[i][0], initvals[i][1], initvals[i][2], initvals[i][3]) ;
const MinuitParameterSet * parSet() const
unsigned int size() const
IMinimisable * theFunction()
virtual const std::string & name() const
IMinuitParameter * getParPtr(unsigned int i)
virtual void parametersChanged()=0
virtual void setResult(double fitMean, double fitErr, double fitErrPos, double fitErrNeg)=0
◆ covMatrix()
TMatrixTSym< double > Minimiser::covMatrix |
( |
| ) |
|
Definition at line 506 of file Minimiser.cpp.
511 unsigned int internalPars = fNpar;
515 this->mnemat(&m1[0][0], internalPars);
516 TMatrixTSym<double> matrix(internalPars);
517 for(
unsigned int i=0; i < internalPars; i++){
518 for(
unsigned int j=i; j < internalPars; j++){
519 matrix(i,j) = matrix(j,i) = m1[i][j];
◆ covMatrixFull()
TMatrixTSym< double > Minimiser::covMatrixFull |
( |
| ) |
|
Definition at line 525 of file Minimiser.cpp.
531 unsigned int internalPars = fNpar;
535 this->mnemat(&m1[0][0], internalPars);
536 TMatrixTSym<double> matrix(
nPars());
537 for(
unsigned int i=0; i < internalPars; i++){
538 for(
unsigned int j=i; j < internalPars; j++){
539 int ex_i = fNexofi[i] -1;
540 int ex_j = fNexofi[j] -1;
542 cout <<
"Minimiser::covMatrixFull(): doing: " 543 <<
"matrix(" << ex_i<<
", " << ex_j <<
" )" 544 <<
" = matrix(" << ex_j <<
", " << ex_i <<
")" 545 <<
" = m1[" << i <<
"][" << j<<
"];" 549 matrix(ex_i,ex_j) = matrix(ex_j,ex_i) = m1[i][j];
unsigned int nPars() const
◆ doFit()
bool Minimiser::doFit |
( |
| ) |
|
Definition at line 391 of file Minimiser.cpp.
394 if(dbThis) cout <<
"Minimiser::doFit() called" << endl;
396 if(dbThis) cout <<
"... called prepFit " << success << endl;
398 if(dbThis) cout <<
"... called MIGRAD" << success << endl;
400 if(dbThis) cout <<
"... scanned" << success << endl;
◆ doMinosFit()
bool Minimiser::doMinosFit |
( |
| ) |
|
Definition at line 404 of file Minimiser.cpp.
409 if(dbThis) cout <<
"called MINOS" << endl;
◆ doSeekFit()
bool Minimiser::doSeekFit |
( |
int |
maxCalls = 100 , |
|
|
int |
devs = 5 |
|
) |
| |
Definition at line 415 of file Minimiser.cpp.
419 success &=
CallSeek(maxCalls, devs);
420 if(dbThis) cout <<
"called SEEK" << endl;
bool CallSeek(int maxCalls=100, int devs=5)
◆ doSimplexFit()
bool Minimiser::doSimplexFit |
( |
int |
maxCalls = 300 , |
|
|
double |
tolerance = 1. |
|
) |
| |
Definition at line 426 of file Minimiser.cpp.
431 if(dbThis) cout <<
"called SIMPLEX" << endl;
bool CallSimplex(int maxCalls=300, double tolerance=1.)
◆ endOfFit()
bool Minimiser::endOfFit |
( |
| ) |
|
|
protected |
Definition at line 250 of file Minimiser.cpp.
251 if(!
parsOK())
return false;
TMatrixTSym< double > covMatrixFull()
const MinuitParameterSet * parSet() const
bool setCovMatrix(const CovMatrix &)
Set the covariance matrix.
IMinimisable * theFunction()
bool setParametersToResult()
◆ Eval()
Int_t Minimiser::Eval |
( |
Int_t |
npar, |
|
|
Double_t * |
grad, |
|
|
Double_t & |
fval, |
|
|
Double_t * |
par, |
|
|
Int_t |
flag |
|
) |
| |
|
protected |
Definition at line 56 of file Minimiser.cpp.
63 if(dbThis) cout <<
"Eval got called " << endl;
65 cout <<
"ERROR in Minimiser::Eval (file: Minimiser.C)" 66 <<
" Got called although I'm not OK" << endl;
75 vector<double> gradient(npar);
77 for(
unsigned int i = 0; i < static_cast<unsigned int>(npar); i++){
void FCNGradient(std::vector< double > &grad)
bool _useAnalyticGradient
bool updateFitParameters(Double_t *p)
◆ FCNGradient()
void Minimiser::FCNGradient |
( |
std::vector< double > & |
grad | ) |
|
Definition at line 281 of file Minimiser.cpp.
283 cout <<
"ERROR IN Minimiser::FCNGradient()" 284 <<
" I'm not OK!!" << endl;
IMinimisable * theFunction()
virtual void Gradient(std::vector< double > &grad)
◆ fcnOK()
bool Minimiser::fcnOK |
( |
| ) |
const |
◆ getDefaultMinimiser()
Minimiser * Minimiser::getDefaultMinimiser |
( |
| ) |
|
|
static |
Definition at line 23 of file Minimiser.cpp.
Minimiser(IMinimisable *fitFunction=0, const double errdef=1.)
static Minimiser * _defaultMinimiser
◆ getFCNVal()
double Minimiser::getFCNVal |
( |
| ) |
|
Definition at line 272 of file Minimiser.cpp.
274 cout <<
"ERROR IN Minimiser::getFCNVal()" 275 <<
" I'm not OK!!" << endl;
IMinimisable * theFunction()
virtual double getVal()=0
◆ getMaxCalls()
int Minimiser::getMaxCalls |
( |
| ) |
const |
◆ getParPtr() [1/2]
Definition at line 149 of file Minimiser.cpp.
151 if(i >=
nPars())
return 0;
MinuitParameterSet * _parSet
IMinuitParameter * getParPtr(unsigned int i)
unsigned int nPars() const
◆ getParPtr() [2/2]
Definition at line 154 of file Minimiser.cpp.
156 if(i >=
nPars())
return 0;
MinuitParameterSet * _parSet
IMinuitParameter * getParPtr(unsigned int i)
unsigned int nPars() const
◆ init()
Definition at line 105 of file Minimiser.cpp.
107 if(dbThis) cout <<
"Minimiser::init(): you called me" << endl;
109 std::cout <<
"ERROR IN Minimiser::init():" 110 <<
" the function-ptr is empty." 111 <<
" I won't do anything for now." 115 if(dbThis) cout <<
" ... calling theFunction()->beginFit()" << endl;
120 std::cout <<
"ERROR IN Minimiser::init():" 121 <<
" theFunction()->getParSet() returned empty pointer" 122 <<
" I won't do anything for now." 129 if(dbThis) cout <<
"... made space, now initialising variables" << endl;
131 if(dbThis) cout <<
" initialised variables." << endl;
135 if(dbThis) cout <<
"Minimiser::init(): returning true" << endl;
bool _useAnalyticGradient
bool initialiseVariables()
MinuitParameterSet * _parSet
IMinimisable * theFunction()
virtual void beginFit()=0
virtual bool useAnalyticGradient()
bool MakeSpace(int needSpace)
virtual MinuitParameterSet * getParSet()=0
unsigned int nPars() const
◆ initialiseVariables()
bool Minimiser::initialiseVariables |
( |
| ) |
|
Definition at line 170 of file Minimiser.cpp.
172 if(!
parsOK())
return false;
176 cout <<
"Minimiser::initialiseVariables() called. " << endl;
177 cout <<
"\n\t(declaring them to MINUIT)" << endl;
181 for(
unsigned int i=0; i <
nPars(); i++){
190 for(
unsigned int i=0; i <
nPars(); i++){
206 success &= ! ierflag;
209 cout <<
"Minimiser::initialiseVariables():" 210 <<
"done declaring variables, now:" 211 <<
"theFunction()->parametersChanged();" 215 if(dbThis) cout <<
"Minimiser::initialiseVariables():" 216 <<
" all done - returning " << success << endl;
const MinuitParameterSet * parSet() const
virtual const std::string & name() const =0
IMinimisable * theFunction()
bool unregister(IMinuitParameter *patPtr)
virtual bool hidden() const =0
IMinuitParameter * getParPtr(unsigned int i)
virtual double stepInit() const =0
virtual void parametersChanged()=0
unsigned int nPars() const
◆ isConverged()
bool Minimiser::isConverged |
( |
| ) |
|
Check if the fit status is CONVERGED
Definition at line 592 of file Minimiser.cpp.
bool isStatus(Minimiser::FitStatus)
CONVERGED: Full accurate covariance matrix.
◆ isStatus()
Check if the fit status is of the given type.
Definition at line 562 of file Minimiser.cpp.
◆ isStatusAtLeast()
Check if the fit status is >= the given status type.
Definition at line 566 of file Minimiser.cpp.
◆ MakeSpace()
bool Minimiser::MakeSpace |
( |
int |
needSpace | ) |
|
|
protected |
Definition at line 97 of file Minimiser.cpp.
100 this->DeleteArrays();
101 this->BuildArrays(needSpace + 2);
◆ nPars()
unsigned int Minimiser::nPars |
( |
| ) |
const |
Definition at line 145 of file Minimiser.cpp.
MinuitParameterSet * _parSet
unsigned int size() const
◆ OK()
bool Minimiser::OK |
( |
| ) |
const |
◆ parSet() [1/2]
Definition at line 63 of file Minimiser.h.
MinuitParameterSet * _parSet
◆ parSet() [2/2]
Definition at line 64 of file Minimiser.h.
MinuitParameterSet * _parSet
◆ parsOK()
bool Minimiser::parsOK |
( |
| ) |
const |
Definition at line 258 of file Minimiser.cpp.
260 if(0 ==
nPars())
return false;
MinuitParameterSet * _parSet
unsigned int nPars() const
◆ prepFit()
bool Minimiser::prepFit |
( |
| ) |
|
Definition at line 381 of file Minimiser.cpp.
387 if(dbThis) cout <<
"re-initialised variables" << endl;
bool initialiseVariables()
IMinimisable * theFunction()
virtual void beginFit()=0
bool SetSomeMinuitOptions()
◆ printResultVsInput()
void Minimiser::printResultVsInput |
( |
std::ostream & |
os = std::cout | ) |
const |
Definition at line 501 of file Minimiser.cpp.
MinuitParameterSet * _parSet
void printResultVsInput(std::ostream &os=std::cout) const
◆ printStatus()
int Minimiser::printStatus |
( |
| ) |
|
Print the fit status.
Definition at line 570 of file Minimiser.cpp.
572 cout <<
"Fit status: " << stat << endl ;
575 cout <<
"FAILED: Covariance matrix not calculated at all." << endl ;
578 cout <<
"FAILED: Covariance matrix approximation only, not accurate." << endl ;
581 cout <<
"FAILED: Full covariance matrix, but forced positive-definite." << endl ;
584 cout <<
"CONVERGED: Full accurate covariance matrix." << endl ;
587 cout <<
"UNKNOWN." << endl ;
FAILED: Covariance matrix approximation only, not accurate.
FAILED: Full covariance matrix, but forced positive-definite.
CONVERGED: Full accurate covariance matrix.
FAILED: Covariance matrix not calculated at all.
◆ resetPrintLevel()
bool Minimiser::resetPrintLevel |
( |
| ) |
|
◆ scan() [1/2]
TGraph * Minimiser::scan |
( |
int |
i, |
|
|
double |
from = 0 , |
|
|
double |
to = 0 |
|
) |
| |
note that the index i is the one in the parameter list which goes from 0 to n-1 (i.e. C-style). This corresponds to Minuit's parameter number i+1. (so if you want Minuit's fit parameter 1, pass it 1-1=0)
Definition at line 473 of file Minimiser.cpp.
482 string fname =
"scan_" + p->
name() +
".root";
489 TGraph *gr = (TGraph*) this->GetPlot();
491 cout <<
" didn't get plot " << endl;
493 TFile fscan(fname.c_str(),
"RECREATE");
virtual const std::string & name() const =0
IMinuitParameter * getParPtr(unsigned int i)
◆ scan() [2/2]
TGraph * Minimiser::scan |
( |
IMinuitParameter & |
fp, |
|
|
double |
from = 0 , |
|
|
double |
to = 0 |
|
) |
| |
Definition at line 459 of file Minimiser.cpp.
461 cout <<
"ERROR Minimiser::scanParameter: " 462 <<
" You are trying to scan a parameter that is" 463 <<
" associated to a different fit (different fit parameter set)" 464 <<
" will not do it." 465 <<
" The parameter you tried was: " << endl;
virtual const MinuitParameterSet * parSet() const =0
const MinuitParameterSet * parSet() const
TGraph * scan(int i, double from=0, double to=0)
virtual void print(std::ostream &os=std::cout) const =0
virtual int parSetIndex() const =0
◆ scanAll()
bool Minimiser::scanAll |
( |
| ) |
|
Definition at line 448 of file Minimiser.cpp.
450 if(0 ==
nPars())
return false;
451 for(
unsigned int i=0; i <
nPars(); i++){
virtual double scanMin() const =0
TGraph * scan(int i, double from=0, double to=0)
IMinuitParameter * getParPtr(unsigned int i)
unsigned int nPars() const
virtual double scanMax() const =0
◆ scanMarked()
bool Minimiser::scanMarked |
( |
| ) |
|
Definition at line 438 of file Minimiser.cpp.
440 if(0 ==
nPars())
return false;
441 for(
unsigned int i=0; i <
nPars(); i++){
443 if(0 == p || (! p->
scan()) )
continue;
virtual double scanMin() const =0
TGraph * scan(int i, double from=0, double to=0)
virtual bool scan() const =0
IMinuitParameter * getParPtr(unsigned int i)
unsigned int nPars() const
virtual double scanMax() const =0
◆ setMaxCalls()
void Minimiser::setMaxCalls |
( |
int |
maxCalls | ) |
|
◆ setParametersToResult()
bool Minimiser::setParametersToResult |
( |
| ) |
|
|
protected |
Definition at line 221 of file Minimiser.cpp.
222 if(!
parsOK())
return false;
224 Double_t mean, err, errN, errP;
226 for(
unsigned int i=0; i <
nPars(); i++){
228 this->mnerrs(i, errP, errN, err, gcc);
229 this->GetParameter(i, mean, err);
IMinimisable * theFunction()
virtual double blinding() const =0
IMinuitParameter * getParPtr(unsigned int i)
virtual void parametersChanged()=0
virtual void setResult(double fitMean, double fitErr, double fitErrPos, double fitErrNeg)=0
unsigned int nPars() const
◆ setPrintLevel()
bool Minimiser::setPrintLevel |
( |
int |
level = -1 | ) |
|
◆ SetSomeMinuitOptions()
bool Minimiser::SetSomeMinuitOptions |
( |
| ) |
|
Definition at line 303 of file Minimiser.cpp.
bool _useAnalyticGradient
bool setPrintLevel(int level=-1)
◆ status()
int Minimiser::status |
( |
| ) |
|
Get the fit status
Definition at line 555 of file Minimiser.cpp.
556 double fmin, fedm, errdef ;
557 int npari, nparx,
status ;
558 mnstat( fmin, fedm, errdef, npari, nparx,
status ) ;
◆ temporarilyQuiet()
bool Minimiser::temporarilyQuiet |
( |
| ) |
|
◆ theFunction() [1/2]
Definition at line 60 of file Minimiser.h.
IMinimisable * _theFunction
◆ theFunction() [2/2]
Definition at line 61 of file Minimiser.h.
IMinimisable * _theFunction
◆ TMinInit()
void Minimiser::TMinInit |
( |
| ) |
|
|
protected |
◆ updateFitParameters()
bool Minimiser::updateFitParameters |
( |
Double_t * |
p | ) |
|
|
protected |
Definition at line 238 of file Minimiser.cpp.
239 if(!
parsOK())
return false;
241 for(
unsigned int i=0; i <
nPars(); i++){
IMinimisable * theFunction()
IMinuitParameter * getParPtr(unsigned int i)
virtual void parametersChanged()=0
virtual void setCurrentFitVal(double pval)=0
unsigned int nPars() const
◆ _defaultMaxCalls
int Minimiser::_defaultMaxCalls =100000 |
|
staticprotected |
◆ _defaultMinimiser
◆ _errdef
double MINT::Minimiser::_errdef |
|
protected |
◆ _maxCalls
int MINT::Minimiser::_maxCalls |
|
protected |
◆ _parSet
◆ _printLevel
int MINT::Minimiser::_printLevel |
|
protected |
◆ _theFunction
◆ _useAnalyticGradient
bool MINT::Minimiser::_useAnalyticGradient |
|
protected |
◆ arglist
Double_t MINT::Minimiser::arglist[10] |
|
mutableprivate |
◆ ierflg
Int_t MINT::Minimiser::ierflg |
|
mutableprivate |
The documentation for this class was generated from the following files: