Skip to content

Commit

Permalink
implement correction (#320)
Browse files Browse the repository at this point in the history
  • Loading branch information
cfuselli authored Oct 24, 2024
1 parent d4ba209 commit 5cf0c22
Showing 1 changed file with 21 additions and 2 deletions.
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

0 comments on commit 5cf0c22

Please sign in to comment.