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

Split aqmon hits issue #1061

Closed
wants to merge 19 commits into from
Closed
Show file tree
Hide file tree
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
30 changes: 21 additions & 9 deletions straxen/plugins/acqmon_processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ class AqmonChannels(IntEnum):
@export
class AqmonHits(strax.Plugin):
"""
Find hits in acquisition monitor data. These hits could be
then used by other plugins for deadtime calculations,
Find hits in acquisition monitor data. Create hitlets to account for hits that are split.
These hitlets could be then used by other plugins for deadtime calculations,
GPS SYNC analysis, etc.
"""
save_when = strax.SaveWhen.TARGET
__version__ = '1.1.2'
__version__ = '1.1.3'
hit_min_amplitude_aqmon = straxen.URLConfig(
default=(
# Analogue signals
Expand Down Expand Up @@ -87,7 +87,11 @@ class AqmonHits(strax.Plugin):
provides = 'aqmon_hits'
data_kind = 'aqmon_hits'

dtype = strax.hit_dtype
def infer_dtype(self):
wanted_fields = ['time', 'length', 'dt', 'channel', 'area']
dtype = [dt for dt in strax.hit_dtype if dt[0][1] in wanted_fields]
return dtype


def compute(self, raw_records_aqmon):
not_allowed_channels = (set(np.unique(raw_records_aqmon['channel']))
Expand All @@ -106,7 +110,13 @@ def compute(self, raw_records_aqmon):
strax.baseline(records, baseline_samples=self.baseline_samples_aqmon, flip=True)
aqmon_hits = self.find_aqmon_hits_per_channel(records)
aqmon_hits = strax.sort_by_time(aqmon_hits)
return aqmon_hits

# in busy runs veto starts get split at chunk edges into two. we introduce hitlets:
aqmon_hitlets = strax.create_hitlets_from_hits(aqmon_hits, (0,0), [0, 1000])
to_pe = np.ones(808) # stay in ADC units: these are NIM signals
aqmon_hitlets = strax.get_hitlets_data(aqmon_hitlets, records, to_pe=to_pe)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is where the current tests are failing. It should actually work like this. When strax.get_hitlets_data is called it lastly complains at https://github.com/AxFoundation/strax/blob/156254287c2037876a7040460b3551d590bf5589/strax/processing/hitlets.py#L214 . My hunch is that we pass something that look's a little different to what https://github.com/AxFoundation/strax/blob/156254287c2037876a7040460b3551d590bf5589/strax/processing/hitlets.py#L222 usually sees and the cached compiled function doesn't like it and seg faults. Any idea on how to fix this? If we delete the cache, we might have the same problem the other way around, no? Maybe we find out what's the difference it doesn't like and provide what it likes.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're back to this issue now:

[...]

Fatal Python error: Segmentation fault
Current thread 0x00007fd8cd53f700 (most recent call first):
File "/opt/hostedtoolcache/Python/3.8.13/x64/lib/python3.8/site-packages/strax/processing/hitlets.py", line 214 in get_hitlets_data
File "/home/runner/work///***/plugins/acqmon_processing.py", line 117 in compute
File "/opt/hostedtoolcache/Python/3.8.13/x64/lib/python3.8/site-packages/strax/plugin.py", line 596 in do_compute
File "/opt/hostedtoolcache/Python/3.8.13/x64/lib/python3.8/site-packages/strax/plugin.py", line 488 in iter
File "/opt/hostedtoolcache/Python/3.8.13/x64/lib/python3.8/site-packages/strax/mailbox.py", line 281 in _send_from
File "/opt/hostedtoolcache/Python/3.8.13/x64/lib/python3.8/threading.py", line 870 in run
File "/opt/hostedtoolcache/Python/3.8.13/x64/lib/python3.8/threading.py", line 932 in _bootstrap_inner
File "/opt/hostedtoolcache/Python/3.8.13/x64/lib/python3.8/threading.py", line 890 in _bootstrap

[...]

/home/runner/work/_temp/a65694df-fcc9-4870-821e-663ce8843c36.sh: line 1: 2489 Segmentation fault (core dumped) coverage run --source=*** -m pytest --durations 0
tests/test_daq_reader.py
Error: Process completed with exit code 139.


return aqmon_hitlets[list(self.dtype.names)]

@property
def aqmon_channels(self):
Expand All @@ -126,7 +136,8 @@ def find_aqmon_hits_per_channel(self, records):

if np.sum(is_artificial):
aqmon_hits = np.concatenate([
aqmon_hits, self.get_deadtime_hits(records[is_artificial])])
aqmon_hits[list(self.dtype.names)],
self.get_deadtime_hits(records[is_artificial])])
return aqmon_hits

def get_deadtime_hits(self, artificial_deadtime):
Expand Down Expand Up @@ -294,9 +305,10 @@ def handle_starts_and_stops_outside_of_run(

return veto_hits_start, veto_hits_stop

@staticmethod
def fake_hit(start, dt=1, length=1):
hit = np.zeros(1, strax.hit_dtype)

def fake_hit(self, start, dt=1, length=1):
aqmon_hit_dtype = strax.unpack_dtype(self.deps['aqmon_hits'].dtype_for('aqmon_hits'))
hit = np.zeros(1, aqmon_hit_dtype)
hit['time'] = start
hit['dt'] = dt
hit['length'] = length
Expand Down
5 changes: 4 additions & 1 deletion tests/test_aqmon.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ class DummyAqmonHits(strax.Plugin):
depends_on = ()
parallel = False
provides = straxen.AqmonHits.provides
dtype = straxen.AqmonHits.dtype
save_when = strax.SaveWhen.NEVER

# Keep track for we need this from plugin to plugin
Expand All @@ -67,6 +66,10 @@ def source_finished(self):
def is_ready(self, chunk_i):
return chunk_i < len(self.vetos_per_chunk)

def infer_dtype(self):
hit_class = straxen.AqmonHits()
return hit_class.infer_dtype()

def compute(self, chunk_i):
if chunk_i == 0:
self._last_channel_was_off = self.start_with_channel_on
Expand Down