Art,
Here is a small example:
void fixp() {
TH1F *h = new TH1F("h","test",100,-4,4);
h->FillRandom("gaus",5000);
TF1 *e = new TF1("e","pol4",-1,1);
e->FixParameter(0,160);
h->Fit("e","br");
}
Using the option "b" (Boundary) is important. The documentation of TH1::Fit
says:
//*-* Setting initial conditions
//*-* ==========================
//*-* Parameters must be initialized before invoking the Fit function.
//*-* The setting of the parameter initial values is automatic for the
//*-* predefined functions : poln, expo, gaus. One can however disable
//*-* this automatic computation by specifying the option "B".
//*-* You can specify boundary limits for some or all parameters via
//*-* f1->SetParLimits(p_number, parmin, parmax);
//*-* if parmin>=parmax, the parameter is fixed
//*-* Note that you are not forced to fix the limits for all parameters.
//*-* For example, if you fit a function with 6 parameters, you can do:
//*-* func->SetParameters(0,3.1,1.e-6,-1.5,0,100);
//*-* func->SetParLimits(3,-10,-4);
//*-* func->FixParameter(4,0);
//*-* func->SetParLimits(5, 1,1);
//*-* With this setup, parameters 0->2 can vary freely
//*-* Parameter 3 has boundaries [-10,-4] with initial value -8
//*-* Parameter 4 is fixed to 0
//*-* Parameter 5 is fixed to 100.
//*-* When the lower limit and upper limit are equal, the parameter is fixed.
//*-* However to fix a parameter to 0, one must call the FixParameter
function.
Rene Brun
Arthur E. Snyder wrote:
>
> The SetParLimits function really seems to be totally ineffective:
>
> root [180] efit->GetParameter(0)
> (Double_t)5.89071269118343935e+02
> root [181] efit->SetParameter(0,2.0)
> root [182] efit->GetParameter(0)
> (Double_t)2.00000000000000000e+00
> root [183] efit->SetParLimits(0,1.0,1.0)
>
> -so parmeter 0 of this function (a "pol4") should be fixed to 2.0
>
> root [184] bhist->Fit("e") [note a]
> FCN=66.7558 FROM MIGRAD STATUS=CONVERGED 134 CALLS 135
> TOTAL
> EDM=5.71703e-14 STRATEGY= 1 ERR MATRIX NOT
> POS-DEF
> EXT PARAMETER APPROXIMATE STEP FIRST
> NO. NAME VALUE ERROR SIZE DERIVATIVE
> 1 p0 5.89071e+02 fixed
> 2 p1 -3.16776e+03 2.00304e+00 1.51050e-03 8.00435e-08
> 3 p2 6.43575e+03 3.89200e+00 3.06881e-03 -8.40017e-09
> 4 p3 -5.79772e+03 4.44730e+00 2.76457e-03 9.71526e-09
> 5 p4 1.94450e+03 3.58314e+00 1.54134e-03 6.48922e-08
>
> -it fits parameter 0 though claiming it is fixed!?
>
> -am I doing somthing real stupid or is this a bug?
>
> Art S.
>
> note a: "e" is the name I gave the TF1 function *efit. BTW, the function
> TH1::Fit(TF1*) also seems to be missing in action, so I have to use the
> one that finds the function by name rather than pointer.
>
> A.E. Snyder, Group EC \!c*p?/
> SLAC Mail Stop #95 ((. .))
> Box 4349 |
> Stanford, Ca, USA, 94309 '\|/`
> e-mail:snyder@slac.stanford.edu o
> phone:650-926-2701 _
> http://www.slac.stanford.edu/~snyder BaBar
> FAX:650-926-2657 Collaboration
>
> On Sun, 2 Dec 2001, Rene Brun wrote:
>
> > Art,
> >
> > Even in PAW, people included the Minuit commands in a KUIP macro.
> > You should do the same. However, currently, it is not easy to get
> > the control after each iteration. You get the control only at the end
> > of the fit, unless you implement your own fitting model (like
> > H1FitChisquare or likelihood). One could imagine a new option
> > to force a call to a function or macro after each iteration.
> > If there are more suggestions, they are welcome.
> >
> > Rene Brun
> >
> > On Sun, 2 Dec 2001, Arthur E. Snyder wrote:
> >
> > > Hi Rene,
> > >
> > > I was able to grab gMinuit and use mnexcm to execute minuit commands, refit,
> > > etc. It is pretty awkward interactively, but works. However, the results do
> > > not propagate back to the function attached to my histogram, so when I
> > > redraw it I see the result of the original default fit. Also, if I refit it
> > > seems to start again from scratch and forget any 'fix' or 'set par' I've
> > > done to gMinuit object.
> > >
> > > Perhaps, I would be better off using the get/set functions provided in TF1?
> > > It looks pretty easy to write my own little macro to manipulate these
> > > functions with minimal typing ...
> > >
> > > Art
> > >
> > >
> > > ----- Original Message -----
> > > From: "Rene Brun" <brun@pcbrun.cern.ch>
> > > To: "Arthur E. Snyder" <snyder@SLAC.Stanford.EDU>
> > > Cc: <roottalk@pcroot.cern.ch>
> > > Sent: Sunday, December 02, 2001 1:39 PM
> > > Subject: Re: [ROOT] Interactive minuit access from ROOT?
> > >
> > >
> > > > Use the global gMinuit
> > > >
> > > > Rene Brun
> > > >
> > > > On Sun, 2 Dec 2001, Arthur E. Snyder wrote:
> > > >
> > > > > Thanks, Rene. Can you tell me how I access TMinuit object when I'm
> > > fitting a
> > > > > histogram? I don't find an assessor either in TF1 or TH1. I've also
> > > looked
> > > > > up the inheritance tree but don't find anything that looks like the
> > > right
> > > > > thing.
> > > > >
> > > > > Art
> > > > >
> > > > >
> > > > >
> > > > > ----- Original Message -----
> > > > > From: "Rene Brun" <brun@pcbrun.cern.ch>
> > > > > To: "Arthur E. Snyder" <snyder@SLAC.Stanford.EDU>
> > > > > Cc: <roottalk@pcroot.cern.ch>
> > > > > Sent: Sunday, December 02, 2001 9:49 AM
> > > > > Subject: Re: [ROOT] Interactive minuit access from ROOT?
> > > > >
> > > > >
> > > > > > Hi Art,
> > > > > >
> > > > > > The direct equivalent of PAW option "M" does not exist.
> > > > > > However, you can invoke any function from TMinuit directly.
> > > > > > This should provide even more flexibility at the expense
> > > > > > of slightly more typing.
> > > > > >
> > > > > > Rene Brun
> > > > > >
> > > > > > On Sat, 1 Dec 2001, Arthur E. Snyder wrote:
> > > > > >
> > > > > > > Try again to post this with more sensible subject line!
> > > > > > >
> > > > > > > ----- Original Message -----
> > > > > > > From: "Arthur E. Snyder" <snyder@SLAC.Stanford.EDU>
> > > > > > > To: <roottalk@pcroot.cern.ch>
> > > > > > > Sent: Saturday, December 01, 2001 12:29 AM
> > > > > > > Subject: Re: [ROOT] tiny Bug in root
> > > > > > >
> > > > > > >
> > > > > > > > Is it possible to invoke interactive minuit from within ROOT?
> > > I.e.,
> > > > > the
> > > > > > > > equivalent of 'h/fit 100 myfunc.f m' in paw? The ROOT fit provides
> > > > > most of
> > > > > > > > the options of paw, but not this one. The 'm' option in ROOT seems
> > > to
> > > > > be
> > > > > > > > something different.
> > > > > > > >
> > > > > > > > I've looked in TMinuit, TF, and TH1 classes, but have not been
> > > able to
> > > > > > > find
> > > > > > > > anyway to get to the interactive interface of minuit or some
> > > > > alternative.
> > > > > > > >
> > > > > > > > Art Snyder at SLAC
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > > >
> > > > >
> > >
> >
This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:51:10 MET