39 #ifndef __ROOFIT_NOROOMINIMIZER    74 #if (__GNUC__==3&&__GNUC_MINOR__==2&&__GNUC_PATCHLEVEL__==3)   125   _minimizerType = 
"Minuit"; 
   127   if (_theFitter) 
delete _theFitter ;
   130   _theFitter->Config().SetMinimizer(_minimizerType.c_str());
   133   _theFitter->Config().MinimizerOptions().SetMaxIterations(500*_fcn->NDim());
   134   _theFitter->Config().MinimizerOptions().SetMaxFunctionCalls(500*_fcn->NDim());
   140   setErrorLevel(_func->defaultErrorLevel()) ;
   143   _fcn->Synchronize(_theFitter->Config().ParamsSettings(),
   144           _optConst,_verbose) ;
   181   _theFitter->Config().MinimizerOptions().SetStrategy(istrat);
   193   _theFitter->Config().MinimizerOptions().SetMaxIterations(n);
   205   _theFitter->Config().MinimizerOptions().SetMaxFunctionCalls(n);
   219   _theFitter->Config().MinimizerOptions().SetErrorDef(level);
   230   _theFitter->Config().MinimizerOptions().SetTolerance(eps);
   240   _func->enableOffsetting(flag) ; 
   251   _minimizerType = 
