{ "cells": [ { "cell_type": "markdown", "id": "0bcdd3c3", "metadata": {}, "source": [ "# hist007_TH1_liveupdate\n", "Simple example illustrating how to use the C++ interpreter\n", "to fill histograms in a loop and show the graphics results\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:11 PM." ] }, { "cell_type": "code", "execution_count": 1, "id": "e93eabce", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:11:56.053716Z", "iopub.status.busy": "2026-05-19T20:11:56.053572Z", "iopub.status.idle": "2026-05-19T20:11:56.394105Z", "shell.execute_reply": "2026-05-19T20:11:56.393411Z" } }, "outputs": [], "source": [ "TCanvas *c1 = new TCanvas(\"c1\", \"Live update of histograms\", 200, 10, 600, 400);\n", "c1->SetGrid();" ] }, { "cell_type": "markdown", "id": "4e1bf110", "metadata": {}, "source": [ "Create some histograms." ] }, { "cell_type": "code", "execution_count": 2, "id": "275fa7b8", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:11:56.399129Z", "iopub.status.busy": "2026-05-19T20:11:56.399001Z", "iopub.status.idle": "2026-05-19T20:11:56.602359Z", "shell.execute_reply": "2026-05-19T20:11:56.601856Z" } }, "outputs": [], "source": [ "auto *total = new TH1D(\"total\", \"This is the total distribution\", 100, -4, 4);\n", "auto *main = new TH1D(\"main\", \"Main contributor\", 100, -4, 4);\n", "auto *s1 = new TH1D(\"s1\", \"This is the first signal\", 100, -4, 4);\n", "auto *s2 = new TH1D(\"s2\", \"This is the second signal\", 100, -4, 4);\n", "total->Sumw2(); // store the sum of squares of weights" ] }, { "cell_type": "markdown", "id": "2bf15e39", "metadata": {}, "source": [ "set some style properties" ] }, { "cell_type": "code", "execution_count": 3, "id": "6cb25673", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:11:56.606468Z", "iopub.status.busy": "2026-05-19T20:11:56.606348Z", "iopub.status.idle": "2026-05-19T20:11:56.810276Z", "shell.execute_reply": "2026-05-19T20:11:56.809782Z" } }, "outputs": [], "source": [ "total->SetMarkerStyle(21); // shape of the markers (\\see EMarkerStyle)\n", "total->SetMarkerSize(0.7);\n", "main->SetFillColor(16);\n", "s1->SetFillColor(42);\n", "s2->SetFillColor(46);\n", "TSlider *slider = nullptr;" ] }, { "cell_type": "markdown", "id": "ddc70a58", "metadata": {}, "source": [ "Fill histograms randomly" ] }, { "cell_type": "code", "execution_count": 4, "id": "aa165cd5", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:11:56.823576Z", "iopub.status.busy": "2026-05-19T20:11:56.823432Z", "iopub.status.idle": "2026-05-19T20:11:57.027475Z", "shell.execute_reply": "2026-05-19T20:11:57.026741Z" } }, "outputs": [ { "data": { "text/html": [ "\n", "\n", "