diff --git a/src/reboost/optmap/evt.py b/src/reboost/optmap/evt.py index 5ce27493..ca83b137 100644 --- a/src/reboost/optmap/evt.py +++ b/src/reboost/optmap/evt.py @@ -3,10 +3,8 @@ import logging from collections import OrderedDict from collections.abc import Generator, Iterable -from pathlib import Path import numpy as np -from lgdo import lh5 from lgdo.lh5 import LH5Iterator from lgdo.types import Table @@ -105,27 +103,6 @@ def _ensure_vert_df(vert_it: LH5Iterator, evtid: int) -> Generator[Table, None, assert had_last_chunk, "did not reach last chunk in optmap-evt building" -def build_optmap_evt( - lh5_in_file: str, lh5_out_file: str, detectors: Iterable[str | int], buffer_len: int = int(5e6) -) -> None: - """Create a faster map for lookup of the hits in each detector, for each primary event.""" - lh5_out_file = Path(lh5_out_file) - lh5_out_file_tmp = lh5_out_file.with_stem(".evt-tmp." + lh5_out_file.stem) - if lh5_out_file_tmp.exists(): - msg = f"temporary output file {lh5_out_file_tmp} already exists" - raise RuntimeError(msg) - - for vert_it_count, chunk in enumerate(generate_optmap_evt(lh5_in_file, detectors, buffer_len)): - log.info("store evt file %s (%d)", lh5_out_file_tmp, vert_it_count - 1) - lh5.write(Table(chunk), name=EVT_TABLE_NAME, lh5_file=lh5_out_file_tmp, wo_mode="append") - - # after finishing the output file, rename to the actual output file name. - if lh5_out_file.exists(): - msg = f"output file {lh5_out_file_tmp} already exists after writing tmp output file" - raise RuntimeError(msg) - lh5_out_file_tmp.rename(lh5_out_file) - - def get_optical_detectors_from_geom(geom_fn) -> dict[int, str]: import pyg4ometry import pygeomtools diff --git a/tests/test_optmap.py b/tests/test_optmap.py index 1d9d08f8..6eaa1e01 100644 --- a/tests/test_optmap.py +++ b/tests/test_optmap.py @@ -13,7 +13,6 @@ merge_optical_maps, rebin_optical_maps, ) -from reboost.optmap.evt import build_optmap_evt from reboost.optmap.optmap import OpticalMap @@ -53,16 +52,6 @@ def tbl_hits(tmptestdir): return (str(hit_file),) -def test_optmap_evt(tbl_hits, tmptestdir): - evt_out_file = tmptestdir / "evt-out.lh5" - build_optmap_evt( - tbl_hits[0], - str(evt_out_file), - detectors=("1", "002", "003"), - buffer_len=20, # note: shorter window sizes (e.g. 10) do not work. - ) - - @pytest.fixture def tbl_evt_fns(tmptestdir) -> tuple[str]: evt_count = 100