00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #ifndef ROOT_TFcnAdapter_H_
00011 #define ROOT_TFcnAdapter_H_
00012
00013 #ifndef ROOT_Minuit2_FCNGradientBase
00014 #include "Minuit2/FCNGradientBase.h"
00015 #endif
00016
00017 #ifndef ROOT_Rtypes
00018 #include "Rtypes.h"
00019 #endif
00020
00021
00022
00023
00024
00025
00026
00027
00028 class TFcnAdapter : public ROOT::Minuit2::FCNGradientBase {
00029
00030 public:
00031
00032 TFcnAdapter(void (*fcn)(int&, double*, double&, double*, int)) : fFCN(fcn), fUp(1) {}
00033
00034 virtual ~TFcnAdapter() {}
00035
00036 const ROOT::Minuit2::FCNBase& Base() const {return *this;}
00037
00038 double operator()(const std::vector<double>&) const;
00039 double Up() const {return fUp; }
00040
00041 void SetErrorDef(double up) { fUp = up; }
00042
00043 std::vector<double> Gradient(const std::vector<double>&) const;
00044
00045
00046 double operator()(int npar, double* params,int iflag = 4) const;
00047
00048 private:
00049
00050 void (*fFCN)(int&, double*, double&, double*, int);
00051 double fUp;
00052 mutable std::vector<double> fGradCache;
00053
00054 ClassDef(TFcnAdapter,0)
00055 };
00056 #endif //ROOT_GFcnAdapter_H_