{ "cells": [ { "cell_type": "markdown", "id": "3d1244d3", "metadata": {}, "source": [ "# hist018_TH2_cutg\n", "use TCutG object to select bins for drawing.\n", "Moving TCutG object one can change displayed region of histogram\n", "\n", "\n", "\n", "\n", "**Author:** Sergey Linev \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": "40617a5a", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:12:20.266288Z", "iopub.status.busy": "2026-05-19T20:12:20.266161Z", "iopub.status.idle": "2026-05-19T20:12:20.608293Z", "shell.execute_reply": "2026-05-19T20:12:20.607471Z" } }, "outputs": [], "source": [ "const int n = 6;\n", "Float_t x[6] = {1, 2, 1, -1, -2, -1};\n", "Float_t y[6] = {2, 0, -2, -2, 0, 2};\n", "TCutG *cut = new TCutG(\"cut\", 6, x, y);\n", "TH2F *hist = new TH2F(\"hist\", \"Histogram with cut\", 40, -10., 10., 40, -10., 10.);\n", "for (int i = 0; i < 100000; i++)\n", " hist->Fill(gRandom->Gaus(0., 3.), gRandom->Gaus(0., 3.));\n", "TCanvas *c1 = new TCanvas(\"c1\", \"Histogram draw with TCutG\", 600, 900);\n", "hist->Draw(\"col [cut]\");\n", "cut->Draw(\"l\");" ] }, { "cell_type": "markdown", "id": "2317a7e6", "metadata": {}, "source": [ "Draw all canvases " ] }, { "cell_type": "code", "execution_count": 2, "id": "cbac1986", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:12:20.610577Z", "iopub.status.busy": "2026-05-19T20:12:20.610453Z", "iopub.status.idle": "2026-05-19T20:12:20.831219Z", "shell.execute_reply": "2026-05-19T20:12:20.830701Z" } }, "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 }