Weights

class coffea.processor.Weights(size, storeIndividual=False)[source]

Bases: object

Container for event weights and associated systematic shifts

This container keeps track of correction factors and systematic effects that can be encoded as multiplicative modifiers to the event weight. All weights are stored in vector form.

Parameters:
  • size (int) – size of the weight arrays to be handled (i.e. the number of events / instances).

  • storeIndividual (bool, optional) – store not only the total weight + variations, but also each individual weight. Default is false.

Attributes Summary

variations

List of available modifiers

Methods Summary

add(name, weight[, weightUp, weightDown, shift])

Add a new weight

partial_weight([include, exclude])

Partial event weight vector

weight([modifier])

Current event weight vector

Attributes Documentation

variations

List of available modifiers

Methods Documentation

add(name, weight, weightUp=None, weightDown=None, shift=False)[source]

Add a new weight

Adds a named correction to the event weight, and optionally also associated systematic uncertainties.

Parameters:
  • name (str) – name of correction

  • weight (numpy.ndarray) – the nominal event weight associated with the correction

  • weightUp (numpy.ndarray, optional) – weight with correction uncertainty shifted up (if available)

  • weightDown (numpy.ndarray, optional) – weight with correction uncertainty shifted down. If weightUp is supplied, and the correction uncertainty is symmetric, this can be set to None to auto-calculate the down shift as 1 / weightUp.

  • shift (bool, optional) – if True, interpret weightUp and weightDown as a realtive difference (additive) to the nominal value

Note

weightUp and weightDown are assumed to be rvalue-like and may be modified in-place by this function

partial_weight(include=[], exclude=[])[source]

Partial event weight vector

Return a partial weight by multiplying a subset of all weights. Can be operated either by specifying weights to include or weights to exclude, but not both at the same time. The method can only be used if the individual weights are stored via the storeIndividual argument in the Weights initializer.

Parameters:
  • include (list) – Weight names to include, defaults to []

  • exclude (list) – Weight names to exclude, defaults to []

Returns:

weight – The weight vector, corresponding to only the effect of the corrections specified.

Return type:

numpy.ndarray

weight(modifier=None)[source]

Current event weight vector

Parameters:

modifier (str, optional) – if supplied, provide event weight corresponding to a particular systematic uncertainty shift, of form str(name + 'Up') or (Down)

Returns:

weight – The weight vector, possibly modified by the effect of a given systematic variation.

Return type:

numpy.ndarray