profile
viewpoint
If you are wondering where the data of this site comes from, please visit https://api.github.com/users/Axel-Naumann/events. GitMemory does not store any data, but only uses NGINX to cache data for a period of time. The idea behind GitMemory is simply to give users a better reading experience.

Axel-Naumann/cling-all-in-one 41

llvm, clang and cling wrapped into one repo

Axel-Naumann/root 4

Mirror of official ROOT git repository located at

Axel-Naumann/clang 2

llvm's clang with some mods

Axel-Naumann/discourse-jira 2

Jira plugin for Discourse

Axel-Naumann/cmssw 1

CMS Offline Software

Axel-Naumann/coffeetable 1

CoffeeTable: arrange for casual, social chats between team members!

Axel-Naumann/asyncforest 0

Asynchronous scheduling of I/O tasks for RForest (demonstrator / testbed)

Axel-Naumann/cling 0

The cling C++ interpreter

Axel-Naumann/cling-rootcern 0

fork of https://github.com/root-project/cling

Axel-Naumann/clingkernel 0

C++ Kernel for Jupyter with Cling

push eventroot-project/root

Axel Naumann

commit sha 8cac072e2e770746b1833df49e4936a72669bcb8

Add missing header (-Ddev).

view details

push time in 5 hours

pull request commentroot-project/root

[ROOT5] cint: implement a stat() call cache for G__matchfilename()

We can create a git tag but we cannot make releases anymore; not sure how useful vs confusing this would be.

veprbl

comment created time in 19 hours

push eventroot-project/root

Axel Naumann

commit sha fc300fd4030ea599f2b884bcbcc9365f36c0fd56

[tree,net] Doc style improvements (NFC).

view details

push time in 2 days

delete branch Axel-Naumann/root

delete branch : random-doc-improvements

delete time in 2 days

pull request commentroot-project/root

[netxng] Implementation of RRawFileNetXNG.

We can use eospublic for testing xrootd. We have existing tutorials / tests that use it, see e.g. test/stressIOPlugins.cxx

simonmichal

comment created time in 2 days

Pull request review commentroot-project/web

[Docs] Rewrite 'Trees' section

 Branches with more data per tree entry will fill more baskets than branches with Conversely, baskets can hold many tree entries if their branch stores only a few bytes per tree entry. This means that generally, all baskets - also of different branches - will contain data of different tree entry ranges. -To allow more efficient pre-fetching and better chunking of tree data stored in ROOT files, TTree groups baskets into clusters, for a defined range of tree entry indices.+To allow more efficient pre-fetching and better chunking of tree data stored in ROOT files, TTree groups baskets into _clusters_.+A cluster contains all the data of a given event range.

Fixed thanks!

Axel-Naumann

comment created time in 2 days

PullRequestReviewEvent

push eventroot-project/web

Axel Naumann

commit sha 27136fe6a034b37514c5d33057f3a4e3a047293e

"event" -> "entry"

view details

push time in 2 days

push eventroot-project/web

Axel Naumann

commit sha 0481268bfc34077080034601066e3f082df44a53

Fix TNtuple constructor doc. Co-authored-by: Javier Lopez-Gomez <javier.lopez.gomez@cern.ch>

view details

push time in 2 days

push eventroot-project/roottest

Axel Naumann

commit sha ab54865fe7e9b2e11722f4663e48a93ff7e29f16

Remove mention of CDash.

view details

push time in 4 days

push eventroot-project/web

Axel Naumann

commit sha ce2d0a84d5361ad5676fee9499be8b743c337009

Use a nice sentence by Jakob; highlight introduced words.

view details

push time in 5 days

push eventroot-project/web

Axel Naumann

commit sha 727b1d2c549e02557a30aa1d56c36f6ff9facee6

Remove unreferenced image.

view details

push time in 5 days

push eventroot-project/web

Axel Naumann

commit sha eb842f61d06ae7851461022ca19bddc2a96ff162

Review comments.

view details

Axel Naumann

