Re: use of TMinuit with FCN = a class member function

From: Rene Brun (Rene.Brun@cern.ch)
Date: Thu Feb 27 1997 - 08:20:34 MET


Martin Woudstra wrote:
> 
> Hello,
> 
> How can I use the TMinuit class with the FCN function being
> a member-function of a class?
> 

TMinuit::SetFCN cannot accept a class member function as parameter.
Only normal static functions are currently supported.
However, it is easy to obtain the equivalent in the following way:
I give below some statements extracted from the histogram class TH1.
Look at TH1::Fit for more details.

//Declare prototype of function

extern void H1FitChisquare(Int_t &npar, Double_t *gin, Double_t &f,
Double_t *u, Int_t flag);

//create Minuit object and set fitting function
TMinuit *minuit = new TMinuit(25);
minuit->SetFCN(H1FitChisquare);

//pass to the Minuit object the address of an object of your class
   minuit->SetObjectFit(myobject);

//In H1FitChisquare, you can access to your object (example in root)
   TH1 *hfit = (TH1*)minuit->GetObjectFit();

Rene Brun



This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:26:18 MET