Re: bug in TMinuit calling "fcn" function

stefan kluth (skluth@mh1.lbl.gov)
Mon, 11 Jan 1999 10:25:56 -0800 (PST)


On Mon, 11 Jan 1999, Rene Brun wrote:
> > with root 2.20/06 I find that in
> >
> > void fcn( Int_t &npar, Double_t *gin, Double_t &f,
> > Double_t *par, Int_t iflag) {
> >
> > // my fit code
> >
> > }
> >
> > which is called by MINUIT through TMinuit the parameter iflag is not
> > passed correctly. Even calling fcn explicitly with
> >
> > ...
> > arglist[0]= 4;
> > gMinuit->mnexcm( "CALL", arglist, 1, ierflg );
> > ...
> >
> > I get nonsense (i.e something like iflag= 6585878) for iflag in fcn. This
> > is bad, because traditionally in MINUIT style fits one has if-blocks in
> > the fcn function which test the value of iflag to initialise, calculate
> > the fit function or do some final calculation after the fit is done. At
> > the moment, I have a workaround by using an extra constant fit parameter
> > to pass a value for iflag, but this is quite ugly.

> I cannot reproduce this problem.
> We provide a simple test program in $ROOTSYS/test/minexam.
> Could you put a print statement in the function fcnk0 of the example
> and tell me if you get what is expected. I have no problems with it.

Hm, the difference is that the minexam.cxx is compiled while mine is
interpreted. I reproduced my problem by modifying minexam.cxx such that it
can be loaded with ".L minexam.cxx". On printing "iflag" at the beginning
if fcnk0 I get:

iflag= 536751360 (dec/alpha cxx6)
iflag= -1073835196 (Linux)

The compiled versions work fine on both systems.

cheers, Stefan

PS: I found that cint doesn't like

const Int_t MXBIN= 50;
static Double_t thplu[MXBIN];

I had to change it to

static Double_t thplu[50];

but I don't understand why.

---Stefan Kluth---------------Lynen Fellow----------------|\--|\-------
- LBNL, MS 50A 2160 - phone: +1 510 495 2376 - |/ |/ -
- 1 Cyclotron Rd. - fax: +1 510 495 2957 - |\/\|\/\|' -
---Berkeley, CA94720, USA-----e-mail: SKluth@lbl.gov------|/\/|/\/|----