commit sha 58c70011bb5d3bf236a7576d4a3153de62f37081

done!

view details

push time in 5 days

push eventroot-project/web

Axel Naumann

commit sha 470e3a929aff2051891e3deee4ddf243262a04a6

tree indexing.

view details

push time in 5 days

PR opened root-project/web

Code indent
+3 -3

0 comment

1 changed file

pr created time in 5 days

create barnchroot-project/web

branch : Axel-Naumann-patch-1

created branch time in 5 days

push eventroot-project/web

Axel Naumann

commit sha a65e16da13079bdc3ee279f5bcd2f165f50b4de7

Review comments

view details

push time in 5 days

Pull request review commentroot-project/web

[Docs] Rewrite 'Trees' section

 toc: true toc_sticky: true --- -ROOT provides the {% include ref class="TTree" %} and the {% include ref class="TNtuple" %} class to store large quantities of same-class objects.<br>-A tree is a typical data container used for example by all LHC (Large Hadron Collider) experiments.<br>-Trees are optimized to reduce disk space and enhance access speed.+## Introducing `TTree` -A tree consists of a list of independent columns, called branches. The {% include ref class="TBranch" %} class represents a branch. A branch can contain all kind of data, such as objects or arrays in addition to all the simple types.+As introduced in → [Storing columnar data in a ROOT file and reading it back]({{ '/manual/root_files/#storing-columnar-data-in-a-root-file-and-reading-it-back' | relative_url }}),+ROOT can handle large columnar datasets.+In the aforementioned section, we made use of {% include ref class="RDataFrame" namespace="ROOT" %} to write and+read back a simple dataset.+RDataFrame traditionally relies on {% include ref class="TTree" %} for columnar data storage, used for example+by all LHC (Large Hadron Collider) experiments.+Trees are optimized for reduced disk space and selecting, high-throughput columnar access with reduced memory usage. -A {% include ref class="TNtuple" %} is a {% include ref class="TTree" %}, which is limited to contain only floating-point numbers.+In addition to the documentation in this manual, we recommend to take a look at the TTree tutorials:  {% include tutorials name="Tree" url="tree" %}  > **RNTuple** >-> [RNTuple](https://root.cern/doc/master/md_tree_ntuple_v7_doc_README.html){:target="_blank"} (for N-tuple and nested tuple) is the experimental evolution of {% include ref class="TTree" %} columnar data storage. `RNTuple` introduces new interfaces that are more robust.+> [RNTuple](https://root.cern/doc/master/md_tree_ntuple_v7_doc_README.html){:target="_blank"} is the experimental evolution of {% include ref class="TTree" %} columnar data storage. {% include ref class="RNTuple" namespace="ROOT::Experimental" %} introduces robust interfaces, a high-performance storage layout, and an asynchronous, thread-safe scheduling. -## Tree classes+> **RDataFrame**+>+> TODO: tell people to use RDF, not TTree -ROOT provides numerous classes for trees and branches, of which the following are among the most used:+### The tree and its data -- [TTree](https://root.cern/doc/master/classTTree.html){:target="_blank"}: Represents a columnar data set. Any C++ type can be stored in its columns.+A `TTree` behaves like an array of a data structure that resides on storage - except for one entry (or row, in database language).+That entry is accessible in memory: you can load any tree entry, ideally sequentially.+You can provide your own storage for the values of the columns of the current entry, in the form of variables.+In this case you have to tell the `TTree` about the address of these variables; either by calling [`TTree::SetBranchAddress()`](https://root.cern/doc/master/classTTree.html#a39b867210e4a77ef44917fd5e7898a1d), or by passing the variable when creating the branch for writing.+When "filling" (writing) the `TTree`, it will read the values out of these variables;+when reading back a `TTree` entry, it will write the values it read from storage into your variables. -- [TNtuple](https://root.cern/doc/master/classTNtuple.html){:target="_blank"}: A simple `TTree` restricted to a list of float variables only.+### Branches and leaves -- [TBranch](https://root.cern/doc/master/classTBranch.html){:target="_blank"}: Organizes columns, i.e. branches, of a `TTree`.+A tree consists of a list of independent columns, called branches. A branch can contain values of any fundamental type, C++ objects known to ROOT's type system, or collections of those.+Branches are represented by {% include ref class="TBranch" %} and its derived classes. -- [TChain](https://root.cern/doc/master/classTChain.html){:target="_blank"}: A list of ROOT files containing `TTree` objects.+While `TBranch` represent structure, objects inheriting from {% include ref class="TLeaf" %} contain the actual data.+Originally, any columnar data was contained in a `TLeaf`; these days, some of the `TBranch`-derived classes contain data themselves, such as {% include ref class="TBranchElement" %}. +### Appending `TTree`s as a `TChain` -## Working with trees+In high energy physics you always want as much data as possible.+But it's not nice to deal with files of multiple terabytes.+ROOT allows to to split data across multiple files, where you can then access the files' tree parts as one large tree.+That's done through {% include ref class="TChain" %}, which inherits from {% include ref class="TTree" %}:+it wants to know the name of the trees in the files (has to be the same throughout), and the file names, and will act as if it was a huge, continuous tree: -ROOT offers many possibilities to work with trees, for example:+_**Example**_ -- [Creating a tree](#creating-a-tree)-- [Creating a tree from a folder structure](#creating-a-tree-from-a-folder-structure)-- [Filling a tree](#filling-a-tree)-- [Writing a tree](#writing-a-tree)-- [Printing the summary of a tree](#printing-the-summary-of-a-tree)-- [Showing an entry of a tree](#showing-an-entry-of-a-tree)-- [Scanning trees](#scanning-trees)+{% highlight C++ %}+TChain chain("CommonTreeName");+if (chain.Add("data_*.root") != 12)+   std::cerr << "Expected to find 12 files!\n";+// Use `chain` as if it was a `TTree`+{% endhighlight %} -### Creating a tree+{% highlight Python %}+chain = ROOT.TChain("CommonTreeName")+if chain.Add("data_*.root" != 12:+   print("Expected to find 12 files!")+# Use `chain` as if it was a `TTree`+{% endhighlight %} -- Use the {% include ref class="TTree" %} constructor to create a tree.+### Widening a `TTree`s through friends -_**Example**_+[TODO](https://TRIGGER CI!) -{% highlight C++ %}-   TTree t("MyTree","Example Tree");-{% endhighlight %}+### Adding friends to trees

