From: Rene Brun <Rene.Brun_at_cern.ch>

Date: Mon, 04 Dec 2006 13:59:39 +0100

Date: Mon, 04 Dec 2006 13:59:39 +0100

Hi Till,

Instead of making the arrays t and sigma global, define only one global
pointer to an object

that includes these 2 arrays.

We are currently considering extensions to the fitter where a pointer to
an object could be specified

instead of the FCN.

Rene Brun

Till Sawala wrote:

*> Hi Rooters,*

*>*

*> I would like to minimze a likelyhood-function of 1 parameter with Tminuit. At the moment, I use the following pair of functions (adapted from http://root.cern.ch/root/html/examples/Ifit.C.html):*

*>*

*> void NLL(Int_t &npar, Double_t *gin, Double_t &f, Double_t *par, Int_t iflag)*

*> {*

*> Double_t LL = 0.0; *

*> const Int_t nbins = 100000;*

*>*

*> for (int i=1; i<nbins; i++)*

*> {*

*> LL += TMath::Log(Prob(t[i], sigma[i],par));*

*> }*

*>*

*> f = -1. * LL;*

*> }*

*>*

*> Double_t Prob(Double_t t, Double_t sigma, Double_t *par)*

*> {*

*> return .5/par[0] * TMath::Exp(.5*sigma*sigma/(par[0]*par[0]) - t/par[0]) * TMath::Erfc(1/TMath::Sqrt(2) * (sigma/par[0] - t/sigma) );*

*> }*

*>*

*> gMinuit->SetFCN(NLL); *

*>*

*> Where NLL is the function to minimize for par[0], and Prob is a function to calculate the probability for each combination of par[0], t[i] and sigma[i]. However, as the format of NLL is fixed, t and sigma now have to be global and fixed, i.e. NLL only works for one set of t and sigma. Is there a way to change the format of NLL in some way, so that I can pass additional references or pointers? Or maybe you have another suggestion?*

*>*

*> Cheers,*

*> Till*

*> *

Received on Mon Dec 04 2006 - 13:59:49 MET

*
This archive was generated by hypermail 2.2.0
: Mon Jan 01 2007 - 16:32:02 MET
*