{ "cells": [ { "cell_type": "markdown", "id": "ab35e7f6", "metadata": {}, "source": [ "# tree114_circular\n", "Example of a circular Tree\n", "\n", "Circular Trees are interesting in online real time environments\n", "to store the results of the last maxEntries events.\n", "for more info, see TTree::SetCircular.\n", "Circular trees must be memory resident.\n", "\n", "\n", "\n", "\n", "**Author:** Rene Brun \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:18 PM." ] }, { "cell_type": "code", "execution_count": 1, "id": "184a9480", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:18:37.407444Z", "iopub.status.busy": "2026-05-19T20:18:37.407315Z", "iopub.status.idle": "2026-05-19T20:18:37.721080Z", "shell.execute_reply": "2026-05-19T20:18:37.720455Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "******************************************************************************\n", "*Tree :T : test circular buffers *\n", "*Entries : 18977 : Total = 420932 bytes File Size = 0 *\n", "* : : Tree compression factor = 1.00 *\n", "******************************************************************************\n", "*Br 0 :px : px/F *\n", "*Entries : 18977 : Total Size= 76529 bytes One basket in memory *\n", "*Baskets : 0 : Basket Size= 32000 bytes Compression= 1.00 *\n", "*............................................................................*\n", "*Br 1 :py : px/F *\n", "*Entries : 18977 : Total Size= 76529 bytes One basket in memory *\n", "*Baskets : 0 : Basket Size= 32000 bytes Compression= 1.00 *\n", "*............................................................................*\n", "*Br 2 :pz : px/F *\n", "*Entries : 18977 : Total Size= 76529 bytes One basket in memory *\n", "*Baskets : 0 : Basket Size= 32000 bytes Compression= 1.00 *\n", "*............................................................................*\n", "*Br 3 :random : random/D *\n", "*Entries : 18977 : Total Size= 152469 bytes One basket in memory *\n", "*Baskets : 0 : Basket Size= 32000 bytes Compression= 1.00 *\n", "*............................................................................*\n", "*Br 4 :i : i/s *\n", "*Entries : 18977 : Total Size= 38565 bytes One basket in memory *\n", "*Baskets : 0 : Basket Size= 32000 bytes Compression= 1.00 *\n", "*............................................................................*\n" ] } ], "source": [ "TRandom r;\n", "Float_t px,py,pz;\n", "Double_t randomNum;\n", "UShort_t i;\n", "auto T = new TTree(\"T\", \"test circular buffers\");\n", "T->Branch(\"px\", &px, \"px/F\");\n", "T->Branch(\"py\", &py, \"px/F\");\n", "T->Branch(\"pz\", &pz, \"px/F\");\n", "T->Branch(\"random\", &randomNum, \"random/D\");\n", "T->Branch(\"i\", &i, \"i/s\");\n", "T->SetCircular(20000); // keep a maximum of 20000 entries in memory\n", "for (i = 0; i < 65000; i++) {\n", " r.Rannor(px, py);\n", " pz = px * px + py * py;\n", " randomNum = r.Rndm();\n", " T->Fill();\n", "}\n", "T->Print();" ] } ], "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 }