Skip to content

Commit

Permalink
Set CNF as the default S2 (x, y) position-reconstruction (#1494)
Browse files Browse the repository at this point in the history
* Set CNF as the default S2 (x, y) position-reconstruction

* Hack into CMT and assign MLP maps when asked for CNF maps

* Hack more

* Fix bug
  • Loading branch information
dachengx authored Dec 16, 2024
1 parent 5704361 commit 7138149
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 7 deletions.
2 changes: 1 addition & 1 deletion straxen/analyses/posrec_comparison.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def load_corrected_positions(
alt_s1=False,
alt_s2=False,
cmt_version=None,
posrec_algos=("mlp"), # TODO: https://github.com/XENONnT/straxen/issues/1454
posrec_algos=("mlp", "cnf"), # TODO: https://github.com/XENONnT/straxen/issues/1454
):
"""Returns the corrected position for each position algorithm available, without the need to
reprocess event_basics, as the needed information is already stored in event_basics.
Expand Down
16 changes: 13 additions & 3 deletions straxen/corrections_services.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@
export, __all__ = strax.exporter()

corrections_w_file = [
"mlp_model",
"mlp_model", # there is no cnf_model because CNF is using another jax protocol
"s2_xy_map_mlp",
"s2_xy_map",
"s2_xy_map_cnf",
"s1_xyz_map_mlp",
"s1_xyz_map_cnf",
"fdc_map_mlp",
"fdc_map_cnf",
"s1_aft_xyz_map",
]

Expand Down Expand Up @@ -168,7 +170,15 @@ def _get_correction(self, run_id, correction, version):
df = self.interface.interpolate(df, when)
values.append(df.loc[df.index == when, version].values[0])
else:
df = self.interface.read_at(correction, when)
# TODO: remove this hack when fdc_map_cnf is available
if correction == "fdc_map_cnf":
df = self.interface.read_at("fdc_map_mlp", when)
elif correction == "s1_xyz_map_cnf":
df = self.interface.read_at("s1_xyz_map_mlp", when)
elif correction == "s2_xy_map_cnf":
df = self.interface.read_at("s2_xy_map_mlp", when)
else:
df = self.interface.read_at(correction, when)
if df[version].isnull().values.any():
raise CMTnanValueError(
f"For {correction} there are NaN values, this means no correction available"
Expand Down
2 changes: 1 addition & 1 deletion straxen/plugins/defaults.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Some shared defaults."""

DEFAULT_POSREC_ALGO = "mlp"
DEFAULT_POSREC_ALGO = "cnf"

HE_PREAMBLE = """High energy channels: attenuated signals of the top PMT-array\n"""

Expand Down
4 changes: 2 additions & 2 deletions tests/test_contexts.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,5 +79,5 @@ def test_cmt_versions():
)

test = unittest.TestCase()
# We should always work for one offline and the online version
test.assertTrue(len(success_for) >= 2)
# We should always work for the online version
test.assertTrue(len(success_for) >= 1)

0 comments on commit 7138149

Please sign in to comment.