Skip to content

Commit

Permalink
Use SE scores instead of SE density (#87)
Browse files Browse the repository at this point in the history
* Use SE scores instead of SE density

Following XENONnT/straxen#1430 and XENONnT/cutax#479

* Use `sr1_leftovers` for the installation, later will change to a tagged version
  • Loading branch information
dachengx authored Sep 27, 2024
1 parent 94e5d92 commit a0b187a
Show file tree
Hide file tree
Showing 11 changed files with 25 additions and 28 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ strax_test_data
build
docs/source/reference/*
docs/source/reference/release_notes.rst
.hypothesis
8 changes: 4 additions & 4 deletions axidence/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@
PeakShadowSalted,
PeakAmbienceSalted,
PeakNearestTriggeringSalted,
PeakSEDensitySalted,
PeakSEScoreSalted,
)
from axidence import (
EventsSalted,
EventBasicsSalted,
EventShadowSalted,
EventAmbienceSalted,
EventNearestTriggeringSalted,
EventSEDensitySalted,
EventSEScoreSalted,
EventsCombine,
MainS1Trigger,
MainS2Trigger,
Expand Down Expand Up @@ -298,13 +298,13 @@ def _salt_to_context(self):
PeakShadowSalted,
PeakAmbienceSalted,
PeakNearestTriggeringSalted,
PeakSEDensitySalted,
PeakSEScoreSalted,
EventsSalted,
EventBasicsSalted,
EventShadowSalted,
EventAmbienceSalted,
EventNearestTriggeringSalted,
EventSEDensitySalted,
EventSEScoreSalted,
EventsCombine,
)
)
Expand Down
8 changes: 2 additions & 6 deletions axidence/dtypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def positioned_peak_dtype(n_channels=straxen.n_tpc_pmts):

ambience_fields = ["n_lh_before", "n_s0_before", "n_s1_before", "n_s2_before", "n_s2_near"]

se_density_fields = ["se_density"]
se_score_fields = ["se_score"]

nearest_triggering_fields = []
for direction in ["left", "right"]:
Expand All @@ -76,11 +76,7 @@ def positioned_peak_dtype(n_channels=straxen.n_tpc_pmts):
]

correlation_fields = (
shadow_fields
+ ambience_fields
+ se_density_fields
+ nearest_triggering_fields
+ peak_misc_fields
shadow_fields + ambience_fields + se_score_fields + nearest_triggering_fields + peak_misc_fields
)

event_level_fields = [
Expand Down
2 changes: 1 addition & 1 deletion axidence/plugins/isolated/isolated_s1.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class IsolatedS1(Plugin):
"peak_proximity",
"peak_shadow",
"peak_ambience",
"peak_se_density",
"peak_se_score",
"peak_nearest_triggering",
)
provides = "isolated_s1"
Expand Down
2 changes: 1 addition & 1 deletion axidence/plugins/isolated/isolated_s2.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class IsolatedS2(Plugin):
"peak_proximity",
"peak_shadow",
"peak_ambience",
"peak_se_density",
"peak_se_score",
"peak_nearest_triggering",
)
provides = "isolated_s2"
Expand Down
4 changes: 2 additions & 2 deletions axidence/plugins/pairing/events_paired.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class EventInfosPaired(Events):
)

alternative_peak_add_fields = straxen.URLConfig(
default=["se_density"],
default=["se_score"],
type=(list, tuple),
help="Fields to store also for alternative peaks",
)
Expand All @@ -83,7 +83,7 @@ def peak_fields(self):
"pdf_s2_position_shadow",
"nearest_dt_s1",
"nearest_dt_s2",
"se_density",
"se_score",
"left_dtime",
"right_dtime",
]
Expand Down
2 changes: 1 addition & 1 deletion axidence/plugins/salting/event_combine.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class EventsCombine(ExhaustPlugin):
"event_shadow_salted",
"event_ambience_salted",
"event_nearest_triggering_salted",
"event_se_density_salted",
"event_se_score_salted",
)
provides = "events_combine"
data_kind = "events_salted"
Expand Down
10 changes: 5 additions & 5 deletions axidence/plugins/salting/event_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import numpy as np
import strax
from strax import Plugin
from straxen import EventShadow, EventAmbience, EventNearestTriggering, EventSEDensity
from straxen import EventShadow, EventAmbience, EventNearestTriggering, EventSEScore

from ...utils import merge_salted_real

Expand Down Expand Up @@ -61,15 +61,15 @@ class EventNearestTriggeringSalted(EventFieldsSalted, EventNearestTriggering):
save_when = strax.SaveWhen.EXPLICIT


class EventSEDensitySalted(EventFieldsSalted, EventSEDensity):
class EventSEScoreSalted(EventFieldsSalted, EventSEScore):
__version__ = "0.0.0"
depends_on: Tuple[str, ...] = (
"event_basics_salted",
"peaks_salted",
"peak_se_density_salted",
"peak_se_score_salted",
"peak_basics",
"peak_se_density",
"peak_se_score",
)
provides = "event_se_density_salted"
provides = "event_se_score_salted"
data_kind = "events_salted"
save_when = strax.SaveWhen.EXPLICIT
10 changes: 5 additions & 5 deletions axidence/plugins/salting/peak_correlation.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import numba
import numpy as np
import strax
from straxen import PeakProximity, PeakShadow, PeakAmbience, PeakNearestTriggering, PeakSEDensity
from straxen import PeakProximity, PeakShadow, PeakAmbience, PeakNearestTriggering, PeakSEScore

from ...utils import copy_dtype

Expand Down Expand Up @@ -122,11 +122,11 @@ def compute(self, peaks_salted, peaks):
return result


class PeakSEDensitySalted(PeakSEDensity):
class PeakSEScoreSalted(PeakSEScore):
__version__ = "0.0.0"
child_plugin = True
depends_on = ("peaks_salted", "peak_basics", "peak_positions")
provides = "peak_se_density_salted"
provides = "peak_se_score_salted"
data_kind = "peaks_salted"
save_when = strax.SaveWhen.EXPLICIT

Expand All @@ -138,7 +138,7 @@ def infer_dtype(self):
return dtype

def compute(self, peaks_salted, peaks):
se_density = self.compute_se_density(peaks, peaks_salted)
se_score = self.compute_se_score(peaks, peaks_salted)
return dict(
time=peaks_salted["time"], endtime=strax.endtime(peaks_salted), se_density=se_density
time=peaks_salted["time"], endtime=strax.endtime(peaks_salted), se_score=se_score
)
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ documentation = "https://readthedocs.org/projects/axidence/"
[tool.poetry.dependencies]
python = ">=3.9,<4.0"
strax = ">=1.6.3,<=1.6.5"
straxen = ">=2.2.1,<=2.3.0"
straxen = { git = "https://github.com/XENONnT/straxen.git@sr1_leftovers"}
GOFevaluation = ">=0.1.4"

[build-system]
Expand Down
4 changes: 2 additions & 2 deletions tests/test_salting.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ def test_salting(self):
"peak_shadow_salted",
"peak_ambience_salted",
"peak_nearest_triggering_salted",
"peak_se_density_salted",
"peak_se_score_salted",
]
event_level_plugins = [
"events_salted",
"event_basics_salted",
"event_shadow_salted",
"event_ambience_salted",
"event_nearest_triggering_salted",
"event_se_density_salted",
"event_se_score_salted",
"events_combine",
"cuts_event_building_salted",
]
Expand Down

0 comments on commit a0b187a

Please sign in to comment.