35#ifdef USE_FUMILI_FUNCTION 
   46template<
class MethodFunc>
 
   57      fObjFunc = 
dynamic_cast<const MethodFunc *
>(func);
 
   71   double DataElement(
const double * , 
unsigned int i, 
double * 
g, 
double *)
 const {
 
   76      unsigned int npar = fObjFunc->NDim();
 
   79      const double *
x = fObjFunc->Data().GetPoint(i,
y,
invError);
 
   80      double fval  = fFumili->EvalTFN(
g,
const_cast<double *
>( 
x));
 
   81      fFumili->Derivatives(
g, 
const_cast<double *
>( 
x));
 
   85         for (
unsigned int k = 0; k < 
npar; ++k) {
 
   93         for (
unsigned int k = 0; k < 
npar; ++k) {
 
  105   double DoEval(
const double *
x )
 const {
 
  106      return (*fObjFunc)(
x);
 
  146#ifdef USE_STATIC_TMINUIT 
 
  187         Error(
"SetFunction",
"Wrong Fit method function type used for Fumili");
 
  201      Error(
"SetFunction",
"Wrong Fit method function type used for Fumili");
 
  209#ifdef USE_FUMILI_FUNCTION 
 
  254   unsigned int ndata = 0;
 
  255   unsigned int npar = 0;
 
  268   std::vector<double> 
gf(
npar);
 
  273   for (
unsigned int ipar = 0; ipar < 
npar; ++ipar)
 
  280   std::cout << 
"=============================================";
 
  281   std::cout << 
"par = ";
 
  282   for (
unsigned int ipar = 0; ipar < 
npar; ++ipar)
 
  283      std::cout << 
x[ipar] << 
"\t";
 
  284   std::cout << std::endl;
 
  285   if (
fgFunc) std::cout << 
"type " << 
fgFunc->Type() << std::endl;
 
  295      for (
unsigned int i = 0; i < 
ndata; ++i) {
 
  311         for (
unsigned int j = 0; 
j < 
npar; ++
j) {
 
  313            for (
unsigned int k = 
j; k < 
npar; ++ k) {
 
  314               int idx =  
j + k*(k+1)/2;
 
  316               hess[idx] += 0.5 * 
h[idx]; 
 
  329      for (
unsigned int i = 0; i < 
ndata; ++i) {
 
  344         for (
unsigned int j = 0; 
j < 
npar; ++
j) {
 
  346            for (
unsigned int k = 
j; k < 
npar; ++ k) {
 
  347               int idx =  
j + k*(k+1)/2;
 
  357      for (
unsigned int i = 0; i < 
ndata; ++i) {
 
  370         for (
unsigned int j = 0; 
j < 
npar; ++
j) {
 
  373            for (
unsigned int k = 
j; k < 
npar; ++k) {
 
  374               int idx = 
j + k * (k + 1) / 2;
 
  380      Error(
"EvaluateFCN", 
" type of fit method is not supported, it must be chi2 or log-likelihood");
 
  391   for (
unsigned int i = 0; i < 
npar; ++i) {
 
  392         for (
unsigned int j = 0; 
j <= i; ++
j) {
 
  393            if (
pl0[i] > 0 && 
pl0[
j] > 0) { 
 
  401   std::cout << 
"FCN value " << 
sum << 
" grad ";
 
  402   for (
unsigned int ipar = 0; ipar < 
npar; ++ipar)
 
  403      std::cout << grad[ipar] << 
"\t";
 
  404   std::cout << std::endl << std::endl;
 
 
  419      Error(
"SetVariableValue",
"invalid TFumili pointer. Set function first ");
 
  423   std::cout << 
"set variable " << 
ivar << 
" " << 
name << 
" value " << val << 
" step " << step << std::endl;
 
  428      Error(
"SetVariable",
"Error for parameter %d ",
ivar);
 
 
  437      Error(
"SetVariableValue",
"invalid TFumili pointer. Set function first ");
 
  441   std::cout << 
"set limited variable " << 
ivar << 
" " << 
name << 
" value " << val << 
" step " << step << std::endl;
 
  445      Error(
"SetLimitedVariable",
"Error for parameter %d ",
ivar);
 
 
  451bool Fumili2Minimizer::SetLowerLimitedVariable(
unsigned int ivar , 
const std::string & 
name , 
double val , 
double step , 
double lower ) {
 
  453   double s = val-
lower;
 
  454   double upper = s*1.0E15;
 
  455   if (s != 0)  
upper = 1.0E15;
 
  463   if (fFumili == 
nullptr) {
 
  464      Error(
"SetVariableValue",
"invalid TFumili pointer. Set function first ");
 
  469   int ierr = fFumili->SetParameter(
ivar, 
name.c_str(), val, 0., val, val );
 
  470   fFumili->FixParameter(
ivar);
 
  473   std::cout << 
"Fix variable " << 
ivar << 
" " << 
name << 
" value " << std::endl;
 
  477      Error(
"SetFixedVariable",
"Error for parameter %d ",
ivar);
 
 
  485   if (fFumili == 
nullptr) {
 
  486      Error(
"SetVariableValue",
"invalid TFumili pointer. Set function first ");
 
  493      Error(
"SetVariableValue",
"Error for parameter %d ",
ivar);
 
  497   std::cout << 
"set variable " << 
ivar << 
" " << 
name << 
" value " 
  498             << val << 
" step " <<  
verr << std::endl;
 
  503      Error(
"SetVariableValue",
"Error for parameter %d ",
ivar);
 
 
  515   if (fFumili == 
nullptr) {
 
  516      Error(
"SetVariableValue",
"invalid TFumili pointer. Set function first ");
 
  537      fFumili->ExecuteCommand(
"SET NOW",
arglist,0);
 
  539      fFumili->ExecuteCommand(
"SET WAR",
arglist,0);
 
  542      fFumili->ExecuteCommand(
"SET NOD",
arglist,0);
 
  544      fFumili->ExecuteCommand(
"SET DEB",
arglist,0);
 
  548   arglist[0] = MaxFunctionCalls();
 
  552      std::cout << 
"Minimize using TFumili with tolerance = " << Tolerance()
 
  553                << 
" max calls " << MaxFunctionCalls() << std::endl;
 
  555   int iret = fFumili->ExecuteCommand(
"MIGRAD",
arglist,2);
 
  582   assert (
static_cast<unsigned int>(
ntot) == fDim);
 
  583   assert( 
nfree == fFumili->GetNumberFreeParameters() );
 
  589   fParams.resize( fDim);
 
  590   fErrors.resize( fDim);
 
  591   fCovar.resize(fDim*fDim);
 
  592   const double * 
cv = fFumili->GetCovarianceMatrix();
 
  594   for (
unsigned int i = 0; i < fDim; ++i) {
 
  595      fParams[i] = fFumili->GetParameter( i );
 
  596      fErrors[i] = fFumili->GetParError( i );
 
  598      if ( !fFumili->IsFixed(i) ) {
 
  599         for (
unsigned int j = 0; 
j <=i ; ++
j) {
 
  600            if ( !fFumili->IsFixed(
j) ) {
 
  601               fCovar[i*fDim + 
j] = 
cv[
l];
 
  602               fCovar[
j*fDim + i] = fCovar[i*fDim + 
j];
 
 
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
 
void Error(const char *location, const char *msgfmt,...)
Use this function in case an error occurred.
 
Chi2FCN class for binned fits using the least square methods.
 
class evaluating the log likelihood for binned Poisson likelihood fits it is template to distinguish ...
 
FitMethodFunction class Interface for objective functions (like chi2 and likelihood used in the fit) ...
 
Type_t
enumeration specifying the possible fit method types
 
FunctionType::BaseFunc BaseFunction
 
Documentation for the abstract class IBaseFunctionMultiDim.
 
virtual bool HasGradient() const
 
virtual unsigned int NDim() const =0
Retrieve the dimension of the function.
 
Param Functor class for Multidimensional functions.
 
static ROOT::Math::FitMethodFunction * fgFunc
 
bool SetFixedVariable(unsigned int, const std::string &, double) override
set fixed variable (override if minimizer supports them )
 
TFumiliMinimizer(int dummy=0)
Default constructor (an argument is needed by plug-in manager)
 
bool SetLimitedVariable(unsigned int ivar, const std::string &name, double val, double step, double, double) override
set upper/lower limited variable (override if minimizer supports them )
 
static double EvaluateFCN(const double *x, double *g)
implementation of FCN for Fumili when user provided gradient is used
 
~TFumiliMinimizer() override
Destructor (no operations)
 
bool Minimize() override
method to perform the minimization
 
static ROOT::Math::FitMethodGradFunction * fgGradFunc
 
static TFumili * fgFumili
 
bool SetVariableValue(unsigned int ivar, double val) override
set the value of an existing variable
 
void SetFunction(const ROOT::Math::IMultiGenFunction &func) override
set the function to minimize
 
bool SetVariable(unsigned int ivar, const std::string &name, double val, double step) override
set free variable
 
static void Fcn(int &, double *, double &f, double *, int)
implementation of FCN for Fumili
 
void SetParNumber(Int_t ParNum)
 
Int_t SetParameter(Int_t ipar, const char *parname, Double_t value, Double_t verr, Double_t vlow, Double_t vhigh) override
Sets for parameter number ipar initial parameter value, name parname, initial error verr and limits v...
 
virtual void SetFCN(void(*fcn)(Int_t &, Double_t *, Double_t &f, Double_t *, Int_t))
To set the address of the minimization objective function called by the native compiler (see function...
 
Namespace for new Math classes and functions.
 
T EvalLog(T x)
safe evaluation of log(x) with a protections against negative or zero argument to the log smooth line...
 
BasicFitMethodFunction< ROOT::Math::IMultiGenFunction > FitMethodFunction
 
static uint64_t sum(uint64_t i)