diff --git a/src/sfx_addons/hitfinder_spi.py b/src/sfx_addons/hitfinder_spi.py index 0561b7a6eeba9c1e9df77bbb98c1e0b0b64cfe74..8725fccaa1bb2b35cc97c6bec08547c2fe449880 100644 --- a/src/sfx_addons/hitfinder_spi.py +++ b/src/sfx_addons/hitfinder_spi.py @@ -2,7 +2,6 @@ import numpy as np from karabo.bound import ( Hash, - NODE_ELEMENT, DOUBLE_ELEMENT, INT32_ELEMENT, STRING_ELEMENT, @@ -15,31 +14,34 @@ from calng.arbiter_kernels.base_kernel import BaseArbiterKernel class HitFinderSPI(BaseArbiterKernel): _node_name = "hitFinderSPI" - def __init__(self, config): - super().__init__(config) - - self._use_spi = config.get("SPI") - self._modules = set(eval("np.r_[{}]".format(config.get("modules")))) - self._absolute_threshold = config.get("absoluteThreshold") - self._use_adaptive_threshold = config.get("useAdaptiveThreshold") - self._sigma_level = config.get("sigmaLevel") - self._max_history_length = config.get("maxHistoryLength") - - self._cur_history_length = 0 - self._history = np.zeros(self._max_history_length, dtype=int) - - self._use_sfx = config.get("SFX") - self._min_peaks = config.get("minPeaks") - self._min_r = config.get("minRadius") - self._max_r = config.get("maxRadius") + def reconfigure(self, config): + # note: automatically called in super().__init__ + if config.has("SPI"): + self._use_spi = config.get("SPI") + if config.has("modules"): + self._modules = set(eval("np.r_[{}]".format(config.get("modules")))) + if config.has("absoluteThreshold"): + self._absolute_threshold = config.get("absoluteThreshold") + if config.has("useAdaptiveThreshold"): + self._use_adaptive_threshold = config.get("useAdaptiveThreshold") + if config.has("sigmaLevel"): + self._sigma_level = config.get("sigmaLevel") + if config.has("maxHistoryLength"): + self._max_history_length = config.get("maxHistoryLength") + self._cur_history_length = 0 + self._history = np.zeros(self._max_history_length, dtype=int) + if config.has("SFX"): + self._use_sfx = config.get("SFX") + if config.has("minPeaks"): + self._min_peaks = config.get("minPeaks") + if config.has("minRadius"): + self._min_r = config.get("minRadius") + if config.has("maxRadius"): + self._max_r = config.get("maxRadius") @staticmethod def extend_device_schema(schema, prefix): ( - NODE_ELEMENT(schema) - .key(prefix) - .commit(), - BOOL_ELEMENT(schema) .key(f"{prefix}.SPI") .assignmentOptional() @@ -118,7 +120,7 @@ class HitFinderSPI(BaseArbiterKernel): self.geometry.get_pixel_positions() / self.geometry.pixel_size ).astype(int) - def consider(self, train_id, sources, num_frames): + def consider(self, train_id, sources, num_frames, mask, out_hash): has_xray = self.get_litframe_pattern(train_id, sources, num_frames) result = Hash()