TFcnAdapter.h

Go to the documentation of this file.
00001 // @(#)root/minuit2:$Id: TFcnAdapter.h 20880 2007-11-19 11:23:41Z rdm $
00002 // Author: L. Moneta    10/2005  
00003 
00004 /**********************************************************************
00005  *                                                                    *
00006  * Copyright (c) 2005 ROOT Foundation,  CERN/PH-SFT                   *
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 // Adapt the interface used in TMinuit (and the TVirtualFitter) for 
00024 // passing the objective function in a Minuit2 interface 
00025 // (ROOT::Minuit2::FCNGradientBase or ROOT::Minuit2::FCNBase)
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    // forward interface
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)  // wrapper class implementing the Minuit2 interface for TMinuit2-like objective functions
00055 };
00056 #endif //ROOT_GFcnAdapter_H_

Generated on Tue Jul 5 14:26:47 2011 for ROOT_528-00b_version by  doxygen 1.5.1