From facde97f9188190f3ccb595e4f84428f6f1be501 Mon Sep 17 00:00:00 2001 From: Luigi Pertoldi Date: Thu, 18 Apr 2024 18:21:19 +0200 Subject: [PATCH] [evt.modules] add xtalk corrector placeholder --- src/pygama/evt/modules/geds.py | 46 ++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 src/pygama/evt/modules/geds.py diff --git a/src/pygama/evt/modules/geds.py b/src/pygama/evt/modules/geds.py new file mode 100644 index 000000000..a655eb56f --- /dev/null +++ b/src/pygama/evt/modules/geds.py @@ -0,0 +1,46 @@ +"""Event processors for HPGe data.""" + +from __future__ import annotations + +from collections.abc import Sequence + +from lgdo import lh5, types + +from .. import utils + + +def apply_xtalk_correction( + datainfo: utils.DataInfo, + tcm: utils.TCMData, + table_names: Sequence[str], + *, + energy_observable: types.VectorOfVectors, + rawids: types.VectorOfVectors, + xtalk_matrix_filename: str, +) -> types.VectorOfVectors: + """Applies the cross-talk correction to the energy observable. + + The format of `xtalk_matrix_filename` should be... + + Parameters + ---------- + datainfo, tcm, table_names + positional arguments automatically supplied by :func:`.build_evt`. + energy_observable + array of energy values to correct, one event per row. The detector + identifier is stored in `rawids`, which has the same layout. + rawids + array of detector identifiers for each energy in `energy_observable`. + xtalk_matrix_filename + name of the file containing the cross-talk matrices. + """ + # read in xtalk matrices + lh5.read_as("", xtalk_matrix_filename, "ak") + + # do the correction + energies_corr = ... + + # return the result as LGDO + return types.VectorOfVectors( + energies_corr, attrs=utils.copy_lgdo_attrs(energy_observable) + )