fitcont.C

Go to the documentation of this file.
00001 void fitcont()
00002 {
00003    // Example illustrating how to draw the n-sigma contour of a Minuit fit.
00004    // To get the n-sigma contour the ERRDEF parameter in Minuit has to set
00005    // to n^2. The fcn function has to be set before the routine is called.
00006    //
00007    // WARNING!!! This test works only with TMinuit
00008    //
00009    // The TGraph object is created via the interpreter. The user must cast it
00010    // to a TGraph*
00011    // Author:  Rene Brun
00012 
00013    //be sure default is Minuit since we will use gMinuit 
00014    TVirtualFitter::SetDefaultFitter("Minuit");  
00015       
00016    TCanvas *c1 = new TCanvas("c1");
00017    TH1F *h = new TH1F("h","My histogram",100,-3,3);
00018    h->FillRandom("gaus",6000);
00019    h->Fit("gaus");
00020    c1->Update();
00021    
00022    TCanvas *c2 = new TCanvas("c2","contours",10,10,600,800);
00023    c2->Divide(1,2);
00024    c2->cd(1);
00025    //get first contour for parameter 1 versus parameter 2
00026    TGraph *gr12 = (TGraph*)gMinuit->Contour(40,1,2);
00027    gr12->Draw("alp");
00028    c2->cd(2);
00029    //Get contour for parameter 0 versus parameter 2  for ERRDEF=2 
00030    gMinuit->SetErrorDef(4); //note 4 and not 2!
00031    TGraph *gr2 = (TGraph*)gMinuit->Contour(80,0,2);
00032    gr2->SetFillColor(42);
00033    gr2->Draw("alf");
00034    //Get contour for parameter 0 versus parameter 2 for ERRDEF=1  
00035    gMinuit->SetErrorDef(1);
00036    TGraph *gr1 = (TGraph*)gMinuit->Contour(80,0,2);
00037    gr1->SetFillColor(38);
00038    gr1->Draw("lf");
00039 }

Generated on Tue Jul 5 15:44:06 2011 for ROOT_528-00b_version by  doxygen 1.5.1