Weights#
- class coffea.analysis_tools.Weights(size, storeIndividual=False)[source]#
Bases:
objectContainer 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:
Attributes Summary
List of available modifiers
Statistics about the weight, including the sum of squared weights and number of entries.
Methods Summary
add(name, weight[, weightUp, weightDown, shift])Add a new weight
add_multivariation(name, weight, ...[, shift])Add a new weight with multiple variations
partial_weight([include, exclude, modifier])Partial event weight vector
weight([modifier])Returns the current event weight vector
Attributes Documentation
- variations#
List of available modifiers
- weightStatistics#
Statistics about the weight, including the sum of squared weights and number of entries.
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 correctionweight (
numpy.ndarray) – the nominal event weight associated with the correctionweightUp (
numpy.ndarray, optional) – weight with correction uncertainty shifted up (if available)weightDown (
numpy.ndarray, optional) – weight with correction uncertainty shifted down. IfweightUpis supplied, and the correction uncertainty is symmetric, this can be set to None to auto-calculate the down shift as1 / weightUp.shift (
bool, optional) – if True, interpret weightUp and weightDown as a relative difference (additive) to the nominal value
Note
weightUpandweightDownare assumed to be rvalue-like and may be modified in-place by this function
- add_multivariation(name, weight, modifierNames, weightsUp, weightsDown, shift=False)[source]#
Add a new weight with multiple variations
Each variation of a single weight is given a different modifier name. This is particularly useful e.g. for btag SF variations.
- Parameters:
name (
str) – name of correctionweight (
numpy.ndarray) – the nominal event weight associated with the correctionmodifierNames (
listofstr) – list of modifiers for each set of weights variationweightsUp (
listofnumpy.ndarray) – weight with correction uncertainty shifted up (if available)weightsDown (
listofnumpy.ndarray) – weight with correction uncertainty shifted down. IfweightUpis supplied, and the correction uncertainty is symmetric, this can be set to None to auto-calculate the down shift as1 / weightUp.shift (
bool, optional) – if True, interpret weightUp and weightDown as a relative difference (additive) to the nominal value
Note
weightUpandweightDownare assumed to be rvalue-like and may be modified in-place by this function
- partial_weight(include=[], exclude=[], modifier=None)[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
storeIndividualargument in theWeightsinitializer.- Parameters:
- Returns:
weight – The weight vector, corresponding to only the effect of the corrections specified.
- Return type:
- weight(modifier=None)[source]#
Returns the current event weight vector
- Parameters:
modifier (
str, optional) – if supplied, provide event weight corresponding to a particular systematic uncertainty shift, of formstr(name + 'Up')or (Down)- Returns:
weight – The weight vector, possibly modified by the effect of a given systematic variation.
- Return type: