Skip to content
Snippets Groups Projects
Commit 0861ae5a authored by Zineb Aly's avatar Zineb Aly
Browse files

add default best track

parent 97e65a40
No related branches found
No related tags found
No related merge requests found
......@@ -4,7 +4,7 @@ import warnings
import numba as nb
import awkward1 as ak1
from .definitions import mc_header, fitparameters
from .definitions import mc_header, fitparameters, reconstruction
from .tools import cached_property, to_num, unfold_indices
from .rootio import Branch, BranchMapper
......@@ -21,6 +21,18 @@ def _nested_mapper(key):
return '_'.join(key.split('.')[1:])
def rec_types():
"""name of the reconstruction type as defined in the official
KM3NeT-Dataformat.
Returns
-------
dict_keys
reconstruction types.
"""
return reconstruction.keys()
def fitinf(fitparam, tracks):
"""Access fit parameters in tracks.fitinf.
......@@ -140,7 +152,7 @@ def mask(rec_stages, stages):
return builder.snapshot() == 1
def best_track(tracks, strategy="first", rec_stages=None):
def best_track(tracks, strategy="first", rec_type=None, rec_stages=None):
"""best track selection based on different strategies
Parameters
......@@ -154,6 +166,9 @@ def best_track(tracks, strategy="first", rec_stages=None):
return tracks[:, 0]
if strategy == "rec_stages" and rec_stages is not None:
return tracks[mask(tracks.rec_stages, rec_stages)]
if strategy == "default" and rec_type is not None:
return tracks[tracks.rec_type == reconstruction[rec_type]][
tracks.lik == ak1.max(tracks.lik, axis=1)][:, 0]
EVENTS_MAP = BranchMapper(name="events",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment