Axel: you shouldn't expect anything good starting fit with initial value
of gaussian sigma = 0 (this is the default). Try setting sigma to 1:
fsum2->SetParameter(2,1)
h1->Fit("fsum2,"r")
-best, Pasha
Axel Naumann wrote:
>
> Hi,
>
> ---
>
> TH1F * h1 = new TH1F("hist1","test hist", 100,0., 1.2);
> for (Int_t iEntry = 0; iEntry<1000; iEntry++) h1->Fill(sin(iEntry));
>
> TF1 *fsum2= new TF1 ("fsum2", "[0]*exp(-0.5*((x-[1])/[2])^2.)",0.8,1.2);
> h1->Fit("fsum2,"r");
>
> ---
>
> Should work, right? At least that's how the gaussian is defined in the Users
> Guide and in the TF1 help. But what I get is
>
> ---
> FCN=42.4465 FROM MIGRAD STATUS=CONVERGED 117 CALLS 118 TOTAL
> EDM=6.75784e-18 STRATEGY= 1 ERROR MATRIX
> UNCERTAINTY 100.0 per cent
> EXT PARAMETER APPROXIMATE STEP FIRST
> NO. NAME VALUE ERROR SIZE DERIVATIVE
> 1 p0 9.44432e+00 7.45351e-01 2.39888e-03 -3.48773e-09
> 2 p1 0.00000e+00 1.69706e-02 -0.00000e+00 0.00000e+00
> 3 p2 0.00000e+00 5.89699e+00 -0.00000e+00 0.00000e+00
> ---
>
> Which totally doesn't make sense to me: If I have a peak, then why does the
> gaussian fit a straight line? I did try "**2." and "pow(..., 2.)" instead of
> "^2.", didn't help. Also, there's no error message when creating fsum2, so
> supposedly the function is parsed correctly...
>
> What did I do wrong? Where's Waldo?
>
> Cheers, Axel.
This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:51:07 MET