TTree Handling
==============

TTree and TBranch are two of the data objects that are versioned and streamed from ROOT files (subclasses of :py:class:`ROOTStreamedObject <uproot.rootio.ROOTStreamedObject>`). As such, their classes do not exist until observed in a ROOT file, and different class objects may be generated by different versions of the class with different member variables.

However, you may use TTrees and TBranches consistently across versions because they inherit from mix-ins :py:class:`TTreeMethods <uproot.tree.TTreeMethods>` and :py:class:`TBranchMethods <uproot.tree.TBranchMethods>`. These interfaces provide more Pythonic names for TTree/TBranch private data and a variety of data-reading routines.

TLeaf and its subclasses do not (currently) have mix-ins: they are used only for their data. TBasket does not even have an instantiation--- TBasket bytes are read directly into arrays.

These bytes are read according to some :py:class:`Interpretation <uproot.interp.interp.Interpretation>`, which governs how the bytes are interpreted (source) and what kinds of objects are filled (destination). For numerical data, the source is usually one big-endian array per basket and the destination is usually one native-endian array per branch. You have complete freedom to set the :py:class:`Interpretation <uproot.interp.interp.Interpretation>` for each branch, but sensible defaults are provided (by the :py:func:`interpret <uproot.interp.auto.interpret>` function, automatically).

Many of the :py:class:`TTreeMethods <uproot.tree.TTreeMethods>` and :py:class:`TBranchMethods <uproot.tree.TBranchMethods>` have the same parameters--- identical parameter names have identical meanings. In the documentation below, the definitions are repeated for each method (because it may be the first you call ``help`` on, though it inflates the size of this page.).

uproot.tree.TTreeMethods
------------------------

Every class read from a ROOT file named "TTree" is mixed in with :py:class:`TTreeMethods <uproot.tree.TTreeMethods>` so that the following methods are available.

.. autoclass:: uproot.tree.TTreeMethods

branch accessors
^^^^^^^^^^^^^^^^

.. automethod:: uproot.tree.TTreeMethods.get

.. automethod:: uproot.tree.TTreeMethods.iterkeys

.. automethod:: uproot.tree.TTreeMethods.itervalues

.. automethod:: uproot.tree.TTreeMethods.iteritems

.. automethod:: uproot.tree.TTreeMethods.keys

.. automethod:: uproot.tree.TTreeMethods.values

.. automethod:: uproot.tree.TTreeMethods.items

.. automethod:: uproot.tree.TTreeMethods.allkeys

.. automethod:: uproot.tree.TTreeMethods.allvalues

.. automethod:: uproot.tree.TTreeMethods.allitems

.. automethod:: uproot.tree.TTreeMethods.clusters

.. automethod:: uproot.tree.TTreeMethods.mempartitions

array
^^^^^

.. automethod:: uproot.tree.TTreeMethods.array

arrays
^^^^^^

.. automethod:: uproot.tree.TTreeMethods.arrays

lazyarray
^^^^^^^^^

.. automethod:: uproot.tree.TTreeMethods.lazyarray

lazyarrays
^^^^^^^^^^

.. automethod:: uproot.tree.TTreeMethods.lazyarrays

iterate
^^^^^^^

.. automethod:: uproot.tree.TTreeMethods.iterate

pandas
^^^^^^

TTree objects can be converted into `Pandas <https://pandas.pydata.org>`__ DataFrames.

.. autoattribute:: uproot.tree.TTreeMethods.pandas
   :annotation: = methods for interacting with Pandas.

.. automethod:: uproot._connect._pandas.TTreeMethods_pandas.df

uproot.tree.TBranchMethods
--------------------------

Every class read from a ROOT file named "TBranch" is mixed in with :py:class:`TBranchMethods <uproot.tree.TBranchMethods>` so that the following methods are available. Subclasses of "TBranch" (such as "TBranchElement") inherit the mix-in.

.. autoclass:: uproot.tree.TBranchMethods

branch accessors
^^^^^^^^^^^^^^^^

.. automethod:: uproot.tree.TBranchMethods.get

.. automethod:: uproot.tree.TBranchMethods.iterkeys

.. automethod:: uproot.tree.TBranchMethods.itervalues

.. automethod:: uproot.tree.TBranchMethods.iteritems

.. automethod:: uproot.tree.TBranchMethods.keys

.. automethod:: uproot.tree.TBranchMethods.values

.. automethod:: uproot.tree.TBranchMethods.items

.. automethod:: uproot.tree.TBranchMethods.allkeys

.. automethod:: uproot.tree.TBranchMethods.allvalues

.. automethod:: uproot.tree.TBranchMethods.allitems

branch information
^^^^^^^^^^^^^^^^^^

.. automethod:: uproot.tree.TBranchMethods.uncompressedbytes

.. automethod:: uproot.tree.TBranchMethods.compressedbytes

.. automethod:: uproot.tree.TBranchMethods.compressionratio

.. automethod:: uproot.tree.TBranchMethods.numitems

.. automethod:: uproot.tree.TBranchMethods.mempartitions

basket information
^^^^^^^^^^^^^^^^^^

.. automethod:: uproot.tree.TBranchMethods.basket_entrystart

.. automethod:: uproot.tree.TBranchMethods.basket_entrystop

.. automethod:: uproot.tree.TBranchMethods.basket_numentries

.. automethod:: uproot.tree.TBranchMethods.basket_uncompressedbytes

.. automethod:: uproot.tree.TBranchMethods.basket_compressedbytes

.. automethod:: uproot.tree.TBranchMethods.basket_numitems

array
^^^^^

.. automethod:: uproot.tree.TBranchMethods.array

lazyarray
^^^^^^^^^

.. automethod:: uproot.tree.TBranchMethods.lazyarray

basket
^^^^^^

.. automethod:: uproot.tree.TBranchMethods.basket

baskets
^^^^^^^

.. automethod:: uproot.tree.TBranchMethods.baskets

iterate_baskets
^^^^^^^^^^^^^^^

.. automethod:: uproot.tree.TBranchMethods.iterate_baskets