Fixed

Axel-Naumann

comment created time in 5 days

PullRequestReviewEvent

Pull request review commentroot-project/web

[Docs] Rewrite 'Trees' section

 toc: true toc_sticky: true --- -ROOT provides the {% include ref class="TTree" %} and the {% include ref class="TNtuple" %} class to store large quantities of same-class objects.<br>-A tree is a typical data container used for example by all LHC (Large Hadron Collider) experiments.<br>-Trees are optimized to reduce disk space and enhance access speed.+## Introducing `TTree` -A tree consists of a list of independent columns, called branches. The {% include ref class="TBranch" %} class represents a branch. A branch can contain all kind of data, such as objects or arrays in addition to all the simple types.+As introduced in → [Storing columnar data in a ROOT file and reading it back]({{ '/manual/root_files/#storing-columnar-data-in-a-root-file-and-reading-it-back' | relative_url }}),+ROOT can handle large columnar datasets.+In the aforementioned section, we made use of {% include ref class="RDataFrame" namespace="ROOT" %} to write and+read back a simple dataset.+RDataFrame traditionally relies on {% include ref class="TTree" %} for columnar data storage, used for example+by all LHC (Large Hadron Collider) experiments.+Trees are optimized for reduced disk space and selecting, high-throughput columnar access with reduced memory usage. -A {% include ref class="TNtuple" %} is a {% include ref class="TTree" %}, which is limited to contain only floating-point numbers.+In addition to the documentation in this manual, we recommend to take a look at the TTree tutorials:  {% include tutorials name="Tree" url="tree" %}  > **RNTuple** >-> [RNTuple](https://root.cern/doc/master/md_tree_ntuple_v7_doc_README.html){:target="_blank"} (for N-tuple and nested tuple) is the experimental evolution of {% include ref class="TTree" %} columnar data storage. `RNTuple` introduces new interfaces that are more robust.+> [RNTuple](https://root.cern/doc/master/md_tree_ntuple_v7_doc_README.html){:target="_blank"} is the experimental evolution of {% include ref class="TTree" %} columnar data storage. {% include ref class="RNTuple" namespace="ROOT::Experimental" %} introduces robust interfaces, a high-performance storage layout, and an asynchronous, thread-safe scheduling. -## Tree classes+> **RDataFrame**+>+> TODO: tell people to use RDF, not TTree -ROOT provides numerous classes for trees and branches, of which the following are among the most used:+### The tree and its data -- [TTree](https://root.cern/doc/master/classTTree.html){:target="_blank"}: Represents a columnar data set. Any C++ type can be stored in its columns.+A `TTree` behaves like an array of a data structure that resides on storage - except for one entry (or row, in database language).+That entry is accessible in memory: you can load any tree entry, ideally sequentially.+You can provide your own storage for the values of the columns of the current entry, in the form of variables.+In this case you have to tell the `TTree` about the address of these variables; either by calling [`TTree::SetBranchAddress()`](https://root.cern/doc/master/classTTree.html#a39b867210e4a77ef44917fd5e7898a1d), or by passing the variable when creating the branch for writing.+When "filling" (writing) the `TTree`, it will read the values out of these variables;+when reading back a `TTree` entry, it will write the values it read from storage into your variables. -- [TNtuple](https://root.cern/doc/master/classTNtuple.html){:target="_blank"}: A simple `TTree` restricted to a list of float variables only.+### Branches and leaves -- [TBranch](https://root.cern/doc/master/classTBranch.html){:target="_blank"}: Organizes columns, i.e. branches, of a `TTree`.+A tree consists of a list of independent columns, called branches. A branch can contain values of any fundamental type, C++ objects known to ROOT's type system, or collections of those.+Branches are represented by {% include ref class="TBranch" %} and its derived classes. -- [TChain](https://root.cern/doc/master/classTChain.html){:target="_blank"}: A list of ROOT files containing `TTree` objects.+While `TBranch` represent structure, objects inheriting from {% include ref class="TLeaf" %} contain the actual data.+Originally, any columnar data was contained in a `TLeaf`; these days, some of the `TBranch`-derived classes contain data themselves, such as {% include ref class="TBranchElement" %}. +### Appending `TTree`s as a `TChain` -## Working with trees+In high energy physics you always want as much data as possible.+But it's not nice to deal with files of multiple terabytes.+ROOT allows to to split data across multiple files, where you can then access the files' tree parts as one large tree.+That's done through {% include ref class="TChain" %}, which inherits from {% include ref class="TTree" %}:+it wants to know the name of the trees in the files (has to be the same throughout), and the file names, and will act as if it was a huge, continuous tree: -ROOT offers many possibilities to work with trees, for example:+_**Example**_ -- [Creating a tree](#creating-a-tree)-- [Creating a tree from a folder structure](#creating-a-tree-from-a-folder-structure)-- [Filling a tree](#filling-a-tree)-- [Writing a tree](#writing-a-tree)-- [Printing the summary of a tree](#printing-the-summary-of-a-tree)-- [Showing an entry of a tree](#showing-an-entry-of-a-tree)-- [Scanning trees](#scanning-trees)+{% highlight C++ %}+TChain chain("CommonTreeName");+if (chain.Add("data_*.root") != 12)+   std::cerr << "Expected to find 12 files!\n";+// Use `chain` as if it was a `TTree`+{% endhighlight %} -### Creating a tree+{% highlight Python %}+chain = ROOT.TChain("CommonTreeName")+if chain.Add("data_*.root" != 12:+   print("Expected to find 12 files!")+# Use `chain` as if it was a `TTree`+{% endhighlight %} -- Use the {% include ref class="TTree" %} constructor to create a tree.+### Widening a `TTree`s through friends -_**Example**_+[TODO](https://TRIGGER CI!) -{% highlight C++ %}-   TTree t("MyTree","Example Tree");-{% endhighlight %}+### Adding friends to trees -It creates a tree with the title `Example Tree`.+> Tutorial+>+>  {% include tutorial name="tree3" %} -_**Example: A simple tree**_+Adding a branch is often not possible because the tree is a read-only file and you do not have permission to save the modified tree with the new branch. Even if you do have the permission, you risk loosing the original tree with an unsuccessful attempt to save the modification. Since trees are usually large, adding a branch could extend it over the 2 GB limit. In this case, the attempt to write the tree fails, and the original data is may also be corrupted. In addition, adding a branch to a tree enlarges the tree and increases the amount of memory needed to read an entry, and therefore decreases the performance.

