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: Path | str)[source]#
Bases:
objectData container for a
pawianHists.rootfile.Data container for a
pawianHists.rootfile that is created by the QA step in Pawian.- import_file(filename: Path | str) None[source]#
Set data member by importing a
pawianHists.rootfile.
- get_uproot_histogram(name: str) TH1 | TH2 | TH3 | None[source]#
Get a histogram from a
pawianHists.rootfile.Get an
uproothistogram from thepawianHists.rootfile.
- 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.histto plot it like so (note thebinsargument!):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.rootfile that you want to plot.plot_on – Feed a matplotlib class with a hist method, such as
matplotlib.axes.Axesto draw the histogram on it.kwargs – See
matplotlib.pyplot.histarguments
- 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.rootfile that you want to plot, but without the prependedData,Fit, orMC/Mc.plot_on – The axis on which to draw the histogram. If
None,matplotlibwill 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.
See also
- property histogram_names: list[str][source]#
Get a list of all histogram names in a
pawianHists.rootfile.
- property unique_histogram_names: list[str][source]#
Get a list of unique histograms from a
pawianHists.rootfile.Get a list of histograms in the
pawianHists.rootfile of which the keywordsData,MC, orFithave been removed.