Skip to content

Commit

Permalink
Add get_paring_rate_correction to PeaksPaired (#61)
Browse files Browse the repository at this point in the history
* Add `get_paring_rate_correction` to `PeaksPaired`

* Debug

* Fix bug
  • Loading branch information
dachengx authored May 1, 2024
1 parent e454a8d commit 1da8ef4
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions axidence/plugins/pairing/peaks_paired.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class PeaksPaired(ExhaustPlugin, DownChunkingPlugin):
depends_on = (
"isolated_s1",
"isolated_s2",
"peaks_salted",
"events_salted",
"event_basics_salted",
"event_shadow_salted",
Expand Down Expand Up @@ -64,12 +65,6 @@ class PeaksPaired(ExhaustPlugin, DownChunkingPlugin):
help="Max bin number of 2D shadow matching",
)

isolated_s1_rate_correction = straxen.URLConfig(
default=True,
type=bool,
help="Whether correct isolated S1 rate when calculating AC rate",
)

# multiple factor in simulation, e.g. AC rate is 1/t/y,
# multiple factor is 100, then we will make 100 AC events
paring_rate_bootstrap_factor = straxen.URLConfig(
Expand Down Expand Up @@ -240,6 +235,9 @@ def simple_pairing(
drift_time,
)

def get_paring_rate_correction(self, peaks_salted):
return 1

def shadow_reference_selection(self, events_salted, s2):
"""Select the reference events for shadow matching, also return
weights."""
Expand Down Expand Up @@ -594,7 +592,7 @@ def build_arrays(

return peaks_arrays, truth_arrays

def compute(self, isolated_s1, isolated_s2, events_salted, start, end):
def compute(self, isolated_s1, isolated_s2, peaks_salted, events_salted, start, end):
for i, s in enumerate([isolated_s1, isolated_s2]):
if np.any(np.diff(s["group_number"]) < 0):
raise ValueError(f"Group number is not sorted in isolated S{i}!")
Expand All @@ -604,10 +602,7 @@ def compute(self, isolated_s1, isolated_s2, events_salted, start, end):
# main S2s in isolated S2
main_isolated_s2 = isolated_s2[s2_main_index]

if self.isolated_s1_rate_correction:
raise NotImplementedError("AC rate correction for isolated S1 is not implemented yet!")
else:
paring_rate_correction = 1
paring_rate_correction = self.get_paring_rate_correction(peaks_salted)
print(f"Isolated S1 correction factor is {paring_rate_correction:.3f}")

run_time = (end - start) / units.s
Expand Down

0 comments on commit 1da8ef4

Please sign in to comment.