Alexander, -send the shortest possible running script reproducing your problem. -indicate which version of ROOT Rene Brun On Thu, 28 Oct 2004, Alexander Bürger wrote: > Hi, > > I have a problem with fitting using TGraphErrors / TF1. I have the > following code: > > Double_t efffun(Double_t *X, Double_t *pars) > { > // par[] = { 0=A, 1=B, 2=C, 3=D, 4=E, 5=F, 6=G, 7=E1, 8=E2, 9=scale } > Double_t x1 = /*log*/(X[0] / pars[7]); > Double_t x2 = /*log*/(X[0] / pars[8]); > if( x1 > exp(-100) ) x1 = log( x1 ); else x1 = -100; > if( x2 > exp(-100) ) x2 = log( x2 ); else x2 = -100; > Double_t g = pars[6]; > Double_t f1 = pars[0] + pars[1]*x1 + pars[2]*x1*x1; > Double_t f2 = pars[3] + pars[4]*x2 + pars[5]*x2*x2; > return pars[9]*exp( pow( pow( f1, -g ) + pow( f2, -g ), -1.0 / g)); > } > > TF1* func = new TF1("eff", efffun, 200, 2500, 10); > func->SetParNames("A", "B", "C", "D", "E", "F", "G", "E1", "E2", "scale"); > func->SetParameters(2.9, 2.2, 0, 5.179, -0.302, -0.17, 15, 100, 1000, 1); > func->FixParameter( 2, 0 ); // C=0 > //func->FixParameter( 6, 15 ); // G=15 > func->FixParameter( 7, 100 ); // E1 = 100 > func->FixParameter( 8, 1000 ); // E2 = 1000 > g->Fit( func, "" ); > > The graph has these values: > > x[0]=244.454, y[0]=121.118, ex[0]=2.44454, ey[0]=1.21118 > x[1]=344.061, y[1]=178.907, ex[1]=3.44061, ey[1]=1.78907 > x[2]=367.594, y[2]=189.898, ex[2]=3.67594, ey[2]=1.89898 > x[3]=410.915, y[3]=192.414, ex[3]=4.10915, ey[3]=1.92414 > x[4]=443.769, y[4]=198.059, ex[4]=4.43769, ey[4]=1.98059 > x[5]=688.482, y[5]=185.509, ex[5]=6.88482, ey[5]=1.85509 > x[6]=778.677, y[6]=189.777, ex[6]=7.78677, ey[6]=1.89777 > x[7]=867.135, y[7]=186.262, ex[7]=8.67135, ey[7]=1.86262 > x[8]=963.785, y[8]=182.018, ex[8]=9.63785, ey[8]=1.82018 > x[9]=1111.76, y[9]=172.064, ex[9]=11.1176, ey[9]=1.72064 > x[10]=1212.64, y[10]=166.903, ex[10]=12.1264, ey[10]=1.66903 > x[11]=1298.83, y[11]=157.176, ex[11]=12.9883, ey[11]=1.57176 > x[12]=1407.69, y[12]=157.646, ex[12]=14.0769, ey[12]=1.57646 > > Now the problem is that before fitting, the TF1 fits really well (I > adjusted the initial values), but after fitting it's "worse", I mean it > fits anything but not the graph (it looks a bit like the fitter is trying > to put the TF1 to 0 outside the graph). > > How can I solve this problem? > > Best wishes, > > Alexander >
This archive was generated by hypermail 2b29 : Sun Jan 02 2005 - 05:50:10 MET