ClusterFinderMT¶
-
template<typename ClusterType = Cluster<int32_t, 3, 3>, typename FRAME_TYPE = uint16_t, typename PEDESTAL_TYPE = double, typename = std::enable_if_t<no_2x2_cluster<ClusterType>::value>>
class ClusterFinderMT¶ ClusterFinderMT is a multi-threaded version of ClusterFinder. It uses a producer-consumer queue to distribute the frames to the threads. The clusters are collected in a single output queue.
- Template Parameters:
FRAME_TYPE – type of the frame data
PEDESTAL_TYPE – type of the pedestal data
CT – type of the cluster data
Public Functions
-
inline ClusterFinderMT(Shape<2> image_size, PEDESTAL_TYPE nSigma = 5.0, size_t capacity = 2000, size_t n_threads = 3, size_t queue_depth = 16, size_t min_pedestal_samples = 1000)¶
Construct a new ClusterFinderMT object.
- Parameters:
image_size – size of the image
cluster_size – size of the cluster
nSigma – number of sigma above the pedestal to consider a photon
capacity – initial capacity of the cluster vector. Should match expected number of clusters in a frame per frame.
n_threads – number of threads to use
queue_depth – number of frame buffers per thread. These are allocated once and recycled, so the total resident frame memory is n_threads * queue_depth * frame size. Keeping the in flight data below the L3 size keeps the per frame copy cheap.
min_pedestal_samples – minimum number of pedestal samples to accumulate before using the pedestal
-
inline ProducerConsumerQueue<ClusterVector<ClusterType>> *sink()¶
Return the sink queue where all the clusters are collected.
Warning
You need to empty this queue otherwise the cluster finder will wait forever
-
inline void start()¶
Start all processing threads.
-
inline void stop()¶
Stop all processing threads.
-
inline void sync()¶
Wait for all the queues to be empty. Mostly used for timing tests.
-
inline void push_pedestal_frame(NDView<FRAME_TYPE, 2> frame)¶
Push a pedestal frame to all the cluster finders. The frames is expected to be dark. No photon finding is done. Just pedestal update.
-
inline void find_clusters(NDView<FRAME_TYPE, 2> frame, uint64_t frame_number = 0)¶
Push the frame to the queue of the next available thread. Function returns once the frame is in a queue.
Note
Spin locks with a default wait if the queue is full.
-
inline void clear_pedestal()¶
-
inline void update_threshold()¶
Recompute the threshold (nSigma * pedestal std) on all cluster finders. Requires the processing threads to be stopped.
-
inline auto pedestal(size_t thread_index = 0)¶
Return the pedestal currently used by the cluster finder.
- Parameters:
thread_index – index of the thread
-
inline auto noise(size_t thread_index = 0)¶
Return the noise currently used by the cluster finder.
- Parameters:
thread_index – index of the thread
-
inline void set_nSigma(const PEDESTAL_TYPE nSigma)¶
Set the nSigma value for all the cluster finders. Waits for the queued frames to be processed first.
- Parameters:
nSigma – number of sigma above the pedestal to consider a photon during cluster finding.
-
inline bool pedestal_ready()¶
Return whether all cluster finders have received enough pedestal frames to find clusters. Waits for the queued frames to be processed first.