mirror of
https://github.com/slsdetectorgroup/aare.git
synced 2025-12-29 08:21:28 +01:00
Cluster cuts (#146)
Some checks failed
Build the package using cmake then documentation / build (ubuntu-latest, 3.12) (push) Failing after 43s
Some checks failed
Build the package using cmake then documentation / build (ubuntu-latest, 3.12) (push) Failing after 43s
Co-authored-by: Patrick <patrick.sieberer@psi.ch> Co-authored-by: JulianHeymes <julian.heymes@psi.ch> Co-authored-by: Dhanya Thattil <dhanya.thattil@psi.ch> Co-authored-by: Xiangyu Xie <45243914+xiangyuxie@users.noreply.github.com> Co-authored-by: xiangyu.xie <xiangyu.xie@psi.ch>
This commit is contained in:
80
src/ClusterFile.test.cpp
Normal file
80
src/ClusterFile.test.cpp
Normal file
@@ -0,0 +1,80 @@
|
||||
#include "aare/ClusterFile.hpp"
|
||||
#include "test_config.hpp"
|
||||
|
||||
|
||||
#include "aare/defs.hpp"
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
#include <filesystem>
|
||||
|
||||
|
||||
|
||||
|
||||
using aare::ClusterFile;
|
||||
|
||||
TEST_CASE("Read one frame from a a cluster file", "[.integration]") {
|
||||
//We know that the frame has 97 clusters
|
||||
auto fpath = test_data_path() / "clusters" / "single_frame_97_clustrers.clust";
|
||||
REQUIRE(std::filesystem::exists(fpath));
|
||||
|
||||
ClusterFile f(fpath);
|
||||
auto clusters = f.read_frame();
|
||||
REQUIRE(clusters.size() == 97);
|
||||
REQUIRE(clusters.frame_number() == 135);
|
||||
}
|
||||
|
||||
TEST_CASE("Read one frame using ROI", "[.integration]") {
|
||||
//We know that the frame has 97 clusters
|
||||
auto fpath = test_data_path() / "clusters" / "single_frame_97_clustrers.clust";
|
||||
REQUIRE(std::filesystem::exists(fpath));
|
||||
|
||||
ClusterFile f(fpath);
|
||||
aare::ROI roi;
|
||||
roi.xmin = 0;
|
||||
roi.xmax = 50;
|
||||
roi.ymin = 200;
|
||||
roi.ymax = 249;
|
||||
f.set_roi(roi);
|
||||
auto clusters = f.read_frame();
|
||||
REQUIRE(clusters.size() == 49);
|
||||
REQUIRE(clusters.frame_number() == 135);
|
||||
|
||||
//Check that all clusters are within the ROI
|
||||
for (size_t i = 0; i < clusters.size(); i++) {
|
||||
auto c = clusters.at<aare::Cluster3x3>(i);
|
||||
REQUIRE(c.x >= roi.xmin);
|
||||
REQUIRE(c.x <= roi.xmax);
|
||||
REQUIRE(c.y >= roi.ymin);
|
||||
REQUIRE(c.y <= roi.ymax);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
TEST_CASE("Read clusters from single frame file", "[.integration]") {
|
||||
|
||||
auto fpath = test_data_path() / "clusters" / "single_frame_97_clustrers.clust";
|
||||
REQUIRE(std::filesystem::exists(fpath));
|
||||
|
||||
SECTION("Read fewer clusters than available") {
|
||||
ClusterFile f(fpath);
|
||||
auto clusters = f.read_clusters(50);
|
||||
REQUIRE(clusters.size() == 50);
|
||||
REQUIRE(clusters.frame_number() == 135);
|
||||
}
|
||||
SECTION("Read more clusters than available") {
|
||||
ClusterFile f(fpath);
|
||||
// 100 is the maximum number of clusters read
|
||||
auto clusters = f.read_clusters(100);
|
||||
REQUIRE(clusters.size() == 97);
|
||||
REQUIRE(clusters.frame_number() == 135);
|
||||
}
|
||||
SECTION("Read all clusters") {
|
||||
ClusterFile f(fpath);
|
||||
auto clusters = f.read_clusters(97);
|
||||
REQUIRE(clusters.size() == 97);
|
||||
REQUIRE(clusters.frame_number() == 135);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user