22namespace TestStatistics {
45 std::vector<ROOT::Fit::ParameterSettings> ¶meters,
LikelihoodMode likelihoodMode,
48 minuit_external_x_(NDim(), 0)
58 likelihood->synchronizeParameterSettings(parameters);
59 gradient->synchronizeParameterSettings(
this, parameters);
78 if (!parameters_changed) {
88 <<
"RooGradMinimizerFcn: Minimized function has error status." << std::endl
89 <<
"Returning maximum FCN so far (" <<
_maxFCN
90 <<
") to force MIGRAD to back out of this region. Error log follows" << std::endl;
93 <<
"RooGradMinimizerFcn: Minimized function has error status but is ignored" << std::endl;
99 auto var =
static_cast<const RooRealVar *
>(rooAbsArg);
125 std::cout <<
"\nprevFCN" << (
likelihood->isOffsetting() ?
"-offset" :
"") <<
" = " << std::setprecision(10)
126 << fvalue << std::setprecision(4) <<
" ";
173 bool a_parameter_has_been_updated =
false;
174 if (minuit_internal) {
176 throw std::logic_error(
"Updating Minuit-internal parameters only makes sense for (gradient) calculators that "
177 "are defined in Minuit-internal parameter space.");
180 for (std::size_t ix = 0; ix <
NDim(); ++ix) {
182 if (parameter_changed) {
185 a_parameter_has_been_updated |= parameter_changed;
188 if (a_parameter_has_been_updated) {
194 bool a_parameter_is_mismatched =
false;
196 for (std::size_t ix = 0; ix <
NDim(); ++ix) {
206 a_parameter_has_been_updated |= parameter_changed;
212 if (a_parameter_has_been_updated) {
218 return a_parameter_has_been_updated;
228 double *previous_gstep)
const
231 gradient->fillGradientWithPrevResult(grad, previous_grad, previous_g2, previous_gstep);
236 throw std::runtime_error(
"MinuitFcnGrad::DoDerivative is not implemented, please use Gradient instead.");
243 likelihood->synchronizeParameterSettings(parameters);
244 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...
Bool_t SetPdfParamVal(int index, double value) const
Set value of parameter i.
std::unique_ptr< RooArgList > _floatParamList
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.
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.
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.
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.
Bool_t Synchronize(std::vector< ROOT::Fit::ParameterSettings > ¶meter_settings, Bool_t optConst, Bool_t verbose=kFALSE) override
Overridden from RooAbsMinimizerFcn to include gradient strategy synchronization.
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
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
unsigned int NDim() const override
Part of IMultiGradFunction interface, used widely both in Minuit and in RooFit.
MinuitFcnGrad(const std::shared_ptr< RooFit::TestStatistics::RooAbsL > &_likelihood, RooMinimizer *context, std::vector< ROOT::Fit::ParameterSettings > ¶meters, LikelihoodMode likelihoodMode, LikelihoodGradientMode likelihoodGradientMode, bool verbose=false)
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...