Commit ef16fb96 authored by Vincent Michel's avatar Vincent Michel

Make statistics consistent between normal and mapping mode

That means the OCR computed by handel is discarded, since it includes
the underflows and overflows that the mapping mode ignores. The new
definition for OCR is events / realtime (= sum(spectrum) / realtime)
parent ef665316
Pipeline #1058 passed with stages
in 1 minute and 16 seconds
......@@ -20,40 +20,38 @@ def stats_from_normal_mode(array):
underflows = int(array[7])
overflows = int(array[8])
total_events = events + underflows + overflows
return make_stats(realtime, livetime, triggers, total_events, icr, ocr)
def stats_from_mapping_mode(array):
realtime = array[0] * CLOCK_TICK
livetime = array[1] * CLOCK_TICK
triggers = int(array[2])
events = int(array[3])
return make_stats(realtime, livetime, triggers, events)
def make_stats(realtime, livetime, triggers, events, icr=None, ocr=None):
# Compute ICR
expected_icr = triggers / livetime if livetime != 0 else 0.
if icr is None:
icr = expected_icr
# Double check the ICR computation
elif expected_icr != icr:
expected_icr = triggers / livetime if livetime != 0 else 0.
if expected_icr != icr:
msg = 'ICR buffer inconsistency: {} != {} (expected)'
warn(msg.format(icr, expected_icr))
# Compute OCR
expected_ocr = events / realtime if realtime != 0 else 0.
if ocr is None:
ocr = expected_ocr
# Double check the OCR computation
expected_ocr = total_events / realtime if realtime != 0 else 0.
if expected_ocr != ocr:
msg = 'OCR buffer inconsistency: {} != {} (expected)'
warn(msg.format(ocr, expected_ocr))
# Note that the OCR reported by handel include underflows and overflows,
# while the computed OCR in the returned statistics does not.
return make_stats(realtime, livetime, triggers, events)
def stats_from_mapping_mode(array):
realtime = array[0] * CLOCK_TICK
livetime = array[1] * CLOCK_TICK
triggers = int(array[2])
events = int(array[3])
return make_stats(realtime, livetime, triggers, events)
def make_stats(realtime, livetime, triggers, events):
# ICR/OCR computation
icr = triggers / livetime if livetime != 0 else 0.
ocr = events / realtime if realtime != 0 else 0.
# Deadtime computation
# It's unclear whether icr=ocr=0 should result in a 0.0 or 1.0 deadtime
# Prospect uses 0% so 0. it is.
deadtime = 1 - float(ocr) / icr if icr != 0 else 0.
return Stats(
realtime, livetime, triggers, events, icr, ocr, deadtime)
return Stats(realtime, livetime, triggers, events, icr, ocr, deadtime)
......@@ -295,10 +295,10 @@ def test_get_module_statistics(interface):
1.00758784,
0.98603936,
3088,
2745,
2742,
3131.720827046904,
2724.3282332585513,
0.1300858589533055)}
2721.350825353351,
0.13103658479051494)}
m.side_effect = side_effect
with mock.patch('handel.interface.get_module_channels') as m2:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment