Logo ROOT  
Reference Guide
TFumiliMinimizer.cxx
Go to the documentation of this file.
1 // @(#)root/fumili:$Id$
2 // Author: L. Moneta Wed Oct 25 16:28:55 2006
3 
4 /**********************************************************************
5  * *
6  * Copyright (c) 2006 LCG ROOT Math Team, CERN/PH-SFT *
7  * *
8  * *
9  **********************************************************************/
10 
11 // Implementation file for class TFumiliMinimizer
12 
13 #include "TFumiliMinimizer.h"
14 #include "Math/IFunction.h"
15 #include "Math/Util.h"
16 #include "TError.h"
17 
18 #include "TFumili.h"
19 
20 #include <iostream>
21 #include <cassert>
22 #include <algorithm>
23 #include <functional>
24 
25 
26 // setting USE_FUMILI_FUNCTION will use the Derivatives provided by Fumili
27 // instead of what proided in FitUtil::EvalChi2Residual
28 // t.d.: use still standard Chi2 but replace model function
29 // with a gradient function where gradient is computed by TFumili
30 // since TFumili knows the step size can calculate it better
31 // Derivative in FUmili are very fast (1 extra call for each parameter)
32 // + 1 function evaluation
33 //
34 //#define USE_FUMILI_FUNCTION
35 #ifdef USE_FUMILI_FUNCTION
36 bool gUseFumiliFunction = true;
37 //#include "FumiliFunction.h"
38 // fit method function used in TFumiliMinimizer
39 
41 #include "Fit/LogLikelihoodFCN.h"
42 #include "Fit/Chi2FCN.h"
43 #include "TF1.h"
44 #include "TFumili.h"
45 
46 template<class MethodFunc>
47 class FumiliFunction : public ROOT::Math::FitMethodFunction {
48 
50 
51 public:
52  FumiliFunction(TFumili * fumili, const ROOT::Math::FitMethodFunction * func) :
53  ROOT::Math::FitMethodFunction(func->NDim(), func->NPoints() ),
54  fFumili(fumili),
55  fObjFunc(0)
56  {
57  fObjFunc = dynamic_cast<const MethodFunc *>(func);
58  assert(fObjFunc != 0);
59 
60  // create TF1 class from model function
61  fModFunc = new TF1("modfunc",ROOT::Math::ParamFunctor( &fObjFunc->ModelFunction() ) );
62  fFumili->SetUserFunc(fModFunc);
63  }
64 
65  ROOT::Math::FitMethodFunction::Type_t Type() const { return fObjFunc->Type(); }
66 
67  FumiliFunction * Clone() const { return new FumiliFunction(fFumili, fObjFunc); }
68 
69 
70  // recalculate data elemet using Fumili stuff
71  double DataElement(const double * /*par */, unsigned int i, double * g) const {
72 
73  // parameter values are inside TFumili
74 
75  // suppose type is bin likelihood
76  unsigned int npar = fObjFunc->NDim();
77  double y = 0;
78  double invError = 0;
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));
82 
83  if ( fObjFunc->Type() == ROOT::Math::FitMethodFunction::kLogLikelihood) {
84  double logPdf = y * ROOT::Math::Util::EvalLog( fval) - fval;
85  for (unsigned int k = 0; k < npar; ++k) {
86  g[k] *= ( y/fval - 1.) ;//* pdfval;
87  }
88 
89  // std::cout << "x = " << x[0] << " logPdf = " << logPdf << " grad";
90 // for (unsigned int ipar = 0; ipar < npar; ++ipar)
91 // std::cout << g[ipar] << "\t";
92 // std::cout << std::endl;
93 
94  return logPdf;
95  }
96  else if (fObjFunc->Type() == ROOT::Math::FitMethodFunction::kLeastSquare ) {
97  double resVal = (y-fval)*invError;
98  for (unsigned int k = 0; k < npar; ++k) {
99  g[k] *= -invError;
100  }
101  return resVal;
102  }
103 
104  return 0;
105  }
106 
107 
108 private:
109 
110  double DoEval(const double *x ) const {
111  return (*fObjFunc)(x);
112  }
113 
114  TFumili * fFumili;
115  const MethodFunc * fObjFunc;
116  TF1 * fModFunc;
117 
118 };
119 #else
120 bool gUseFumiliFunction = false;
121 #endif
122 //______________________________________________________________________________
123 //
124 // TFumiliMinimizer class implementing the ROOT::Math::Minimizer interface using
125 // TFumili.
126 // This class is normally instantiates using the plug-in manager
127 // (plug-in with name Fumili or TFumili)
128 // In addition the user can choose the minimizer algorithm: Migrad (the default one), Simplex, or Minimize (combined Migrad + Simplex)
129 //
130 //__________________________________________________________________________________________
131 
132 // initialize the static instances
133 
137 
138 
140 
141 
143  fDim(0),
144  fNFree(0),
145  fMinVal(0),
146  fEdm(-1),
147  fFumili(0)
148 {
149  // Constructor for TFumiliMinimier class
150 
151  // construct with npar = 0 (by default a value of 25 is used in TFumili for allocating the arrays)
152 #ifdef USE_STATIC_TMINUIT
153  // allocate here only the first time
154  if (fgFumili == 0) fgFumili = new TFumili(0);
155  fFumili = fgFumili;
156 #else
157  if (fFumili) delete fFumili;
158  fFumili = new TFumili(0);
159  fgFumili = fFumili;
160 #endif
161 
162 }
163 
164 
166 {
167  // Destructor implementation.
168  if (fFumili) delete fFumili;
169 }
170 
172  Minimizer()
173 {
174  // Implementation of copy constructor (it is private).
175 }
176 
178 {
179  // Implementation of assignment operator (private)
180  if (this == &rhs) return *this; // time saving self-test
181  return *this;
182 }
183 
184 
185 
187  // Set the objective function to be minimized, by passing a function object implement the
188  // basic multi-dim Function interface. In this case the derivatives will be
189  // calculated by Fumili
190 
191  // Here a TFumili instance is created since only at this point we know the number of parameters
192  // needed to create TFumili
193  fDim = func.NDim();
195 
196  // for Fumili the fit method function interface is required
197  const ROOT::Math::FitMethodFunction * fcnfunc = dynamic_cast<const ROOT::Math::FitMethodFunction *>(&func);
198  if (!fcnfunc) {
199  Error("SetFunction","Wrong Fit method function type used for Fumili");
200  return;
201  }
202  // assign to the static pointer (NO Thread safety here)
203  fgFunc = const_cast<ROOT::Math::FitMethodFunction *>(fcnfunc);
204  fgGradFunc = 0;
206 
207 #ifdef USE_FUMILI_FUNCTION
208  if (gUseFumiliFunction) {
211  else if (fcnfunc->Type() == ROOT::Math::FitMethodFunction::kLeastSquare)
213  }
214 #endif
215 
216 }
217 
219  // Set the objective function to be minimized, by passing a function object implement the
220  // multi-dim gradient Function interface. In this case the function derivatives are provided
221  // by the user via this interface and there not calculated by Fumili.
222 
223  fDim = func.NDim();
225 
226  // for Fumili the fit method function interface is required
227  const ROOT::Math::FitMethodGradFunction * fcnfunc = dynamic_cast<const ROOT::Math::FitMethodGradFunction *>(&func);
228  if (!fcnfunc) {
229  Error("SetFunction","Wrong Fit method function type used for Fumili");
230  return;
231  }
232  // assign to the static pointer (NO Thread safety here)
233  fgFunc = 0;
234  fgGradFunc = const_cast<ROOT::Math::FitMethodGradFunction *>(fcnfunc);
236 
237 }
238 
239 void TFumiliMinimizer::Fcn( int & , double * g , double & f, double * x , int /* iflag */) {
240  // implementation of FCN static function used internally by TFumili.
241  // Adapt IMultiGenFunction interface to TFumili FCN static function
242  f = TFumiliMinimizer::EvaluateFCN(const_cast<double*>(x),g);
243 }
244 
245 // void TFumiliMinimizer::FcnGrad( int &, double * g, double & f, double * x , int iflag ) {
246 // // implementation of FCN static function used internally by TFumili.
247 // // Adapt IMultiGradFunction interface to TFumili FCN static function in the case of user
248 // // provided gradient.
249 // ROOT::Math::IMultiGradFunction * gFunc = dynamic_cast<ROOT::Math::IMultiGradFunction *> ( fgFunc);
250 
251 // assert(gFunc != 0);
252 // f = gFunc->operator()(x);
253 
254 // // calculates also derivatives
255 // if (iflag == 2) gFunc->Gradient(x,g);
256 // }
257 
258 double TFumiliMinimizer::EvaluateFCN(const double * x, double * grad) {
259  // function callaed to evaluate the FCN at the value x
260  // calculates also the matrices of the second derivatives of the objective function needed by FUMILI
261 
262 
263  //typedef FumiliFCNAdapter::Function Function;
264 
265 
266 
267  // reset
268 // assert(grad.size() == npar);
269 // grad.assign( npar, 0.0);
270 // hess.assign( hess.size(), 0.0);
271 
272  double sum = 0;
273  unsigned int ndata = 0;
274  unsigned int npar = 0;
275  if (fgFunc) {
276  ndata = fgFunc->NPoints();
277  npar = fgFunc->NDim();
278  fgFunc->UpdateNCalls();
279  }
280  else if (fgGradFunc) {
281  ndata = fgGradFunc->NPoints();
282  npar = fgGradFunc->NDim();
284  }
285 
286  // eventually store this matrix as static member to optimize speed
287  std::vector<double> gf(npar);
288  std::vector<double> hess(npar*(npar+1)/2);
289 
290  // reset gradients
291  for (unsigned int ipar = 0; ipar < npar; ++ipar)
292  grad[ipar] = 0;
293 
294 
295  //loop on the data points
296 //#define DEBUG
297 #ifdef DEBUG
298  std::cout << "=============================================";
299  std::cout << "par = ";
300  for (unsigned int ipar = 0; ipar < npar; ++ipar)
301  std::cout << x[ipar] << "\t";
302  std::cout << std::endl;
303  if (fgFunc) std::cout << "type " << fgFunc->Type() << std::endl;
304 #endif
305 
306 
307  // assume for now least-square
308  // since TFumili doet not use errodef I must diveide chi2 by 2
311 
312  double fval = 0;
313  for (unsigned int i = 0; i < ndata; ++i) {
314  // calculate data element and gradient
315  // DataElement returns (f-y)/s and gf is derivatives of model function multiplied by (-1/sigma)
316  if (gUseFumiliFunction) {
317  fval = fgFunc->DataElement( x, i, &gf[0]);
318  }
319  else {
320  if (fgFunc != 0)
321  fval = fgFunc->DataElement(x, i, &gf[0]);
322  else
323  fval = fgGradFunc->DataElement(x, i, &gf[0]);
324  }
325 
326  // t.b.d should protect for bad values of fval
327  sum += fval*fval;
328 
329  // to be check (TFumili uses a factor of 1/2 for chi2)
330 
331  for (unsigned int j = 0; j < npar; ++j) {
332  grad[j] += fval * gf[j];
333  for (unsigned int k = j; k < npar; ++ k) {
334  int idx = j + k*(k+1)/2;
335  hess[idx] += gf[j] * gf[k];
336  }
337  }
338  }
339  }
342 
343 
344 
345  double fval = 0;
346 
347  //std::cout << "\t x " << x[0] << " " << x[1] << " " << x[2] << std::endl;
348 
349  for (unsigned int i = 0; i < ndata; ++i) {
350 
351  if (gUseFumiliFunction) {
352  fval = fgFunc->DataElement( x, i, &gf[0]);
353  }
354  else {
355  // calculate data element and gradient
356  if (fgFunc != 0)
357  fval = fgFunc->DataElement(x, i, &gf[0]);
358  else
359  fval = fgGradFunc->DataElement(x, i, &gf[0]);
360  }
361 
362  // protect for small values of fval
363  // std::cout << i << " " << fval << " log " << " grad " << gf[0] << " " << gf[1] << " " << gf[2] << std::endl;
364 // sum -= ROOT::Math::Util::EvalLog(fval);
365  sum -= fval;
366 
367  for (unsigned int j = 0; j < npar; ++j) {
368  double gfj = gf[j];// / fval;
369  grad[j] -= gfj;
370  for (unsigned int k = j; k < npar; ++ k) {
371  int idx = j + k*(k+1)/2;
372  hess[idx] += gfj * gf[k];// / (fval );
373  }
374  }
375  }
376  }
377  else {
378  Error("EvaluateFCN"," type of fit method is not supported, it must be chi2 or log-likelihood");
379  }
380 
381  // now TFumili excludes fixed prameter in second-derivative matrix
382  // ned to get them using the static instance of TFumili
383  double * zmatrix = fgFumili->GetZ();
384  double * pl0 = fgFumili->GetPL0(); // parameter limits
385  assert(zmatrix != 0);
386  assert(pl0 != 0);
387  unsigned int k = 0;
388  unsigned int l = 0;
389  for (unsigned int i = 0; i < npar; ++i) {
390  for (unsigned int j = 0; j <= i; ++j) {
391  if (pl0[i] > 0 && pl0[j] > 0) { // only for non-fixed parameters
392  zmatrix[l++] = hess[k];
393  }
394  k++;
395  }
396  }
397 
398 #ifdef DEBUG
399  std::cout << "FCN value " << sum << " grad ";
400  for (unsigned int ipar = 0; ipar < npar; ++ipar)
401  std::cout << grad[ipar] << "\t";
402  std::cout << std::endl << std::endl;
403 #endif
404 
405 
406  return 0.5*sum; // fumili multiply then by 2
407 
408 }
409 
410 
411 
412 bool TFumiliMinimizer::SetVariable(unsigned int ivar, const std::string & name, double val, double step) {
413  // set a free variable.
414  if (fFumili == 0) {
415  Error("SetVariableValue","invalid TFumili pointer. Set function first ");
416  return false;
417  }
418 #ifdef DEBUG
419  std::cout << "set variable " << ivar << " " << name << " value " << val << " step " << step << std::endl;
420 #endif
421 
422  int ierr = fFumili->SetParameter(ivar , name.c_str(), val, step, 0., 0. );
423  if (ierr) {
424  Error("SetVariable","Error for parameter %d ",ivar);
425  return false;
426  }
427  return true;
428 }
429 
430 bool TFumiliMinimizer::SetLimitedVariable(unsigned int ivar, const std::string & name, double val, double step, double lower, double upper) {
431  // set a limited variable.
432  if (fFumili == 0) {
433  Error("SetVariableValue","invalid TFumili pointer. Set function first ");
434  return false;
435  }
436 #ifdef DEBUG
437  std::cout << "set limited variable " << ivar << " " << name << " value " << val << " step " << step << std::endl;
438 #endif
439  int ierr = fFumili->SetParameter(ivar, name.c_str(), val, step, lower, upper );
440  if (ierr) {
441  Error("SetLimitedVariable","Error for parameter %d ",ivar);
442  return false;
443  }
444  return true;
445 }
446 #ifdef LATER
447 bool Fumili2Minimizer::SetLowerLimitedVariable(unsigned int ivar , const std::string & name , double val , double step , double lower ) {
448  // add a lower bounded variable as a double bound one, using a very large number for the upper limit
449  double s = val-lower;
450  double upper = s*1.0E15;
451  if (s != 0) upper = 1.0E15;
452  return SetLimitedVariable(ivar, name, val, step, lower,upper);
453 }
454 #endif
455 
456 
457 bool TFumiliMinimizer::SetFixedVariable(unsigned int ivar, const std::string & name, double val) {
458  // set a fixed variable.
459  if (fFumili == 0) {
460  Error("SetVariableValue","invalid TFumili pointer. Set function first ");
461  return false;
462  }
463 
464 
465  int ierr = fFumili->SetParameter(ivar, name.c_str(), val, 0., val, val );
466  fFumili->FixParameter(ivar);
467 
468 #ifdef DEBUG
469  std::cout << "Fix variable " << ivar << " " << name << " value " << std::endl;
470 #endif
471 
472  if (ierr) {
473  Error("SetFixedVariable","Error for parameter %d ",ivar);
474  return false;
475  }
476  return true;
477 }
478 
479 bool TFumiliMinimizer::SetVariableValue(unsigned int ivar, double val) {
480  // set the variable value
481  if (fFumili == 0) {
482  Error("SetVariableValue","invalid TFumili pointer. Set function first ");
483  return false;
484  }
485  TString name = fFumili->GetParName(ivar);
486  double oldval, verr, vlow, vhigh = 0;
487  int ierr = fFumili->GetParameter( ivar, &name[0], oldval, verr, vlow, vhigh);
488  if (ierr) {
489  Error("SetVariableValue","Error for parameter %d ",ivar);
490  return false;
491  }
492 #ifdef DEBUG
493  std::cout << "set variable " << ivar << " " << name << " value "
494  << val << " step " << verr << std::endl;
495 #endif
496 
497  ierr = fFumili->SetParameter(ivar , name , val, verr, vlow, vhigh );
498  if (ierr) {
499  Error("SetVariableValue","Error for parameter %d ",ivar);
500  return false;
501  }
502  return true;
503 }
504 
506  // perform the minimization using the algorithm chosen previously by the user
507  // By default Migrad is used.
508  // Return true if the found minimum is valid and update internal chached values of
509  // minimum values, errors and covariance matrix.
510 
511  if (fFumili == 0) {
512  Error("SetVariableValue","invalid TFumili pointer. Set function first ");
513  return false;
514  }
515 
516  // need to set static instance to be used when calling FCN
517  fgFumili = fFumili;
518 
519 
520  double arglist[10];
521 
522  // error cannot be set in TFumili (always the same)
523 // arglist[0] = ErrorUp();
524 // fFumili->ExecuteCommand("SET Err",arglist,1);
525 
526  int printlevel = PrintLevel();
527  // not implemented in TFumili yet
528  //arglist[0] = printlevel - 1;
529  //fFumili->ExecuteCommand("SET PRINT",arglist,1,ierr);
530 
531  // suppress warning in case Printlevel() == 0
532  if (printlevel == 0) fFumili->ExecuteCommand("SET NOW",arglist,0);
533  else fFumili->ExecuteCommand("SET WAR",arglist,0);
534 
535 
536  // minimize: use ExecuteCommand instead of Minimize to set tolerance and maxiter
537 
538  arglist[0] = MaxFunctionCalls();
539  arglist[1] = Tolerance();
540 
541  if (printlevel > 0)
542  std::cout << "Minimize using TFumili with tolerance = " << Tolerance()
543  << " max calls " << MaxFunctionCalls() << std::endl;
544 
545  int iret = fFumili->ExecuteCommand("MIGRAD",arglist,2);
546  fStatus = iret;
547  //int iret = fgFumili->Minimize();
548 
549  // Hesse and IMP not implemented
550 // // run improved if needed
551 // if (ierr == 0 && fType == ROOT::Fumili::kMigradImproved)
552 // fFumili->mnexcm("IMPROVE",arglist,1,ierr);
553 
554 // // check if Hesse needs to be run
555 // if (ierr == 0 && IsValidError() ) {
556 // fFumili->mnexcm("HESSE",arglist,1,ierr);
557 // }
558 
559 
560  int ntot;
561  int nfree;
562  double errdef = 0; // err def is not used by Fumili
563  fFumili->GetStats(fMinVal,fEdm,errdef,nfree,ntot);
564 
565  if (printlevel > 0)
566  fFumili->PrintResults(printlevel,fMinVal);
567 
568 
569  assert (static_cast<unsigned int>(ntot) == fDim);
570  assert( nfree == fFumili->GetNumberFreeParameters() );
571  fNFree = nfree;
572 
573 
574  // get parameter values and correlation matrix
575  // fumili stores only lower part of diagonal matrix of the free parameters
576  fParams.resize( fDim);
577  fErrors.resize( fDim);
578  fCovar.resize(fDim*fDim);
579  const double * cv = fFumili->GetCovarianceMatrix();
580  unsigned int l = 0;
581  for (unsigned int i = 0; i < fDim; ++i) {
582  fParams[i] = fFumili->GetParameter( i );
583  fErrors[i] = fFumili->GetParError( i );
584 
585  if ( !fFumili->IsFixed(i) ) {
586  for (unsigned int j = 0; j <=i ; ++j) {
587  if ( !fFumili->IsFixed(j) ) {
588  fCovar[i*fDim + j] = cv[l];
589  fCovar[j*fDim + i] = fCovar[i*fDim + j];
590  l++;
591  }
592  }
593  }
594  }
595 
596  return (iret==0) ? true : false;
597 }
598 
599 
600 // } // end namespace Fit
601 
602 // } // end namespace ROOT
603 
TFumiliMinimizer::SetVariable
virtual bool SetVariable(unsigned int ivar, const std::string &name, double val, double step)
set free variable
Definition: TFumiliMinimizer.cxx:412
l
auto * l
Definition: textangle.C:4
TFumili::FixParameter
virtual void FixParameter(Int_t ipar)
Fixes parameter number ipar.
Definition: TFumili.cxx:766
TFumili::SetParameter
virtual Int_t SetParameter(Int_t ipar, const char *parname, Double_t value, Double_t verr, Double_t vlow, Double_t vhigh)
Sets for parameter number ipar initial parameter value, name parname, initial error verr and limits v...
Definition: TFumili.cxx:1633
Util.h
ROOT::Fit::PoissonLikelihoodFCN
class evaluating the log likelihood for binned Poisson likelihood fits it is template to distinguish ...
Definition: PoissonLikelihoodFCN.h:58
ROOT::Math::BasicFitMethodFunction::kLeastSquare
@ kLeastSquare
Definition: FitMethodFunction.h:59
ROOT::Fit::Chi2FCN
Chi2FCN class for binnned fits using the least square methods.
Definition: Chi2FCN.h:49
IFunction.h
f
#define f(i)
Definition: RSha256.hxx:122
TFumili::GetPL0
Double_t * GetPL0() const
Definition: TFumili.h:95
ROOT::Math::Minimizer::PrintLevel
int PrintLevel() const
minimizer configuration parameters
Definition: Minimizer.h:412
TFumiliMinimizer::fgFumili
static TFumili * fgFumili
Definition: TFumiliMinimizer.h:178
TFumiliMinimizer.h
ClassImp
#define ClassImp(name)
Definition: Rtypes.h:364
TFumili::ExecuteCommand
virtual Int_t ExecuteCommand(const char *command, Double_t *args, Int_t nargs)
Execute MINUIT commands.
Definition: TFumili.cxx:383
ROOT::Math::BasicFitMethodFunction::NDim
virtual unsigned int NDim() const
Number of dimension (parameters) .
Definition: FitMethodFunction.h:76
TFumili::GetZ
Double_t * GetZ() const
Definition: TFumili.h:102
TFumiliMinimizer::fFumili
TFumili * fFumili
Definition: TFumiliMinimizer.h:171
TFumiliMinimizer::fDim
unsigned int fDim
Definition: TFumiliMinimizer.h:163
TFumiliMinimizer::SetFunction
virtual void SetFunction(const ROOT::Math::IMultiGenFunction &func)
set the function to minimize
Definition: TFumiliMinimizer.cxx:186
PoissonLikelihoodFCN.h
TFumiliMinimizer::fEdm
double fEdm
Definition: TFumiliMinimizer.h:166
TGeant4Unit::s
static constexpr double s
Definition: TGeant4SystemOfUnits.h:168
gUseFumiliFunction
bool gUseFumiliFunction
Definition: TFumiliMinimizer.cxx:120
TFumiliMinimizer::fgFunc
static ROOT::Math::FitMethodFunction * fgFunc
Definition: TFumiliMinimizer.h:175
ROOT::Math::IBaseFunctionMultiDimTempl::NDim
virtual unsigned int NDim() const =0
Retrieve the dimension of the function.
x
Double_t x[n]
Definition: legend1.C:17
ROOT::Math::IGradientFunctionMultiDimTempl
Interface (abstract class) for multi-dimensional functions providing a gradient calculation.
Definition: IFunction.h:326
ROOT::Math::BasicFitMethodFunction::UpdateNCalls
virtual void UpdateNCalls() const
update number of calls
Definition: FitMethodFunction.h:105
ROOT::Math::Minimizer::MaxFunctionCalls
unsigned int MaxFunctionCalls() const
max number of function calls
Definition: Minimizer.h:415
TFumiliMinimizer::fMinVal
double fMinVal
Definition: TFumiliMinimizer.h:165
TFumiliMinimizer::fgGradFunc
static ROOT::Math::FitMethodGradFunction * fgGradFunc
Definition: TFumiliMinimizer.h:176
TString
Definition: TString.h:136
TFumiliMinimizer::TFumiliMinimizer
TFumiliMinimizer(int dummy=0)
Default constructor (an argument is needed by plug-in manager)
Definition: TFumiliMinimizer.cxx:142
TFumiliMinimizer::fErrors
std::vector< double > fErrors
Definition: TFumiliMinimizer.h:168
TFumiliMinimizer::Fcn
static void Fcn(int &, double *, double &f, double *, int)
implementation of FCN for Fumili
Definition: TFumiliMinimizer.cxx:239
TFumili
Definition: TFumili.h:11
TFumili::GetCovarianceMatrix
virtual Double_t * GetCovarianceMatrix() const
Return a pointer to the covariance matrix.
Definition: TFumili.cxx:776
LogLikelihoodFCN.h
TVirtualFitter::SetFCN
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...
Definition: TVirtualFitter.cxx:267
Chi2FCN.h
TFumiliMinimizer::Minimize
virtual bool Minimize()
method to perform the minimization
Definition: TFumiliMinimizer.cxx:505
ROOT::Math::BasicFitMethodFunction::Type_t
Type_t
enumeration specyfing the possible fit method types
Definition: FitMethodFunction.h:59
TFumili::PrintResults
virtual void PrintResults(Int_t k, Double_t p) const
Prints fit results.
Definition: TFumili.cxx:1475
TFumili::GetStats
virtual Int_t GetStats(Double_t &amin, Double_t &edm, Double_t &errdef, Int_t &nvpar, Int_t &nparx) const
Return global fit parameters.
Definition: TFumili.cxx:896
TFumili::SetParNumber
void SetParNumber(Int_t ParNum)
Definition: TFumili.h:112
ROOT::Math::Minimizer::Tolerance
double Tolerance() const
absolute tolerance
Definition: Minimizer.h:421
ROOT::Math::Minimizer::fStatus
int fStatus
Definition: Minimizer.h:494
TFumiliMinimizer::SetFixedVariable
virtual bool SetFixedVariable(unsigned int, const std::string &, double)
set fixed variable (override if minimizer supports them )
Definition: TFumiliMinimizer.cxx:457
y
Double_t y[n]
Definition: legend1.C:17
TFumili::GetParError
virtual Double_t GetParError(Int_t ipar) const
Return error of parameter ipar.
Definition: TFumili.cxx:818
TFumiliMinimizer::SetLimitedVariable
virtual bool SetLimitedVariable(unsigned int ivar, const std::string &name, double val, double step, double, double)
set upper/lower limited variable (override if minimizer supports them )
Definition: TFumiliMinimizer.cxx:430
ROOT::Math::BasicFitMethodFunction::Type
virtual Type_t Type() const
return the type of method, override if needed
Definition: FitMethodFunction.h:95
ROOT::Math::BasicFitMethodFunction::NPoints
virtual unsigned int NPoints() const
return the number of data points used in evaluating the function
Definition: FitMethodFunction.h:90
TFumili::GetParName
virtual const char * GetParName(Int_t ipar) const
Return name of parameter ipar.
Definition: TFumili.cxx:864
RooFit::Minimizer
RooCmdArg Minimizer(const char *type, const char *alg=0)
Definition: RooGlobalFunc.cxx:211
sum
static long int sum(long int i)
Definition: Factory.cxx:2272
TFumili::IsFixed
virtual Bool_t IsFixed(Int_t ipar) const
Return kTRUE if parameter ipar is fixed, kFALSE otherwise)
Definition: TFumili.cxx:1052
TFumiliMinimizer::EvaluateFCN
static double EvaluateFCN(const double *x, double *g)
implementation of FCN for Fumili when user provided gradient is used
Definition: TFumiliMinimizer.cxx:258
ROOT::Math::Util::EvalLog
T EvalLog(T x)
safe evaluation of log(x) with a protections against negative or zero argument to the log smooth line...
Definition: Util.h:64
TFumili::GetNumberFreeParameters
virtual Int_t GetNumberFreeParameters() const
Return the number of free parameters.
Definition: TFumili.cxx:806
ROOT::Math::IGradientFunctionMultiDimTempl::NDim
virtual unsigned int NDim() const=0
Retrieve the dimension of the function.
TF1.h
TFumiliMinimizer
TFumiliMinimizer class: minimizer implementation based on TFumili.
Definition: TFumiliMinimizer.h:43
name
char name[80]
Definition: TGX11.cxx:110
ROOT::Math::BasicFitMethodFunction::BaseFunction
FunctionType::BaseFunc BaseFunction
Definition: FitMethodFunction.h:56
ROOT::Math::BasicFitMethodFunction::DataElement
virtual double DataElement(const double *x, unsigned int i, double *g=0) const =0
method returning the data i-th contribution to the fit objective function For example the residual fo...
TFumili::GetParameter
virtual Double_t GetParameter(Int_t ipar) const
Return current value of parameter ipar.
Definition: TFumili.cxx:827
TFumiliMinimizer::fNFree
unsigned int fNFree
Definition: TFumiliMinimizer.h:164
ROOT::Math::BasicFitMethodFunction
FitMethodFunction class Interface for objective functions (like chi2 and likelihood used in the fit) ...
Definition: Fitter.h:40
TFumiliMinimizer::fCovar
std::vector< double > fCovar
Definition: TFumiliMinimizer.h:169
ROOT::Math::IBaseFunctionMultiDimTempl
Documentation for the abstract class IBaseFunctionMultiDim.
Definition: IFunction.h:62
ROOT::Math::BasicFitMethodFunction::kLogLikelihood
@ kLogLikelihood
Definition: FitMethodFunction.h:59
TF1
1-Dim function class
Definition: TF1.h:212
TFumiliMinimizer::operator=
TFumiliMinimizer & operator=(const TFumiliMinimizer &rhs)
Assignment operator.
Definition: TFumiliMinimizer.cxx:177
ROOT::Math::ParamFunctorTempl
Param Functor class for Multidimensional functions.
Definition: ParamFunctor.h:283
TFumiliMinimizer::~TFumiliMinimizer
~TFumiliMinimizer()
Destructor (no operations)
Definition: TFumiliMinimizer.cxx:165
ROOT::Math::FitMethodFunction
BasicFitMethodFunction< ROOT::Math::IMultiGenFunction > FitMethodFunction
Definition: Fitter.h:40
TFumiliMinimizer::fParams
std::vector< double > fParams
Definition: TFumiliMinimizer.h:167
TFumiliMinimizer::SetVariableValue
virtual bool SetVariableValue(unsigned int ivar, double val)
set the value of an existing variable
Definition: TFumiliMinimizer.cxx:479
ROOT
VSD Structures.
Definition: StringConv.hxx:21
Math
TFumili.h
Error
void Error(const char *location, const char *msgfmt,...)
Use this function in case an error occurred.
Definition: TError.cxx:187
TError.h
g
#define g(i)
Definition: RSha256.hxx:123