util#
General producers that might be utilized in various places.
Classes:
|
Functions:
|
Build an array containing only certain fields of an input array arr, preserving behaviors. |
|
Construct a LorentzVectorArray from an input array. |
|
Construct a PtEtaPhiMLorentzVectorArray from an input array. |
|
Construct a PtEtaPhiELorentzVectorArray from an input array. |
|
Return the sum of identically-structured arrays containing Lorentz vectors. |
|
Match entries in the source array src_lv to the closest entry in the destination array dst_lvs using delta-R as a metric. |
|
Like delta_r_match, except source array src_lvs can contain more than one entry per event. |
|
Transfers all columns produced by a |
- class attach_coffea_behavior(*args, **kwargs)[source]#
Bases:
ProducerAttributes:
Methods:
call_func(events[, collections])Add coffea's NanoEvents behavior to collections.
skip_func(**kwargs)Default skip function.
update_cls_dict(cls_name, cls_dict, get_attr)- cache_instances = True#
- call_force = True#
- call_func(events, collections=None, **kwargs)#
Add coffea’s NanoEvents behavior to collections.
This might become relevant in case some of the collections have been invalidated in a potential previous step. All information on source collection names, Welcome to the coffea documentation type names, attributes to check whether the correct behavior is already attached, and fields to potentially skip is taken from
columnar_util.default_coffea_collections.However, this information is updated by collections when it is a dict. In case it is a list, its items are interpreted as names of collections defined as keys in the default collections for which the behavior should be attached.
- static update_cls_dict(cls_name, cls_dict, get_attr)#
- ak_extract_fields(arr, fields, optional_fields=None, **kwargs)[source]#
Build an array containing only certain fields of an input array arr, preserving behaviors.
- lv_xyzt(*args, **kwargs)#
Construct a LorentzVectorArray from an input array.
- lv_mass(*args, **kwargs)#
Construct a PtEtaPhiMLorentzVectorArray from an input array.
- lv_energy(*args, **kwargs)#
Construct a PtEtaPhiELorentzVectorArray from an input array.
- lv_sum(lv_arrays)[source]#
Return the sum of identically-structured arrays containing Lorentz vectors.
- delta_r_match(src_lv, dst_lvs, max_dr=None, as_index=False)[source]#
Match entries in the source array src_lv to the closest entry in the destination array dst_lvs using delta-R as a metric.
The array src_lv should contain a single entry per event and dst_lvs should be a list of possible matches.
The parameter max_dr optionally indicates the maximum possible delta-R value for a match (if the best possible match has a higher value, it is not considered a valid match).
Returns a tuple (best_match, dst_lvs_filtered), where best_match is an array containing either the best match in dst_lvs per event (if as_index is false), or the index to be applied to dst_lvs in order to obtain the best match (if as_index is true). The second tuple entry, dst_lvs_filtered, is a view of dst_lvs with the best matches removed, and can be used for subsequent matching.
- delta_r_match_multiple(src_lvs, dst_lvs, max_dr=None, as_index=False)[source]#
Like delta_r_match, except source array src_lvs can contain more than one entry per event. The matching is done sequentially for each entry in src_lvs, with previous matches being filtered from the destination array each time to prevent double counting.
- transfer_produced_columns(func, src_array, dst_array, filter_routes=None)[source]#
Transfers all columns produced by a
TaskArrayFunctionfrom a source array src_array to a destination array dst_array. Optionally, only columns produced for certain routes can be transferred by specifying filter_routes, which can be a sequence or set of route names or patterns, or a callable that receives aRoute.- Parameters:
func (TaskArrayFunction) –
TaskArrayFunctionthat produced columns in src_array.src_array (ak.Array) – Source array containing the produced columns.
dst_array (ak.Array) – Destination array to which the produced columns are transferred.
filter_routes (Sequence[str] | set[str] | Callable[[Route], bool] | None, default:
None) – Optional filter.
- Return type:
ak.Array
- Returns:
Destination array with transferred columns.