43 : _context(context), _verbose(verbose)
60 const RooAbsArg* arg = (*_floatParamList).at(i);
61 if (!arg->IsA()->
InheritsFrom(RooAbsRealLValue::Class())) {
62 oocoutW(
_context,Minimization) <<
"RooAbsMinimizerFcn::RooAbsMinimizerFcn: removing parameter "
63 << arg->
GetName() <<
" from list because it is not of type RooRealVar" << endl;
78 : _context(other._context), _maxFCN(other._maxFCN),
79 _funcOffset(other._funcOffset),
80 _recoverFromNaNStrength(other._recoverFromNaNStrength),
81 _numBadNLL(other._numBadNLL),
82 _printEvalErrors(other._printEvalErrors), _evalCounter(other._evalCounter),
83 _nDim(other._nDim), _optConst(other._optConst),
84 _floatParamList(new
RooArgList(*other._floatParamList)), _constParamList(new
RooArgList(*other._constParamList)),
85 _initFloatParamList((
RooArgList *)other._initFloatParamList->snapshot(
kFALSE)),
86 _initConstParamList((
RooArgList *)other._initConstParamList->snapshot(
kFALSE)),
87 _logfile(other._logfile), _doEvalErrorWall(other._doEvalErrorWall), _verbose(other._verbose)
119 constStatChange =
kTRUE;
124 <<
"RooAbsMinimizerFcn::synchronize: parameter " << par->
GetName() <<
" is now floating." << endl;
130 constValChange =
kTRUE;
133 <<
"RooAbsMinimizerFcn::synchronize: value of constant parameter " << par->
GetName() <<
" changed from "
158 oocoutW(
_context, Minimization) <<
"RooAbsMinimizerFcn::fit: Error, non-constant parameter "
159 << par->
GetName() <<
" is not of type RooRealVar, skipping" << endl;
181 pstep = 0.1 * (pmax - pmin);
184 if (pmax - par->
getVal() < 2 * pstep) {
185 pstep = (pmax - par->
getVal()) / 2;
186 }
else if (par->
getVal() - pmin < 2 * pstep) {
187 pstep = (par->
getVal() - pmin) / 2;
192 pstep = 0.1 * (pmax - pmin);
200 <<
"RooAbsMinimizerFcn::synchronize: WARNING: no initial error estimate available for "
201 << par->
GetName() <<
": using " << pstep << endl;
210 if (index >=
Int_t(parameters.size())) {
213 parameters.emplace_back(par->
GetName(), par->
getVal(), pstep, pmin, pmax);
215 parameters.emplace_back(par->
GetName(), par->
getVal(), pstep);
217 parameters.back().SetLowerLimit(pmin);
219 parameters.back().SetUpperLimit(pmax);
225 Bool_t oldFixed = parameters[index].IsFixed();
226 Double_t oldVar = parameters[index].Value();
227 Double_t oldVerr = parameters[index].StepSize();
228 Double_t oldVlo = parameters[index].LowerLimit();
229 Double_t oldVhi = parameters[index].UpperLimit();
234 if (oldVar != par->
getVal()) {
235 parameters[index].SetValue(par->
getVal());
238 <<
"RooAbsMinimizerFcn::synchronize: value of parameter " << par->
GetName() <<
" changed from "
239 << oldVar <<
" to " << par->
getVal() << endl;
242 parameters[index].Fix();
243 constStatChange =
kTRUE;
246 <<
"RooAbsMinimizerFcn::synchronize: parameter " << par->
GetName() <<
" is now fixed." << endl;
252 if (oldVar != par->
getVal()) {
253 parameters[index].SetValue(par->
getVal());
254 constValChange =
kTRUE;
258 <<
"RooAbsMinimizerFcn::synchronize: value of fixed parameter " << par->
GetName() <<
" changed from "
259 << oldVar <<
" to " << par->
getVal() << endl;
266 parameters[index].Release();
267 constStatChange =
kTRUE;
271 <<
"RooAbsMinimizerFcn::synchronize: parameter " << par->
GetName() <<
" is now floating." << endl;
276 if (oldVar != par->
getVal() || oldVlo != pmin || oldVhi != pmax || oldVerr != pstep) {
277 parameters[index].SetValue(par->
getVal());
278 parameters[index].SetStepSize(pstep);
280 parameters[index].SetLimits(pmin, pmax);
282 parameters[index].SetLowerLimit(pmin);
284 parameters[index].SetUpperLimit(pmax);
291 if (oldVar != par->
getVal()) {
293 <<
"RooAbsMinimizerFcn::synchronize: value of parameter " << par->
GetName() <<
" changed from "
294 << oldVar <<
" to " << par->
getVal() << endl;
296 if (oldVlo != pmin || oldVhi != pmax) {
298 <<
"RooAbsMinimizerFcn::synchronize: limits of parameter " << par->
GetName() <<
" changed from ["
299 << oldVlo <<
"," << oldVhi <<
"] to [" << pmin <<
"," << pmax <<
"]" << endl;
303 if (oldVerr != pstep && oldVerr != 0) {
305 <<
"RooAbsMinimizerFcn::synchronize: error/step size of parameter " << par->
GetName()
306 <<
" changed from " << oldVerr <<
" to " << pstep << endl;
345 for (
unsigned int index = 0; index <
_nDim; index++) {
356 if (eplus > 0 || eminus < 0) {
372 oocoutI(
_context, Minimization) <<
"RooAbsMinimizerFcn::setLogFile: closing previous log file" << endl;
379 oocoutI(
_context, Minimization) <<
"RooAbsMinimizerFcn::setLogFile: cannot open file " << inLogfile << endl;
393 for (
unsigned int i = 0; i <
_nDim; i++) {
405 auto par =
static_cast<RooRealVar*
>(&(*_floatParamList)[index]);
407 if (par->getVal()!=value) {
425 std::ostringstream msg;
427 msg <<
"RooAbsMinimizerFcn: Minimized function has error status." << endl
428 <<
"Returning maximum FCN so far (" <<
_maxFCN
429 <<
") to force MIGRAD to back out of this region. Error log follows.\n";
431 msg <<
"RooAbsMinimizerFcn: Minimized function has error status but is ignored.\n";
434 msg <<
"Parameter values: " ;
436 auto var =
static_cast<const RooRealVar*
>(par);
437 msg <<
"\t" << var->
GetName() <<
"=" << var->getVal() ;
504 oocoutI(
_context, Minimization) <<
"RooAbsMinimizerFcn::setOptimizeConst: deactivating const optimization" << endl;
509 oocoutI(
_context, Minimization) <<
"RooAbsMinimizerFcn::setOptimizeConst: activating const optimization" << endl;
514 oocoutI(
_context, Minimization) <<
"RooAbsMinimizerFcn::setOptimizeConst: const optimization already active" << endl;
517 oocoutI(
_context, Minimization) <<
"RooAbsMinimizerFcn::setOptimizeConst: const optimization wasn't active" << endl;
524 if (constStatChange) {
528 oocoutI(
_context,Minimization) <<
"RooAbsMinimizerFcn::optimizeConstantTerms: set of constant parameters changed, rerunning const optimizer" << endl ;
530 }
else if (constValChange) {
531 oocoutI(
_context,Minimization) <<
"RooAbsMinimizerFcn::optimizeConstantTerms: constant parameter values changed, rerunning const optimizer" << endl ;
546 std::vector<double> values;
547 values.reserve(
_nDim);
549 for (std::size_t index = 0; index <
_nDim; ++index) {
551 values.push_back(par->
getVal());
class containg the result of the fit and all the related information (fitted parameter values,...
double UpperError(unsigned int i) const
upper Minos error. If Minos has not run for parameter i return the parabolic error
double Error(unsigned int i) const
parameter error by index
double Value(unsigned int i) const
parameter value by index
double LowerError(unsigned int i) const
lower Minos error. If Minos has not run for parameter i return the parabolic error
RooAbsArg is the common abstract base class for objects that represent a value and a "shape" in RooFi...
void setValueDirty()
Mark the element dirty. This forces a re-evaluation when a value is requested.
Bool_t isConstant() const
Check if the "Constant" attribute is set.
Storage_t const & get() const
Const access to the underlying stl container.
RooAbsCollection * selectByAttrib(const char *name, Bool_t value) const
Create a subset of the current collection, consisting only of those elements with the specified attri...
RooArgList * GetInitFloatParamList()
Bool_t SetPdfParamVal(int index, double value) const
Set value of parameter i.
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...
std::unique_ptr< RooArgList > _floatParamList
void SetPrintEvalErrors(Int_t numEvalErrors)
Int_t GetNumInvalidNLL() const
RooArgList * GetConstParamList()
virtual void setOptimizeConstOnFunction(RooAbsArg::ConstOpCode opcode, Bool_t doAlsoTrackingOpt)=0
This function must be overridden in the derived class to pass on constant term optimization configura...
void BackProp(const ROOT::Fit::FitResult &results)
Put Minuit results back into RooFit objects.
void optimizeConstantTerms(bool constStatChange, bool constValChange)
void printEvalErrors() const
Print information about why evaluation failed.
void ClearPdfParamAsymErr(Int_t index)
Modify PDF parameter error by ordinal index (needed by MINUIT)
std::vector< double > getParameterValues() const
void ApplyCovarianceMatrix(TMatrixDSym &V)
Set different external covariance matrix.
std::unique_ptr< RooArgList > _initConstParamList
Bool_t synchronizeParameterSettings(std::vector< ROOT::Fit::ParameterSettings > ¶meters, Bool_t optConst, Bool_t verbose)
Informs Minuit through its parameter_settings vector of RooFit parameter properties.
RooArgList * GetFloatParamList()
Logistics.
void SetEvalErrorWall(Bool_t flag)
void SetVerbose(Bool_t flag=kTRUE)
std::unique_ptr< RooArgList > _constParamList
RooAbsMinimizerFcn(RooArgList paramList, RooMinimizer *context, bool verbose=false)
RooArgList * GetInitConstParamList()
std::unique_ptr< RooArgList > _initFloatParamList
Bool_t SetLogFile(const char *inLogfile)
Change the file name for logging of a RooMinimizer of all MINUIT steppings through the parameter spac...
Int_t evalCounter() const
void SetPdfParamErr(Int_t index, Double_t value)
Modify PDF parameter error by ordinal index (needed by MINUIT)
virtual Double_t getMax(const char *name=0) const
Get maximum of currently defined range.
Bool_t hasMax(const char *name=0) const
Check if variable has an upper bound.
Bool_t hasMin(const char *name=0) const
Check if variable has a lower bound.
virtual Double_t getMin(const char *name=0) const
Get miniminum of currently defined range.
Double_t getVal(const RooArgSet *normalisationSet=nullptr) const
Evaluate object.
static void setEvalErrorLoggingMode(ErrorLoggingMode m)
Set evaluation error logging mode.
static void printEvalErrors(std::ostream &os=std::cout, Int_t maxPerNode=10000000)
Print all outstanding logged evaluation error on the given ostream.
RooArgList is a container object that can hold multiple RooAbsArg objects.
RooMinimizer is a wrapper class around ROOT::Fit:Fitter that provides a seamless interface between th...
Int_t getPrintLevel() const
RooRealVar represents a variable that can be changed from the outside.
Double_t getError() const
virtual const char * GetName() const
Returns name of object.
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".