merge conflict

This commit is contained in:
Mazzoleni Alice Francesca 2025-04-01 17:50:11 +02:00
parent 4240942cec
commit 3083d51699
3 changed files with 32 additions and 35 deletions

View File

@ -152,8 +152,10 @@ template <typename T> Eta2 calculate_eta2(const Cluster<T, 3, 3> &cl) {
template <typename T> Eta2 calculate_eta2(const Cluster<T, 2, 2> &cl) { template <typename T> Eta2 calculate_eta2(const Cluster<T, 2, 2> &cl) {
Eta2 eta{}; Eta2 eta{};
eta.x = static_cast<double>(cl.data[1]) / (cl.data[0] + cl.data[1]); if ((cl.data[0] + cl.data[1]) != 0)
eta.y = static_cast<double>(cl.data[2]) / (cl.data[0] + cl.data[2]); eta.x = static_cast<double>(cl.data[1]) / (cl.data[0] + cl.data[1]);
if ((cl.data[0] + cl.data[2]) != 0)
eta.y = static_cast<double>(cl.data[2]) / (cl.data[0] + cl.data[2]);
eta.sum = cl.data[0] + cl.data[1] + cl.data[2] + cl.data[3]; eta.sum = cl.data[0] + cl.data[1] + cl.data[2] + cl.data[3];
eta.c = cBottomLeft; // TODO! This is not correct, but need to put something eta.c = cBottomLeft; // TODO! This is not correct, but need to put something
return eta; return eta;

View File

@ -272,25 +272,25 @@ class ClusterVector<Cluster<T, ClusterSizeX, ClusterSizeY, CoordType>> {
m_size = new_size; m_size = new_size;
} }
void apply_gain_map(const NDView<double> gain_map){ // TODO: Generalize !!!!
//in principle we need to know the size of the image for this lookup void apply_gain_map(const NDView<double> gain_map) {
//TODO! check orientations // in principle we need to know the size of the image for this lookup
// TODO! check orientations
std::array<int64_t, 9> xcorr = {-1, 0, 1, -1, 0, 1, -1, 0, 1}; std::array<int64_t, 9> xcorr = {-1, 0, 1, -1, 0, 1, -1, 0, 1};
std::array<int64_t, 9> ycorr = {-1, -1, -1, 0, 0, 0, 1, 1, 1}; std::array<int64_t, 9> ycorr = {-1, -1, -1, 0, 0, 0, 1, 1, 1};
for (size_t i=0; i<m_size; i++){ for (size_t i = 0; i < m_size; i++) {
auto& cl = at<Cluster3x3>(i); auto &cl = at(i);
if (cl.x > 0 && cl.y > 0 && cl.x < gain_map.shape(1)-1 && cl.y < gain_map.shape(0)-1){ if (cl.x > 0 && cl.y > 0 && cl.x < gain_map.shape(1) - 1 &&
for (size_t j=0; j<9; j++){ cl.y < gain_map.shape(0) - 1) {
for (size_t j = 0; j < 9; j++) {
size_t x = cl.x + xcorr[j]; size_t x = cl.x + xcorr[j];
size_t y = cl.y + ycorr[j]; size_t y = cl.y + ycorr[j];
cl.data[j] = static_cast<T>(cl.data[j] * gain_map(y, x)); cl.data[j] = static_cast<T>(cl.data[j] * gain_map(y, x));
} }
}else{ } else {
memset(cl.data, 0, 9*sizeof(T)); //clear edge clusters memset(cl.data, 0, 9 * sizeof(T)); // clear edge clusters
} }
} }
} }

View File

@ -1,33 +1,32 @@
#include "aare/ClusterFile.hpp" #include "aare/ClusterFile.hpp"
#include "test_config.hpp" #include "test_config.hpp"
#include "aare/defs.hpp" #include "aare/defs.hpp"
#include <catch2/catch_test_macros.hpp> #include <catch2/catch_test_macros.hpp>
#include <filesystem> #include <filesystem>
using aare::Cluster;
using aare::ClusterFile; using aare::ClusterFile;
TEST_CASE("Read one frame from a a cluster file", "[.integration]") { TEST_CASE("Read one frame from a a cluster file", "[.integration]") {
//We know that the frame has 97 clusters // We know that the frame has 97 clusters
auto fpath = test_data_path() / "clusters" / "single_frame_97_clustrers.clust"; auto fpath =
test_data_path() / "clusters" / "single_frame_97_clustrers.clust";
REQUIRE(std::filesystem::exists(fpath)); REQUIRE(std::filesystem::exists(fpath));
ClusterFile f(fpath); ClusterFile<Cluster<int32_t, 3, 3>> f(fpath);
auto clusters = f.read_frame(); auto clusters = f.read_frame();
REQUIRE(clusters.size() == 97); REQUIRE(clusters.size() == 97);
REQUIRE(clusters.frame_number() == 135); REQUIRE(clusters.frame_number() == 135);
} }
TEST_CASE("Read one frame using ROI", "[.integration]") { TEST_CASE("Read one frame using ROI", "[.integration]") {
//We know that the frame has 97 clusters // We know that the frame has 97 clusters
auto fpath = test_data_path() / "clusters" / "single_frame_97_clustrers.clust"; auto fpath =
test_data_path() / "clusters" / "single_frame_97_clustrers.clust";
REQUIRE(std::filesystem::exists(fpath)); REQUIRE(std::filesystem::exists(fpath));
ClusterFile f(fpath); ClusterFile<Cluster<int32_t, 3, 3>> f(fpath);
aare::ROI roi; aare::ROI roi;
roi.xmin = 0; roi.xmin = 0;
roi.xmax = 50; roi.xmax = 50;
@ -38,43 +37,39 @@ TEST_CASE("Read one frame using ROI", "[.integration]") {
REQUIRE(clusters.size() == 49); REQUIRE(clusters.size() == 49);
REQUIRE(clusters.frame_number() == 135); REQUIRE(clusters.frame_number() == 135);
//Check that all clusters are within the ROI // Check that all clusters are within the ROI
for (size_t i = 0; i < clusters.size(); i++) { for (size_t i = 0; i < clusters.size(); i++) {
auto c = clusters.at<aare::Cluster3x3>(i); auto c = clusters.at(i);
REQUIRE(c.x >= roi.xmin); REQUIRE(c.x >= roi.xmin);
REQUIRE(c.x <= roi.xmax); REQUIRE(c.x <= roi.xmax);
REQUIRE(c.y >= roi.ymin); REQUIRE(c.y >= roi.ymin);
REQUIRE(c.y <= roi.ymax); REQUIRE(c.y <= roi.ymax);
} }
} }
TEST_CASE("Read clusters from single frame file", "[.integration]") { TEST_CASE("Read clusters from single frame file", "[.integration]") {
auto fpath = test_data_path() / "clusters" / "single_frame_97_clustrers.clust"; auto fpath =
test_data_path() / "clusters" / "single_frame_97_clustrers.clust";
REQUIRE(std::filesystem::exists(fpath)); REQUIRE(std::filesystem::exists(fpath));
SECTION("Read fewer clusters than available") { SECTION("Read fewer clusters than available") {
ClusterFile f(fpath); ClusterFile<Cluster<int32_t, 3, 3>> f(fpath);
auto clusters = f.read_clusters(50); auto clusters = f.read_clusters(50);
REQUIRE(clusters.size() == 50); REQUIRE(clusters.size() == 50);
REQUIRE(clusters.frame_number() == 135); REQUIRE(clusters.frame_number() == 135);
} }
SECTION("Read more clusters than available") { SECTION("Read more clusters than available") {
ClusterFile f(fpath); ClusterFile<Cluster<int32_t, 3, 3>> f(fpath);
// 100 is the maximum number of clusters read // 100 is the maximum number of clusters read
auto clusters = f.read_clusters(100); auto clusters = f.read_clusters(100);
REQUIRE(clusters.size() == 97); REQUIRE(clusters.size() == 97);
REQUIRE(clusters.frame_number() == 135); REQUIRE(clusters.frame_number() == 135);
} }
SECTION("Read all clusters") { SECTION("Read all clusters") {
ClusterFile f(fpath); ClusterFile<Cluster<int32_t, 3, 3>> f(fpath);
auto clusters = f.read_clusters(97); auto clusters = f.read_clusters(97);
REQUIRE(clusters.size() == 97); REQUIRE(clusters.size() == 97);
REQUIRE(clusters.frame_number() == 135); REQUIRE(clusters.frame_number() == 135);
} }
} }