mirror of
https://github.com/slsdetectorgroup/aare.git
synced 2025-04-20 05:40:03 +02:00
replaced extract template parameters
This commit is contained in:
parent
1174f7f434
commit
fca9d5d2fa
@ -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 <typename T> struct Cluster<T, 2, 2, int16_t> {
|
||||
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<T, int> max_sum_2x2() const {
|
||||
@ -77,6 +87,10 @@ template <typename T> struct Cluster<T, 3, 3, int16_t> {
|
||||
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<Cluster<T, X, Y, CoordType>> : std::true_type {}; // Cluster
|
||||
|
||||
template <typename T> constexpr bool is_cluster_v = is_cluster<T>::value;
|
||||
|
||||
template <typename ClusterType,
|
||||
typename = std::enable_if_t<is_cluster_v<ClusterType>>>
|
||||
struct extract_template_arguments; // Forward declaration
|
||||
|
||||
// helper struct to extract template argument
|
||||
template <typename T, uint8_t ClusterSizeX, uint8_t ClusterSizeY,
|
||||
typename CoordType>
|
||||
struct extract_template_arguments<
|
||||
Cluster<T, ClusterSizeX, ClusterSizeY, CoordType>> {
|
||||
|
||||
using value_type = T;
|
||||
static constexpr int cluster_size_x = ClusterSizeX;
|
||||
static constexpr int cluster_size_y = ClusterSizeY;
|
||||
using coordtype = CoordType;
|
||||
};
|
||||
|
||||
} // namespace aare
|
||||
|
@ -465,13 +465,9 @@ bool ClusterFile<ClusterType, Enable>::is_selected(ClusterType &cl) {
|
||||
}
|
||||
}
|
||||
|
||||
auto cluster_size_x = extract_template_arguments<
|
||||
std::remove_reference_t<decltype(cl)>>::cluster_size_x;
|
||||
auto cluster_size_y = extract_template_arguments<
|
||||
std::remove_reference_t<decltype(cl)>>::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
|
||||
|
@ -20,11 +20,9 @@ class ClusterFinder {
|
||||
Pedestal<PEDESTAL_TYPE> m_pedestal;
|
||||
ClusterVector<ClusterType> m_clusters;
|
||||
|
||||
static const uint8_t ClusterSizeX =
|
||||
extract_template_arguments<ClusterType>::cluster_size_x;
|
||||
static const uint8_t ClusterSizeY =
|
||||
extract_template_arguments<ClusterType>::cluster_size_x;
|
||||
using CT = typename extract_template_arguments<ClusterType>::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:
|
||||
/**
|
||||
|
@ -34,7 +34,7 @@ template <typename ClusterType = Cluster<int32_t, 3, 3>,
|
||||
typename FRAME_TYPE = uint16_t, typename PEDESTAL_TYPE = double>
|
||||
class ClusterFinderMT {
|
||||
|
||||
using CT = typename extract_template_arguments<ClusterType>::value_type;
|
||||
using CT = typename ClusterType::value_type;
|
||||
size_t m_current_thread{0};
|
||||
size_t m_n_threads{0};
|
||||
using Finder = ClusterFinder<ClusterType, FRAME_TYPE, PEDESTAL_TYPE>;
|
||||
|
Loading…
x
Reference in New Issue
Block a user