59 const RooAbsArg *arg = (*_floatParamList).at(i);
61 oocoutW(
_context, Minimization) <<
"RooAbsMinimizerFcn::RooAbsMinimizerFcn: removing parameter "
62 << arg->
GetName() <<
" from list because it is not of type RooRealVar" << endl;
79 : _context(other._context), _maxFCN(other._maxFCN), _funcOffset(other._funcOffset), _numBadNLL(other._numBadNLL),
80 _evalCounter(other._evalCounter), _nDim(other._nDim), _optConst(other._optConst),
81 _floatParamList(new
RooArgList(*other._floatParamList)), _constParamList(new
RooArgList(*other._constParamList)),
82 _initFloatParamList(std::make_unique<
RooArgList>()), _initConstParamList(std::make_unique<
RooArgList>()),
83 _logfile(other._logfile)
94 bool constValChange(
false);
95 bool constStatChange(
false);
116 constStatChange =
true;
121 <<
"RooAbsMinimizerFcn::synchronize: parameter " << par->
GetName() <<
" is now floating." << endl;
127 constValChange =
true;
130 <<
"RooAbsMinimizerFcn::synchronize: value of constant parameter " << par->
GetName() <<
" changed from "
155 oocoutW(
_context, Minimization) <<
"RooAbsMinimizerFcn::fit: Error, non-constant parameter "
156 << par->
GetName() <<
" is not of type RooRealVar, skipping" << endl;
178 pstep = 0.1 * (pmax - pmin);
181 if (pmax - par->
getVal() < 2 * pstep) {
182 pstep = (pmax - par->
getVal()) / 2;
183 }
else if (par->
getVal() - pmin < 2 * pstep) {
184 pstep = (par->
getVal() - pmin) / 2;
189 pstep = 0.1 * (pmax - pmin);
197 <<
"RooAbsMinimizerFcn::synchronize: WARNING: no initial error estimate available for "
198 << par->
GetName() <<
": using " << pstep << endl;
207 if (
index >= parameters.size()) {
210 parameters.emplace_back(par->
GetName(), par->
getVal(), pstep, pmin, pmax);
212 parameters.emplace_back(par->
GetName(), par->
getVal(), pstep);
214 parameters.back().SetLowerLimit(pmin);
215 }
else if (par->
hasMax()) {
216 parameters.back().SetUpperLimit(pmax);
223 bool oldFixed = parameters[
index].IsFixed();
224 double oldVar = parameters[
index].Value();
225 double oldVerr = parameters[
index].StepSize();
226 double oldVlo = parameters[
index].LowerLimit();
227 double oldVhi = parameters[
index].UpperLimit();
232 if (oldVar != par->
getVal()) {
236 <<
"RooAbsMinimizerFcn::synchronize: value of parameter " << par->
GetName() <<
" changed from "
237 << oldVar <<
" to " << par->
getVal() << endl;
240 parameters[
index].Fix();
241 constStatChange =
true;
244 <<
"RooAbsMinimizerFcn::synchronize: parameter " << par->
GetName() <<
" is now fixed." << endl;
250 if (oldVar != par->
getVal()) {
252 constValChange =
true;
256 <<
"RooAbsMinimizerFcn::synchronize: value of fixed parameter " << par->
GetName() <<
" changed from "
257 << oldVar <<
" to " << par->
getVal() << endl;
264 parameters[
index].Release();
265 constStatChange =
true;
269 <<
"RooAbsMinimizerFcn::synchronize: parameter " << par->
GetName() <<
" is now floating." << endl;
274 if (oldVar != par->
getVal() || oldVlo != pmin || oldVhi != pmax || oldVerr != pstep) {
276 parameters[
index].SetStepSize(pstep);
278 parameters[
index].SetLimits(pmin, pmax);
279 }
else if (par->
hasMin()) {
280 parameters[
index].SetLowerLimit(pmin);
281 }
else if (par->
hasMax()) {
282 parameters[
index].SetUpperLimit(pmax);
290 if (oldVar != par->
getVal()) {
292 <<
"RooAbsMinimizerFcn::synchronize: value of parameter " << par->
GetName() <<
" changed from "
293 << oldVar <<
" to " << par->
getVal() << endl;
295 if (oldVlo != pmin || oldVhi != pmax) {
297 <<
"RooAbsMinimizerFcn::synchronize: limits of parameter " << par->
GetName() <<
" changed from ["
298 << oldVlo <<
"," << oldVhi <<
"] to [" << pmin <<
"," << pmax <<
"]" << endl;
302 if (oldVerr != pstep && oldVerr != 0) {
304 <<
"RooAbsMinimizerFcn::synchronize: error/step size of parameter " << par->
GetName()
305 <<
" changed from " << oldVerr <<
" to " << pstep << endl;
355 if (eplus > 0 || eminus < 0) {
371 oocoutI(
_context, Minimization) <<
"RooAbsMinimizerFcn::setLogFile: closing previous log file" << endl;
378 oocoutI(
_context, Minimization) <<
"RooAbsMinimizerFcn::setLogFile: cannot open file " << inLogfile << endl;
392 for (
unsigned int i = 0; i <
_nDim; i++) {
406 if (par->getVal() !=
value) {
425 std::ostringstream msg;
426 if (
cfg().doEEWall) {
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();
451 const char *
name =
"minimizer_log_dataset";
467 oocoutI(
_context, Minimization) <<
"RooAbsMinimizerFcn::setOptimizeConst: deactivating const optimization"
474 oocoutI(
_context, Minimization) <<
"RooAbsMinimizerFcn::setOptimizeConst: activating const optimization"
481 oocoutI(
_context, Minimization) <<
"RooAbsMinimizerFcn::setOptimizeConst: const optimization already active"
486 oocoutI(
_context, Minimization) <<
"RooAbsMinimizerFcn::setOptimizeConst: const optimization wasn't active"
496 if (constStatChange) {
499 <<
"RooAbsMinimizerFcn::optimizeConstantTerms: set of constant parameters changed, rerunning const optimizer"
502 }
else if (constValChange) {
504 <<
"RooAbsMinimizerFcn::optimizeConstantTerms: constant parameter values changed, rerunning const optimizer"
513 std::vector<double> values;
514 values.reserve(
_nDim);
518 values.push_back(par->
getVal());
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t index
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
class containing 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
Common abstract base class for objects that represent a value and a "shape" in RooFit.
bool isConstant() const
Check if the "Constant" attribute is set.
void setValueDirty()
Mark the element dirty. This forces a re-evaluation when a value is requested.
RooAbsCollection * selectByAttrib(const char *name, bool value) const
Create a subset of the current collection, consisting only of those elements with the specified attri...
void setOptimizeConst(Int_t flag)
std::unique_ptr< RooArgList > _floatParamList
bool SetLogFile(const char *inLogfile)
Change the file name for logging of a RooMinimizer of all MINUIT steppings through the parameter spac...
RooAbsMinimizerFcn(RooArgList paramList, RooMinimizer *context)
virtual bool Synchronize(std::vector< ROOT::Fit::ParameterSettings > ¶meters)
Like synchronizeParameterSettings, Synchronize informs Minuit through its parameter_settings vector o...
virtual void setOptimizeConstOnFunction(RooAbsArg::ConstOpCode opcode, bool 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.
RooMinimizer::Config const & cfg() const
void finishDoEval() const
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 SetPdfParamErr(Int_t index, double value)
Modify PDF parameter error by ordinal index (needed by MINUIT)
bool synchronizeParameterSettings(std::vector< ROOT::Fit::ParameterSettings > ¶meters, bool optConst)
Informs Minuit through its parameter_settings vector of RooFit parameter properties.
void ApplyCovarianceMatrix(TMatrixDSym &V)
Set different external covariance matrix.
std::unique_ptr< RooArgList > _initConstParamList
std::unique_ptr< RooArgList > _constParamList
bool SetPdfParamVal(int index, double value) const
Set value of parameter i.
std::unique_ptr< RooArgList > _initFloatParamList
virtual double getMax(const char *name=nullptr) const
Get maximum of currently defined range.
bool hasMax(const char *name=nullptr) const
Check if variable has an upper bound.
virtual double getMin(const char *name=nullptr) const
Get minimum of currently defined range.
bool hasMin(const char *name=nullptr) const
Check if variable has a lower bound.
double getVal(const RooArgSet *normalisationSet=nullptr) const
Evaluate object.
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.
Wrapper class around ROOT::Fit:Fitter that provides a seamless interface between the minimizer functi...
static int getPrintLevel()
Get the MINUIT internal printing level.
std::unique_ptr< RooDataSet > _logDataSet
std::unique_ptr< RooAbsReal::EvalErrorContext > makeEvalErrorContext() const
Variable that can be changed from the outside.
TClass * IsA() const override
Bool_t InheritsFrom(const char *cl) const override
Return kTRUE if this class inherits from a class with name "classname".
const char * GetName() const override
Returns name of object.
TClass * IsA() const override