PackedSelection

class coffea.processor.PackedSelection(dtype='uint64')[source]

Bases: object

Store boolean mask vectors in a compact manner

This class can store several boolean masks (cuts, selections) and evaluate arbitrary combinations of the requirements in an CPU-efficient way

Parameters:

dtype (str) – internal bitwidth of mask vector, which governs the maximum number of boolean masks storable in this object. By default, up to 64 masks can be stored, but smaller values for the numpy.dtype may be more efficient.

Attributes Summary

names

Current list of mask names available

Methods Summary

add(name, selection)

Add a named mask

all(*names)

Shorthand for require, where all the values are True

require(**names)

Return a mask vector corresponding to specific requirements

Attributes Documentation

names

Current list of mask names available

Methods Documentation

add(name, selection)[source]

Add a named mask

Parameters:
  • name (str) – name of the mask

  • selection (numpy.ndarray) – a flat array of dtype bool. If not the first mask added, it must also have the same shape as previously added masks.

all(*names)[source]

Shorthand for require, where all the values are True

require(**names)[source]

Return a mask vector corresponding to specific requirements

Specify an exact requirement on an arbitrary subset of the masks

Parameters:

**names (kwargs) – Each argument to require specific value for, in form arg=True or arg=False.

Examples

If

>>> selection.names
['cut1', 'cut2', 'cut3']

then

>>> selection.require(cut1=True, cut2=False)
array([True, False, True, ...])

returns a boolean array where each entry passes if the corresponding entry has cut1 == True, cut2 == False, and cut3 arbitrary.