diff --git a/RELEASE.md b/RELEASE.md index 8762827..a48c221 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -1,5 +1,11 @@ # Release notes +## HEAD + +### New Features: + +- setter and getter for nSigma for ClusterFinder ``aare.ClusterFinder().nSigma = 2``, ``aare.ClusterFinderMT().set_nSigma(2)`` + ## 2026.3.17 ### New Features: diff --git a/include/aare/ClusterFinder.hpp b/include/aare/ClusterFinder.hpp index 7d059ff..83b5c78 100644 --- a/include/aare/ClusterFinder.hpp +++ b/include/aare/ClusterFinder.hpp @@ -23,7 +23,7 @@ template , typename = std::enable_if_t::value>> class ClusterFinder { Shape<2> m_image_size; - const PEDESTAL_TYPE m_nSigma; + PEDESTAL_TYPE m_nSigma; const PEDESTAL_TYPE c2; const PEDESTAL_TYPE c3; Pedestal m_pedestal; @@ -53,6 +53,10 @@ class ClusterFinder { << ", nSigma: " << nSigma << ", capacity: " << capacity; } + void set_nSigma(PEDESTAL_TYPE nSigma) { m_nSigma = nSigma; } + + PEDESTAL_TYPE get_nSigma() const { return m_nSigma; } + void push_pedestal_frame(NDView frame) { m_pedestal.push(frame); } diff --git a/include/aare/ClusterFinderMT.hpp b/include/aare/ClusterFinderMT.hpp index b5df766..d4ff001 100644 --- a/include/aare/ClusterFinderMT.hpp +++ b/include/aare/ClusterFinderMT.hpp @@ -284,6 +284,23 @@ class ClusterFinderMT { // auto rc = m_input_queue.write(std::move(frame)); // fmt::print("pushed frame {}\n", rc); // } + + /** + * @brief Set the nSigma value for all the cluster finders. + * @param nSigma number of sigma above the pedestal to consider a photon + * during cluster finding. + */ + void set_nSigma(const PEDESTAL_TYPE nSigma) { + // Wait for all queues to be empty before changing the sigma + for (auto &q : m_input_queues) { + while (!q->isEmpty()) { + std::this_thread::sleep_for(m_default_wait); + } + } + for (auto &cf : m_cluster_finders) { + cf->set_nSigma(nSigma); + } + } }; } // namespace aare \ No newline at end of file diff --git a/python/src/bind_ClusterFinder.hpp b/python/src/bind_ClusterFinder.hpp index 49e203b..da479dc 100644 --- a/python/src/bind_ClusterFinder.hpp +++ b/python/src/bind_ClusterFinder.hpp @@ -33,6 +33,13 @@ void define_ClusterFinder(py::module &m, const std::string &typestr) { m, class_name.c_str()) .def(py::init, pd_type, size_t>(), py::arg("image_size"), py::arg("n_sigma") = 5.0, py::arg("capacity") = 1'000'000) + + .def_property( + "nSigma", + &ClusterFinder::get_nSigma, + &ClusterFinder::set_nSigma, + R"(number of sigma above the pedestal to consider a photon during cluster finding.)") + .def("push_pedestal_frame", [](ClusterFinder &self, py::array_t frame) { diff --git a/python/src/bind_ClusterFinderMT.hpp b/python/src/bind_ClusterFinderMT.hpp index c03eeeb..4bb8101 100644 --- a/python/src/bind_ClusterFinderMT.hpp +++ b/python/src/bind_ClusterFinderMT.hpp @@ -76,7 +76,12 @@ void define_ClusterFinderMT(py::module &m, const std::string &typestr) { *arr = self.noise(thread_index); return return_image_data(arr); }, - py::arg("thread_index") = 0); + py::arg("thread_index") = 0) + + .def("set_nSigma", + &ClusterFinderMT::set_nSigma, + py::arg("nSigma"), + R"(sets the number of sigma for all cluster finders.)"); } #pragma GCC diagnostic pop \ No newline at end of file