22 gStyle->SetOptStat(0);
25 TCanvas *c =
new TCanvas(
"c",
"Graph2D example",0,0,600,800);
28 Double_t rnd, x, y, z;
35 TF2 *f2 =
new TF2(
"f2",
"1000*(([0]*sin(x)/x)*([1]*sin(y)/y))+200",
37 f2->SetParameters(1,1);
38 TGraph2D *dt =
new TGraph2D();
42 for (Int_t N=0; N<nd; N++) {
46 z = f2->Eval(x,y)*(1+rnd);
48 dt->SetPoint(N,x,y,z);
52 TH1D *h1 =
new TH1D(
"h1",
53 "#splitline{Difference between Original}{#splitline{function and Function}{with noise}}",
55 TH1D *h2 =
new TH1D(
"h2",
56 "#splitline{Difference between Original}{#splitline{function and Delaunay triangles}{interpolation}}",
58 TH1D *h3 =
new TH1D(
"h3",
59 "#splitline{Difference between Original}{function and Minuit fit}",
62 f2->SetParameters(0.5,1.5);
64 TF2 *fit2 = (TF2*)dt->FindObject(
"f2");
66 f2->SetParameters(1,1);
68 for (Int_t N=0; N<np; N++) {
72 z = f2->Eval(x,y)*(1+rnd);
73 h1->Fill(f2->Eval(x,y)-z);
74 z = dt->Interpolate(x,y);
75 h2->Fill(f2->Eval(x,y)-z);
77 h3->Fill(f2->Eval(x,y)-z);
81 f2->SetTitle(
"Original function with Graph2D points on top");
83 gStyle->SetHistTopMargin(0);
90 dt->SetTitle(
"Histogram produced with Delaunay interpolation");
94 fit2->SetTitle(
"Minuit fit result on the Graph2D points");
101 c->cd(2); h1->Fit(
"gaus",
"Q") ; h1->Draw();
102 c->cd(4); h2->Fit(
"gaus",
"Q") ; h2->Draw();
103 c->cd(6); h3->Fit(
"gaus",
"Q") ; h3->Draw();