{ "cells": [ { "cell_type": "markdown", "id": "e2111bb1", "metadata": {}, "source": [ "# hist019_TH2_projection\n", "A TExec allows to redraw automatically the projections when a zoom is performed\n", "on the 2D histogram.\n", "\n", "\n", "\n", "\n", "**Author:** Olivier Couet \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": "9c8616bb", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:12:21.860701Z", "iopub.status.busy": "2026-05-19T20:12:21.860567Z", "iopub.status.idle": "2026-05-19T20:12:22.201199Z", "shell.execute_reply": "2026-05-19T20:12:22.200329Z" } }, "outputs": [], "source": [ "TH2F *h2;\n", "TH1D *projh2X;\n", "TH1D *projh2Y;\n", "TPad *right_pad, *top_pad;" ] }, { "cell_type": "markdown", "id": "b2ab31f7", "metadata": {}, "source": [ " Definition of a helper function: " ] }, { "cell_type": "code", "execution_count": 2, "id": "98bc493b", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:12:22.203166Z", "iopub.status.busy": "2026-05-19T20:12:22.203040Z", "iopub.status.idle": "2026-05-19T20:12:22.211583Z", "shell.execute_reply": "2026-05-19T20:12:22.211076Z" } }, "outputs": [], "source": [ "%%cpp -d\n", "void ZoomExec()\n", "{\n", " int xfirst = h2->GetXaxis()->GetFirst();\n", " int xlast = h2->GetXaxis()->GetLast();\n", " double xmin = h2->GetXaxis()->GetBinLowEdge(xfirst);\n", " double xmax = h2->GetXaxis()->GetBinUpEdge(xlast);\n", " projh2X->GetXaxis()->SetRangeUser(xmin, xmax);\n", " top_pad->Modified();\n", "\n", " int yfirst = h2->GetYaxis()->GetFirst();\n", " int ylast = h2->GetYaxis()->GetLast();\n", " double ymin = h2->GetYaxis()->GetBinLowEdge(yfirst);\n", " double ymax = h2->GetYaxis()->GetBinUpEdge(ylast);\n", " projh2Y->GetXaxis()->SetRangeUser(ymin, ymax);\n", " right_pad->Modified();\n", "}" ] }, { "cell_type": "code", "execution_count": 3, "id": "7bb9c181", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:12:22.213063Z", "iopub.status.busy": "2026-05-19T20:12:22.212944Z", "iopub.status.idle": "2026-05-19T20:12:22.432811Z", "shell.execute_reply": "2026-05-19T20:12:22.432225Z" } }, "outputs": [ { "data": { "text/html": [ "\n", "\n", "