Fixed

Axel-Naumann

comment created time in 5 days

PullRequestReviewEvent
PullRequestReviewEvent

Pull request review commentroot-project/web

[Docs] Rewrite 'Trees' section

 toc: true toc_sticky: true --- -ROOT provides the {% include ref class="TTree" %} and the {% include ref class="TNtuple" %} class to store large quantities of same-class objects.<br>-A tree is a typical data container used for example by all LHC (Large Hadron Collider) experiments.<br>-Trees are optimized to reduce disk space and enhance access speed.+## Introducing `TTree` -A tree consists of a list of independent columns, called branches. The {% include ref class="TBranch" %} class represents a branch. A branch can contain all kind of data, such as objects or arrays in addition to all the simple types.+As introduced in → [Storing columnar data in a ROOT file and reading it back]({{ '/manual/root_files/#storing-columnar-data-in-a-root-file-and-reading-it-back' | relative_url }}),+ROOT can handle large columnar datasets.+In the aforementioned section, we made use of {% include ref class="RDataFrame" namespace="ROOT" %} to write and+read back a simple dataset.+RDataFrame traditionally relies on {% include ref class="TTree" %} for columnar data storage, used for example+by all LHC (Large Hadron Collider) experiments.+Trees are optimized for reduced disk space and selecting, high-throughput columnar access with reduced memory usage. -A {% include ref class="TNtuple" %} is a {% include ref class="TTree" %}, which is limited to contain only floating-point numbers.+In addition to the documentation in this manual, we recommend to take a look at the TTree tutorials:  {% include tutorials name="Tree" url="tree" %}  > **RNTuple** >-> [RNTuple](https://root.cern/doc/master/md_tree_ntuple_v7_doc_README.html){:target="_blank"} (for N-tuple and nested tuple) is the experimental evolution of {% include ref class="TTree" %} columnar data storage. `RNTuple` introduces new interfaces that are more robust.+> [RNTuple](https://root.cern/doc/master/md_tree_ntuple_v7_doc_README.html){:target="_blank"} is the experimental evolution of {% include ref class="TTree" %} columnar data storage. {% include ref class="RNTuple" namespace="ROOT::Experimental" %} introduces robust interfaces, a high-performance storage layout, and an asynchronous, thread-safe scheduling. -## Tree classes+> **RDataFrame**+>+> TODO: tell people to use RDF, not TTree -ROOT provides numerous classes for trees and branches, of which the following are among the most used:+### The tree and its data -- [TTree](https://root.cern/doc/master/classTTree.html){:target="_blank"}: Represents a columnar data set. Any C++ type can be stored in its columns.+A `TTree` behaves like an array of a data structure that resides on storage - except for one entry (or row, in database language).+That entry is accessible in memory: you can load any tree entry, ideally sequentially.+You can provide your own storage for the values of the columns of the current entry, in the form of variables.+In this case you have to tell the `TTree` about the address of these variables; either by calling [`TTree::SetBranchAddress()`](https://root.cern/doc/master/classTTree.html#a39b867210e4a77ef44917fd5e7898a1d), or by passing the variable when creating the branch for writing.+When "filling" (writing) the `TTree`, it will read the values out of these variables;+when reading back a `TTree` entry, it will write the values it read from storage into your variables. -- [TNtuple](https://root.cern/doc/master/classTNtuple.html){:target="_blank"}: A simple `TTree` restricted to a list of float variables only.+### Branches and leaves -- [TBranch](https://root.cern/doc/master/classTBranch.html){:target="_blank"}: Organizes columns, i.e. branches, of a `TTree`.+A tree consists of a list of independent columns, called branches. A branch can contain values of any fundamental type, C++ objects known to ROOT's type system, or collections of those.+Branches are represented by {% include ref class="TBranch" %} and its derived classes. -- [TChain](https://root.cern/doc/master/classTChain.html){:target="_blank"}: A list of ROOT files containing `TTree` objects.+While `TBranch` represent structure, objects inheriting from {% include ref class="TLeaf" %} contain the actual data.+Originally, any columnar data was contained in a `TLeaf`; these days, some of the `TBranch`-derived classes contain data themselves, such as {% include ref class="TBranchElement" %}. +### Appending `TTree`s as a `TChain` -## Working with trees+In high energy physics you always want as much data as possible.+But it's not nice to deal with files of multiple terabytes.+ROOT allows to to split data across multiple files, where you can then access the files' tree parts as one large tree.+That's done through {% include ref class="TChain" %}, which inherits from {% include ref class="TTree" %}:+it wants to know the name of the trees in the files (has to be the same throughout), and the file names, and will act as if it was a huge, continuous tree: -ROOT offers many possibilities to work with trees, for example:+_**Example**_ -- [Creating a tree](#creating-a-tree)-- [Creating a tree from a folder structure](#creating-a-tree-from-a-folder-structure)-- [Filling a tree](#filling-a-tree)-- [Writing a tree](#writing-a-tree)-- [Printing the summary of a tree](#printing-the-summary-of-a-tree)-- [Showing an entry of a tree](#showing-an-entry-of-a-tree)-- [Scanning trees](#scanning-trees)+{% highlight C++ %}+TChain chain("CommonTreeName");+if (chain.Add("data_*.root") != 12)+   std::cerr << "Expected to find 12 files!\n";+// Use `chain` as if it was a `TTree`+{% endhighlight %} -### Creating a tree+{% highlight Python %}+chain = ROOT.TChain("CommonTreeName")+if chain.Add("data_*.root" != 12:+   print("Expected to find 12 files!")+# Use `chain` as if it was a `TTree`+{% endhighlight %} -- Use the {% include ref class="TTree" %} constructor to create a tree.+### Widening a `TTree`s through friends -_**Example**_+[TODO](https://TRIGGER CI!) -{% highlight C++ %}-   TTree t("MyTree","Example Tree");-{% endhighlight %}+### Adding friends to trees -It creates a tree with the title `Example Tree`.+> Tutorial+>+>  {% include tutorial name="tree3" %} -_**Example: A simple tree**_+Adding a branch is often not possible because the tree is a read-only file and you do not have permission to save the modified tree with the new branch. Even if you do have the permission, you risk loosing the original tree with an unsuccessful attempt to save the modification. Since trees are usually large, adding a branch could extend it over the 2 GB limit. In this case, the attempt to write the tree fails, and the original data is may also be corrupted. In addition, adding a branch to a tree enlarges the tree and increases the amount of memory needed to read an entry, and therefore decreases the performance. -The following script builds a {% include ref class="TTree" %} from an ASCII file containing-statistics about the staff at CERN. Both, `staff.C` and `staff.dat` are in available in-`$ROOTSYS/tutorials/tree`.+For these reasons ROOT offers the concept of friends for trees (and chains) by adding a branch manually with [TTree::AddFriend()](https://root.cern/doc/master/classTTree.html#a011d362261b694ee7dd780bad21f030b){:target="_blank"}.

