uproot.TBranch

Defined in uproot.behaviors.TBranch on line 1758.

Inheritance order:

  1. uproot.behaviors.TBranch.HasBranches

  2. collections.abc.Mapping

  3. collections.abc.Collection

  4. collections.abc.Sized

  5. collections.abc.Iterable

  6. collections.abc.Container

class uproot.behaviors.TBranch.TBranch

Behaviors for a TBranch, which mostly consist of array-reading methods.

Since a uproot.TBranch is a uproot.behaviors.TBranch.HasBranches, it is also a Python Mapping, which uses square bracket syntax to extract subbranches:

my_branch["subbranch"]
my_branch["subbranch"]["subsubbranch"]
my_branch["subbranch/subsubbranch"]

array

TBranch.array(interpretation=None, entry_start=None, entry_stop=None, decompression_executor=None, interpretation_executor=None, array_cache='inherit', library='ak')
Parameters
  • interpretation (None or uproot.interpretation.Interpretation) – An interpretation of the TBranch data as an array. If None, the standard interpretation is used, which is derived from uproot.interpretation.identify.interpretation_of.

  • entry_start (None or int) – The first entry to include. If None, start at zero. If negative, count from the end, like a Python slice.

  • entry_stop (None or int) – The first entry to exclude (i.e. one greater than the last entry to include). If None, stop at num_entries. If negative, count from the end, like a Python slice.

  • decompression_executor (None or Executor with a submit method) – The executor that is used to decompress TBaskets; if None, the file’s decompression_executor is used.

  • interpretation_executor (None or Executor with a submit method) – The executor that is used to interpret uncompressed TBasket data as arrays; if None, the file’s interpretation_executor is used.

  • array_cache ("inherit", None, MutableMapping, or memory size) – Cache of arrays; if “inherit”, use the file’s cache; if None, do not use a cache; if a memory size, create a new cache of this size.

  • library (str or uproot.interpretation.library.Library) – The library that is used to represent arrays. Options are "np" for NumPy, "ak" for Awkward Array, and "pd" for Pandas.

Returns the TBranch data as an array.

For example:

>>> array = tree
>>> array = tree.arrays(["x", "y"])    # only reads branches "x" and "y"
>>> array
<Array [{x: -41.2, y: 17.4}, ... {x: 32.5, y: 1.2}], type='2304 * {"x": float64,...'>
>>> array["x"]
<Array [-41.2, 35.1, 35.1, ... 32.4, 32.5] type='2304 * float64'>
>>> array["y"]
<Array [17.4, -16.6, -16.6, ... 1.2, 1.2, 1.2] type='2304 * float64'>

See also arrays to read multiple TBranches into a group of arrays or an array-group.

name

TBranch.name

Name of the TBranch.

Note that TBranch names are not guaranteed to be unique; it is sometimes necessary to address a branch by its index.

title

TBranch.title

Title of the TBranch.

object_path

TBranch.object_path

Object path of the TBranch.

cache_key

TBranch.cache_key

String that uniquely specifies this TBranch in its path, to use as part of object and array cache keys.

index

TBranch.index

Integer position of this TBranch in its parent’s list of branches.

Useful for cases in which the name is not unique: the non-recursive index is always unique.

interpretation

TBranch.interpretation

The standard uproot.interpretation.Interpretation of this TBranch as an array, derived from uproot.interpretation.identify.interpretation_of.

If no interpretation could be found, the value of this property would be a uproot.interpretation.identify.UnknownInterpretation, which is a Python Exception. Since the exception is returned, rather than raised, a branch lacking an interpretation is not a fatal error.

However, any attempt to use this exception object as an uproot.interpretation.Interpretation causes it to raise itself: attempting to read a branch lacking an interpretation is a fatal error.

typename

TBranch.typename

The C++ typename of the TBranch, derived from its interpretation. If the interpretation is uproot.interpretation.identify.UnknownInterpretation, the typename is "unknown".

num_entries

TBranch.num_entries

The number of entries in the TBranch, as reported by fEntries.

In principle, this could disagree with the num_entries, which is from the TTree’s fEntries.

The TBranch also has a fEntryNumber, which ought to be equal to the TBranch and TTree’s fEntries, and the last value of entry_offsets ought to be equal to the number of entries as well.

entry_offsets

TBranch.entry_offsets

The starting and stopping entry numbers for all the TBaskets in the TBranch as a list of increasing, non-negative integers.

The number of entry_offsets in this list of integers is one more than the number of TBaskets. The first is 0 and the last is the number of entries (num_entries).

basket_entry_start_stop

TBranch.basket_entry_start_stop(basket_num)

The starting and stopping entry number for TBasket number basket_num.

tree

TBranch.tree

The TTree to which this TBranch belongs. The branch might be deeply nested; this property ascends all the way to the top.

top_level

TBranch.top_level

True if this branch’s immediate parent is the TTree; False otherwise.

streamer

TBranch.streamer

The TStreamerInfo or TStreamerElement for this TBranch, which may be None.

If the streamers have not yet been read, this method might cause them to be read. (Only TBranchElements can have streamers.)

context

TBranch.context

Auxiliary data used in deserialization. This is a copy of the context dict at the time that the TBranch was deserialized with "in_TBranch": True added.

aliases

TBranch.aliases

The aliases, which are used as the aliases argument to arrays, iterate, uproot.iterate, and uproot.concatenate if one is not given.

The return type is always a dict of str → str, even if there are no aliases (an empty dict).

count_branch

TBranch.count_branch

The TBranch object in which this branch’s “counts” reside or None if this branch has no “counts”.

count_leaf

TBranch.count_leaf

The TLeaf object of this branch’s “counts” or None if this branch has no “counts”.

compression

TBranch.compression

A uproot.compression.Compression object describing the compression setting for the TBranch.

Note that different TBranches in a TTree can be compressed differently from each other, and they can be compressed differently from the file’s global compression setting.

It is also in principle possible for the blocks in each TBasket to be compresssed differently: see block_compression_info if you’re paranoid.

compressed_bytes

TBranch.compressed_bytes

The number of compressed bytes in all TBaskets of this TBranch, including the TKey headers (which are always uncompressed).

This information is specified in the TBranch metadata (fZipBytes) and can be determined without reading any additional data.

uncompressed_bytes

TBranch.uncompressed_bytes

The number of uncompressed bytes in all TBaskets of this TBranch, including the TKey headers.

This information is specified in the TBranch metadata (fTotBytes) and can be determined without reading any additional data.

compression_ratio

TBranch.compression_ratio

The number of uncompressed bytes divided by the number of compressed bytes for this TBranch.

See compressed_bytes and uncompressed_bytes.

num_baskets

TBranch.num_baskets

The number of TBaskets in this TBranch, including both normal (free) TBaskets and embedded_baskets.

basket

TBranch.basket(basket_num)

The uproot.models.TBasket.Model_TBasket at index basket_num.

It may be a normal (free) TBasket or one of the embedded_baskets.

basket_chunk_cursor

TBranch.basket_chunk_cursor(basket_num)

Returns a uproot.source.chunk.Chunk and uproot.Cursor as a 2-tuple for a given basket_num.

If the file source is uproot.MemmapSource and the file gets closed, accessing the Chunk would cause a segfault. If that’s a possibility, be sure to call uproot.source.chunk.Chunk.detach_memmap to ensure that any memmap-derived data gets copied for safety.

basket_compressed_bytes

TBranch.basket_compressed_bytes(basket_num)

The number of compressed bytes for the TBasket at basket_num, including the TKey header.

The number of compressed bytes is specified in the TBranch metadata and can be determined without reading any additional data. The uncompressed bytes requires reading the TBasket’s TKey at least.

basket_uncompressed_bytes

TBranch.basket_uncompressed_bytes(basket_num)

The number of uncompressed bytes for the TBasket at basket_num, including the TKey header.

The number of uncompressed bytes cannot be determined without reading a TKey, which are small, but may be slow for remote connections because of the latency of round-trip requests.

