From 240960d3e7e5c27ad1ba82ffa8a909a92134af97 Mon Sep 17 00:00:00 2001 From: Mazzoleni Alice Francesca Date: Wed, 2 Apr 2025 12:05:16 +0200 Subject: [PATCH] generalized FindCluster to read in general cluster sizes - assuming that finding cluster center is equal for all clusters --- include/aare/CalculateEta.hpp | 2 +- include/aare/ClusterFinder.hpp | 19 ++++++++++--------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/include/aare/CalculateEta.hpp b/include/aare/CalculateEta.hpp index 1a0797a..088b4e8 100644 --- a/include/aare/CalculateEta.hpp +++ b/include/aare/CalculateEta.hpp @@ -67,7 +67,7 @@ Eta2 calculate_eta2( size_t index_bottom_left_max_2x2_subcluster = (int(c / (ClusterSizeX - 1))) * ClusterSizeX + c % (ClusterSizeX - 1); - if ((cl.data[index_bottom_left_max_2x2_subcluster] + + if ((cl.data[index_bottom_left_max_2x2_subcluster] +s cl.data[index_bottom_left_max_2x2_subcluster + 1]) != 0) eta.x = static_cast( cl.data[index_bottom_left_max_2x2_subcluster + 1]) / diff --git a/include/aare/ClusterFinder.hpp b/include/aare/ClusterFinder.hpp index 6a8fec4..19ada67 100644 --- a/include/aare/ClusterFinder.hpp +++ b/include/aare/ClusterFinder.hpp @@ -70,6 +70,12 @@ class ClusterFinder { // // 4,4 -> +/- 2 int dy = ClusterSizeY / 2; int dx = ClusterSizeX / 2; + int has_center_pixel_x = + ClusterSizeX % + 2; // for even sized clusters there is no proper cluster center and + // even amount of pixels around the center + int has_center_pixel_y = ClusterSizeY % 2; + m_clusters.set_frame_number(frame_number); std::vector cluster_data(ClusterSizeX * ClusterSizeY); for (int iy = 0; iy < frame.shape(0); iy++) { @@ -86,8 +92,8 @@ class ClusterFinder { continue; // NEGATIVE_PEDESTAL go to next pixel // TODO! No pedestal update??? - for (int ir = -dy; ir < dy + 1; ir++) { - for (int ic = -dx; ic < dx + 1; ic++) { + for (int ir = -dy; ir < dy + has_center_pixel_y; ir++) { + 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)) { PEDESTAL_TYPE val = @@ -125,8 +131,8 @@ class ClusterFinder { // It's worth redoing the look since most of the time we // don't have a photon int i = 0; - for (int ir = -dy; ir < dy + 1; ir++) { - for (int ic = -dx; ic < dx + 1; ic++) { + for (int ir = -dy; ir < dy + has_center_pixel_y; ir++) { + for (int ic = -dx; ic < dx + has_center_pixel_y; ic++) { if (ix + ic >= 0 && ix + ic < frame.shape(1) && iy + ir >= 0 && iy + ir < frame.shape(0)) { CT tmp = @@ -140,11 +146,6 @@ class ClusterFinder { } // Add the cluster to the output ClusterVector - /* - m_clusters.push_back( - ix, iy, - reinterpret_cast(cluster_data.data())); - */ m_clusters.push_back( Cluster{ ix, iy, cluster_data.data()});