diff --git a/include/aare/Cluster.hpp b/include/aare/Cluster.hpp index a2c9b55..7eb1a13 100644 --- a/include/aare/Cluster.hpp +++ b/include/aare/Cluster.hpp @@ -32,6 +32,11 @@ struct Cluster { CoordType y; T data[ClusterSizeX * ClusterSizeY]; + static constexpr uint8_t cluster_size_x = ClusterSizeX; + static constexpr uint8_t cluster_size_y = ClusterSizeY; + using value_type = T; + using coord_type = CoordType; + T sum() const { return std::accumulate(data, data + ClusterSizeX * ClusterSizeY, 0); } @@ -64,6 +69,11 @@ template struct Cluster { int16_t y; T data[4]; + static constexpr uint8_t cluster_size_x = 2; + static constexpr uint8_t cluster_size_y = 2; + using value_type = T; + using coord_type = int16_t; + T sum() const { return std::accumulate(data, data + 4, 0); } std::pair max_sum_2x2() const { @@ -77,6 +87,10 @@ template struct Cluster { int16_t x; int16_t y; T data[9]; + static constexpr uint8_t cluster_size_x = 3; + static constexpr uint8_t cluster_size_y = 3; + using value_type = T; + using coord_type = int16_t; T sum() const { return std::accumulate(data, data + 9, 0); } @@ -102,20 +116,4 @@ struct is_cluster> : std::true_type {}; // Cluster template constexpr bool is_cluster_v = is_cluster::value; -template >> -struct extract_template_arguments; // Forward declaration - -// helper struct to extract template argument -template -struct extract_template_arguments< - Cluster> { - - using value_type = T; - static constexpr int cluster_size_x = ClusterSizeX; - static constexpr int cluster_size_y = ClusterSizeY; - using coordtype = CoordType; -}; - } // namespace aare diff --git a/include/aare/ClusterFile.hpp b/include/aare/ClusterFile.hpp index 06de985..b063008 100644 --- a/include/aare/ClusterFile.hpp +++ b/include/aare/ClusterFile.hpp @@ -465,13 +465,9 @@ bool ClusterFile::is_selected(ClusterType &cl) { } } - auto cluster_size_x = extract_template_arguments< - std::remove_reference_t>::cluster_size_x; - auto cluster_size_y = extract_template_arguments< - std::remove_reference_t>::cluster_size_y; - size_t cluster_center_index = - (cluster_size_x / 2) + (cluster_size_y / 2) * cluster_size_x; + (ClusterType::cluster_size_x / 2) + + (ClusterType::cluster_size_y / 2) * ClusterType::cluster_size_x; if (m_noise_map) { auto sum_1x1 = cl.data[cluster_center_index]; // central pixel diff --git a/include/aare/ClusterFinder.hpp b/include/aare/ClusterFinder.hpp index 8c3540a..b3538eb 100644 --- a/include/aare/ClusterFinder.hpp +++ b/include/aare/ClusterFinder.hpp @@ -20,11 +20,9 @@ class ClusterFinder { Pedestal m_pedestal; ClusterVector m_clusters; - static const uint8_t ClusterSizeX = - extract_template_arguments::cluster_size_x; - static const uint8_t ClusterSizeY = - extract_template_arguments::cluster_size_x; - using CT = typename extract_template_arguments::value_type; + static const uint8_t ClusterSizeX = ClusterType::cluster_size_x; + static const uint8_t ClusterSizeY = ClusterType::cluster_size_y; + using CT = typename ClusterType::value_type; public: /** diff --git a/include/aare/ClusterFinderMT.hpp b/include/aare/ClusterFinderMT.hpp index 75b6497..29fc715 100644 --- a/include/aare/ClusterFinderMT.hpp +++ b/include/aare/ClusterFinderMT.hpp @@ -34,7 +34,7 @@ template , typename FRAME_TYPE = uint16_t, typename PEDESTAL_TYPE = double> class ClusterFinderMT { - using CT = typename extract_template_arguments::value_type; + using CT = typename ClusterType::value_type; size_t m_current_thread{0}; size_t m_n_threads{0}; using Finder = ClusterFinder;