basket_key

TBranch.basket_key(basket_num)

The TKey (uproot.reading.ReadOnlyKey) for the TBasket at basket_num.

Only applies to normal (free) TBaskets, not embedded_baskets.

embedded_baskets

TBranch.embedded_baskets

The TBaskets that are embedded within the TBranch metadata, usually because the ROOT process that was writing the file closed unexpectedly.

entries_to_ranges_or_baskets

TBranch.entries_to_ranges_or_baskets(entry_start, entry_stop)

Returns a list of (start, stop) integer pairs for free (normal) TBaskets and uproot.models.TBasket.Model_TBasket objects for embedded TBaskets.

The intention is for this list to be updated in place, replacing (start, stop) integer pairs with uproot.models.TBasket.Model_TBasket objects as they get read and interpreted.

postprocess

TBranch.postprocess(chunk, cursor, context, file)

debug

TBranch.debug(entry, skip_bytes=None, limit_bytes=None, dtype=None, offset=0, stream=<_io.TextIOWrapper name='<stdout>' mode='w' encoding='UTF-8'>)
Parameters
  • entry (int) – Entry number to inspect. Note: this debugging routine is not applicable to data without entry offsets (nor would it be needed).

  • skip_bytes (int) – Number of bytes to skip before presenting the remainder of the entry. May be negative, to examine the byte stream before the entry.

  • limit_bytes (None or int) – Number of bytes to limit the output to. A line of debugging output (without any offset) is 20 bytes, so multiples of 20 show full lines. If None, everything is shown to the end of the entry, which might be large.

  • dtype (None, numpy.dtype, or its constructor argument) – If None, present only the bytes as decimal values (0-255). Otherwise, also interpret them as an array of a given NumPy type.

  • offset (int) – Number of bytes to skip before interpreting a dtype; can be helpful if the numerical values are out of phase with the first byte shown. Not to be confused with skip_bytes, which determines which bytes are shown at all. Any offset values that are equivalent modulo dtype.itemsize show equivalent interpretations.

  • stream (object with a write(str) method) – Stream to write the debugging output to.

Presents the data for one entry as raw bytes.

Example output with dtype=">f4" and offset=3.

