ROOT  6.06/09
Reference Guide
FcnAdapter.h
Go to the documentation of this file.
1 // @(#)root/minuit2:$Id$
2 // Author: L. Moneta 10/2005
3 
4 /**********************************************************************
5  * *
6  * Copyright (c) 2005 ROOT Foundation, CERN/PH-SFT *
7  * *
8  **********************************************************************/
9 
10 #ifndef ROOT_Fit_FcnAdapter_H_
11 #define ROOT_Fit_FcnAdapter_H_
12 
13 #ifndef ROOT_Math_IFunction
14 #include "Math/IFunction.h"
15 #endif
16 
17 
18 //___________________________________________________________
19 //
20 // Adapt the interface used in TMinuit (and the TVirtualFitter) for
21 // passing the objective function in a IFunction interface
22 // (ROOT::Math::IMultiGenFunction)
23 //
24 
25 namespace ROOT {
26 
27  namespace Fit {
28 
30 
31 public:
32 
33  FcnAdapter(void (*fcn)(int&, double*, double&, double*, int ), int dim = 0) :
34  fDim(dim),
35  fFCN(fcn)
36  {}
37 
38  virtual ~FcnAdapter() {}
39 
40  virtual unsigned int NDim() const { return fDim; }
41 
43  return new FcnAdapter(fFCN,fDim);
44  }
45 
46  void SetDimension(int dim) { fDim = dim; }
47 
48 private:
49 
50  virtual double DoEval(const double * x) const {
51  double fval = 0;
52  int dim = fDim;
53  // call with flag 4
54  fFCN(dim, 0, fval, const_cast<double *>(x), 4);
55  return fval;
56  }
57 
58 private:
59 
60  unsigned int fDim;
61  void (*fFCN)(int&, double*, double&, double*, int);
62 
63 
64 };
65 
66  } // end namespace Fit
67 
68 } // end namespace ROOT
69 
70 #endif //ROOT_Fit_FcnAdapter
Namespace for new ROOT classes and functions.
Definition: ROOT.py:1
FcnAdapter(void(*fcn)(int &, double *, double &, double *, int), int dim=0)
Definition: FcnAdapter.h:33
void(* fFCN)(int &, double *, double &, double *, int)
Definition: FcnAdapter.h:61
Double_t x[n]
Definition: legend1.C:17
virtual ~FcnAdapter()
Definition: FcnAdapter.h:38
ROOT::Math::IMultiGenFunction * Clone() const
Clone a function.
Definition: FcnAdapter.h:42
TFitResultPtr Fit(FitObject *h1, TF1 *f1, Foption_t &option, const ROOT::Math::MinimizerOptions &moption, const char *goption, ROOT::Fit::DataRange &range)
Definition: HFitImpl.cxx:132
typedef void((*Func_t)())
unsigned int fDim
Definition: FcnAdapter.h:60
virtual unsigned int NDim() const
Retrieve the dimension of the function.
Definition: FcnAdapter.h:40
void SetDimension(int dim)
Definition: FcnAdapter.h:46
Documentation for the abstract class IBaseFunctionMultiDim.
Definition: IFunction.h:63
virtual double DoEval(const double *x) const
Implementation of the evaluation function.
Definition: FcnAdapter.h:50