qa#

import pawian.qa

Handle output of the QA step performed by Pawian.

Usually, a pawianHists.root file is produced if you run Pawian in QA mode. This module contains handlers for such files.

class PawianHists(filename: str)[source]#

Bases: object

Data container for a pawianHists.root file.

Data container for a pawianHists.root file that is created by the QA step in Pawian.

import_file(filename: str) None[source]#

Set data member by importing a pawianHists.root file.

get_uproot_histogram(name: str) TH1 | TH2 | TH3 | None[source]#

Get a histogram from a pawianHists.root file.

Get an uproot histogram from the pawianHists.root file.

get_histogram_content(name: str) tuple[list, list] | None[source]#

Get an array of lower edges and an array of values for the histogram.

You can then for instance use matplotlib.pyplot.hist to plot it like so (note the bins argument!):

from pawian.qa import PawianHists
import matplotlib.pyplot as plt

hist_file = PawianHists(FILENAME)
edges, values = hist_file.get_histogram_content(HISTOGRAM_NAME)
plt.hist(edges, weights=values, bins=len(values))
draw_histogram(name: str, plot_on: Axes | None = None, **kwargs: Any) tuple[ndarray, ndarray, BarContainer][source]#

Plot a histogram in a matplotlib figure.

Parameters:
  • name – The name of the histogram in the pawianHists.root file that you want to plot.

  • plot_on – Feed a matplotlib class with a hist method, such as matplotlib.axes.Axes to draw the histogram on it.

  • kwargs – See matplotlib.pyplot.hist arguments

draw_combined_histogram(name: str, plot_on: Axes | None = None, data: bool = True, fit: bool = True, mc: bool = True, **kwargs: Any) dict[str, tuple[ndarray, ndarray, BarContainer]][source]#

Combine the three types of histograms in one plot.

Parameters:
  • name – The name of the histogram in the pawianHists.root file that you want to plot, but without the prepended Data, Fit, or MC/Mc.

  • plot_on – The axis on which to draw the histogram. If None, matplotlib will create a new figure.

  • data – Whether to draw the data histogram.

  • fit – Whether to draw the ‘fitted’ histogram.

  • mc – Whether to draw the Monte Carlo histogram.

  • kwargs – Arguments that are passed to draw_histogram().

draw_all_histograms(plot_on: Figure | None = None, legend: bool = True, **kwargs: Any) None[source]#

Draw a comparative overview of all histograms.

property histogram_names: list[str][source]#

Get a list of all histogram names in a pawianHists.root file.

property unique_histogram_names: list[str][source]#

Get a list of unique histograms from a pawianHists.root file.

Get a list of histograms in the pawianHists.root file of which the keywords Data, MC, or Fit have been removed.

property particles: list[str][source]#

Get particle names contained in the file.

property data: DataFrame[source]#

Get a DataFrame of the data intensity sample.

Get a DataFrame of the data events contained in the pawianHists.root file.

See also

fit

property fit: DataFrame[source]#

Get a DataFrame of the fit intensity sample.

Get a DataFrame of the fit intensity sample contained in the pawianHists.root file.