10#ifndef ROOT_Minuit2_FumiliFCNAdapter 
   11#define ROOT_Minuit2_FumiliFCNAdapter 
   42template <
class Function>
 
   47   typedef typename Function::Type_t 
Type_t;
 
   51   double operator()(std::vector<double> 
const &
v)
 const override { 
return fFunc.operator()(&
v[0]); }
 
   53   double Up()
 const override { 
return fUp; }
 
 
   68template <
class Function>
 
   71   MnPrint print(
"FumiliFCNAdapter");
 
   74   unsigned int npar = Dimension();
 
   76      print.
Error(
"npar", 
npar, 
"v.size()", 
v.size());
 
   80   std::vector<double> &grad = Gradient();
 
   81   std::vector<double> &
hess = Hessian();
 
   84   grad.assign(
npar, 0.0);
 
   87   unsigned int ndata = fFunc.NPoints();
 
   89   std::vector<double> 
gf(
npar);
 
   90   std::vector<double> 
h(
hess.size());
 
   95   if (fFunc.Type() == Function::kLeastSquare) {
 
   96      print.
Debug(
"Chi2 FCN: Evaluate gradient and Hessian");
 
   98      for (
unsigned int i = 0; i < 
ndata; ++i) {
 
  100         double fval = fFunc.DataElement(&
v.front(), i, &
gf[0]);
 
  102         for (
unsigned int j = 0; 
j < 
npar; ++
j) {
 
  104            for (
unsigned int k = 
j; k < 
npar; ++k) {
 
  105               int idx = 
j + k * (k + 1) / 2;
 
  110   } 
else if (fFunc.Type() == Function::kLogLikelihood) {
 
  111      print.
Debug(
"LogLikelihood FCN: Evaluate gradient and Hessian");
 
  112      for (
unsigned int i = 0; i < 
ndata; ++i) {
 
  115         fFunc.DataElement(&
v.front(), i, &
gf[0]);
 
  117         for (
unsigned int j = 0; 
j < 
npar; ++
j) {
 
  120            for (
unsigned int k = 
j; k < 
npar; ++k) {
 
  121               int idx = 
j + k * (k + 1) / 2;
 
  126   } 
else if (fFunc.Type() == Function::kPoissonLikelihood) {
 
  127      print.
Debug(
"Poisson Likelihood FCN: Evaluate gradient and Hessian");
 
  129      for (
unsigned int i = 0; i < 
ndata; ++i) {
 
  131         fFunc.DataElement(&
v.front(), i, 
gf.data(), 
h.data());
 
  132         for (
size_t j = 0; 
j < 
npar; ++
j) {
 
  134            for (
unsigned int k = 
j; k < 
npar; ++k) {
 
  135               int idx = 
j + k * (k + 1) / 2;
 
  141      print.
Error(
"Type of fit method is not supported, it must be chi2 or log-likelihood or Poisson Likelihood");
 
 
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Double_t(* Function)(Double_t)
template wrapped class for adapting to FumiliFCNBase signature
double Up() const override
Error definition of the function.
double operator()(const double *v) const
void SetErrorDef(double up) override
add interface to set dynamically a new error definition Re-implement this function if needed.
void EvaluateAll(std::vector< double > const &v) override
evaluate gradient hessian and function value needed by Fumili
FumiliFCNAdapter(const Function &f, unsigned int ndim, double up=1.)
double operator()(std::vector< double > const &v) const override
The meaning of the vector of parameters is of course defined by the user, who uses the values of thos...
Extension of the FCNBase for the Fumili method.
void Debug(const Ts &... args)
void Error(const Ts &... args)
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...