{ "cells": [ { "cell_type": "markdown", "id": "0fd76c0e", "metadata": {}, "source": [ "# hist052_Graphics_candle_plot_whiskers\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:13 PM." ] }, { "cell_type": "code", "execution_count": 1, "id": "9e934d23", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:13:07.106618Z", "iopub.status.busy": "2026-05-19T20:13:07.106479Z", "iopub.status.idle": "2026-05-19T20:13:07.613013Z", "shell.execute_reply": "2026-05-19T20:13:07.612660Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Q1 (-25%): -0.675525 Median: 0.00168511 Q3 (+25%): 0.676189\n", "****************************************\n", "Minimizer is Minuit2 / Migrad\n", "Chi2 = 11.7941\n", "NDf = 17\n", "Edm = 1.90451e-06\n", "NCalls = 131\n", "Constant = 3728.5 +/- 182.158 \n", "Mean = -0.110704 +/- 0.072107 \n", "Sigma = 0.959495 +/- 0.0251539 \t (limited)\n", "****************************************\n", "Minimizer is Minuit2 / Migrad\n", "Chi2 = 8.0469\n", "NDf = 17\n", "Edm = 1.56502e-05\n", "NCalls = 132\n", "Constant = 4071.09 +/- 244.488 \n", "Mean = -0.0289155 +/- 0.0871655 \n", "Sigma = 1.00961 +/- 0.0288273 \t (limited)\n", "****************************************\n", "Minimizer is Minuit2 / Migrad\n", "Chi2 = 6.93238\n", "NDf = 11\n", "Edm = 3.27924e-08\n", "NCalls = 107\n", "Constant = 3970.02 +/- 25.7596 \n", "Mean = -0.000189021 +/- 0.0118284 \n", "Sigma = 1.02465 +/- 0.0335469 \t (limited)\n" ] } ], "source": [ "auto c1 = new TCanvas(\"c1\", \"Candle Presets\", 700, 800);\n", "c1->Divide(1, 2);\n", "\n", "auto rng = new TRandom();\n", "auto h1 = new TH2I(\"h1\", \"Gaus\", 100, -5, 5, 1, 0, 1);\n", "auto h2 = new TH1I(\"h2\", \"Gaus\", 100, -5, 5);\n", "\n", "h1->GetXaxis()->SetTitle(\"Standard deviation #sigma\");\n", "h2->GetXaxis()->SetTitle(\"Standard deviation #sigma\");\n", "h2->GetYaxis()->SetTitle(\"dN/d#sigma\");\n", "\n", "float myRand;\n", "for (int i = 0; i < 100000; i++) {\n", " myRand = rng->Gaus(0, 1);\n", " h1->Fill(myRand, 0);\n", " h2->Fill(myRand);\n", "}\n", "\n", "Double_t *q = new Double_t[3];\n", "Double_t *p = new Double_t[3];\n", "q[0] = 0.;\n", "q[1] = 0.;\n", "q[2] = 0.;\n", "p[0] = 0.25;\n", "p[1] = 0.5;\n", "p[2] = 0.75;\n", "\n", "h2->GetQuantiles(3, q, p);\n", "cout << \"Q1 (-25%): \" << q[0] << \" Median: \" << q[1] << \" Q3 (+25%): \" << q[2] << endl;\n", "double iqr = q[2] - q[0];\n", "auto mygaus_1_middle = new TF1(\"mygaus_1_middle\", \"gaus\", q[0], q[2]);\n", "auto mygaus_1_left = new TF1(\"mygaus_1_left\", \"gaus\", q[0] - 1.5 * iqr, q[0]);\n", "mygaus_1_left->SetLineColor(kGreen);\n", "auto mygaus_1_right = new TF1(\"mygaus_1_right\", \"gaus\", q[2], q[2] + 1.5 * iqr);\n", "mygaus_1_right->SetLineColor(kGreen);\n", "c1->cd(1);\n", "h1->SetLineWidth(3);\n", "h1->SetFillStyle(0);\n", "h1->Draw(\"candley2 scat\");\n", "\n", "c1->cd(2);\n", "h2->Draw(\"\");\n", "h2->Fit(\"mygaus_1_left\", \"R\");\n", "mygaus_1_left->Draw(\"same\");\n", "auto l3 = new TLine(q[0] - 1.5 * iqr, 0, q[0] - 1.5 * iqr, mygaus_1_left->Eval(q[0] - 1.5 * iqr));\n", "l3->SetLineColor(kGreen);\n", "l3->SetLineWidth(2);\n", "l3->Draw(\"\");\n", "auto l1 = new TLine(q[0], 0, q[0], mygaus_1_left->Eval(q[0]));\n", "l1->SetLineWidth(2);\n", "l1->SetLineColor(kGreen);\n", "l1->Draw(\"\");\n", "\n", "h2->Fit(\"mygaus_1_right\", \"R\", \"\");\n", "mygaus_1_right->Draw(\"same\");\n", "auto l4 = new TLine(q[2] + 1.5 * iqr, 0, q[2] + 1.5 * iqr, mygaus_1_left->Eval(q[2] + 1.5 * iqr));\n", "l4->SetLineColor(kGreen);\n", "l4->SetLineWidth(2);\n", "l4->Draw(\"\");\n", "auto l5 = new TLine(q[2], 0, q[2], mygaus_1_right->Eval(q[2]));\n", "l5->SetLineWidth(2);\n", "l5->SetLineColor(kGreen);\n", "l5->Draw(\"\");\n", "\n", "h2->Fit(\"mygaus_1_middle\", \"R\");\n", "mygaus_1_middle->Draw(\"same\");" ] }, { "cell_type": "markdown", "id": "e6423482", "metadata": {}, "source": [ "In principal one could calculate these values by h2->Integral() as well" ] }, { "cell_type": "code", "execution_count": 2, "id": "0d2fdb14", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:13:07.615070Z", "iopub.status.busy": "2026-05-19T20:13:07.614944Z", "iopub.status.idle": "2026-05-19T20:13:07.818823Z", "shell.execute_reply": "2026-05-19T20:13:07.818444Z" } }, "outputs": [], "source": [ "TText t;\n", "t.SetTextFont(42);\n", "t.DrawText(0, mygaus_1_middle->Eval(0) / 2, \"50%\");\n", "t.DrawText(-1.5, mygaus_1_middle->Eval(-1.5) / 2, \"24.65%\");\n", "t.DrawText(+1, mygaus_1_middle->Eval(+1.5) / 2, \"24.65%\");\n", "t.DrawText(q[0] - 1.5 * iqr, 1000, Form(\"%.3f\", q[0] - 1.5 * iqr))->SetTextAngle(90);\n", "t.DrawText(q[2] + 1.5 * iqr, 1000, Form(\"%.3f\", q[2] + 1.5 * iqr))->SetTextAngle(90);\n", "t.DrawText(q[0], 1000, Form(\"%.3f\", q[0]))->SetTextAngle(90);\n", "t.DrawText(q[2], 1000, Form(\"%.3f\", q[2]))->SetTextAngle(90);" ] }, { "cell_type": "markdown", "id": "46e24838", "metadata": {}, "source": [ "Draw all canvases " ] }, { "cell_type": "code", "execution_count": 3, "id": "25db59bb", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:13:07.832240Z", "iopub.status.busy": "2026-05-19T20:13:07.832101Z", "iopub.status.idle": "2026-05-19T20:13:08.146921Z", "shell.execute_reply": "2026-05-19T20:13:08.146489Z" } }, "outputs": [ { "data": { "text/html": [ "\n", "\n", "
\n", "
\n", "\n", "\n", "\n" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stderr", "output_type": "stream", "text": [ "Warning in : option SCAT is deprecated.\n" ] } ], "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 }