50 oocoutW(
_context, Minimization) <<
"RooAbsMinimizerFcn::RooAbsMinimizerFcn: removing parameter "
51 << param->
GetName() <<
" from list because it is not of type RooRealVar"
58 std::size_t iParam = 0;
78 <<
" is not constant anymore, but it was constant at the time where the RooMinimizer was constructed."
79 " This is illegal. The other way around is supported: you can always change the constant flag of "
80 "parameters that were floating at the time the minimizer was instantiated.";
81 oocxcoutF(
nullptr, LinkStateMgmt) << ss.str() << std::endl;
82 throw std::runtime_error(ss.str());
86 std::vector<ROOT::Fit::ParameterSettings> oldParameters = parameters;
99 double pmin = par.hasMin() ? par.getMin() : 0.0;
100 double pmax = par.hasMax() ? par.getMax() : 0.0;
103 double pstep = par.getError();
106 if (par.hasMin() && par.hasMax()) {
107 pstep = 0.1 * (pmax - pmin);
110 if (pmax - par.getVal() < 2 * pstep) {
111 pstep = (pmax - par.getVal()) / 2;
112 }
else if (par.getVal() - pmin < 2 * pstep) {
113 pstep = (par.getVal() - pmin) / 2;
118 pstep = 0.1 * (pmax - pmin);
126 <<
"RooAbsMinimizerFcn::synchronize: WARNING: no initial error estimate available for " << par.GetName()
127 <<
": using " << pstep << std::endl;
131 if (par.hasMin() && par.hasMax()) {
132 parameters.emplace_back(par.GetName(), par.getVal(), pstep, pmin, pmax);
134 parameters.emplace_back(par.GetName(), par.getVal(), pstep);
136 parameters.back().SetLowerLimit(pmin);
137 }
else if (par.hasMax()) {
138 parameters.back().SetUpperLimit(pmax);
142 par.isConstant() ? parameters.back().Fix() : parameters.back().Release();
146 bool constStateChange =
false;
147 bool constValChange =
false;
148 for (std::size_t i = 0; i < oldParameters.size(); ++i) {
149 auto const &newParam = parameters[i];
150 auto const &oldParam = oldParameters[i];
151 constStateChange &= (newParam.IsFixed() != oldParam.IsFixed());
152 constValChange &= (newParam.IsFixed() && (newParam.Value() != oldParam.Value()));
178 double err = results.fErrors[
index];
181 double eminus = results.lowerError(
index);
182 double eplus = results.upperError(
index);
184 if (eplus > 0 || eminus < 0) {
186 param.setAsymError(eminus, eplus);
189 param.removeAsymError();
200 oocoutI(
_context, Minimization) <<
"RooAbsMinimizerFcn::setLogFile: closing previous log file" << std::endl;
205 _logfile =
new std::ofstream(inLogfile);
207 oocoutI(
_context, Minimization) <<
"RooAbsMinimizerFcn::setLogFile: cannot open file " << inLogfile << std::endl;
221 for (
unsigned int i = 0; i <
getNDim(); i++) {
231 if (par.getVal() !=
value) {
233 std::cout << par.GetName() <<
"=" <<
value <<
", ";
250 std::ostringstream msg;
251 if (
cfg().doEEWall) {
252 msg <<
"RooAbsMinimizerFcn: Minimized function has error status." << std::endl
253 <<
"Returning maximum FCN so far (" <<
_maxFCN
254 <<
") to force MIGRAD to back out of this region. Error log follows.\n";
256 msg <<
"RooAbsMinimizerFcn: Minimized function has error status but is ignored.\n";
259 msg <<
"Parameter values: ";
260 for (std::size_t i = 0; i <
getNDim(); ++i) {
262 msg <<
"\t" << var.GetName() <<
"=" << var.getVal();
283 if (
cfg().doEEWall) {
311 oocoutI(
_context, Minimization) <<
"RooAbsMinimizerFcn::setOptimizeConst: deactivating const optimization"
318 oocoutI(
_context, Minimization) <<
"RooAbsMinimizerFcn::setOptimizeConst: activating const optimization"
325 oocoutI(
_context, Minimization) <<
"RooAbsMinimizerFcn::setOptimizeConst: const optimization already active"
330 oocoutI(
_context, Minimization) <<
"RooAbsMinimizerFcn::setOptimizeConst: const optimization wasn't active"
340 if (constStatChange) {
343 <<
"RooAbsMinimizerFcn::optimizeConstantTerms: set of constant parameters changed, rerunning const optimizer"
346 }
else if (constValChange) {
348 <<
"RooAbsMinimizerFcn::optimizeConstantTerms: constant parameter values changed, rerunning const optimizer"
380 initFloatableParams.
add(*param);
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
Common abstract base class for objects that represent a value and a "shape" in RooFit.
RooAbsCollection * snapshot(bool deepCopy=true) const
Take a snap shot of current collection contents.
const char * GetName() const override
Returns name of object.
virtual bool add(const RooAbsArg &var, bool silent=false)
Add the specified argument to list.
Storage_t::size_type size() const
bool selectCommon(const RooAbsCollection &refColl, RooAbsCollection &outColl) const
Create a subset of the current collection, consisting only of those elements that are contained as we...
std::vector< std::size_t > _floatableParamIndices
void setOptimizeConst(Int_t flag)
static bool canBeFloating(RooAbsArg const &arg)
static bool treatAsConstant(RooAbsArg const &arg)
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...
double applyEvalErrorHandling(double fvalue) const
Apply corrections on the fvalue if errors were signaled.
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...
RooArgList constParams() const
RooMinimizer::Config const & cfg() const
RooArgList _allParamsInit
void finishDoEval() const
void optimizeConstantTerms(bool constStatChange, bool constValChange)
void printEvalErrors() const
Print information about why evaluation failed.
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.
RooArgList initFloatParams() const
RooRealVar & floatableParam(std::size_t i) const
void BackProp()
Put Minuit results back into RooFit objects.
bool SetPdfParamVal(int index, double value) const
Set value of parameter i.
RooArgList floatParams() const
unsigned int getNDim() const
static Int_t numEvalErrors()
Return the number of logged evaluation errors since the last clearing.
static void printEvalErrors(std::ostream &os=std::cout, Int_t maxPerNode=10000000)
Print all outstanding logged evaluation error on the given ostream.
static void clearEvalErrorLog()
Clear the stack of evaluation error messages.
RooArgList is a container object that can hold multiple RooAbsArg objects.
Wrapper class around ROOT::Math::Minimizer that provides a seamless interface between the minimizer f...
int getPrintLevel()
Get the MINUIT internal printing level.
auto fitter()
Return underlying ROOT fitter object.
std::unique_ptr< RooAbsReal::EvalErrorContext > makeEvalErrorContext() const
void setError(double value)
static float unpackNaN(double val)
If val is NaN and a this NaN has been tagged as containing a payload, unpack the float from the manti...