{ "cells": [ { "cell_type": "markdown", "id": "d59ea6ab", "metadata": {}, "source": [ "# tree141_parallelcoord\n", "Script illustrating the use of the TParallelCoord class\n", "\n", "\n", "\n", "\n", "**Author:** Bastien Dallapiazza \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:19 PM." ] }, { "cell_type": "code", "execution_count": 1, "id": "00d85e28", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:19:19.456561Z", "iopub.status.busy": "2026-05-19T20:19:19.456450Z", "iopub.status.idle": "2026-05-19T20:19:19.466094Z", "shell.execute_reply": "2026-05-19T20:19:19.465625Z" } }, "outputs": [], "source": [ "%%cpp -d\n", "#include \"TFile.h\"\n", "#include \"TCanvas.h\"\n", "#include \"TStyle.h\"\n", "#include \"TRandom.h\"\n", "#include \"TNtuple.h\"\n", "#include \"TParallelCoord.h\"\n", "#include \"TParallelCoordVar.h\"\n", "#include \"TParallelCoordRange.h\"\n", "\n", "Double_t r1, r2, r3, r4, r5, r6, r7, r8, r9;\n", "Double_t dr = 3.5;\n", "TRandom *r;" ] }, { "cell_type": "markdown", "id": "1499f8af", "metadata": {}, "source": [ " Definition of a helper function: " ] }, { "cell_type": "code", "execution_count": 2, "id": "3e7e08a5", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:19:19.467478Z", "iopub.status.busy": "2026-05-19T20:19:19.467361Z", "iopub.status.idle": "2026-05-19T20:19:19.470974Z", "shell.execute_reply": "2026-05-19T20:19:19.470497Z" } }, "outputs": [], "source": [ "%%cpp -d\n", "void generate_random(Int_t i)\n", "{\n", " r1 = (2 * dr * r->Rndm(i)) - dr;\n", " r2 = (2 * dr * r->Rndm(i)) - dr;\n", " r7 = (2 * dr * r->Rndm(i)) - dr;\n", " r9 = (2 * dr * r->Rndm(i)) - dr;\n", " r4 = (2 * dr * r->Rndm(i)) - dr;\n", " r3 = (2 * dr * r->Rndm(i)) - dr;\n", " r5 = (2 * dr * r->Rndm(i)) - dr;\n", " r6 = (2 * dr * r->Rndm(i)) - dr;\n", " r8 = (2 * dr * r->Rndm(i)) - dr;\n", "}" ] }, { "cell_type": "code", "execution_count": 3, "id": "fb431011", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:19:19.472265Z", "iopub.status.busy": "2026-05-19T20:19:19.472155Z", "iopub.status.idle": "2026-05-19T20:19:19.976318Z", "shell.execute_reply": "2026-05-19T20:19:19.975559Z" } }, "outputs": [], "source": [ "TNtuple *nt = nullptr;\n", "\n", "Double_t s1x, s1y, s1z;\n", "Double_t s2x, s2y, s2z;\n", "Double_t s3x, s3y, s3z;\n", "r = new TRandom();;\n", "\n", "new TCanvas(\"c1\", \"c1\",0,0,800,700);\n", "\n", "nt = new TNtuple(\"nt\",\"Demo ntuple\",\"x:y:z:u:v:w\");\n", "\n", "for (Int_t i = 0; i < 20000; i++) {\n", " r->Sphere(s1x, s1y, s1z, 0.1);\n", " r->Sphere(s2x, s2y, s2z, 0.2);\n", " r->Sphere(s3x, s3y, s3z, 0.05);\n", "\n", " generate_random(i);\n", " nt->Fill(r1, r2, r3, r4, r5, r6);\n", "\n", " generate_random(i);\n", " nt->Fill(s1x, s1y, s1z, s2x, s2y, s2z);\n", "\n", " generate_random(i);\n", " nt->Fill(r1, r2, r3, r4, r5, r6);\n", "\n", " generate_random(i);\n", " nt->Fill(s2x-1, s2y-1, s2z, s1x+.5, s1y+.5, s1z+.5);\n", "\n", " generate_random(i);\n", " nt->Fill(r1, r2, r3, r4, r5, r6);\n", "\n", " generate_random(i);\n", " nt->Fill(s1x+1, s1y+1, s1z+1, s3x-2, s3y-2, s3z-2);\n", "\n", " generate_random(i);\n", " nt->Fill(r1, r2, r3, r4, r5, r6);\n", "}\n", "nt->Draw(\"x:y:z:u:v:w\", \"\", \"para\", 5000);\n", "auto para = (TParallelCoord*)gPad->GetListOfPrimitives()->FindObject(\"ParaCoord\");\n", "para->SetDotsSpacing(5);\n", "auto firstaxis = (TParallelCoordVar*)para->GetVarList()->FindObject(\"x\");\n", "firstaxis->AddRange(new TParallelCoordRange(firstaxis, 0.846018, 1.158469));\n", "para->AddSelection(\"violet\");\n", "para->GetCurrentSelection()->SetLineColor(kViolet);\n", "firstaxis->AddRange(new TParallelCoordRange(firstaxis, -0.169447, 0.169042));\n", "para->AddSelection(\"Orange\");\n", "para->GetCurrentSelection()->SetLineColor(kOrange+9);\n", "firstaxis->AddRange(new TParallelCoordRange(firstaxis, -1.263024, -0.755292));" ] } ], "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 }