39#ifndef __ROOFIT_NOROOMINIMIZER
71#if (__GNUC__==3&&__GNUC_MINOR__==2&&__GNUC_PATCHLEVEL__==3)
376 coutW(Minimization) <<
"RooMinimizer::hesse: Error, run Migrad before Hesse!"
413 coutW(Minimization) <<
"RooMinimizer::minos: Error, run Migrad before Minos!"
451 coutW(Minimization) <<
"RooMinimizer::minos: Error, run Migrad before Minos!"
455 else if (minosParamList.
getSize()>0) {
466 std::vector<unsigned int> paramInd;
471 paramInd.push_back(index);
476 if (paramInd.size()) {
608 if (
_printLevel>-1)
coutI(Minimization) <<
"RooMinimizer::optimizeConst: deactivating const optimization" << endl ;
612 if (
_printLevel>-1)
coutI(Minimization) <<
"RooMinimizer::optimizeConst: activating const optimization" << endl ;
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 ;
638 coutW(Minimization) <<
"RooMinimizer::save: Error, run minimization before!"
657 saveFloatFinalList.
remove(*par) ;
658 saveConstList.
add(*par) ;
661 saveConstList.
sort() ;
668 double removeOffset = 0.;
671 removeOffset = - fitFcn->getOffset();
680 std::vector<double> globalCC;
729 coutE(Minimization) <<
"RooMinimizer::contour(" <<
GetName()
730 <<
") ERROR: " << var1.
GetName()
731 <<
" is not a floating parameter of "
738 coutE(Minimization) <<
"RooMinimizer::contour(" <<
GetName()
739 <<
") ERROR: " << var2.
GetName()
740 <<
" is not a floating parameter of PDF "
755 coutW(Minimization) <<
"RooMinimizer::contour: Error, run Migrad before contours!"
765 n[0] = n1 ;
n[1] = n2 ;
n[2] = n3 ;
n[3] = n4 ;
n[4] = n5 ;
n[5] = n6 ;
767 for (
Int_t ic = 0 ; ic<6 ; ic++) {
779 coutE(Minimization) <<
"RooMinimizer::contour("
781 <<
") ERROR: MINUIT did not return a contour graph for n="
784 xcoor[npoints] = xcoor[0];
785 ycoor[npoints] = ycoor[0];
789 graph->SetLineStyle(ic+1) ;
790 graph->SetLineWidth(2) ;
805 *params = *paramSave ;
863 oocoutE((
TObject*)0,InputArguments) <<
"RooMinimizer::save: Error, run minimization before!"
871 <<
"RooMinimizer::lastMinuitFit: ERROR: supplied variable list must be either empty " << endl
872 <<
" or match the number of variables of the last fit ("
883 oocoutE((
TObject*)0,InputArguments) <<
"RooMinimizer::lastMinuitFit: ERROR: variable '"
884 << arg->
GetName() <<
"' is not of type RooRealVar" << endl ;
911 if ((xlo<xhi) && !isConst) {
912 var =
new RooRealVar(varName,varName,xval,xlo,xhi) ;
927 oocoutI((
TObject*)0,Eval) <<
"RooMinimizer::lastMinuitFit: fit parameter '" << varName
928 <<
"' stored in variable '" << var->
GetName() <<
"'" << endl ;
948 std::vector<double> globalCC;
char * Form(const char *fmt,...)
TString operator+(const TString &s1, const TString &s2)
Use the special concatenation constructor.
void SetMinosErrors(bool on=true)
set Minos erros computation to be performed after fitting
void SetMinimizer(const char *type, const char *algo=0)
set minimizer type
const std::vector< ROOT::Fit::ParameterSettings > & ParamsSettings() const
get the vector of parameter settings (const method)
const ParameterSettings & ParSettings(unsigned int i) const
get the parameter settings for the i-th parameter (const method)
ROOT::Math::MinimizerOptions & MinimizerOptions()
access to the minimizer control parameter (non const method)
bool IsParameterFixed(unsigned int ipar) const
query if a parameter is fixed
double Error(unsigned int i) const
parameter error by index
double CovMatrix(unsigned int i, unsigned int j) const
retrieve covariance matrix element
double Value(unsigned int i) const
parameter value by index
const std::vector< double > & Parameters() const
parameter values (return std::vector)
std::string GetParameterName(unsigned int ipar) const
get name of parameter (deprecated)
double MinFcnValue() const
Return value of the objective function (chi2 or likelihood) used in the fit.
double Edm() const
Expected distance from minimum.
double Correlation(unsigned int i, unsigned int j) const
retrieve correlation elements
unsigned int NTotalParameters() const
get total number of parameters
int Status() const
minimizer status code
double GlobalCC(unsigned int i) const
parameter global correlation coefficient
Fitter class, entry point for performing all type of fits.
ROOT::Math::IMultiGenFunction * GetFCN() const
return pointer to last used objective function (is NULL in case fit is not yet done) This pointer wil...
bool FitFCN(unsigned int npar, Function &fcn, const double *params=0, unsigned int dataSize=0, bool chi2fit=false)
Fit using the a generic FCN function as a C++ callable object implementing double () (const double *)...
ROOT::Math::Minimizer * GetMinimizer() const
return pointer to last used minimizer (is NULL in case fit is not yet done) This pointer is guranteed...
const FitResult & Result() const
get fit result
const FitConfig & Config() const
access to the fit configuration (const method)
bool CalculateMinosErrors()
perform an error analysis on the result using MINOS To be called only after fitting and when a minimi...
bool CalculateHessErrors()
perform an error analysis on the result using the Hessian Errors are obtaied from the inverse of the ...
double LowerLimit() const
return lower limit value
double UpperLimit() const
return upper limit value
void SetMaxFunctionCalls(unsigned int maxfcn)
set maximum of function calls
void SetStrategy(int stra)
set the strategy
void SetMaxIterations(unsigned int maxiter)
set maximum iterations (one iteration can have many function calls)
void SetErrorDef(double err)
set error def
void SetPrintLevel(int level)
set print level
void SetTolerance(double tol)
set the tolerance
void SetErrorDef(double up)
set scale for calculating the errors
virtual int CovMatrixStatus() const
return status of covariance matrix using Minuit convention {0 not calculated 1 approximated 2 made po...
double ErrorDef() const
return the statistical scale used for calculate the error is typically 1 for Chi2 and 0....
virtual bool Contour(unsigned int ivar, unsigned int jvar, unsigned int &npoints, double *xi, double *xj)
find the contour points (xi, xj) of the function for parameter ivar and jvar around the minimum The c...
RooAbsArg is the common abstract base class for objects that represent a value and a "shape" in RooFi...
virtual TObject * Clone(const char *newname=0) const
Make a clone of an object using the Streamer facility.
virtual void constOptimizeTestStatistic(ConstOpCode opcode, Bool_t doAlsoTrackingOpt=kTRUE)
Interface function signaling a request to perform constant term optimization.
Bool_t isConstant() const
Check if the "Constant" attribute is set.
void sort(Bool_t reverse=false)
Sort collection using std::sort and name comparison.
RooAbsCollection * snapshot(Bool_t deepCopy=kTRUE) const
Take a snap shot of current collection contents.
virtual Bool_t addOwned(RooAbsArg &var, Bool_t silent=kFALSE)
Add the specified argument to list.
Int_t index(const RooAbsArg *arg) const
Returns index of given arg, or -1 if arg is not in the collection.
virtual Bool_t add(const RooAbsArg &var, Bool_t silent=kFALSE)
Add the specified argument to list.
virtual Bool_t remove(const RooAbsArg &var, Bool_t silent=kFALSE, Bool_t matchByNameOnly=kFALSE)
Remove the specified argument from our list.
TIterator * createIterator(Bool_t dir=kIterForward) const
TIterator-style iteration over contained elements.
RooAbsArg * find(const char *name) const
Find object with given name in list.
void setConstant(Bool_t value=kTRUE)
RooAbsReal is the common abstract base class for objects that represent a real value and implements f...
virtual Double_t defaultErrorLevel() const
Double_t getVal(const RooArgSet *normalisationSet=nullptr) const
Evaluate object.
virtual void enableOffsetting(Bool_t)
static void setEvalErrorLoggingMode(ErrorLoggingMode m)
Set evaluation error logging mode.
static void clearEvalErrorLog()
Clear the stack of evaluation error messages.
RooArgList is a container object that can hold multiple RooAbsArg objects.
RooAbsArg * at(Int_t idx) const
Return object at given index, or nullptr if index is out of range.
RooArgSet is a container object that can hold multiple RooAbsArg objects.
RooFitResult is a container class to hold the input and output of a PDF fit to a dataset.
void fillCorrMatrix()
Internal utility method to extract the correlation matrix and the global correlation coefficients fro...
void setCovQual(Int_t val)
void setMinNLL(Double_t val)
void setNumInvalidNLL(Int_t val)
void setStatus(Int_t val)
void setConstParList(const RooArgList &list)
Fill the list of constant parameters.
void setCovarianceMatrix(TMatrixDSym &V)
Store externally provided correlation matrix in this RooFitResult ;.
void setEDM(Double_t val)
void setStatusHistory(std::vector< std::pair< std::string, int > > &hist)
void setInitParList(const RooArgList &list)
Fill the list of initial values of the floating parameters.
void setFinalParList(const RooArgList &list)
Fill the list of final values of the floating parameters.
RooMinimizerFcn is an interface to the ROOT::Math::IBaseFunctionMultiDim, a function that ROOT's mini...
RooArgList * GetInitFloatParamList()
void ApplyCovarianceMatrix(TMatrixDSym &V)
Apply results of given external covariance matrix.
virtual unsigned int NDim() const
Retrieve the dimension of the function.
Bool_t Synchronize(std::vector< ROOT::Fit::ParameterSettings > ¶meters, 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.
RooArgList * GetFloatParamList()
RooArgList * GetConstParamList()
RooMinimizer is a wrapper class around ROOT::Fit:Fitter that provides a seamless interface between th...
std::vector< std::pair< std::string, int > > _statusHistory
RooMinimizer(RooAbsReal &function)
Construct MINUIT interface to given function.
Int_t hesse()
Execute HESSE.
void setMaxIterations(Int_t n)
Change maximum number of MINUIT iterations (RooMinimizer default 500 * #parameters)
RooFitResult * save(const char *name=0, const char *title=0)
Save and return a RooFitResult snapshot of current minimizer status.
void setMinimizerType(const char *type)
Choose the minimiser algorithm.
void saveStatus(const char *label, Int_t status)
Int_t improve()
Execute IMPROVE.
void profileStart()
Start profiling timer.
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, unsigned int npoints=50)
Create and draw a TH2 with the error contours in the parameters var1 and var2.
Int_t migrad()
Execute MIGRAD.
Int_t minimize(const char *type, const char *alg=0)
Minimise the function passed in the constructor.
void profileStop()
Stop profiling timer and report results of last session.
static RooFitResult * lastMinuitFit(const RooArgList &varList=RooArgList())
RooFitResult * fit(const char *options)
Parse traditional RooAbsPdf::fitTo driver options.
void setOffsetting(Bool_t flag)
Enable internal likelihood offsetting for enhanced numeric precision.
Int_t seek()
Execute SEEK.
Bool_t setLogFile(const char *logf=0)
void setProfile(Bool_t flag=kTRUE)
void setEps(Double_t eps)
Change MINUIT epsilon.
void setErrorLevel(Double_t level)
Set the level for MINUIT error analysis to the given value.
static ROOT::Fit::Fitter * _theFitter
static void cleanup()
Cleanup method called by atexit handler installed by RooSentinel to delete all global heap objects wh...
Int_t setPrintLevel(Int_t newLevel)
Change the MINUIT internal printing level.
void setMaxFunctionCalls(Int_t n)
Change maximum number of likelihood function calss from MINUIT (RooMinimizer default 500 * #parameter...
Int_t minos()
Execute MINOS.
void applyCovarianceMatrix(TMatrixDSym &V)
Apply results of given external covariance matrix.
void optimizeConst(Int_t flag)
If flag is true, perform constant term optimization on function being minimized.
Int_t simplex()
Execute SIMPLEX.
ROOT::Fit::Fitter * fitter()
Return underlying ROOT fitter object.
void setStrategy(Int_t strat)
Change MINUIT strategy to istrat.
std::string _minimizerType
void setVerbose(Bool_t flag=kTRUE)
virtual ~RooMinimizer()
Destructor.
static RooMsgService & instance()
Return reference to singleton instance.
A RooPlot is a plot frame and a container for graphics objects within that frame.
void addObject(TObject *obj, Option_t *drawOptions="", Bool_t invisible=kFALSE)
Add a generic object to this plot.
RooRealVar represents a variable that can be changed from the outside.
void setError(Double_t value)
void setRange(const char *name, Double_t min, Double_t max)
Set a fit or plotting range.
virtual void setVal(Double_t value)
Set value of variable to 'value'.
static void activate()
Install atexit handler that calls CleanupRooFitAtExit() on program termination.
A TGraph is an object made of two arrays X and Y with npoints each.
Iterator abstract base class.
virtual TObject * Next()=0
virtual const char * GetTitle() const
Returns title of object.
virtual const char * GetName() const
Returns name of object.
Mother of all ROOT objects.
virtual const char * GetName() const
Returns name of object.
virtual TObject * Clone(const char *newname="") const
Make a clone of an object using the Streamer facility.
void Start(Bool_t reset=kTRUE)
Start the stopwatch.
void Stop()
Stop the stopwatch.
void Print(Option_t *option="") const
Print the real and cpu time passed between the start and stop events.
void ToLower()
Change string to lower-case.
int CompareTo(const char *cs, ECaseCompare cmp=kExact) const
Compare a string to char *cs2.
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const