RE: [ROOT] Using TH1 Fit method within TMinuit

From: Greg Landsberg (landsberg@hep.brown.edu)
Date: Tue Mar 04 2003 - 14:26:38 MET


Hi Rene,

Thanks for the prompt reply, and sorry for not being more specific in my
original e-mail!

I have, in fact, tried all three: the TMinuit, TFitter, and
TVirtualFitter in the main minimization procedure, and in all cases the
switch from fcn to the histogram fitting function occurred, once the
first instance of TH1F Fit() has been used. As per your suggestion, I
made my own TMinuit (or TFitter/TVirtualFitter) object and did not use
the global ones. Nevertheless I saw the very same behavior. For the
histogram fit I did not _explicitly_ use TMinuit functions, as the
fitting function is fairly simple (A Gaussian plus an exponent), so I
merely defined an appropriate TF1 and then used the TH1F's Fit() method
with standard parameters to perform the fit (i.e., I passed no
user-defined functions to the histogram fitter).

The original code is somewhat too complicated to send around, as it uses
TTree to fill the histogram to be fit. I'll try to come up with a simple
example that illustrates the above behavior and send it to this list.

Thanks,

Greg

> -----Original Message-----
> From: Rene Brun [mailto:brun@pcbrun.cern.ch]
> Sent: Tuesday, March 04, 2003 4:09 AM
> To: Greg Landsberg
> Cc: roottalk@pcroot.cern.ch
> Subject: Re: [ROOT] Using TH1 Fit method within TMinuit
> 
> Hi Greg,
> 
> You mention TMinuit and TVirtualFitter, but you do not indicate which
> one you are really using in your external loop and in your internal
loop.
> The following should work:
>  - you create your own instance of TMinuit *myminuit = new
TMinuit(...);
>  - you then use only the myminuit pointer (not gMinuit)
>  - you let TH1::Fit calls TVirtualFitter
> 
> Rene Brun
> 
> On
> Mon, 3 Mar 2003, Greg Landsberg wrote:
> 
> > Dear Rooters,
> >
> > I have faced the following problem when trying to use TMinuit or
> > TVirtualFitter class to do a complicated minimization. My
minimization
> > function, fcn, which is passed to TMinuit/TVirtualFitter via the
SetFCN
> > method fills a histogram that it further fits to a certain function
via
> > standard TH1F Fit() method. The results of this 'internal' fit are
used
> > in order to estimate the return value of fcn.
> >
> > However, as soon as the first instance of the TH1F Fit() is called,
the
> > Minuit is switched to optimize the histogram, not the function fcn!
This
> > is as if there were just a single copy of the TMinuit object that
exists
> > in memory, and is superceded with whatever the latest initialization
> > setting that took place (i.e. via TH1F Fit).
> >
> > This sounds like a bug to me, rather than a designed behavior. I
wonder
> > if anyone faced a similar problem and knows a workaround.
> >
> > Please, CC: your reply directly to me, as I don't always read the
> > roottalk.
> >
> > Many thanks,
> >
> > Greg Landsberg
> >



This archive was generated by hypermail 2b29 : Thu Jan 01 2004 - 17:50:09 MET