#include "TGraphErrors.h" #include "TGraph.h" #include "TF1.h" #include "TCanvas.h" void example05(){ TVirtualFitter::SetDefaultFitter("Minuit"); TGraphErrors *data = new TGraphErrors("dataset2.dat"); TF1 *myModel = new TF1("oscillation","[0]*exp(-[1]*x)*sin([2]*x)^2"); myModel->SetParameters(9.,1./100.,1./15.); data->Fit(myModel); gMinuit->SetErrorDef(1); // just to show, since it starts TGraph *cont01_1s = (TGraph*) gMinuit->Contour(100,0,1); TGraph *cont02_1s = (TGraph*) gMinuit->Contour(100,0,2); TGraph *cont12_1s = (TGraph*) gMinuit->Contour(100,1,2); gMinuit->SetErrorDef(4); TGraph *cont01_2s = (TGraph*) gMinuit->Contour(100,0,1); TGraph *cont02_2s = (TGraph*) gMinuit->Contour(100,0,2); TGraph *cont12_2s = (TGraph*) gMinuit->Contour(100,1,2); TCanvas *canvas = new TCanvas("canvas","My Fit",1000,500); canvas->Divide(2,2); canvas->cd(1); cont01_2s->SetFillColor(kOrange); cont01_1s->SetFillColor(kBlue); cont01_2s->Draw("AF"); cont01_1s->Draw("F same"); canvas->cd(3); cont02_2s->SetFillColor(kOrange); cont02_1s->SetFillColor(kBlue); cont02_2s->Draw("AF"); cont02_1s->Draw("F same"); canvas->cd(4); cont12_2s->SetFillColor(kOrange); cont12_1s->SetFillColor(kBlue); cont12_2s->Draw("AF"); cont12_1s->Draw("F same"); double cl = 0.95; int N=100; double xmin = 0.; double xmax = 35.; canvas->cd(2); TGraphErrors *band = new TGraphErrors(N); for (int i=0;iSetPoint(i, i*(xmax-xmin)/(N-1.), 0); (TVirtualFitter::GetFitter())->GetConfidenceIntervals(band,cl); band->SetFillColor(kOrange-2); band->Draw("A3"); data->SetMarkerStyle(kFullCircle); data->SetMarkerColor(kBlue+2); data->Draw("PZ same"); }