{ "cells": [ { "cell_type": "markdown", "id": "f74edf4c", "metadata": {}, "source": [ "# gr008_multierrors\n", "for example statistical and systematic errors.\n", "\n", "\n", "\n", "\n", "**Author:** Simon Spies \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:37 PM." ] }, { "cell_type": "code", "execution_count": 1, "id": "6c1a85d6", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:37:52.408212Z", "iopub.status.busy": "2026-05-19T20:37:52.408083Z", "iopub.status.idle": "2026-05-19T20:37:52.883673Z", "shell.execute_reply": "2026-05-19T20:37:52.883120Z" } }, "outputs": [], "source": [ "TCanvas *c1 = new TCanvas(\"c1\", \"A Simple Graph with multiple y-errors\", 200, 10, 700, 500);\n", "c1->SetGrid();\n", "c1->GetFrame()->SetBorderSize(12);\n", "\n", "const Int_t np = 5;\n", "Double_t x[np] = {0, 1, 2, 3, 4};\n", "Double_t y[np] = {0, 2, 4, 1, 3};\n", "Double_t exl[np] = {0.3, 0.3, 0.3, 0.3, 0.3}; //Lower x errors\n", "Double_t exh[np] = {0.3, 0.3, 0.3, 0.3, 0.3}; //Higher x errors\n", "Double_t eylstat[np] = {1, 0.5, 1, 0.5, 1}; //Lower y statistical errors\n", "Double_t eyhstat[np] = {0.5, 1, 0.5, 1, 0.5}; //Higher y statistical errors\n", "Double_t eylsys[np] = {0.5, 0.4, 0.8, 0.3, 1.2}; //Lower y systematic errors\n", "Double_t eyhsys[np] = {0.6, 0.7, 0.6, 0.4, 0.8}; //Higher y systematic errors\n", "\n", "TGraphMultiErrors *gme = new TGraphMultiErrors(\"gme\", \"TGraphMultiErrors Example\", np, x, y, exl, exh, eylstat, eyhstat); //Create the TGraphMultiErrors object\n", "gme->AddYError(np, eylsys, eyhsys); //Add the systematic y-errors to the graph\n", "gme->SetMarkerStyle(20);\n", "gme->SetLineColor(kRed);\n", "gme->GetAttLine(0)->SetLineColor(kRed); //Color for statistical error bars\n", "gme->GetAttLine(1)->SetLineColor(kBlue); //Color for systematic error bars\n", "gme->GetAttFill(1)->SetFillStyle(0);" ] }, { "cell_type": "markdown", "id": "effd3068", "metadata": {}, "source": [ "Graph is drawn with the option \"APS\": \"A\" draw axes, \"P\" draw points and \"S\" draw symmetric horizontal error bars (x-errors)\n", "Statistical y-errors are drawn with the option \"Z\" vertical error bars.\n", "Systematic y-errors are drawn with the option \"5 s=0.5\":\n", "\"5\" draw rectangles to represent the systematic y-error bars.\n", "\"s=0.5\" scale the rectangles horizontally (along the x-axis) by a factor of 0.5." ] }, { "cell_type": "code", "execution_count": 2, "id": "72f32909", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:37:52.885148Z", "iopub.status.busy": "2026-05-19T20:37:52.885025Z", "iopub.status.idle": "2026-05-19T20:37:53.096409Z", "shell.execute_reply": "2026-05-19T20:37:53.095973Z" } }, "outputs": [ { "data": { "text/html": [ "\n", "\n", "
\n", "
\n", "\n", "\n", "\n" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "gme->Draw(\"APS ; Z ; 5 s=0.5\");\n", "\n", "\n", "c1->Update();" ] }, { "cell_type": "markdown", "id": "0919c277", "metadata": {}, "source": [ "Draw all canvases " ] }, { "cell_type": "code", "execution_count": 3, "id": "c8d4ff2f", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:37:53.098404Z", "iopub.status.busy": "2026-05-19T20:37:53.098270Z", "iopub.status.idle": "2026-05-19T20:37:53.319397Z", "shell.execute_reply": "2026-05-19T20:37:53.318837Z" } }, "outputs": [ { "data": { "text/html": [ "\n", "\n", "
\n", "
\n", "\n", "\n", "\n" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "%jsroot on\n", "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 }