Hi Matt,
Currently TH1::Fit has a special case when setting parameter limits that
are both equal to zero.
To fix a parameter, you only have to specify the lower>=upper limit.
In your case do;
e1.SetParLimits(1,1,1);
e1.SetParameter(1,exconst);
Rene Brun
Matt Fritts wrote:
>
> I've been having a minor problem with a fitting macro I've been writing. I
> wanted to include an option to set a constant to zero, but it's not
> working. I can illustrate the problem with this test macro:
>
> {
> Float_t exconst;
>
> Float_t x[5], y[5], xe[5], ye[5];
> for(int l=0;l<5;l++){
> x[l]=l;
> y[l]=11*pow(l,2)-330*l+2500;
> xe[l]=.2;
> ye[l]=2.5;
> }
>
> // define fit function //
> TF1 *e1 = new TF1("e1","[0]*x+[1]",.5,15);
>
> // set guess parameters //
> e1.SetParameter(0,2000);
> e1.SetParameter(1,1);
>
> printf("Enter constant: ");
> scanf("%f",&exconst);
> e1.SetParLimits(1,exconst,exconst);
> e1.SetParameter(1,exconst);
>
> gre = new TGraphErrors(5,x,y,xe,ye);
> gre.Fit("e1");
> }
>
> The macro will fix parameter 1 properly for any entered value except zero.
> If zero is entered, it fits parameter 1. (At least in Root Version 2.21/08.)
>
> By the way, thanks for the help with the download.
>
> -Matt Fritts
This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:43:36 MET