diff --git a/CMakeLists.txt b/CMakeLists.txt index 1de16ae..dfd7357 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -240,9 +240,7 @@ endif() add_library(aare_compiler_flags INTERFACE) target_compile_features(aare_compiler_flags INTERFACE cxx_std_17) -if(AARE_PYTHON_BINDINGS) - add_subdirectory(python) -endif() + ################# # MSVC specific # @@ -308,6 +306,9 @@ target_compile_options( endif() #GCC/Clang specific +if(AARE_PYTHON_BINDINGS) + add_subdirectory(python) +endif() if(AARE_ASAN) message(STATUS "AddressSanitizer enabled") diff --git a/RELEASE.md b/RELEASE.md index d9c0888..6ca6f44 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -16,6 +16,7 @@ ### Bugfixes: - multi threaded cluster finder doesnt drop frames if queues are full + - Round before casting in the cluster finder to avoid biasing clusters by truncating ### 2025.11.21 diff --git a/include/aare/ClusterFinder.hpp b/include/aare/ClusterFinder.hpp index 3f140a9..7d059ff 100644 --- a/include/aare/ClusterFinder.hpp +++ b/include/aare/ClusterFinder.hpp @@ -148,12 +148,27 @@ class ClusterFinder { for (int ic = -dx; ic < dx + has_center_pixel_x; ic++) { if (ix + ic >= 0 && ix + ic < frame.shape(1) && iy + ir >= 0 && iy + ir < frame.shape(0)) { - CT tmp = - static_cast(frame(iy + ir, ix + ic)) - - static_cast( + + // If the cluster type is an integral type, and + // the pedestal is a floating point type then we + // need to round the value before storing it + if constexpr (std::is_integral_v && + std::is_floating_point_v< + PEDESTAL_TYPE>) { + auto tmp = std::lround( + frame(iy + ir, ix + ic) - m_pedestal.mean(iy + ir, ix + ic)); - cluster.data[i] = - tmp; // Watch for out of bounds access + cluster.data[i] = static_cast(tmp); + } + // On the other hand if both are floating point + // or both are integral then we can just static + // cast directly + else { + auto tmp = + frame(iy + ir, ix + ic) - + m_pedestal.mean(iy + ir, ix + ic); + cluster.data[i] = static_cast(tmp); + } } i++; } diff --git a/include/aare/ProducerConsumerQueue.hpp b/include/aare/ProducerConsumerQueue.hpp index bf24c25..184ceb4 100644 --- a/include/aare/ProducerConsumerQueue.hpp +++ b/include/aare/ProducerConsumerQueue.hpp @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #include