e15190.utilities.root6

A list of convenient functions to interact with PyROOT6.

A version of ROOT 6.20 or above is assumed.

Functions

get_all_branches(path, tree)

get_n_entries(path, tree)

histo_conversion(histo, *args, **kwargs)

Automatically convert 1D or 2D ROOT histograms to pandas.DataFrame.

infer_tree_name(path)

param path

Path(s) to the ROOT file(s) of interest.

Classes

HistogramConversion()

RandomName()

TFile(path[, mode])

e15190.utilities.root6.histo_conversion(histo, *args, **kwargs)

Automatically convert 1D or 2D ROOT histograms to pandas.DataFrame.

Parameters
  • histo (ROOT.TH1 or ROOT.TH2 or ROOT.RDF.RResultPtr) – ROOT histogram to be converted.

  • xname (str, optional) – Name of the x-axis, by default ‘x’.

  • yname (str, optional) – Name of the y-axis, by default ‘y’.

  • zname (str, optional) – Name of the z-axis, by default ‘z’. Only used for 2D histograms.

  • keep_zeros (bool, default True) – Whether to keep bins with zero content, i.e. z = 0, by default True. Only used for 2D histograms.

  • ignore_errors (bool, default False) – Whether to ignore errors. Only used for 2D histograms.

Returns

histo – Converted histogram.

Return type

pandas.DataFrame

e15190.utilities.root6.infer_tree_name(path: str | pathlib.Path | Sequence[str | pathlib.Path]) → str
Parameters

path (str or pathlib.Path, or sequence of str or pathlib.Path) – Path(s) to the ROOT file(s) of interest.

Returns

tree_name – Name of the tree.

Return type

str

Raises

ValueError – One of the following causes: - No tree name found in the given path(s). - Paths contain different tree names. - Cannot infer tree name from the given path(s), e.g. no ROOT file found, multiple trees, etc.