"""Architecture-neutral representation of one collider event.""" from __future__ import annotations from collections.abc import Mapping from dataclasses import dataclass from typing import Any import numpy as np from .metadata import EventMetadata @dataclass(frozen=True) class EventSample: """One event before conversion into a model-specific representation. ``objects`` is a read-only mapping of selected ROOT branch names to the event's scalar or jagged values. Keeping branch values here lets the shared feature layer consume the sample without introducing DGL or model classes into the data package. """ objects: Mapping[str, Any] label: Any global_features: np.ndarray event_index: int metadata: EventMetadata | None = None @property def branches(self) -> Mapping[str, Any]: """Alias that makes the raw branch-level representation explicit.""" return self.objects @property def event_metadata(self) -> EventMetadata: """Return the required named metadata for this event.""" if self.metadata is None: raise ValueError("sample has no named metadata") return self.metadata @property def tracking(self): """Compatibility view for callers still expecting a tracking row. New code must use :attr:`event_metadata`; this view is deliberately created only when an old caller asks for it and is never propagated by the new data pipeline. """ import numpy as np metadata = self.event_metadata return np.asarray([metadata.fold, metadata.weight], dtype=np.float32)