atompy.load_1d_from_root#

atompy.load_1d_from_root(fname, hname, output_format='ndarray')[source]#

Import a 1d histogram from a ROOT file.

Parameters:
fnamestr

The filename of the ROOT file, e.g., important_data.root

hnamestr

The name of the histogram within the ROOT file, e.g., path/to/histogram1d.

output_format{"ndarray", "Hist1d"}, default "ndarray"

Change output format. See Returns.

Returns:
outputndarray or Hist1d

Depends on output_format.

  • output_format == "ndarray": Return a NumPy ndarray. output[0] refers to the bin-centers of the loaded histogram, output[1] to the corresponding values.

  • output_format == "Hist1d": Return a Hist1d. output.centers (output.histogram) is analogous to output[0] (output[1]) of the "ndarray" output.

Examples

x, y = ap.load_root_hist1d("rootfile.root", "path/to/hist1d", output_format="ndarray")
plt.plot(x, y)

hist = ap.load_root_hist1d("rootfile.root", "path/to/hist1d", output_format="Hist1d")
plt.plot(hist.centers, hist.histogram)