--+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+-
123 123 123  63 140 204 205  64  12 204 205  64  83  51  51  64 140 204 205  64
  {   {   {   ? --- --- ---   @ --- --- ---   @   S   3   3   @ --- --- ---   @
                        1.1             2.2             3.3             4.4
    --+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+-
    176   0   0  64 211  51  51  64 246 102 102  65  12 204 205  65  30 102 102  66
    --- --- ---   @ ---   3   3   @ ---   f   f   A --- --- ---   A ---   f   f   B
            5.5             6.6             7.7             8.8             9.9
    --+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+-
    202   0   0  67  74   0   0  67 151 128   0 123 123
    --- --- ---   C   J --- ---   C --- --- ---   {   {
          101.0           202.0           303.0

debug_array

TBranch.debug_array(entry, skip_bytes=0, dtype=dtype('uint8'))
Parameters
  • entry (int) – Entry number to inspect. Note: this debugging routine is not applicable to data without entry offsets (nor would it be needed).

  • skip_bytes (int) – Number of bytes to skip before presenting the remainder of the entry. May be negative, to examine the byte stream before the entry.

  • dtype (numpy.dtype or its constructor argument) – Data type in which to interpret the data. (The size of the array returned is truncated to this dtype.itemsize.)

Like debug, but returns a NumPy array for further inspection.

branches

Inherited from uproot.behaviors.TBranch.HasBranches.

TBranch.branches

The list of uproot.TBranch directly under this uproot.TTree or uproot.TBranch (i.e. not recursive).

show

Inherited from uproot.behaviors.TBranch.HasBranches.

TBranch.show(filter_name=<function no_filter>, filter_typename=<function no_filter>, filter_branch=<function no_filter>, recursive=True, full_paths=True, name_width=20, typename_width=24, interpretation_width=30, stream=<_io.TextIOWrapper name='<stdout>' mode='w' encoding='UTF-8'>)
Parameters
  • filter_name (None, glob string, regex string in "/pattern/i" syntax, function of str → bool, or iterable of the above) – A filter to select TBranches by name.

  • filter_typename (None, glob string, regex string in "/pattern/i" syntax, function of str → bool, or iterable of the above) – A filter to select TBranches by type.

  • filter_branch (None or function of uproot.TBranch → bool, uproot.interpretation.Interpretation, or None) – A filter to select TBranches using the full uproot.TBranch object. The TBranch is included if the function returns True, excluded if it returns False.

  • recursive (bool) – If True, recursively descend into the branches’ branches.

  • full_paths (bool) – If True, include the full path to each subbranch with slashes (/); otherwise, use the descendant’s name as the display name.

  • name_width (int) – Number of characters to reserve for the TBranch names.

  • typename_width (int) – Number of characters to reserve for the C++ typenames.

  • interpretation_width (int) – Number of characters to reserve for the uproot.interpretation.Interpretation displays.

  • stream (object with a write(str) method) – Stream to write the output to.

Interactively display the TBranches.

For example,

name                 | typename             | interpretation
---------------------+----------------------+-----------------------------------
event_number         | int32_t              | AsDtype('>i4')
trigger_isomu24      | bool                 | AsDtype('bool')
eventweight          | float                | AsDtype('>f4')
MET                  | TVector2             | AsStridedObjects(Model_TVector2_v3
jetp4                | std::vector<TLorentz | AsJagged(AsStridedObjects(Model_TL
jetbtag              | std::vector<float>   | AsJagged(AsDtype('>f4'), header_by
jetid                | std::vector<bool>    | AsJagged(AsDtype('bool'), header_b

arrays

Inherited from uproot.behaviors.TBranch.HasBranches.

TBranch.arrays(expressions=None, cut=None, filter_name=<function no_filter>, filter_typename=<function no_filter>, filter_branch=<function no_filter>, aliases=None, language=uproot.language.python.PythonLanguage(), entry_start=None, entry_stop=None, decompression_executor=None, interpretation_executor=None, array_cache='inherit', library='ak', how=None)
Parameters
  • expressions (None, str, or list of str) – Names of TBranches or aliases to convert to arrays or mathematical expressions of them. Uses the language to evaluate. If None, all TBranches selected by the filters are included.

  • cut (None or str) – If not None, this expression filters all of the expressions.

  • filter_name (None, glob string, regex string in "/pattern/i" syntax, function of str → bool, or iterable of the above) – A filter to select TBranches by name.

  • filter_typename (None, glob string, regex string in "/pattern/i" syntax, function of str → bool, or iterable of the above) – A filter to select TBranches by type.

  • filter_branch (None or function of uproot.TBranch → bool, uproot.interpretation.Interpretation, or None) – A filter to select TBranches using the full uproot.TBranch object. If the function returns False or None, the TBranch is excluded; if the function returns True, it is included with its standard interpretation; if an uproot.interpretation.Interpretation, this interpretation overrules the standard one.

  • aliases (None or dict of str → str) – Mathematical expressions that can be used in expressions or other aliases (without cycles). Uses the language engine to evaluate. If None, only the aliases are available.

  • language (uproot.language.Language) – Language used to interpret the expressions and aliases.

  • entry_start (None or int) – The first entry to include. If None, start at zero. If negative, count from the end, like a Python slice.

  • entry_stop (None or int) – The first entry to exclude (i.e. one greater than the last entry to include). If None, stop at num_entries. If negative, count from the end, like a Python slice.

  • decompression_executor (None or Executor with a submit method) – The executor that is used to decompress TBaskets; if None, the file’s decompression_executor is used.

  • interpretation_executor (None or Executor with a submit method) – The executor that is used to interpret uncompressed TBasket data as arrays; if None, the file’s interpretation_executor is used.

  • array_cache ("inherit", None, MutableMapping, or memory size) – Cache of arrays; if “inherit”, use the file’s cache; if None, do not use a cache; if a memory size, create a new cache of this size.

  • library (str or uproot.interpretation.library.Library) – The library that is used to represent arrays. Options are "np" for NumPy, "ak" for Awkward Array, and "pd" for Pandas.

  • how (None, str, or container type) – Library-dependent instructions for grouping. The only recognized container types are tuple, list, and dict. Note that the container type itself must be passed as how, not an instance of that type (i.e. how=tuple, not how=()).

Returns a group of arrays from the TTree.

For example:

>>> my_tree["x"].array()
<Array [-41.2, 35.1, 35.1, ... 32.4, 32.5] type='2304 * float64'>
>>> my_tree["y"].array()
<Array [17.4, -16.6, -16.6, ... 1.2, 1.2, 1.2] type='2304 * float64'>

See also array to read a single TBranch as an array.

See also iterate to iterate over the array in contiguous ranges of entries.

iterate

Inherited from uproot.behaviors.TBranch.HasBranches.

TBranch.iterate(expressions=None, cut=None, filter_name=<function no_filter>, filter_typename=<function no_filter>, filter_branch=<function no_filter>, aliases=None, language=uproot.language.python.PythonLanguage(), entry_start=None, entry_stop=None, step_size='100 MB', decompression_executor=None, interpretation_executor=None, library='ak', how=None, report=False)
Parameters
  • expressions (None, str, or list of str) – Names of TBranches or aliases to convert to arrays or mathematical expressions of them. Uses the language to evaluate. If None, all TBranches selected by the filters are included.

  • cut (None or str) – If not None, this expression filters all of the expressions.

  • filter_name (None, glob string, regex string in "/pattern/i" syntax, function of str → bool, or iterable of the above) – A filter to select TBranches by name.

  • filter_typename (None, glob string, regex string in "/pattern/i" syntax, function of str → bool, or iterable of the above) – A filter to select TBranches by type.

  • filter_branch (None or function of uproot.TBranch → bool, uproot.interpretation.Interpretation, or None) – A filter to select TBranches using the full uproot.TBranch object. If the function returns False or None, the TBranch is excluded; if the function returns True, it is included with its standard interpretation; if an uproot.interpretation.Interpretation, this interpretation overrules the standard one.

  • aliases (None or dict of str → str) – Mathematical expressions that can be used in expressions or other aliases (without cycles). Uses the language engine to evaluate. If None, only the aliases are available.

  • language (uproot.language.Language) – Language used to interpret the expressions and aliases.

  • entry_start (None or int) – The first entry to include. If None, start at zero. If negative, count from the end, like a Python slice.

  • entry_stop (None or int) – The first entry to exclude (i.e. one greater than the last entry to include). If None, stop at num_entries. If negative, count from the end, like a Python slice.

  • step_size (int or str) – If an integer, the maximum number of entries to include in each iteration step; if a string, the maximum memory size to include. The string must be a number followed by a memory unit, such as “100 MB”.

  • decompression_executor (None or Executor with a submit method) – The executor that is used to decompress TBaskets; if None, the file’s decompression_executor is used.

  • interpretation_executor (None or Executor with a submit method) – The executor that is used to interpret uncompressed TBasket data as arrays; if None, the file’s interpretation_executor is used.

  • library (str or uproot.interpretation.library.Library) – The library that is used to represent arrays. Options are "np" for NumPy, "ak" for Awkward Array, and "pd" for Pandas.

  • how (None, str, or container type) – Library-dependent instructions for grouping. The only recognized container types are tuple, list, and dict. Note that the container type itself must be passed as how, not an instance of that type (i.e. how=tuple, not how=()).

  • report (bool) – If True, this generator yields (arrays, uproot.behaviors.TBranch.Report) pairs; if False, it only yields arrays. The report has data about the TFile, TTree, and global and local entry ranges.

Iterates through contiguous chunks of entries from the TTree.

For example:

>>> for array in tree.iterate(["x", "y"], step_size=100):
...     # each of the following have 100 entries
...     array["x"], array["y"]

See also arrays to read everything in a single step, without iteration.

See also uproot.iterate to iterate over many files.

keys

Inherited from uproot.behaviors.TBranch.HasBranches.

TBranch.keys(filter_name=<function no_filter>, filter_typename=<function no_filter>, filter_branch=<function no_filter>, recursive=True, full_paths=True)
Parameters
  • filter_name (None, glob string, regex string in "/pattern/i" syntax, function of str → bool, or iterable of the above) – A filter to select TBranches by name.

  • filter_typename (None, glob string, regex string in "/pattern/i" syntax, function of str → bool, or iterable of the above) – A filter to select TBranches by type.

  • filter_branch (None or function of uproot.TBranch → bool, uproot.interpretation.Interpretation, or None) – A filter to select TBranches using the full uproot.TBranch object. The TBranch is included if the function returns True, excluded if it returns False.

  • recursive (bool) – If True, descend into any nested subbranches. If False, only return the names of branches directly accessible under this object.

  • full_paths (bool) – If True, include the full path to each subbranch with slashes (/); otherwise, use the descendant’s name as the output name.

Returns the names of the subbranches as a list of strings.

values

Inherited from uproot.behaviors.TBranch.HasBranches.

TBranch.values(filter_name=<function no_filter>, filter_typename=<function no_filter>, filter_branch=<function no_filter>, recursive=True)
Parameters
  • filter_name (None, glob string, regex string in "/pattern/i" syntax, function of str → bool, or iterable of the above) – A filter to select TBranches by name.

  • filter_typename (None, glob string, regex string in "/pattern/i" syntax, function of str → bool, or iterable of the above) – A filter to select TBranches by type.

  • filter_branch (None or function of uproot.TBranch → bool, uproot.interpretation.Interpretation, or None) – A filter to select TBranches using the full uproot.TBranch object. The TBranch is included if the function returns True, excluded if it returns False.

  • recursive (bool) – If True, descend into any nested subbranches. If False, only return branches that are directly accessible under this object.

Returns the subbranches as a list of uproot.TBranch.

(Note: with recursive=False, this is the same as branches.)

items

Inherited from uproot.behaviors.TBranch.HasBranches.

TBranch.items(filter_name=<function no_filter>, filter_typename=<function no_filter>, filter_branch=<function no_filter>, recursive=True, full_paths=True)
Parameters
  • filter_name (None, glob string, regex string in "/pattern/i" syntax, function of str → bool, or iterable of the above) – A filter to select TBranches by name.

  • filter_typename (None, glob string, regex string in "/pattern/i" syntax, function of str → bool, or iterable of the above) – A filter to select TBranches by type.

  • filter_branch (None or function of uproot.TBranch → bool, uproot.interpretation.Interpretation, or None) – A filter to select TBranches using the full uproot.TBranch object. The TBranch is included if the function returns True, excluded if it returns False.

  • recursive (bool) – If True, descend into any nested subbranches. If False, only return (name, branch) pairs for branches directly accessible under this object.

  • full_paths (bool) – If True, include the full path to each subbranch with slashes (/) in the name; otherwise, use the descendant’s name as the name without modification.

Returns (name, branch) pairs of the subbranches as a list of 2-tuples of (str, uproot.TBranch).

typenames

Inherited from uproot.behaviors.TBranch.HasBranches.

TBranch.typenames(filter_name=<function no_filter>, filter_typename=<function no_filter>, filter_branch=<function no_filter>, recursive=True, full_paths=True)
Parameters
  • filter_name (None, glob string, regex string in "/pattern/i" syntax, function of str → bool, or iterable of the above) – A filter to select TBranches by name.

  • filter_typename (None, glob string, regex string in "/pattern/i" syntax, function of str → bool, or iterable of the above) – A filter to select TBranches by type.

  • filter_branch (None or function of uproot.TBranch → bool, uproot.interpretation.Interpretation, or None) – A filter to select TBranches using the full uproot.TBranch object. The TBranch is included if the function returns True, excluded if it returns False.

  • recursive (bool) – If True, descend into any nested subbranches. If False, only return (name, typename) pairs for branches directly accessible under this object.

  • full_paths (bool) – If True, include the full path to each subbranch with slashes (/) in the name; otherwise, use the descendant’s name as the name without modification.

Returns (name, typename) pairs of the subbranches as a dict of str → str.

iterkeys

Inherited from uproot.behaviors.TBranch.HasBranches.

TBranch.iterkeys(filter_name=<function no_filter>, filter_typename=<function no_filter>, filter_branch=<function no_filter>, recursive=True, full_paths=True)
Parameters
  • filter_name (None, glob string, regex string in "/pattern/i" syntax, function of str → bool, or iterable of the above) – A filter to select TBranches by name.

  • filter_typename (None, glob string, regex string in "/pattern/i" syntax, function of str → bool, or iterable of the above) – A filter to select TBranches by type.

  • filter_branch (None or function of uproot.TBranch → bool, uproot.interpretation.Interpretation, or None) – A filter to select TBranches using the full uproot.TBranch object. The TBranch is included if the function returns True, excluded if it returns False.

  • recursive (bool) – If True, descend into any nested subbranches. If False, only return the names of branches directly accessible under this object.

  • full_paths (bool) – If True, include the full path to each subbranch with slashes (/); otherwise, use the descendant’s name as the output name.

Returns the names of the subbranches as an iterator over strings.

itervalues

Inherited from uproot.behaviors.TBranch.HasBranches.

TBranch.itervalues(filter_name=<function no_filter>, filter_typename=<function no_filter>, filter_branch=<function no_filter>, recursive=True)
Parameters
  • filter_name (None, glob string, regex string in "/pattern/i" syntax, function of str → bool, or iterable of the above) – A filter to select TBranches by name.

  • filter_typename (None, glob string, regex string in "/pattern/i" syntax, function of str → bool, or iterable of the above) – A filter to select TBranches by type.

  • filter_branch (None or function of uproot.TBranch → bool, uproot.interpretation.Interpretation, or None) – A filter to select TBranches using the full uproot.TBranch object. The TBranch is included if the function returns True, excluded if it returns False.

  • recursive (bool) – If True, descend into any nested subbranches. If False, only return branches that are directly accessible under this object.

Returns the subbranches as an iterator over uproot.TBranch.

(Note: with recursive=False, this is the same as branches.)

iteritems

Inherited from uproot.behaviors.TBranch.HasBranches.

TBranch.iteritems(filter_name=<function no_filter>, filter_typename=<function no_filter>, filter_branch=<function no_filter>, recursive=True, full_paths=True)
Parameters
  • filter_name (None, glob string, regex string in "/pattern/i" syntax, function of str → bool, or iterable of the above) – A filter to select TBranches by name.

  • filter_typename (None, glob string, regex string in "/pattern/i" syntax, function of str → bool, or iterable of the above) – A filter to select TBranches by type.

  • filter_branch (None or function of uproot.TBranch → bool, uproot.interpretation.Interpretation, or None) – A filter to select TBranches using the full uproot.TBranch object. The TBranch is included if the function returns True, excluded if it returns False.

  • recursive (bool) – If True, descend into any nested subbranches. If False, only return (name, branch) pairs for branches directly accessible under this object.

  • full_paths (bool) – If True, include the full path to each subbranch with slashes (/) in the name; otherwise, use the descendant’s name as the name without modification.

Returns (name, branch) pairs of the subbranches as an iterator over 2-tuples of (str, uproot.TBranch).

itertypenames

Inherited from uproot.behaviors.TBranch.HasBranches.

TBranch.itertypenames(filter_name=<function no_filter>, filter_typename=<function no_filter>, filter_branch=<function no_filter>, recursive=True, full_paths=True)
Parameters
  • filter_name (None, glob string, regex string in "/pattern/i" syntax, function of str → bool, or iterable of the above) – A filter to select TBranches by name.

  • filter_typename (None, glob string, regex string in "/pattern/i" syntax, function of str → bool, or iterable of the above) – A filter to select TBranches by type.

  • filter_branch (None or function of uproot.TBranch → bool, uproot.interpretation.Interpretation, or None) – A filter to select TBranches using the full uproot.TBranch object. The TBranch is included if the function returns True, excluded if it returns False.

  • recursive (bool) – If True, descend into any nested subbranches. If False, only return (name, typename) pairs for branches directly accessible under this object.

  • full_paths (bool) – If True, include the full path to each subbranch with slashes (/) in the name; otherwise, use the descendant’s name as the name without modification.

Returns (name, typename) pairs of the subbranches as an iterator over 2-tuples of (str, str).

num_entries_for

Inherited from uproot.behaviors.TBranch.HasBranches.

TBranch.num_entries_for(memory_size, expressions=None, cut=None, filter_name=<function no_filter>, filter_typename=<function no_filter>, filter_branch=<function no_filter>, aliases=None, language=uproot.language.python.PythonLanguage(), entry_start=None, entry_stop=None)
Parameters
  • memory_size (int or str) – An integer is interpreted as a number of bytes and a string must be a number followed by a unit, such as “100 MB”.

  • expressions (None, str, or list of str) – Names of TBranches or aliases to convert to arrays or mathematical expressions of them. Uses the language to evaluate. If None, all TBranches selected by the filters are included.

  • cut (None or str) – If not None, this expression filters all of the expressions.

  • filter_name (None, glob string, regex string in "/pattern/i" syntax, function of str → bool, or iterable of the above) – A filter to select TBranches by name.

  • filter_typename (None, glob string, regex string in "/pattern/i" syntax, function of str → bool, or iterable of the above) – A filter to select TBranches by type.

  • filter_branch (None or function of uproot.TBranch → bool, uproot.interpretation.Interpretation, or None) – A filter to select TBranches using the full uproot.TBranch object. The TBranch is included if the function returns True, excluded if it returns False.

  • aliases (None or dict of str → str) – Mathematical expressions that can be used in expressions or other aliases (without cycles). Uses the language engine to evaluate. If None, only the aliases are available.

  • language (uproot.language.Language) – Language used to interpret the expressions and aliases.

  • entry_start (None or int) – The first entry to include. If None, start at zero. If negative, count from the end, like a Python slice.

  • entry_stop (None or int) – The first entry to exclude (i.e. one greater than the last entry to include). If None, stop at num_entries. If negative, count from the end, like a Python slice.

Returns an approximate step size as a number of entries to read a given memory_size in each step.

This method does not actually read the TBranch data or compute any expressions to arrive at its estimate. It only uses metadata from the already-loaded TTree; it only needs language to parse the expressions, not to evaluate them.

In addition, the estimate is based on compressed TBasket sizes (the amount of data that would have to be read), not uncompressed TBasket sizes (the amount of data that the final arrays would use in memory, without considering cuts).

This is the algorithm that iterate uses to convert a step_size expressed in memory units into a number of entries.

common_entry_offsets

Inherited from uproot.behaviors.TBranch.HasBranches.

TBranch.common_entry_offsets(filter_name=<function no_filter>, filter_typename=<function no_filter>, filter_branch=<function no_filter>, recursive=True)
Parameters
  • filter_name (None, glob string, regex string in "/pattern/i" syntax, function of str → bool, or iterable of the above) – A filter to select TBranches by name.

  • filter_typename (None, glob string, regex string in "/pattern/i" syntax, function of str → bool, or iterable of the above) – A filter to select TBranches by type.

  • filter_branch (None or function of uproot.TBranch → bool, uproot.interpretation.Interpretation, or None) – A filter to select TBranches using the full uproot.TBranch object. The TBranch is included if the function returns True, excluded if it returns False.

  • recursive (bool) – If True, descend into any nested subbranches. If False, only consider branches directly accessible under this object. (Only applies when branches=None.)

Returns entry offsets in which TBasket boundaries align in the specified set of branches.

If this uproot.TBranch has no subbranches, the output is identical to entry_offsets.