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->SetFillColor(42); // c1->Range(0.0,0.0,3.5,50.0); 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*"); // To make sure this enviornment can recognize TMath class // printf("Erf(0) = %f",TMath::Erf(0.0)); // printf("Erf(0.5) = %f",TMath::Erf(0.5)); // printf("Erf(1.0) = %f",TMath::Erf(1.0)); // TF1 *fitfcn = new TF1("fitfcn",erf,0.0,5.0); gr->Fit("fitfcn"); //Add axis titles. //A graph is drawn using the services of the TH1F histogram class. //The histogram is created by TGraph::Paint. //TGraph::Paint is called by TCanvas::Update. This function is called by default //when typing at the keyboard. In a macro, one must force TCanvas::Update. c1->Update(); // c1->GetFrame()->SetFillColor(21); // c1->GetFrame()->SetBorderSize(12); gr->GetHistogram()->SetXTitle("Pt (GeV)"); gr->GetHistogram()->SetYTitle("eff. (# of tracks over 500 pions)"); c1->Modified(); }