{
"cells": [
{
"cell_type": "markdown",
"id": "da4f4672",
"metadata": {},
"source": [
"# tree102_basic\n",
"Create can ntuple reading data from an ascii file.\n",
"This macro is a variant of tree101_basic.C\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:17 PM."
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "f0c2c73f",
"metadata": {
"collapsed": false,
"execution": {
"iopub.execute_input": "2026-05-19T20:17:50.322143Z",
"iopub.status.busy": "2026-05-19T20:17:50.322033Z",
"iopub.status.idle": "2026-05-19T20:17:50.791227Z",
"shell.execute_reply": "2026-05-19T20:17:50.790487Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
" found 1000 points\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"Info in : created default TCanvas with name c1\n"
]
}
],
"source": [
"TString dir = gROOT->GetTutorialDir();\n",
"dir.Append(\"/io/tree/\");\n",
"dir.ReplaceAll(\"/./\", \"/\");\n",
"\n",
"auto f = TFile::Open(\"tree102.root\", \"RECREATE\");\n",
"auto h1 = new TH1F(\"h1\", \"x distribution\", 100, -4, 4);\n",
"auto T = new TTree(\"ntuple\", \"data from ascii file\");\n",
"Long64_t nlines = T->ReadFile(TString::Format(\"%sbasic.dat\", dir.Data()), \"x:y:z\");\n",
"printf(\" found %lld points\\n\", nlines);\n",
"T->Draw(\"x\", \"z>2\");\n",
"T->Write();"
]
},
{
"cell_type": "markdown",
"id": "c23b5ce5",
"metadata": {},
"source": [
"Draw all canvases "
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "3b1ceba0",
"metadata": {
"collapsed": false,
"execution": {
"iopub.execute_input": "2026-05-19T20:17:50.792933Z",
"iopub.status.busy": "2026-05-19T20:17:50.792810Z",
"iopub.status.idle": "2026-05-19T20:17:51.016400Z",
"shell.execute_reply": "2026-05-19T20:17:51.015612Z"
}
},
"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
}