{ "cells": [ { "cell_type": "markdown", "id": "661c4857", "metadata": {}, "source": [ "# hist047_Graphics_candle_decay\n", "\n", "\n", "\n", "\n", "**Author:** Georg Troska \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": "markdown", "id": "e0f95a2d", "metadata": {}, "source": [ "create a new 2D histogram with x-axis title probability density and y-axis title time\n", "it is of a type TH2I (2D histogram with integer values)" ] }, { "cell_type": "code", "execution_count": 1, "id": "5ad57907", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:12:58.235589Z", "iopub.status.busy": "2026-05-19T20:12:58.235458Z", "iopub.status.idle": "2026-05-19T20:12:59.288286Z", "shell.execute_reply": "2026-05-19T20:12:59.287154Z" } }, "outputs": [], "source": [ "auto *hist = new TH2I(\"hist\", \"Decay; probability density; time\", 1000, 0, 1000, 20, 0, 20);\n", "TRandom rand; // create a random number generator outside the loop to avoid reseeding\n", "\n", "for (int iBin = 0; iBin < 19; iBin++) {\n", " for (int j = 0; j < 1000000; j++) {\n", " // generate a random number from a 2D Gaussian distribution\n", " // a simulation of a time development of a certain value\n", " float myRand = rand.Gaus(350 + iBin * 8, 20 + 2 * iBin);\n", " hist->Fill(myRand, iBin);\n", " }\n", "}\n", "hist->SetBarWidth(3);\n", "hist->SetFillStyle(0);\n", "hist->SetFillColor(kGray);\n", "hist->SetLineColor(kBlue);" ] }, { "cell_type": "markdown", "id": "f8aa835f", "metadata": {}, "source": [ "create a new canvas" ] }, { "cell_type": "code", "execution_count": 2, "id": "7b2deabe", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:12:59.289829Z", "iopub.status.busy": "2026-05-19T20:12:59.289703Z", "iopub.status.idle": "2026-05-19T20:12:59.506684Z", "shell.execute_reply": "2026-05-19T20:12:59.503700Z" } }, "outputs": [], "source": [ "auto *can = new TCanvas(\"can\", \"Candle Decay\", 800, 600);\n", "can->Divide(2, 1); // divide the canvas into 2 pads (2 rows, 1 column)\n", "\n", "can->cd(1);\n", "hist->Draw(\"violiny(112000000)\");\n", "can->cd(2);\n", "auto *hist2 = static_cast(hist->Clone(\"hist2\"));\n", "hist2->SetBarWidth(0.8);" ] }, { "cell_type": "markdown", "id": "bcf674af", "metadata": {}, "source": [ "There are six predefined candle-plot representations: (X can be replaced by Y)\n", "\"CANDLEX1\": Standard candle (whiskers cover the whole distribution)\n", "\"CANDLEX2\": Standard candle with better whisker definition + outliers. It is a good compromise\n", "\"CANDLEX3\": Like candle2 but with a mean as a circle. It is easier to distinguish mean and median\n", "\"CANDLEX4\": Like candle3 but showing the uncertainty of the median as well (notched candle plots). For bigger\n", "datasets per candle \"CANDLEX5\": Like candle2 but showing all data points. For very small datasets \"CANDLEX6\":\n", "Like candle2 but showing all datapoints scattered. For huge datasets" ] }, { "cell_type": "code", "execution_count": 3, "id": "031b8617", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:12:59.508464Z", "iopub.status.busy": "2026-05-19T20:12:59.508332Z", "iopub.status.idle": "2026-05-19T20:12:59.712570Z", "shell.execute_reply": "2026-05-19T20:12:59.711478Z" } }, "outputs": [], "source": [ "hist2->DrawCopy(\"candley2\");" ] }, { "cell_type": "markdown", "id": "611bcab3", "metadata": {}, "source": [ "Draw all canvases " ] }, { "cell_type": "code", "execution_count": 4, "id": "29db3375", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:12:59.714070Z", "iopub.status.busy": "2026-05-19T20:12:59.713943Z", "iopub.status.idle": "2026-05-19T20:12:59.918853Z", "shell.execute_reply": "2026-05-19T20:12:59.918496Z" } }, "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 }