Addressed (differently)

Axel-Naumann

comment created time in 5 days

Pull request review commentroot-project/web

[Docs] Rewrite 'Trees' section

 The `TTree::Write()` method is needed to write the ROOT file header.  When writing a {% include ref class="TTree" %} to a ROOT file and if the ROOT file size reaches the value stored in the [TTree::GetMaxTreeSize()](https://root.cern/doc/master/classTTree.html#aca38baf017a203ddb3119a9ab7283cd9){:target="_blank"}, the current ROOT file is closed and a new ROOT file is created. If the original ROOT file is named `myfile.root`, the subsequent ROOT files are named `myfile_1.root`, `myfile_2.root`, etc. -**Autosave**+_Autosave_

Addressed

Axel-Naumann

comment created time in 5 days

PullRequestReviewEvent

Pull request review commentroot-project/web

[Docs] Rewrite 'Trees' section

 The `TTree::Write()` method is needed to write the ROOT file header.  When writing a {% include ref class="TTree" %} to a ROOT file and if the ROOT file size reaches the value stored in the [TTree::GetMaxTreeSize()](https://root.cern/doc/master/classTTree.html#aca38baf017a203ddb3119a9ab7283cd9){:target="_blank"}, the current ROOT file is closed and a new ROOT file is created. If the original ROOT file is named `myfile.root`, the subsequent ROOT files are named `myfile_1.root`, `myfile_2.root`, etc. -**Autosave**+_Autosave_++You can flush the tree data to file after the tree has collected a certain amount of data in memory (by default, 300MB).+If your program crashes, you can recover the ROOT file and the tree entries since the last autosave.++You can adjust the threshold (in bytes or entries) using [TTree::SetAutosave()](https://root.cern/doc/master/classTTree.html#a76259576b0094536ad084cde665c13a8){:target="_blank"}.++## Reading a tree++> **Note**+>+> Please use {% include ref class="RDataFrame" namespace="ROOT" %} to read trees, unless you need to do low-level I/O!++To read a tree, you need to associate your variables with the tree's branches, as when writing.+When loading a tree entry, the tree will set the variables to the branch's value as read from the storage.+That is done by calling [`TTree::SetBranchAddress()`](https://root.cern/doc/master/classTTree.html#a39b867210e4a77ef44917fd5e7898a1d):++_**Example**_++{% highlight C++ %}+std::unique_ptr<TFile> myFile( TFile::Open("file.root") );+auto tree = myFile->Get<TTree>("TreeName");++int variable;+tree->SetBranchAddress("branchName", &variable);++for (int iEntry = 0; tree->LoadTree(iEntry) >= 0; ++iEntry) {+   // Load the data for the given tree entry+   tree->GetEntry(iEntry);++   // Now, `variable` is set to the value of the branch+   // "branchName" in tree entry `iEntry`+   printf("%d\n", variable);+}+{% endhighlight %}++In Python you can simply use the branch name as an attribute on the tree:++{% highlight Python %}+myFile = ROOT.TFile.Open("file.root")+myTree = myFile.TreeName+for entry in myTree:+   print(entry.branchName)+{% endhighlight %}+++### Selecting a subset of branches to be read++You can select or deselect branches from being read by `GetEntry()` by calling [`TTree::SetBranchStatus()`](https://root.cern/doc/master/classTTree.html#aeca53bcd4482de1d883d259df6663920).+It is vividly recommended to only read the branches actually needed:+`TTree` is optimized for exactly this use case, and most analyses will only need a fraction of the available branches.++{% highlight C++ %}+// Extract the tree as above.++// Disable everything...+tree->SetBranchStatus("*", false);+// ...but the branch we need+tree->SetBranchStatus("branchName", true);++// Now proceed as above.+int variable;+tree->SetBranchAddress("branchName", &variable);+for (int iEntry = 0; tree->LoadTree(iEntry) >= 0; ++iEntry) {+   // Load the data for the given tree entry+   tree->GetEntry(iEntry);++   printf("%d\n", variable);+}+{% endhighlight %} -`Autosave` gives you the option to save all branch buffers every n byte. It is recommended to use `Autosave` for large acquisitions. If the acquisition fails to complete, you can recover the ROOT file and all the contents since the last `Autosave`. -- Use the [TTree::SetAutosave()](https://root.cern/doc/master/classTTree.html#a76259576b0094536ad084cde665c13a8){:target="_blank"} method to set the number of bytes between `Autosave`.+### Selecting a subset of entries to be read -You can also use [TTree::SetAutosave()](https://root.cern/doc/master/classTTree.html#a76259576b0094536ad084cde665c13a8){:target="_blank"} in the acquisition loop every n entry.+To process only a selection of tree entries, you can use a {% include ref class="TEntryList" %}.+First you inserting the tree entry numbers you want to process into the `TEntryList`.++{% highlight Python %}+entryList = ROOT.TEntryList("entryListName", "Title of the entry list")+for entry in tree:+   if entry.missingET < 100:+      entryList.Enter(tree.GetReadEntry())+myFile = ROOT.TFile.Open("entrylist.root", "RECREATE")+myFile.WriteObject(entrylist)+{% endhighlight %}++You can then re-use the `TEntryList` in subsequent processing of the tree, skipping irrelevant entries.++{% highlight Python %}+myFile = ROOT.TFile.Open("entrylist.root")+entrylist = myFile.entryListName+tree.SetEntryList(entrylist)+for entry in tree:+   # all entries will have missingET < 100+{% endhighlight %}++## Appending `TTree`s as a `TChain`++In high energy physics you always want as much data as possible.+But it's not nice to deal with files of multiple terabytes.+ROOT allows to to split data across multiple files, where you can then access the files' tree parts as one large tree.+That's done through {% include ref class="TChain" %}, which inherits from {% include ref class="TTree" %}:+it wants to know the name of the trees in the files (has to be the same throughout), and the file names, and will act as if it was a huge, continuous tree:

Clarified

Axel-Naumann

comment created time in 5 days

PullRequestReviewEvent

Pull request review commentroot-project/web

[Docs] Rewrite 'Trees' section

 Use [TTree:Fill()](https://root.cern/doc/master/classTTree.html#a00e0c422f5e4f6e  The data of a tree are saved in a ROOT file (see → [ROOT files]({{ '/manual/root_files' | relative_url }})). -- Use the [TTree::Write()](https://root.cern/doc/master/classTTree.html#af6f2d9ae4048ad85fcae5d2afa05100f){:target="_blank"} method to write the tree into a ROOT file.+Use [TTree::Write()](https://root.cern/doc/master/classTTree.html#af6f2d9ae4048ad85fcae5d2afa05100f){:target="_blank"} to write the tree into a ROOT file.+Earlier entries' data might already be written as part of `TTree::Fill()`. -The `TTree::Write()` method is needed to write the ROOT file header.+If due to the data written during `TTree::Fill()`, the file's size increases beyond [TTree::GetMaxTreeSize()](https://root.cern/doc/master/classTTree.html#aca38baf017a203ddb3119a9ab7283cd9){:target="_blank"}, the current ROOT file is closed and a new ROOT file is created.+For an original ROOT file named `myfile.root`, the subsequent ROOT files are named `myfile_1.root`, `myfile_2.root`, etc. -When writing a {% include ref class="TTree" %} to a ROOT file and if the ROOT file size reaches the value stored in the [TTree::GetMaxTreeSize()](https://root.cern/doc/master/classTTree.html#aca38baf017a203ddb3119a9ab7283cd9){:target="_blank"}, the current ROOT file is closed and a new ROOT file is created. If the original ROOT file is named `myfile.root`, the subsequent ROOT files are named `myfile_1.root`, `myfile_2.root`, etc.+_AutoFlush_ -_Autosave_+The tree can flush its data (i.e. its baskets) to file when reaching a given cluster size, thus closing the cluster.+By default this happens every 30MB.

Applied

Axel-Naumann

comment created time in 5 days

PullRequestReviewEvent