aare/examples/cluster_example.cpp
Bechir Braham 5b7ab5a810
cluster finder (#72)
implement fixed size cluster finder algorithm 
clusterFile functions are commented and put on hold.

---------

Co-authored-by: Bechir <bechir.brahem420@gmail.com>
Co-authored-by: Erik Fröjdh <erik.frojdh@gmail.com>
2024-06-17 10:57:23 +02:00

39 lines
1.0 KiB
C++

#include "aare.hpp"
#include "aare/examples/defs.hpp"
#include <cassert>
#include <iostream>
using namespace aare;
int main() {
auto PROJECT_ROOT_DIR = std::filesystem::path(getenv("AARE_ROOT_DIR"));
std::filesystem::path const fpath("/mnt/sls_det_storage/moench_data/testNewFW20230714/cu_half_speed_master_4.json");
NDArray<double, 2> frame({10, 10});
frame = 0;
for (int i = 5; i < 8; i++) {
for (int j = 5; j < 8; j++) {
frame(i, j) = (i + j) % 10;
}
}
for (int i = 0; i < frame.shape(0); i++) {
for (int j = 0; j < frame.shape(1); j++) {
std::cout << frame(i, j) << " ";
}
std::cout << std::endl;
}
ClusterFinder clusterFinder(3, 3, 1, 1); // 3x3 cluster, 1 nSigma, 1 threshold
Pedestal p(10, 10);
auto clusters = clusterFinder.find_clusters(frame.span(), p);
aare::logger::info("nclusters:", clusters.size());
for (auto &cluster : clusters) {
aare::logger::info("cluster center:", cluster.to_string<double>());
}
}