I have solved similar problems posed by CINT's inability to handle pointers to member functions by declaring a function that wraps the access: static DPrecAlign * g_DPA_Object = NULL; // global object, to give fcn a context... void fcn_wrapper(Int_t &npar, Double_t *gin, Double_t &f, Double_t *u, Int_t flag) { assert(g_DPA_Object != NULL); if (g_DPA_Object) g_DPA_Object->fcn(npar, gin, f, u, flag); // if fcn needs a this context (to access member variables), // it gets it from g_DPA_Object. } then in your code, you can write: DPrecAlign * localObject; ... g_DPA_Object = localObject; fit->SetFCN(fcn_wrapper); ... // do your fitting here... ... g_DPA_Object = NULL; // when you're done. If DPrecAlign::fit() does not use any non-static member variables, then you can dispense with the need for a global g_DPS_Object altogether At 04:57 AM 2/2/2000 , Gilles Orazi wrote: >Hello, > >Is it possible to use Minuit with a fcn which is a member of an >object ? I have some problems when trying to do it. > > >Here is a more precise description of what I'm trying to do: > >I have created a class called DPrecAlign which contains a list of data >points. > >I also have a class called DPrecAlignWithFit declared as follows : > >class DPrecAlignWithFit : public TObject { > public: > DPrecAlign *alignement ; > TMinuit *fit ; >... >} > >The TMinuit object is used to fit the list of data points contained in >the DPrecAlign object. > >The likelihood function is computed by a method of DPrecAlign, >declared as follows: >void DPrecAlign::fcn(...) > >My problem is that when I'm trying to define this method as the minuit >FCN: > > fit->SetFCN(&DPrecAlign::fcn); > >I get a compiler error: >"Argument of type 'void (DPrecAlign::*)(int,double *,double,double *,int)' >could not be converted to 'void *'" > >I tryed many things to solve it but nothing worked. > > > >Thanks a lot by advance for your answers. > >Cheers, >-- > Gilles > > =========================================================================== Jonathan M. Gilligan <jonathan.gilligan@vanderbilt.edu> Research Assistant Professor of Physics (615) 343-6252 Dept. of Physics and Astronomy, Box 1807-B Fax: 343-7263 6823 Stevenson Center Vanderbilt University, Nashville, TN 37235 Dep't Office: 322-2828
This archive was generated by hypermail 2b29 : Tue Jan 02 2001 - 11:50:18 MET