{ "cells": [ { "cell_type": "markdown", "id": "c04c1ca1", "metadata": {}, "source": [ "# hist030_TRatioPlot_residual\n", "\n", "Creates a histogram filled with random numbers from a gaussian distribution\n", "and fits it with a standard gaussian function. The result is passed to the `TRatioPlot`\n", "constructor. Additionally, after calling `TRatioPlot::Draw` the upper and lower y axis\n", "titles are modified.\n", "Confidence interval bands are automatically drawn on the bottom (but can be disabled by draw option `nobands`).\n", "\n", "\n", "\n", "\n", "**Author:** Paul Gessinger \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:12 PM." ] }, { "cell_type": "code", "execution_count": 1, "id": "5e6c4638", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:12:38.188715Z", "iopub.status.busy": "2026-05-19T20:12:38.188572Z", "iopub.status.idle": "2026-05-19T20:12:38.893876Z", "shell.execute_reply": "2026-05-19T20:12:38.893509Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "****************************************\n", "Minimizer is Minuit2 / Migrad\n", "Chi2 = 22.1778\n", "NDf = 33\n", "Edm = 6.53577e-08\n", "NCalls = 55\n", "Constant = 158.988 +/- 4.47298 \n", "Mean = 0.00662197 +/- 0.0225355 \n", "Sigma = 0.993481 +/- 0.0169678 \t (limited)\n" ] } ], "source": [ "gStyle->SetOptStat(0);\n", "auto c1 = new TCanvas(\"c1\", \"fit residual simple\");\n", "auto h1 = new TH1D(\"h1\", \"h1\", 50, -5, 5);\n", "h1->FillRandom(\"gaus\", 2000);\n", "h1->Fit(\"gaus\", \"0\");\n", "h1->GetXaxis()->SetTitle(\"x\");\n", "auto rp1 = new TRatioPlot(h1);\n", "rp1->Draw();\n", "rp1->GetLowerRefYaxis()->SetTitle(\"ratio\");\n", "rp1->GetUpperRefYaxis()->SetTitle(\"entries\");" ] }, { "cell_type": "markdown", "id": "beeae8b6", "metadata": {}, "source": [ "Draw all canvases " ] }, { "cell_type": "code", "execution_count": 2, "id": "580fff38", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:12:38.913434Z", "iopub.status.busy": "2026-05-19T20:12:38.913287Z", "iopub.status.idle": "2026-05-19T20:12:39.224723Z", "shell.execute_reply": "2026-05-19T20:12:39.224337Z" } }, "outputs": [ { "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 }