Re: [ROOT] TMinuit with fcn as a member function of a class ?

From: Dr. John Krane (jkrane@netzero.com)
Date: Fri Apr 02 2004 - 00:10:02 MEST


Ooohh...kay....  I'm just gonna nod my head and smile, and hope there is 
no quiz later.

    - John

>Yes, but it does involve using a global function of sort, but it's
>declared static, so it's not accessible from outside it's compilation
>unit: 
>
>  // Header file 
>  class MyFitfunction 
>  { 
>    static MyFitFunction* _instance;
>    MyFitFunction() {}
>    MyFitFunction(const MyFitFunction& o) {}
>    MyFitFunction& operator=(const MyFitFunction& o) { return *this; }
>  public:
>    static MyFitFunction& Instance();
>    Double_t Function(Int_t&, Double_t*, Double_t*, Int_t);
>    static void Use();
>  };
>
>  // Source 
>  static myFitFunction(Int_t& a, Double_t* p, Double_t &f, Double_t* d, Int_t f)  
>  {
>    MyFitFunction& fitFunc = MyFitFunction::Instance();
>    f = fitFunction.Function(a, p, d, f);
>  }
>
>  MyFitFunction* MyFitFunction::_instance = 0;
>
>  MyFitFunction* MyFitFunction::Instance() 
>  { 
>    if (!_instance) _instance = new MyFitFunction;
>    return _instance;
>  }
>
>  MyFitFunction::MyFitFunction() 
>  {}
>
>  void MyFitFunction::Use() 
>  {
>    gMinuit->SetFcn(myFitFunction);
>  }
>
>Another way would be to use the Functor stuff from
>www.moderncppdesign.com. 
>
>My 2 cents.
>
>Yours,
>
> ___  |  Christian Holm Christensen 
>  |_| |	 -------------------------------------------------------------
>    | |	 Address: Sankt Hansgade 23, 1. th.  Phone:  (+45) 35 35 96 91
>     _|	          DK-2200 Copenhagen N       Cell:   (+45) 24 61 85 91
>    _|	          Denmark                    Office: (+45) 353  25 404
> ____|	 Email:   cholm@nbi.dk               Web:    www.nbi.dk/~cholm
> | |
>
>
>
>  
>

-- 

Dr. John Krane
jkrane@netzero.com



This archive was generated by hypermail 2b29 : Sun Jan 02 2005 - 05:50:07 MET