22namespace TestStatistics {
49 std::vector<ROOT::Fit::ParameterSettings> ¶meters,
LikelihoodMode likelihoodMode,
51 :
RooAbsMinimizerFcn(*_likelihood->getParameters(), context), minuit_internal_x_(NDim(), 0),
52 minuit_external_x_(NDim(), 0)
67 likelihood->synchronizeParameterSettings(parameters);
71 gradient->synchronizeParameterSettings(
this, parameters);
89 likelihood_here->evaluate();
90 double fvalue = likelihood_here->getResult().Sum();
94 if (!parameters_changed) {
103 oocoutW(
nullptr,
Eval) <<
"MinuitFcnGrad: Minimized function has error status." << std::endl
104 <<
"Returning maximum FCN so far (" <<
_maxFCN
105 <<
") to force MIGRAD to back out of this region. Error log follows" << std::endl;
107 oocoutW(
nullptr,
Eval) <<
"MinuitFcnGrad: Minimized function has error status but is ignored"
114 auto var =
static_cast<const RooRealVar *
>(rooAbsArg);
128 if (
cfg().doEEWall) {
140 std::cout <<
"\nprevFCN" << (likelihood_here->isOffsetting() ?
"-offset" :
"") <<
" = " << std::setprecision(10)
141 << fvalue << std::setprecision(4) <<
" ";
188 bool a_parameter_has_been_updated =
false;
189 if (minuit_internal) {
191 throw std::logic_error(
"Updating Minuit-internal parameters only makes sense for (gradient) calculators that "
192 "are defined in Minuit-internal parameter space.");
195 for (std::size_t ix = 0; ix <
NDim(); ++ix) {
197 if (parameter_changed) {
200 a_parameter_has_been_updated |= parameter_changed;
203 if (a_parameter_has_been_updated) {
212 bool a_parameter_is_mismatched =
false;
214 for (std::size_t ix = 0; ix <
NDim(); ++ix) {
224 a_parameter_has_been_updated |= parameter_changed;
230 if (a_parameter_has_been_updated) {
239 return a_parameter_has_been_updated;
251 double *previous_gstep)
const
255 gradient->fillGradientWithPrevResult(grad, previous_grad, previous_g2, previous_gstep);
261 throw std::runtime_error(
"MinuitFcnGrad::DoDerivative is not implemented, please use Gradient instead.");
267 likelihood->synchronizeParameterSettings(parameters);
271 gradient->synchronizeParameterSettings(parameters);
ROOT::Math::MinimizerOptions & MinimizerOptions()
access to the minimizer control parameter (non const method)
const FitConfig & Config() const
access to the fit configuration (const method)
RooAbsArg is the common abstract base class for objects that represent a value and a "shape" in RooFi...
std::unique_ptr< RooArgList > _floatParamList
RooMinimizer::Config const & cfg() const
void finishDoEval() const
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.
bool SetPdfParamVal(int index, double value) const
Set value of parameter i.
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.
static std::unique_ptr< LikelihoodGradientWrapper > create(LikelihoodGradientMode likelihoodGradientMode, std::shared_ptr< RooAbsL > likelihood, std::shared_ptr< WrapperCalculationCleanFlags > calculationIsClean, std::size_t nDim, RooMinimizer *minimizer)
Factory method.
static std::unique_ptr< LikelihoodWrapper > create(LikelihoodMode likelihoodMode, std::shared_ptr< RooAbsL > likelihood, std::shared_ptr< WrapperCalculationCleanFlags > calculationIsClean)
Factory method.
MinuitFcnGrad(const std::shared_ptr< RooFit::TestStatistics::RooAbsL > &_likelihood, RooMinimizer *context, std::vector< ROOT::Fit::ParameterSettings > ¶meters, LikelihoodMode likelihoodMode, LikelihoodGradientMode likelihoodGradientMode)
bool Synchronize(std::vector< ROOT::Fit::ParameterSettings > ¶meter_settings) override
Overridden from RooAbsMinimizerFcn to include gradient strategy synchronization.
std::vector< double > minuit_internal_x_
double DoDerivative(const double *x, unsigned int icoord) const override
This override should not be used in this class, so it throws.
double DoEval(const double *x) const override
IMultiGradFunction override necessary for Minuit.
bool syncParameterValuesFromMinuitCalls(const double *x, bool minuit_internal) const
Minuit calls (via FcnAdapters etc) DoEval or Gradient with a set of parameters x.
std::shared_ptr< WrapperCalculationCleanFlags > calculation_is_clean
bool returnsInMinuit2ParameterSpace() const override
std::shared_ptr< LikelihoodWrapper > likelihood_in_gradient
bool minuit_internal_roofit_x_mismatch_
void GradientWithPrevResult(const double *x, double *grad, double *previous_grad, double *previous_g2, double *previous_gstep) const override
void Gradient(const double *x, double *grad) const override
IMultiGradFunction overrides necessary for Minuit.
std::shared_ptr< LikelihoodWrapper > likelihood
std::vector< double > minuit_external_x_
std::shared_ptr< LikelihoodGradientWrapper > gradient
bool calculating_gradient_
unsigned int NDim() const override
Part of IMultiGradFunction interface, used widely both in Minuit and in RooFit.
RooMinimizer is a wrapper class around ROOT::Fit:Fitter that provides a seamless interface between th...
ROOT::Fit::Fitter * fitter()
Return underlying ROOT fitter object.
RooRealVar represents a variable that can be changed from the outside.
The namespace RooFit contains mostly switches that change the behaviour of functions of PDFs (or othe...