Skip to content

Conversation

@FaroutYLq
Copy link
Contributor

Before you submit this PR: make sure to put all operations-related information in a wiki-note, a PR should be about code and is publicly accessible

What does the code in this PR do / what does it improve?

Previously, the matching is based on the overlap of the truth and hit. However, that window is a bit too generous, which leads to fake non-zero efficiency at low-energy (due to pile up) and fake non-unitary efficiency at high energy (due to splitting). Now we introduce functionality to reduce the window range. I think 2 ms should be a reasonable window length for this purpose.

Can you briefly describe how it works?

Can you give a minimal working example (or illustrate with a figure)?

Please include the following if applicable:

  • Add an appropriate tag to this PR
  • Update the docstring(s)
  • Update the documentation
  • Tests to check the (new) code is working as desired.
  • Does it solve one of the open issues on github?

Notes on testing

  • Until the automated tests pass, please mark the PR as a draft.

All italic comments can be removed from this template.

FaroutYLq and others added 2 commits January 2, 2026 18:18
Introduces a configurable time window (match_window_ms) around waveform maxima for matching hits and truth events in the Match plugin. Updates the plugin to restrict matching to this window if set, adds related configuration for sampling frequency, and provides a test to verify the new option's behavior.
* Use robust std estimate for hit threshold calculation

Replaces standard deviation with a robust estimate based on the central 68% (16th-84th percentiles) of the signal distribution when calculating the hit threshold. This change makes the threshold calculation more resistant to extreme values.

* Version bump

* Fix hit length calculation in DxHits plugin

Updated the calculation of 'hit["length"]' to use the number of samples in the record (right_i - left_i) instead of the waveform array size (target_end - target_start), ensuring consistency when endtime is clamped to record boundaries.

* Use exact dt for endtime calculations in plugins

Updated endtime calculations in QUALIPHIDETHzReader and NX3LikeReader to use the more precise dt_exact value instead of the integer-cast dt. Also clarified the calculation of hit length in DxHits for consistency.

* Revert changes on online readout plugin
@FaroutYLq FaroutYLq added the enhancement New feature or request label Jan 3, 2026
@FaroutYLq FaroutYLq self-assigned this Jan 3, 2026
@coveralls
Copy link

coveralls commented Jan 3, 2026

Pull Request Test Coverage Report for Build 20685140006

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 36 of 38 (94.74%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+1.1%) to 52.635%

Changes Missing Coverage Covered Lines Changed/Added Lines %
straxion/plugins/match.py 36 38 94.74%
Totals Coverage Status
Change from base Build 20669391449: 1.1%
Covered Lines: 789
Relevant Lines: 1499

💛 - Coveralls

FaroutYLq and others added 10 commits January 2, 2026 21:05
Replaces use of self.dt with self.dt_exact when calculating the chunk end time to ensure more accurate timing based on the exact data type.
Enhanced the _check_endtime_consistency function to use the sampling frequency (fs) for more accurate endtime calculation when available, with a fallback to dt and a tolerance for rounding errors. Updated test_records_data_consistency to pass fs from the context config.
Added a 60-minute timeout to the test job in the GitHub Actions pytest workflow to prevent jobs from running indefinitely.
Updated endtime consistency checks in test_baseline_monitor.py and test_records.py to use dt_exact calculated from sampling frequency (fs) and SECOND_TO_NANOSECOND, ensuring accurate endtime computation in tests.
Introduces a new config option for specifying the template interpolation file path and updates the Match plugin to use an interpolated template for accurate pulse maximum alignment. The calculation of the pulse template argmax is now based on the interpolated template, improving matching precision for different sampling frequencies.
Updated the __version__ attribute of the Match plugin from 0.0.3 to 0.0.4.
Replaces the previous approximation of hit maximum times with a calculation that finds the actual maximum position in each hit's waveform, accounting for waveform padding. This increases the accuracy of hit timing in the plugin.
@FaroutYLq FaroutYLq marked this pull request as ready for review January 4, 2026 00:17
@cursor
Copy link

cursor bot commented Jan 4, 2026

You have run out of free Bugbot PR reviews for this billing cycle. This will reset on February 16.

To receive reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.

Introduces a .cursorrules file outlining mandatory usage of the 'straxion' conda environment for all Python commands and scripts. Provides examples and rationale to prevent dependency issues.
Introduces a new TestMatchRestrictWindow class with comprehensive unit tests for the _restrict_to_maximum_window method in the Match plugin. Tests cover window restriction logic for both hits and truth data, including cases with and without waveform padding, boundary conditions, and behavior with different sampling frequencies.
@FaroutYLq FaroutYLq merged commit aff1ed4 into main Jan 4, 2026
4 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants