cpalgnodes.selection module

Algorithm node types and utilities for dealing with selections

A lot of the complexity which has to be dealt with here comes from having to deal with scale factors. Most scale factors are relatively simple in that unrelated scale factors simply combine multiplicatively. However there are some cases which complicate things:

  • Some selections also have ‘inefficiency’ scale factors: these are extra weights that must be applied whenever the associated selection fails

  • Some selections are related and only the tightest scale factor should be applied. For example, if applying a Medium muon ID before overlap removal and then a Tight muon ID after, only the tight ID should be considered in the overall scale factor

In general, the naive approach to combining similar scale factors (i.e. only take the tightest) will not apply when there are inefficiency-SFs involved and a dedicated approach must be used.

Because the maths of what we should do in these cases is not settled, if any selection in an definition provides an inefficiency scale factor, none of the other selections may be of the same type. This should be OK for now as the only place where we have inefficiency scale factors defined is for jets and there we do not usually apply multiple selections of the same type.

class cpalgnodes.selection.Definition(name: str, selections: Iterable[Selection])

Bases: Iterable[Selection], Selection

Named selection formed from the AND of multiple sub-selections

property selections

The selections in the definition

class cpalgnodes.selection.InefficiencyScaleFactorCombinationAlg(container: str, selection_name: str, input_sfs: List[Tuple[Selection | None, ScaleFactor | None]], sf_name: str | None = None, out_of_valid_name: str | None = None, **kwargs)

Bases: ScaleFactorAlg

SF combination alg that correctly deals with inefficiency scale factors

class cpalgnodes.selection.OutOfValidityAction(value)

Bases: Enum

How to respond to attempts to calculate values outside of their range of validity

ABORT = 0
SILENT = 2
WARNING = 1
class cpalgnodes.selection.ScaleFactor(sf: str, out_of_valid: str | None = None, provides_inefficiency: bool = False)

Bases: object

Information about the scale factor for a selection

class cpalgnodes.selection.ScaleFactorAlg(type: str, name: str, container_property: str, container: str, sf_name: str, sf_property: str = 'scaleFactorDecoration', out_of_validity_deco: str | None = None, out_of_validity_deco_property: str = 'outOfValidityDeco', out_of_validity_mode: OutOfValidityAction = OutOfValidityAction.SILENT, out_of_validity_mode_property: str = 'outOfValidity', priority: int = -10, provides_inefficiency=False, **kwargs)

Bases: SimpleAlgNode

Base class for algorithms which calculate scale factors

property out_of_validity_deco: str

The name of the out of validity decoration

property out_of_validity_mode: OutOfValidityAction

How to respond to values out of their range of validity

property provides_inefficiency: bool

Whether this algorithm calculates an inefficiency SF

property sf: ScaleFactor

Get the scale factor information for this algorithm

property sf_name: str

Get the scale factor decoration set by this algorithm

class cpalgnodes.selection.Selection(name: str, count: int | None = None, previous: Iterable[str] | None = None)

Bases: object

Single selection

property count: int | None

The number of bits in the selection, None if the selection is a simple char

property name: str

The name of the selection

property previous: Tuple[str]

Any selections implicit in this

property selection_prop_value: str

The value to set on a property

class cpalgnodes.selection.SelectionAlgNode(name: str, container: str, selection_name: str, selection_count: int | None = None, priority: int = 10, selection_property='selectionDecoration', type: str = 'CP::AsgSelectionAlg', container_property: str = 'particles', **kwargs)

Bases: SimpleAlgNode

Base class for nodes which define a single selection on a single container

property selection: Selection

The selection defined by this algorithm

property selection_count

The number of bits in the selection, None if the selection is char

property selection_name
class cpalgnodes.selection.SimpleScaleFactorCombinationAlg(container: str, selection_name: str, input_sfs: List[ScaleFactor], sf_name: str | None = None, out_of_valid_name: str | None = None, **kwargs)

Bases: ScaleFactorAlg

Algorithm to combine scale factors for selections which have no inefficiency scale factors