type;
   289   TString opts(options) ;
   293   if (opts.Contains(
"v")) setVerbose(1) ;
   294   if (opts.Contains(
"t")) setProfile(1) ;
   295   if (opts.Contains(
"l")) setLogFile(
Form(
"%s.log",_func->GetName())) ;
   296   if (opts.Contains(
"c")) optimizeConst(1) ;
   299   if (opts.Contains(
"0")) setStrategy(0) ;
   301   if (opts.Contains(
"0")) setStrategy(1) ;
   302   if (opts.Contains(
"h")||!opts.Contains(
"m")) hesse() ;
   303   if (!opts.Contains(
"m")) minos() ;
   305   return (opts.Contains(
"r")) ? save() : 0 ;
   315   _fcn->Synchronize(_theFitter->Config().ParamsSettings(),
   316           _optConst,_verbose) ;
   318   _theFitter->Config().SetMinimizer(type,alg);
   324   bool ret = _theFitter->FitFCN(*_fcn);
   325   _status = ((ret) ? _theFitter->Result().Status() : -1);
   329   _fcn->BackProp(_theFitter->Result());
   331   saveStatus(
"MINIMIZE",_status) ;
   346   _fcn->Synchronize(_theFitter->Config().ParamsSettings(),
   347           _optConst,_verbose) ;
   352   _theFitter->Config().SetMinimizer(_minimizerType.c_str(),
"migrad");
   353   bool ret = _theFitter->FitFCN(*_fcn);
   354   _status = ((ret) ? _theFitter->Result().Status() : -1);
   358   _fcn->BackProp(_theFitter->Result());
   360   saveStatus(
"MIGRAD",_status) ;
   375   if (_theFitter->GetMinimizer()==0) {
   382     _fcn->Synchronize(_theFitter->Config().ParamsSettings(),
   383           _optConst,_verbose) ;
   388     _theFitter->Config().SetMinimizer(_minimizerType.c_str());
   389     bool ret = _theFitter->CalculateHessErrors();
   390     _status = ((ret) ? _theFitter->Result().Status() : -1);
   394     _fcn->BackProp(_theFitter->Result());
   396     saveStatus(
"HESSE",_status) ;
   412   if (_theFitter->GetMinimizer()==0) {
   419     _fcn->Synchronize(_theFitter->Config().ParamsSettings(),
   420             _optConst,_verbose) ;
   425     _theFitter->Config().SetMinimizer(_minimizerType.c_str());
   426     bool ret = _theFitter->CalculateMinosErrors();
   427     _status = ((ret) ? _theFitter->Result().Status() : -1);
   431     _fcn->BackProp(_theFitter->Result());
   433     saveStatus(
"MINOS",_status) ;
   450   if (_theFitter->GetMinimizer()==0) {
   455   else if (minosParamList.
getSize()>0) {
   457     _fcn->Synchronize(_theFitter->Config().ParamsSettings(),
   458             _optConst,_verbose) ;
   466     std::vector<unsigned int> paramInd;
   470    Int_t index = _fcn->GetFloatParamList()->index(par);
   471    paramInd.push_back(index);
   476     if (paramInd.size()) {
   478       _theFitter->Config().SetMinosErrors(paramInd);
   480       _theFitter->Config().SetMinimizer(_minimizerType.c_str());
   481       bool ret = _theFitter->CalculateMinosErrors();
   482       _status = ((ret) ? _theFitter->Result().Status() : -1);
   484       _theFitter->Config().SetMinosErrors(
kFALSE);
   490     _fcn->BackProp(_theFitter->Result());
   492     saveStatus(
"MINOS",_status) ;
   509   _fcn->Synchronize(_theFitter->Config().ParamsSettings(),
   510           _optConst,_verbose) ;
   515   _theFitter->Config().SetMinimizer(_minimizerType.c_str(),
"seek");
   516   bool ret = _theFitter->FitFCN(*_fcn);
   517   _status = ((ret) ? _theFitter->Result().Status() : -1);
   521   _fcn->BackProp(_theFitter->Result());
   523   saveStatus(
"SEEK",_status) ;
   538   _fcn->Synchronize(_theFitter->Config().ParamsSettings(),
   539           _optConst,_verbose) ;
   544   _theFitter->Config().SetMinimizer(_minimizerType.c_str(),
"simplex");
   545   bool ret = _theFitter->FitFCN(*_fcn);
   546   _status = ((ret) ? _theFitter->Result().Status() : -1);
   550   _fcn->BackProp(_theFitter->Result());
   552   saveStatus(
"SEEK",_status) ;
   567   _fcn->Synchronize(_theFitter->Config().ParamsSettings(),
   568           _optConst,_verbose) ;
   573   _theFitter->Config().SetMinimizer(_minimizerType.c_str(),
"migradimproved");
   574   bool ret = _theFitter->FitFCN(*_fcn);
   575   _status = ((ret) ? _theFitter->Result().Status() : -1);
   579   _fcn->BackProp(_theFitter->Result());
   581   saveStatus(
"IMPROVE",_status) ;
   593   Int_t ret = _printLevel ;
   594   _theFitter->Config().MinimizerOptions().SetPrintLevel(newLevel+1);
   595   _printLevel = newLevel+1 ;
   607   if (_optConst && !flag){
   608     if (_printLevel>-1) 
coutI(
Minimization) << 
"RooMinimizer::optimizeConst: deactivating const optimization" << endl ;
   611   } 
else if (!_optConst && flag) {
   612     if (_printLevel>-1) 
coutI(
Minimization) << 
"RooMinimizer::optimizeConst: activating const optimization" << endl ;
   615   } 
else if (_optConst && flag) {
   616     if (_printLevel>-1) 
coutI(
Minimization) << 
"RooMinimizer::optimizeConst: const optimization already active" << endl ;
   618     if (_printLevel>-1) 
coutI(
Minimization) << 
"RooMinimizer::optimizeConst: const optimization wasn't active" << endl ;
   637   if (_theFitter->GetMinimizer()==0) {
   644   name = userName ? userName : 
Form(
"%s", _func->GetName()) ;
   645   title = userTitle ? userTitle : 
Form(
"%s", _func->GetTitle()) ;
   650   RooArgList saveConstList(*(_fcn->GetConstParamList())) ;
   651   RooArgList saveFloatInitList(*(_fcn->GetInitFloatParamList())) ;
   652   RooArgList saveFloatFinalList(*(_fcn->GetFloatParamList())) ;
   653   for (i=0 ; i<_fcn->GetFloatParamList()->getSize() ; i++) {
   654     RooAbsArg* par = _fcn->GetFloatParamList()->at(i) ;
   657       saveFloatFinalList.
remove(*par) ;
   658       saveConstList.
add(*par) ;
   661   saveConstList.
sort() ;
   663   fitRes->setConstParList(saveConstList) ;
   664   fitRes->setInitParList(saveFloatInitList) ;
   666   fitRes->setStatus(_status) ;
   667   fitRes->setCovQual(_theFitter->GetMinimizer()->CovMatrixStatus()) ;
   668   fitRes->setMinNLL(_theFitter->Result().MinFcnValue()) ;
   669   fitRes->setNumInvalidNLL(_fcn->GetNumInvalidNLL()) ;
   670   fitRes->setEDM(_theFitter->Result().Edm()) ;
   671   fitRes->setFinalParList(saveFloatFinalList) ;
   673     std::vector<double> globalCC;
   674     TMatrixDSym corrs(_theFitter->Result().Parameters().size()) ;
   675     TMatrixDSym covs(_theFitter->Result().Parameters().size()) ;
   676     for (
UInt_t ic=0; ic<_theFitter->Result().Parameters().size(); ic++) {
   677       globalCC.push_back(_theFitter->Result().GlobalCC(ic));
   678       for (
UInt_t ii=0; ii<_theFitter->Result().Parameters().size(); ii++) {
   679    corrs(ic,ii) = _theFitter->Result().Correlation(ic,ii);
   680    covs(ic,ii) = _theFitter->Result().CovMatrix(ic,ii);
   683     fitRes->fillCorrMatrix(globalCC,corrs,covs) ;
   685     fitRes->setCovarianceMatrix(*_extV) ;
   688   fitRes->setStatusHistory(_statusHistory) ;
   704   RooArgList* params = _fcn->GetFloatParamList() ;
   708   Int_t index1= _fcn->GetFloatParamList()->index(&var1);
   711          << 
") ERROR: " << var1.
GetName()
   712          << 
" is not a floating parameter of "   713          << _func->GetName() << endl ;
   717   Int_t index2= _fcn->GetFloatParamList()->index(&var2);
   720          << 
") ERROR: " << var2.
GetName()
   721          << 
" is not a floating parameter of PDF "   722          << _func->GetName() << endl ;
   735   if (_theFitter->GetMinimizer()==0) {
   736      coutW(
Minimization) << 
"RooMinimizer::contour: Error, run Migrad before contours!"   743   Double_t errdef= _theFitter->GetMinimizer()->ErrorDef();
   746   n[0] = n1 ; n[1] = n2 ; n[2] = n3 ; n[3] = n4 ; n[4] = n5 ; n[5] = n6 ;
   747   unsigned int npoints(50);
   749   for (
Int_t ic = 0 ; ic<6 ; ic++) {
   753        _theFitter->GetMinimizer()->SetErrorDef(n[ic]*n[ic]*errdef);
   758       bool ret = _theFitter->GetMinimizer()->Contour(index1,index2,npoints,xcoor,ycoor);
   763              << 
") ERROR: MINUIT did not return a contour graph for n="   766    xcoor[npoints] = xcoor[0];
   767    ycoor[npoints] = ycoor[0];
   770    graph->
SetName(
Form(
"contour_%s_n%f",_func->GetName(),n[ic])) ;
   784   _theFitter->Config().MinimizerOptions().SetErrorDef(errdef);
   787   *params = *paramSave ;
   803     _profileStart = 
kTRUE ;
   833   _fcn->ApplyCovarianceMatrix(*_extV);
   844   if (_theFitter==0 || _theFitter->GetMinimizer()==0) {
   851   if (varList.
getSize()>0 && varList.
getSize()!=
Int_t(_theFitter->Result().NTotalParameters())) {
   853       << 
"RooMinimizer::lastMinuitFit: ERROR: supplied variable list must be either empty " << endl
   854       << 
"                             or match the number of variables of the last fit ("   855       << _theFitter->Result().NTotalParameters() << 
")" << endl ;
   864     if (!dynamic_cast<RooRealVar*>(arg)) {
   866                  << arg->
GetName() << 
"' is not of type RooRealVar" << endl ;
   880   for (i = 0; i < _theFitter->Result().NTotalParameters(); ++i) {
   882     TString varName(_theFitter->Result().GetParameterName(i));
   883     Bool_t isConst(_theFitter->Result().IsParameterFixed(i)) ;
   885     Double_t xlo = _theFitter->Config().ParSettings(i).LowerLimit();
   886     Double_t xhi = _theFitter->Config().ParSettings(i).UpperLimit();
   887     Double_t xerr = _theFitter->Result().Error(i);
   888     Double_t xval = _theFitter->Result().Value(i);
   893       if ((xlo<xhi) && !isConst) {
   894         var = 
new RooRealVar(varName,varName,xval,xlo,xhi) ;
   908       if (varName.CompareTo(var->
GetName())) {
   909    oocoutI((
TObject*)0,
Eval)  << 
"RooMinimizer::lastMinuitFit: fit parameter '" << varName
   910                << 
"' stored in variable '" << var->
GetName() << 
"'" << endl ;
   926   res->
setMinNLL(_theFitter->Result().MinFcnValue()) ;
   927   res->
setEDM(_theFitter->Result().Edm()) ;
   928   res->
setCovQual(_theFitter->GetMinimizer()->CovMatrixStatus()) ;
   929   res->
setStatus(_theFitter->Result().Status()) ;
   930   std::vector<double> globalCC;
   931   TMatrixDSym corrs(_theFitter->Result().Parameters().size()) ;
   932   TMatrixDSym covs(_theFitter->Result().Parameters().size()) ;
   933   for (
UInt_t ic=0; ic<_theFitter->Result().Parameters().size(); ic++) {
   934     globalCC.push_back(_theFitter->Result().GlobalCC(ic));
   935     for (
UInt_t ii=0; ii<_theFitter->Result().Parameters().size(); ii++) {
   936       corrs(ic,ii) = _theFitter->Result().Correlation(ic,ii);
   937       covs(ic,ii) = _theFitter->Result().CovMatrix(ic,ii);
 virtual const char * GetName() const
Returns name of object. 
std::string GetName(const std::string &scope_name)
virtual void SetLineWidth(Width_t lwidth)
Set the line width. 
TIterator * createIterator(Bool_t dir=kIterForward) const
virtual Bool_t add(const RooAbsArg &var, Bool_t silent=kFALSE)
Add the specified argument to list. 
void sort(Bool_t reverse=kFALSE)
void optimizeConst(Int_t flag)
If flag is true, perform constant term optimization on function being minimized. 
Int_t seek()
Execute SEEK. 
void applyCovarianceMatrix(TMatrixDSym &V)
Apply results of given external covariance matrix. 
virtual ~RooMinimizer()
Destructor. 
void addObject(TObject *obj, Option_t *drawOptions="", Bool_t invisible=kFALSE)
Add a generic object to this plot. 
virtual Bool_t addOwned(RooAbsArg &var, Bool_t silent=kFALSE)
Add the specified argument to list. 
Double_t getVal(const RooArgSet *set=0) const
Int_t improve()
Execute IMPROVE. 
virtual void SetName(const char *name)
Set the name of the TNamed. 
void setStatus(Int_t val)
static void clearEvalErrorLog()
Clear the stack of evaluation error messages. 
virtual TObject * Clone(const char *newname=0) const
Make a clone of an object using the Streamer facility. 
ROOT::Fit::Fitter * fitter()
Return underlying ROOT fitter object. 
static RooMsgService & instance()
Return reference to singleton instance. 
void setInitParList(const RooArgList &list)
Fill the list of initial values of the floating parameters. 
Iterator abstract base class. 
void setMinimizerType(const char *type)
Choose the minimzer algorithm. 
void setEps(Double_t eps)
Change MINUIT epsilon. 
void setStrategy(Int_t strat)
Change MINUIT strategy to istrat. 
void setEDM(Double_t val)
Int_t simplex()
Execute SIMPLEX. 
static void setEvalErrorLoggingMode(ErrorLoggingMode m)
Set evaluation error logging mode. 
Bool_t silentMode() const
RooMinimizer(RooAbsReal &function)
Construct MINUIT interface to given function. 
void function(const Char_t *name_, T fun, const Char_t *docstring=0)
void setMaxIterations(Int_t n)
Change maximum number of MINUIT iterations (RooMinimizer default 500 * #parameters) ...
TString operator+(const TString &s1, const TString &s2)
Use the special concatenation constructor. 
RooRealVar represents a fundamental (non-derived) real valued object. 
void setMinNLL(Double_t val)
virtual void setVal(Double_t value)
Set value of variable to 'value'. 
virtual void SetLineColor(Color_t lcolor)
Set the line color. 
void setMaxFunctionCalls(Int_t n)
Change maximum number of likelihood function calss from MINUIT (RooMinimizer default 500 * #parameter...
RooAbsCollection * snapshot(Bool_t deepCopy=kTRUE) const
Take a snap shot of current collection contents: An owning collection is returned containing clones o...
RooAbsArg * at(Int_t idx) const
void setConstant(Bool_t value=kTRUE)
RooFitResult * save(const char *name=0, const char *title=0)
Save and return a RooFitResult snaphot of current minimizer status. 
Fitter class, entry point for performing all type of fits. 
char * Form(const char *fmt,...)
void setFinalParList(const RooArgList &list)
Fill the list of final values of the floating parameters. 
Int_t migrad()
Execute MIGRAD. 
A RooPlot is a plot frame and a container for graphics objects within that frame. ...
static void activate()
Install atexit handler that calls CleanupRooFitAtExit() on program termination. 
void setConstParList(const RooArgList &list)
Fill the list of constant parameters. 
RooAbsArg * find(const char *name) const
Find object with given name in list. 
RooAbsReal is the common abstract base class for objects that represent a real value and implements f...
Int_t minos()
Execute MINOS. 
void setErrorLevel(Double_t level)
Set the level for MINUIT error analysis to the given value. 
Int_t minimize(const char *type, const char *alg=0)
virtual void SetLineStyle(Style_t lstyle)
Set the line style. 
void profileStop()
Stop profiling timer and report results of last session. 
void setRange(const char *name, Double_t min, Double_t max)
Set range named 'name to [min,max]. 
Mother of all ROOT objects. 
Int_t setPrintLevel(Int_t newLevel)
Change the MINUIT internal printing level. 
virtual TObject * Clone(const char *newname="") const
Make a clone of an object using the Streamer facility. 
virtual Bool_t remove(const RooAbsArg &var, Bool_t silent=kFALSE, Bool_t matchByNameOnly=kFALSE)
Remove the specified argument from our list. 
Int_t hesse()
Execute HESSE. 
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...
RooMinimizer is a wrapper class around ROOT::Fit:Fitter that provides a seamless interface between th...
virtual TObject * Next()=0
A Graph is a graphics object made of two arrays X and Y with npoints each. 
void setCovQual(Int_t val)
static void cleanup()
Cleanup method called by atexit handler installed by RooSentinel to delete all global heap objects wh...
static ROOT::Fit::Fitter * _theFitter
RooAbsArg is the common abstract base class for objects that represent a value (of arbitrary type) an...
void fillCorrMatrix()
Internal utility method to extract the correlation matrix and the global correlation coefficients fro...
void setOffsetting(Bool_t flag)
Enable internal likelihood offsetting for enhanced numeric precision. 
RooFitResult * fit(const char *options)
Parse traditional RooAbsPdf::fitTo driver options. 
static RooFitResult * lastMinuitFit(const RooArgList &varList=RooArgList())
void profileStart()
Start profiling timer. 
Bool_t isConstant() const
void setError(Double_t value)