{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Visualisation of Geometries\n", "
\n", "With ROOT you can visualize complex geometries, for example the ones of the LHC experiments or the one of a space station. In this notebook we will read a geometry from a ROOT file and display it. The possibility to save and resume geometries persisted on disk is a powerful feature as it avoids all the complex calculations behind the construction of a geometry from scratch, e.g. from a CAD or XML file. " ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "collapsed": true }, "outputs": [], "source": [ "%%python\n", "inputFileName = 'spaceStation.root'\n", "import os\n", "if not os.path.exists(inputFileName):\n", " import urllib2\n", " response = urllib2.urlopen('https://raw.githubusercontent.com/dpiparo/swanExamples/master/notebooks/Geometry_Visualisation_cpp/spaceStation.root')\n", " filecontent = response.read() \n", " with open(inputFileName,\"w\") as f_out:\n", " f_out.write(filecontent)" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "collapsed": false, "scrolled": true }, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "Info in : Reading geometry from file: spaceStation.root\n", "Info in : Geometry loaded from file...\n", "Info in : Top volume is top. Master volume is top\n", "Info in : --- Maximum geometry depth set to 100\n", "Info in : Voxelizing...\n", "Info in : max level = 1, max placements = 645\n", "Info in : 0 nodes/ 645 volume UID's in Space Station\n", "Info in : ----------------modeler ready----------------\n" ] } ], "source": [ "TGeoManager::Import(\"spaceStation.root\");\n", "\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We now get the top volume of the geometry to which all volumes are attached and draw it. The visualisation is interactive Rotate and zoom it with your mouse!\n" ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "collapsed": false }, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "Info in : created default TCanvas with name c1\n" ] }, { "data": { "text/html": [ "\n", "
\n", "
\n", "\n", "\n" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "auto topVolume = gGeoManager->GetTopVolume();\n", "topVolume->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": 0 }