Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement naive S1 Z correction #320

Merged
merged 1 commit into from
Oct 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 21 additions & 2 deletions amstrax/plugins/events/corrected_areas.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@
default=30000,
help="electron lifetime in [ns] (should be implemented in db soon)",
),
strax.Option(
"s1_naive_z_correction",
default=[-52, 0, 700, -7.69],
help="Parameters for the z-dependent S1 correction \
[zmin, zmax, y0, a] where y0 + a*z is the correction",
)
)
class CorrectedAreas(strax.Plugin):
"""Plugin which applies light collection efficiency maps and electron life time to the data.
Expand All @@ -28,7 +34,7 @@ class CorrectedAreas(strax.Plugin):

"""

__version__ = "0.5.1"
__version__ = "0.6.0"

depends_on = ("event_basics", "event_positions")

Expand All @@ -48,6 +54,19 @@ def infer_dtype(self):
return dtype


def s1_naive_z_correction(self, z):
"""
Apply a naive z-dependent S1 correction.
Returns the correction factor for the S1 area.
"""

s1_correction_function = lambda z: y0 + a * z
zmin, zmax, y0, a = self.config["s1_naive_z_correction"]
s1_correction_average = s1_correction_function((zmin + zmax) / 2)
correction = s1_correction_average/s1_correction_function(z)

return correction

def compute(self, events):
result = np.zeros(len(events), self.dtype)
result["time"] = events["time"]
Expand All @@ -62,7 +81,7 @@ def compute(self, events):

for peak_type in ["", "alt_"]:

result[f"{peak_type}cs1"] = events[f"{peak_type}s1_area"]
result[f"{peak_type}cs1"] = events[f"{peak_type}s1_area"]*self.s1_naive_z_correction(events["z"])
result[f"{peak_type}cs2"] = events[f"{peak_type}s2_area"]*np.exp(events["drift_time"]/elife)

return result
Loading