diff --git a/include/aare/defs.hpp b/include/aare/defs.hpp index af73a84d..f810f411 100644 --- a/include/aare/defs.hpp +++ b/include/aare/defs.hpp @@ -38,87 +38,6 @@ inline constexpr size_t bits_per_byte = 8; void assert_failed(const std::string &msg); -class DynamicCluster { - public: - int cluster_sizeX; - int cluster_sizeY; - int16_t x; - int16_t y; - Dtype dt; // 4 bytes - - private: - std::byte *m_data; - - public: - DynamicCluster(int cluster_sizeX_, int cluster_sizeY_, - Dtype dt_ = Dtype(typeid(int32_t))) - : cluster_sizeX(cluster_sizeX_), cluster_sizeY(cluster_sizeY_), - dt(dt_) { - m_data = new std::byte[cluster_sizeX * cluster_sizeY * dt.bytes()]{}; - } - DynamicCluster() : DynamicCluster(3, 3) {} - DynamicCluster(const DynamicCluster &other) - : DynamicCluster(other.cluster_sizeX, other.cluster_sizeY, other.dt) { - if (this == &other) - return; - x = other.x; - y = other.y; - memcpy(m_data, other.m_data, other.bytes()); - } - DynamicCluster &operator=(const DynamicCluster &other) { - if (this == &other) - return *this; - this->~DynamicCluster(); - new (this) DynamicCluster(other); - return *this; - } - DynamicCluster(DynamicCluster &&other) noexcept - : cluster_sizeX(other.cluster_sizeX), - cluster_sizeY(other.cluster_sizeY), x(other.x), y(other.y), - dt(other.dt), m_data(other.m_data) { - other.m_data = nullptr; - other.dt = Dtype(Dtype::TypeIndex::ERROR); - } - ~DynamicCluster() { delete[] m_data; } - template T get(int idx) { - (sizeof(T) == dt.bytes()) - ? 0 - : throw std::invalid_argument("[ERROR] Type size mismatch"); - return *reinterpret_cast(m_data + idx * dt.bytes()); - } - template auto set(int idx, T val) { - (sizeof(T) == dt.bytes()) - ? 0 - : throw std::invalid_argument("[ERROR] Type size mismatch"); - return memcpy(m_data + idx * dt.bytes(), &val, dt.bytes()); - } - - template std::string to_string() const { - (sizeof(T) == dt.bytes()) - ? 0 - : throw std::invalid_argument("[ERROR] Type size mismatch"); - std::string s = "x: " + std::to_string(x) + " y: " + std::to_string(y) + - "\nm_data: ["; - for (int i = 0; i < cluster_sizeX * cluster_sizeY; i++) { - s += std::to_string( - *reinterpret_cast(m_data + i * dt.bytes())) + - " "; - } - s += "]"; - return s; - } - /** - * @brief size of the cluster in bytes when saved to a file - */ - size_t size() const { return cluster_sizeX * cluster_sizeY; } - size_t bytes() const { return cluster_sizeX * cluster_sizeY * dt.bytes(); } - auto begin() const { return m_data; } - auto end() const { - return m_data + cluster_sizeX * cluster_sizeY * dt.bytes(); - } - std::byte *data() { return m_data; } -}; - /** * @brief header contained in parts of frames */ diff --git a/python/src/ctb_raw_file.hpp b/python/src/ctb_raw_file.hpp index 5570254a..5a6953b7 100644 --- a/python/src/ctb_raw_file.hpp +++ b/python/src/ctb_raw_file.hpp @@ -9,7 +9,6 @@ #include "aare/decode.hpp" #include "aare/defs.hpp" -// #include "aare/fClusterFileV2.hpp" #include "np_helper.hpp" diff --git a/python/src/file.hpp b/python/src/file.hpp index b6026730..ccb62d1f 100644 --- a/python/src/file.hpp +++ b/python/src/file.hpp @@ -7,7 +7,6 @@ #include "aare/RawSubFile.hpp" #include "aare/defs.hpp" -// #include "aare/fClusterFileV2.hpp" #include #include @@ -195,52 +194,4 @@ void define_file_io_bindings(py::module &m) { }); #pragma GCC diagnostic pop - // py::class_(m, "ClusterHeader") - // .def(py::init<>()) - // .def_readwrite("frame_number", &ClusterHeader::frame_number) - // .def_readwrite("n_clusters", &ClusterHeader::n_clusters) - // .def("__repr__", [](const ClusterHeader &a) { return ""; }); - - // py::class_(m, "ClusterV2_") - // .def(py::init<>()) - // .def_readwrite("x", &ClusterV2_::x) - // .def_readwrite("y", &ClusterV2_::y) - // .def_readwrite("data", &ClusterV2_::data) - // .def("__repr__", [](const ClusterV2_ &a) { return ""; }); - - // py::class_(m, "ClusterV2") - // .def(py::init<>()) - // .def_readwrite("cluster", &ClusterV2::cluster) - // .def_readwrite("frame_number", &ClusterV2::frame_number) - // .def("__repr__", [](const ClusterV2 &a) { return ""; }); - - // py::class_(m, "ClusterFileV2") - // .def(py::init()) - // .def("read", py::overload_cast<>(&ClusterFileV2::read)) - // .def("read", py::overload_cast(&ClusterFileV2::read)) - // .def("frame_number", &ClusterFileV2::frame_number) - // .def("write", py::overload_cast const - // &>(&ClusterFileV2::write)) - - // .def("close", &ClusterFileV2::close); - - // m.def("to_clustV2", [](std::vector &clusters, const int - // frame_number) { - // std::vector clusters_; - // for (auto &c : clusters) { - // ClusterV2 cluster; - // cluster.cluster.x = c.x; - // cluster.cluster.y = c.y; - // int i=0; - // for(auto &d : cluster.cluster.data) { - // d=c.get(i++); - // } - // cluster.frame_number = frame_number; - // clusters_.push_back(cluster); - // } - // return clusters_; - // }); -} +} \ No newline at end of file diff --git a/python/src/raw_master_file.hpp b/python/src/raw_master_file.hpp index b67720b2..7f1837c0 100644 --- a/python/src/raw_master_file.hpp +++ b/python/src/raw_master_file.hpp @@ -8,7 +8,6 @@ #include "aare/RawSubFile.hpp" #include "aare/defs.hpp" -// #include "aare/fClusterFileV2.hpp" #include #include diff --git a/python/src/raw_sub_file.hpp b/python/src/raw_sub_file.hpp index 6e2b6ca1..5359c054 100644 --- a/python/src/raw_sub_file.hpp +++ b/python/src/raw_sub_file.hpp @@ -7,7 +7,6 @@ #include "aare/RawSubFile.hpp" #include "aare/defs.hpp" -// #include "aare/fClusterFileV2.hpp" #include #include diff --git a/python/src/var_cluster.hpp b/python/src/var_cluster.hpp index 3437acd5..44d70db1 100644 --- a/python/src/var_cluster.hpp +++ b/python/src/var_cluster.hpp @@ -1,17 +1,11 @@ // SPDX-License-Identifier: MPL-2.0 #include "aare/VarClusterFinder.hpp" #include "np_helper.hpp" -// #include "aare/defs.hpp" -// #include "aare/fClusterFileV2.hpp" #include -// #include #include -// #include #include #include -// #include -// #include namespace py = pybind11; using namespace ::aare; diff --git a/src/defs.test.cpp b/src/defs.test.cpp index af7902ad..815d4321 100644 --- a/src/defs.test.cpp +++ b/src/defs.test.cpp @@ -22,20 +22,6 @@ TEST_CASE("Enum values") { REQUIRE(static_cast(aare::DetectorType::Moench03) == 100); } -TEST_CASE("DynamicCluster creation") { - aare::DynamicCluster c(13, 15); - REQUIRE(c.cluster_sizeX == 13); - REQUIRE(c.cluster_sizeY == 15); - REQUIRE(c.dt == aare::Dtype(typeid(int32_t))); - REQUIRE(c.data() != nullptr); - - aare::DynamicCluster c2(c); - REQUIRE(c2.cluster_sizeX == 13); - REQUIRE(c2.cluster_sizeY == 15); - REQUIRE(c2.dt == aare::Dtype(typeid(int32_t))); - REQUIRE(c2.data() != nullptr); -} - TEST_CASE("Basic ops on BitOffset") { REQUIRE_THROWS(aare::BitOffset(10));