[ROOT] fitting problem

From: Dongwook Jang (dwjang@physics.rutgers.edu)
Date: Fri Jun 01 2001 - 03:32:09 MEST


Hello,

I wanna fit a error function onto graph. When I run this macro, the error
message read "unknown erf"
Can anyone help me in solving this problem? Or please tell me what the
problem is in my file.

Here is my macro file.

//----> start
Double_t erf( Double_t *x, Double_t par){
  return par*TMath::Erf(x);
}

void eff()
{
   gROOT->Reset();
   c1 = new TCanvas("c1","title",200,10,700,500);

   c1->SetGrid();

   const Int_t n = 10;
   const Int_t ntot = 500;
   Double_t x[n], ytemp[n], y[n], ex[n], ey[n];
   Double_t erf(Double_t *, Double_t );
   
   x[0] = 0.1; ytemp[0] = 9.  ;
   x[1] = 0.2; ytemp[1] = 8.  ;
   x[2] = 0.3; ytemp[2] = 150.;
   x[3] = 0.4; ytemp[3] = 317.;
   x[4] = 0.5; ytemp[4] = 350.;
   x[5] = 0.8; ytemp[5] = 349.;
   x[6] = 1.0; ytemp[6] = 350.;
   x[7] = 2.0; ytemp[7] = 325.;
   x[8] = 3.0; ytemp[8] = 310.;
   x[9] = 5.0; ytemp[9] = 261.;
   //
   y[0] =ytemp[0]/ntot  ; ex[0] = 0.; ey[0] = sqrt(ytemp[0])/ntot;
   y[1] =ytemp[1]/ntot  ; ex[1] = 0.; ey[1] = sqrt(ytemp[1])/ntot;
   y[2] =ytemp[2]/ntot; ex[2] = 0.; ey[2] = sqrt(ytemp[2])/ntot;  
   y[3] =ytemp[3]/ntot; ex[3] = 0.; ey[3] = sqrt(ytemp[3])/ntot;  
   y[4] =ytemp[4]/ntot; ex[4] = 0.; ey[4] = sqrt(ytemp[4])/ntot;  
   y[5] =ytemp[5]/ntot; ex[5] = 0.; ey[5] = sqrt(ytemp[5])/ntot;  
   y[6] =ytemp[6]/ntot; ex[6] = 0.; ey[6] = sqrt(ytemp[6])/ntot;  
   y[7] =ytemp[7]/ntot; ex[7] = 0.; ey[7] = sqrt(ytemp[7])/ntot;  
   y[8] =ytemp[8]/ntot; ex[8] = 0.; ey[8] = sqrt(ytemp[8])/ntot;  
   y[9] =ytemp[9]/ntot; ex[9] = 0.; ey[9] = sqrt(ytemp[9])/ntot;  
   //
   gr = new TGraphErrors(n,x,y,ex,ey);
   gr->SetFillColor(19);
   gr->SetLineColor(2);
   gr->SetLineWidth(1);
   gr->SetMarkerColor(4);
   gr->SetMarkerStyle(21);
   gr->SetTitle("Track eff.");
   gr->Draw("AL*");
   //
   TF1 *fitfcn = new TF1("fitfcn",erf,0.0,5.0);
   gr->Fit("fitfcn");

   c1->Update();
   gr->GetHistogram()->SetXTitle("Pt (GeV)");
   gr->GetHistogram()->SetYTitle("eff. (# of tracks over 500 pions)");
   c1->Modified();

//<---- end

Best regards,
Dongwook Jang.
@+------------------------------------------------------------
| email     :	dwjang@fnal.gov 
|		dwjang@physics.rutgers.edu
| phone     :	630-840-2118 (office)
|		630-406-1315 (Home)
|		630-840-6315 (FAX)
+-------------------------------------------------------------
I'm staying at the office 170-I, B0 Trailer at Fermilab.

The mailing address is :
CDF/Rutgers MS 318 Fermilab P.O. 500
Batavia, IL 60510-0500

My school is :
Department of Physics and Astronomy
Rutgers, the State University of New Jersey
136 Frelinghuysen Road
Piscataway, NJ 08854-8019





This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:50:47 MET