diff --git a/km3io/tools.py b/km3io/tools.py index 2827f82e538c94e28fede7c033bd10f3f1728de8..5cf69a138be1b7d32578d0c1adf903df36fc8d4b 100644 --- a/km3io/tools.py +++ b/km3io/tools.py @@ -302,7 +302,11 @@ def best_track(tracks, strategy="default", rec_type=None): if strategy not in options: raise ValueError("{} not in {}".format(strategy, options)) - n_events = len(tracks) + try: + n_events = len(count_nested(tracks.lik, axis=1)) + except ValueError: + n_events = 1 + if n_events > 1 and any(count_nested(tracks.lik, axis=1) == 0): raise ValueError( "'events' should not contain empty tracks. Consider applying the mask: events.n_tracks>0"