mirror of
https://github.com/slsdetectorgroup/aare.git
synced 2025-06-05 04:20:40 +02:00
fixed calculate eta
This commit is contained in:
parent
15e52565a9
commit
f161df3591
@ -297,7 +297,7 @@ class ClusterVector<Cluster<T, ClusterSizeX, ClusterSizeY, CoordType>> {
|
||||
* @param frame_number frame number of the clusters. Default is 0, which is
|
||||
* also used to indicate that the clusters come from many frames
|
||||
*/
|
||||
ClusterVector(size_t capacity = 300, uint64_t frame_number = 0)
|
||||
ClusterVector(size_t capacity = 300, int32_t frame_number = 0)
|
||||
: m_frame_number(frame_number) {
|
||||
m_data.reserve(capacity);
|
||||
}
|
||||
|
@ -37,16 +37,6 @@ auto get_test_parameters() {
|
||||
Eta2<int>{3. / 5, 4. / 6, 1, 11}));
|
||||
}
|
||||
|
||||
TEST_CASE("compute_largest_2x2_subcluster", "[.eta_calculation]") {
|
||||
auto [cluster, expected_eta] = get_test_parameters();
|
||||
|
||||
auto [sum, index] = std::visit(
|
||||
[](const auto &clustertype) { return clustertype.max_sum_2x2(); },
|
||||
cluster);
|
||||
CHECK(expected_eta.c == index);
|
||||
CHECK(expected_eta.sum == sum);
|
||||
}
|
||||
|
||||
TEST_CASE("calculate_eta2", "[.eta_calculation]") {
|
||||
|
||||
auto [cluster, expected_eta] = get_test_parameters();
|
||||
|
@ -26,3 +26,49 @@ TEST_CASE("Correct Instantiation of Cluster and ClusterVector",
|
||||
CHECK(not is_cluster_v<int>);
|
||||
CHECK(is_cluster_v<Cluster<int, 3, 3>>);
|
||||
}
|
||||
<<<<<<< Updated upstream
|
||||
=======
|
||||
|
||||
using ClusterTypes =
|
||||
std::variant<Cluster<int, 2, 2>, Cluster<int, 3, 3>, Cluster<int, 5, 5>,
|
||||
Cluster<int, 4, 2>, Cluster<int, 2, 3>>;
|
||||
|
||||
auto get_test_sum_parameters() {
|
||||
return GENERATE(
|
||||
std::make_tuple(ClusterTypes{Cluster<int, 2, 2>{0, 0, {1, 2, 3, 1}}},
|
||||
std::make_pair(7, 0)),
|
||||
std::make_tuple(
|
||||
ClusterTypes{Cluster<int, 3, 3>{0, 0, {1, 2, 3, 4, 5, 6, 1, 2, 7}}},
|
||||
std::make_pair(20, 3)),
|
||||
std::make_tuple(ClusterTypes{Cluster<int, 5, 5>{
|
||||
0, 0, {1, 6, 7, 6, 5, 4, 3, 2, 1, 8, 8, 9, 2,
|
||||
1, 4, 5, 6, 7, 8, 4, 1, 1, 1, 1, 1}}},
|
||||
std::make_pair(28, 8)),
|
||||
std::make_tuple(
|
||||
ClusterTypes{Cluster<int, 4, 2>{0, 0, {1, 4, 7, 2, 5, 6, 4, 3}}},
|
||||
std::make_pair(21, 1)),
|
||||
std::make_tuple(
|
||||
ClusterTypes{Cluster<int, 2, 3>{0, 0, {1, 3, 2, 3, 4, 2}}},
|
||||
std::make_pair(11, 1)));
|
||||
}
|
||||
|
||||
TEST_CASE("compute_largest_2x2_subcluster", "[.cluster]") {
|
||||
auto [cluster, sum_pair] = get_test_sum_parameters();
|
||||
|
||||
auto sum = std::visit(
|
||||
[](const auto &clustertype) { return clustertype.max_sum_2x2(); },
|
||||
cluster);
|
||||
CHECK(sum_pair.first == sum.first);
|
||||
CHECK(sum_pair.second == sum.second);
|
||||
}
|
||||
|
||||
TEST_CASE("Test sum of Cluster", "[.cluster]") {
|
||||
Cluster<int, 2, 2> cluster{0, 0, {1, 2, 3, 4}};
|
||||
|
||||
CHECK(cluster.sum() == 10);
|
||||
|
||||
Cluster<int, 2, 3> cluster2x3{0, 0, {1, 3, 2, 3, 4, 2}};
|
||||
|
||||
CHECK(cluster2x3.sum() == 15);
|
||||
}
|
||||
>>>>>>> Stashed changes
|
||||
|
@ -30,6 +30,21 @@ TEST_CASE("item_size return the size of the cluster stored"){
|
||||
using C4 = Cluster<char, 10, 5>;
|
||||
ClusterVector<C4> cv4(4);
|
||||
CHECK(cv4.item_size() == sizeof(C4));
|
||||
<<<<<<< Updated upstream
|
||||
=======
|
||||
|
||||
using C5 = Cluster<int32_t, 2, 3>;
|
||||
ClusterVector<C5> cv5(4);
|
||||
CHECK(cv5.item_size() == sizeof(C5));
|
||||
|
||||
using C6 = Cluster<double, 5, 5>;
|
||||
ClusterVector<C6> cv6(4);
|
||||
CHECK(cv6.item_size() == sizeof(C6)); // double uses padding!!!
|
||||
|
||||
using C7 = Cluster<double, 3, 3>;
|
||||
ClusterVector<C7> cv7(4);
|
||||
CHECK(cv7.item_size() == sizeof(C7));
|
||||
>>>>>>> Stashed changes
|
||||
}
|
||||
|
||||
TEST_CASE("ClusterVector 2x2 int32_t capacity 4, push back then read",
|
||||
@ -211,6 +226,32 @@ TEST_CASE("Concatenate two cluster vectors where we need to allocate",
|
||||
REQUIRE(ptr[3].y == 17);
|
||||
}
|
||||
|
||||
TEST_CASE("calculate cluster sum", "[.ClusterVector]") {
|
||||
ClusterVector<Cluster<int32_t, 2, 2>> cv1(2);
|
||||
Cluster<int32_t, 2, 2> c1 = {1, 2, {3, 4, 5, 6}};
|
||||
cv1.push_back(c1);
|
||||
Cluster<int32_t, 2, 2> c2 = {6, 7, {8, 9, 10, 11}};
|
||||
cv1.push_back(c2);
|
||||
|
||||
auto sum1 = cv1.sum();
|
||||
|
||||
std::vector<int32_t> expected_sum1{18, 38};
|
||||
|
||||
CHECK(sum1 == expected_sum1);
|
||||
|
||||
ClusterVector<Cluster<int32_t, 3, 3>> cv2(2);
|
||||
Cluster<int32_t, 3, 3> c3 = {1, 2, {3, 4, 5, 6, 1, 7, 8, 1, 1}};
|
||||
cv2.push_back(c3);
|
||||
Cluster<int32_t, 3, 3> c4 = {6, 7, {8, 9, 10, 11, 13, 5, 12, 2, 4}};
|
||||
cv2.push_back(c4);
|
||||
|
||||
auto sum2 = cv2.sum();
|
||||
|
||||
std::vector<int32_t> expected_sum2{36, 74};
|
||||
|
||||
CHECK(sum2 == expected_sum2);
|
||||
}
|
||||
|
||||
struct ClusterTestData {
|
||||
uint8_t ClusterSizeX;
|
||||
uint8_t ClusterSizeY;
|
||||
|
Loading…
x
Reference in New Issue
Block a user