{ "cells": [ { "cell_type": "markdown", "id": "4d7118f5", "metadata": {}, "source": [ "# fitcont\n", "Example illustrating how to draw the n-sigma contour of a Minuit fit.\n", "To get the n-sigma contour the ERRDEF parameter in Minuit has to set\n", "to n^2. The fcn function has to be set before the routine is called.\n", "\n", "WARNING!!! This test works only with TMinuit\n", "\n", "The TGraph object is created via the interpreter. The user must cast it\n", "to a TGraph*\n", "\n", "\n", "\n", "\n", "**Author:** Rene Brun \n", "This notebook tutorial was automatically generated with ROOTBOOK-izer from the macro found in the ROOT repository on Tuesday, May 19, 2026 at 08:24 PM." ] }, { "cell_type": "markdown", "id": "55d72e5f", "metadata": {}, "source": [ "be sure default is Minuit since we will use gMinuit" ] }, { "cell_type": "code", "execution_count": 1, "id": "5e3ecc6b", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:24:45.257684Z", "iopub.status.busy": "2026-05-19T20:24:45.257553Z", "iopub.status.idle": "2026-05-19T20:24:46.056151Z", "shell.execute_reply": "2026-05-19T20:24:46.055326Z" } }, "outputs": [ { "data": { "text/html": [ "\n", "\n", "
\n", "
\n", "\n", "\n", "\n" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ " FCN=96.6163 FROM MIGRAD STATUS=CONVERGED 62 CALLS 63 TOTAL\n", " EDM=2.07594e-08 STRATEGY= 1 ERROR MATRIX ACCURATE \n", " EXT PARAMETER STEP FIRST \n", " NO. NAME VALUE ERROR SIZE DERIVATIVE \n", " 1 Constant 1.43454e+02 2.29666e+00 9.00732e-03 -6.49594e-05\n", " 2 Mean 1.60911e-02 1.30402e-02 6.28520e-05 3.57224e-03\n", " 3 Sigma 9.87683e-01 9.45637e-03 1.24479e-05 2.14428e-02\n" ] } ], "source": [ "TVirtualFitter::SetDefaultFitter(\"Minuit\");\n", "\n", "TCanvas *c1 = new TCanvas(\"c1\");\n", "TH1F *h = new TH1F(\"h\",\"My histogram\",100,-3,3);\n", "h->FillRandom(\"gaus\",6000);\n", "h->Fit(\"gaus\");\n", "c1->Update();\n", "\n", "TCanvas *c2 = new TCanvas(\"c2\",\"contours\",10,10,600,800);\n", "c2->Divide(1,2);\n", "c2->cd(1);\n", "/*get first contour for parameter 1 versus parameter 2*/\n", "TGraph *gr12 = (TGraph*)gMinuit->Contour(40,1,2);\n", "gr12->Draw(\"alp\");\n", "c2->cd(2);\n", "/*Get contour for parameter 0 versus parameter 2 for ERRDEF=2*/\n", "gMinuit->SetErrorDef(4); //note 4 and not 2!\n", "TGraph *gr2 = (TGraph*)gMinuit->Contour(80,0,2);\n", "gr2->SetFillColor(42);\n", "gr2->Draw(\"alf\");\n", "/*Get contour for parameter 0 versus parameter 2 for ERRDEF=1*/\n", "gMinuit->SetErrorDef(1);\n", "TGraph *gr1 = (TGraph*)gMinuit->Contour(80,0,2);\n", "gr1->SetFillColor(38);\n", "gr1->Draw(\"lf\");" ] }, { "cell_type": "markdown", "id": "6c32a3f8", "metadata": {}, "source": [ "Draw all canvases " ] }, { "cell_type": "code", "execution_count": 2, "id": "ef7e9549", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:24:46.058221Z", "iopub.status.busy": "2026-05-19T20:24:46.058096Z", "iopub.status.idle": "2026-05-19T20:24:46.264881Z", "shell.execute_reply": "2026-05-19T20:24:46.264430Z" } }, "outputs": [ { "data": { "text/html": [ "\n", "\n", "
\n", "
\n", "\n", "\n", "\n" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "\n", "\n", "
\n", "
\n", "\n", "\n", "\n" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "gROOT->GetListOfCanvases()->Draw()" ] } ], "metadata": { "kernelspec": { "display_name": "ROOT C++", "language": "c++", "name": "root" }, "language_info": { "codemirror_mode": "text/x-c++src", "file_extension": ".C", "mimetype": " text/x-c++src", "name": "c++" } }, "nbformat": 4, "nbformat_minor": 5 }