Cutflow
- class coffea.analysis_tools.Cutflow(names, nevonecut, nevcutflow, masksonecut, maskscutflow, delayed_mode)[source]
Bases:
object
Object to be returned by PackedSelection.cutflow()
Methods Summary
plot_vars
(vars[, axes, bins, start, stop, ...])Plot the histograms of variables for each step of the N-1 selection
print
()Prints the statistics of the Cutflow
result
()Returns the results of the cutflow as a namedtuple
to_npz
(file[, compressed, compute])Saves the results of the cutflow to a .npz file
Returns the cutflow yields as
hist.Hist
objectsMethods Documentation
- plot_vars(vars, axes=None, bins=None, start=None, stop=None, edges=None, transform=None)[source]
Plot the histograms of variables for each step of the N-1 selection
- Parameters:
vars (dict) – A dictionary in the form
{name: array}
wherename
is the name of the variable, andarray
is the corresponding array of values. The arrays must be the same length as each mask of the cutflow.axes (list of hist.axis objects, optional) – The axes objects to histogram the variables on. This will override all the following arguments that define axes. Must be the same length as
vars
.bins (iterable of integers or Nones, optional) – The number of bins for each variable histogram. If not specified, it defaults to 20. Must be the same length as
vars
.start (iterable of floats or integers or Nones, optional) – The lower edge of the first bin for each variable histogram. If not specified, it defaults to the minimum value of the variable array. Must be the same length as
vars
.stop (iterable of floats or integers or Nones, optional) – The upper edge of the last bin for each variable histogram. If not specified, it defaults to the maximum value of the variable array. Must be the same length as
vars
.edges (list of iterables of floats or integers, optional) – The bin edges for each variable histogram. This overrides
bins
,start
, andstop
if specified. Must be the same length asvars
.transform (iterable of hist.axis.transform objects or Nones, optional) – The transforms to apply to each variable histogram axis. If not specified, it defaults to None. Must be the same length as
vars
.
- Returns:
histsonecut (list of hist.Hist or hist.dask.Hist objects) – A list of 1D histograms of the variables of events surviving each cut alone. The first axis is the variable, the second axis is the cuts.
histscutflow (list of hist.Hist or hist.dask.Hist objects) – A list of 1D histograms of the variables of events surviving the cumulative cutflow. The first axis is the variable, the second axis is the cuts.
labels (list of strings) – The bin labels of the y axis of the histograms.
- result()[source]
Returns the results of the cutflow as a namedtuple
- Returns:
result – A namedtuple with the following attributes:
- nevonecutlist of integers or dask_awkward.lib.core.Scalar objects
The number of events that survive each cut alone as a list of integers or delayed integers
- nevcutflowlist of integers or dask_awkward.lib.core.Scalar objects
The number of events that survive the cumulative cutflow as a list of integers or delayed integers
- masksonecutlist of boolean numpy.ndarray or dask_awkward.lib.core.Array objects
The boolean mask vectors of which events pass each cut alone as a list of materialized or delayed boolean arrays
- maskscutflowlist of boolean numpy.ndarray or dask_awkward.lib.core.Array objects
The boolean mask vectors of which events pass the cumulative cutflow a list of materialized or delayed boolean arrays
- Return type:
CutflowResult
- to_npz(file, compressed=False, compute=False)[source]
Saves the results of the cutflow to a .npz file
- Parameters:
file (str or file) – Either the filename (string) or an open file (file-like object) where the data will be saved. If file is a string or a Path, the
.npz
extension will be appended to the filename if it is not already there.compressed (bool, optional) – If True, the data will be compressed in the
.npz
file. Default is False.compute (bool, optional) – Whether to immediately start writing or to return an object that the user can choose when to start writing by calling compute(). Default is False.
- Returns:
out – If
compute=True
, returns None. Otherwise, returns an object that can be used to start writing the data by calling compute().- Return type:
CutflowToNpz or None
- yieldhist()[source]
Returns the cutflow yields as
hist.Hist
objects- Returns:
honecut (hist.Hist or hist.dask.Hist) – Histogram of the number of events surviving each cut alone
hcutflow (hist.Hist or hist.dask.Hist) – Histogram of the number of events surviving the cumulative cutflow
labels (list of strings) – The bin labels of the histograms