70#if (__GNUC__==3&&__GNUC_MINOR__==2&&__GNUC_PATCHLEVEL__==3)
124 throw std::logic_error(
"In RooMinimizer constructor: fcnMode::generic_wrapper cannot be used on a RooAbsReal! "
125 "Please use the TestStatistics::RooAbsL based constructor instead.");
128 throw std::logic_error(
"In RooMinimizer constructor: fcnMode has an unsupported value!");
138 : _fcnMode(
FcnMode::generic_wrapper)
280 throw std::invalid_argument(
"In RooMinimizer::setMinimizerType: only Minuit2 is supported when not using classic function mode!");
357 throw std::logic_error(
"In RooMinimizer::fitFcn: _fcnMode has an unsupported value!");
434 coutW(Minimization) <<
"RooMinimizer::hesse: Error, run Migrad before Hesse!"
471 coutW(Minimization) <<
"RooMinimizer::minos: Error, run Migrad before Minos!"
509 coutW(Minimization) <<
"RooMinimizer::minos: Error, run Migrad before Minos!"
513 else if (minosParamList.
getSize()>0) {
524 std::vector<unsigned int> paramInd;
529 paramInd.push_back(index);
534 if (paramInd.size()) {
679 coutW(Minimization) <<
"RooMinimizer::save: Error, run minimization before!"
698 saveFloatFinalList.
remove(*par) ;
699 saveConstList.
add(*par) ;
702 saveConstList.
sort() ;
709 double removeOffset = 0.;
712 removeOffset = -
fitFcn->getOffset();
721 std::vector<double> globalCC;
770 coutE(Minimization) <<
"RooMinimizer::contour(" <<
GetName()
771 <<
") ERROR: " << var1.
GetName()
772 <<
" is not a floating parameter of "
779 coutE(Minimization) <<
"RooMinimizer::contour(" <<
GetName()
780 <<
") ERROR: " << var2.
GetName()
781 <<
" is not a floating parameter of PDF "
796 coutW(Minimization) <<
"RooMinimizer::contour: Error, run Migrad before contours!"
806 n[0] = n1 ;
n[1] = n2 ;
n[2] = n3 ;
n[3] = n4 ;
n[4] = n5 ;
n[5] = n6 ;
808 for (
Int_t ic = 0 ; ic<6 ; ic++) {
820 coutE(Minimization) <<
"RooMinimizer::contour("
822 <<
") ERROR: MINUIT did not return a contour graph for n="
825 xcoor[npoints] = xcoor[0];
826 ycoor[npoints] = ycoor[0];
830 graph->SetLineStyle(ic+1) ;
831 graph->SetLineWidth(2) ;
846 params->
assign(*paramSave) ;
903 throw std::logic_error(
"In RooMinimizer::getMultiGenFcn: _fcnMode has an unsupported value!");
924 throw std::logic_error(
"In RooMinimizer::fitterFcn: _fcnMode has an unsupported value!");
959 oocoutE((
TObject*)0,InputArguments) <<
"RooMinimizer::save: Error, run minimization before!"
967 <<
"RooMinimizer::lastMinuitFit: ERROR: supplied variable list must be either empty " << endl
968 <<
" or match the number of variables of the last fit ("
979 oocoutE((
TObject*)0,InputArguments) <<
"RooMinimizer::lastMinuitFit: ERROR: variable '"
980 << arg->
GetName() <<
"' is not of type RooRealVar" << endl ;
1006 if ((xlo<xhi) && !isConst) {
1007 var =
new RooRealVar(varName,varName,xval,xlo,xhi) ;
1022 oocoutI((
TObject*)0,Eval) <<
"RooMinimizer::lastMinuitFit: fit parameter '" << varName
1023 <<
"' stored in variable '" << var->
GetName() <<
"'" << endl ;
1043 std::vector<double> globalCC;
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
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
Documentation for the abstract class IBaseFunctionMultiDim.
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.
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.
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.
void assign(const RooAbsCollection &other) const
Sets the value, cache and constant attribute of any argument in our set that also appears in the othe...
virtual Bool_t addOwned(RooAbsArg &var, Bool_t silent=kFALSE)
Add an argument and transfer the ownership to the collection.
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.
RooArgList * GetInitFloatParamList()
void setOptimizeConst(Int_t flag)
virtual Bool_t Synchronize(std::vector< ROOT::Fit::ParameterSettings > ¶meters, Bool_t optConst, Bool_t verbose)
Like synchronizeParameterSettings, Synchronize informs Minuit through its parameter_settings vector o...
RooArgList * GetConstParamList()
void BackProp(const ROOT::Fit::FitResult &results)
Put Minuit results back into RooFit objects.
virtual std::string getFunctionName() const =0
RooMinimizer sometimes needs the name of the minimized function. Implement this in the derived class.
virtual std::string getFunctionTitle() const =0
RooMinimizer sometimes needs the title of the minimized function. Implement this in the derived class...
void ApplyCovarianceMatrix(TMatrixDSym &V)
Set different external covariance matrix.
RooArgList * GetFloatParamList()
Logistics.
unsigned int getNDim() const
virtual void setOffsetting(Bool_t flag)=0
Enable or disable offsetting on the function to be minimized, which enhances numerical precision.
void setConstant(Bool_t value=kTRUE)
RooAbsReal is the common abstract base class for objects that represent a real value and implements f...
Double_t getVal(const RooArgSet *normalisationSet=nullptr) const
Evaluate object.
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.
Minuit-RooMinimizer interface which synchronizes parameter data and coordinates evaluation of likelih...
RooMinimizerFcn is an interface to the ROOT::Math::IBaseFunctionMultiDim, a function that ROOT's mini...
RooMinimizer is a wrapper class around ROOT::Fit:Fitter that provides a seamless interface between th...
std::vector< std::pair< std::string, int > > _statusHistory
void initMinimizerFirstPart()
Initialize the part of the minimizer that is independent of the function to be minimized.
RooMinimizer(RooAbsReal &function, FcnMode fcnMode=FcnMode::classic)
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 minimizer 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 initMinimizerFcnDependentPart(double defaultErrorLevel)
Initialize the part of the minimizer that is dependent on the function to be minimized.
RooFitResult * fit(const char *options) R__DEPRECATED(6
Parse traditional RooAbsPdf::fitTo driver options.
void profileStop()
Stop profiling timer and report results of last session.
ROOT::Math::IMultiGenFunction * getFitterMultiGenFcn() const
static RooFitResult * lastMinuitFit(const RooArgList &varList=RooArgList())
const RooAbsMinimizerFcn * fitterFcn() const
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.
~RooMinimizer() override
Destructor.
void optimizeConst(Int_t flag)
If flag is true, perform constant term optimization on function being minimized.
ROOT::Math::IMultiGenFunction * getMultiGenFcn() const
Int_t simplex()
Execute SIMPLEX.
Int_t getPrintLevel() const
ROOT::Fit::Fitter * fitter()
Return underlying ROOT fitter object.
void setStrategy(Int_t strat)
Change MINUIT strategy to istrat.
std::string _minimizerType
RooAbsMinimizerFcn * _fcn
void setVerbose(Bool_t flag=kTRUE)
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 * 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