9#include <pxd/reconstruction/ClusterCache.h>
10#include <gtest/gtest.h>
48 for (
int v = 0; v < 4; ++v) {
49 for (
int u = 0; u < 5; ++u) {
50 if (v == 0 && u <= 2)
continue;
53 if ((v == 0 && u == 3) || (v == 1 && u >= 1 && u <= 3)) {
55 EXPECT_EQ(&cls1, &cache.
findCluster(u, v)) <<
"u: " << u <<
" v: " << v;
58 EXPECT_NE(&cls1, &cache.
findCluster(u, v)) <<
"u: " << u <<
" v: " << v;
104 ASSERT_EQ(2u, foundX.
size());
106 EXPECT_TRUE(&foundX == &cls1 || &foundX == &cls2);
108 EXPECT_EQ(3u, foundX.
pixels()[0].getIndex() + foundX.
pixels()[1].getIndex());
110 EXPECT_TRUE((cls1.
size() == 0 && cls2.
size() == 2) || (cls1.
size() == 2 && cls2.
size() == 0));
116 EXPECT_EQ(4u, foundY.
size());
121 EXPECT_EQ(foundX.
merge(t1), foundY.
merge(t2));
127 ASSERT_EQ(7u, foundY.
size());
132 EXPECT_EQ(foundX.
merge(t1), foundZ.
merge(t2));
136 std::bitset<7> check_index(-1);
138 ASSERT_LT(0u, px.getIndex());
139 ASSERT_GE(7u, px.getIndex());
140 EXPECT_TRUE(check_index[px.getIndex() - 1]) <<
"index: " << px.getIndex();
141 check_index[px.getIndex() - 1] =
false;
143 EXPECT_TRUE(check_index.none());
152 ASSERT_TRUE(cache.
empty());
154 ASSERT_FALSE(cache.
empty());
161 for (
int i = -10; i < 260; ++i) {
162 if (i >= 0 && i < 250) {
165 ASSERT_THROW(cache.
findCluster(i, 0), std::out_of_range);
Class to remember recently assigned clusters This class will remember the current and the last pixel ...
ClusterCandidate & findCluster(unsigned int u, unsigned int v)
Find a cluster adjacent to the given coordinates.
bool empty() const
Check if there are any clusters.
void clear()
Clear the cache structure.
Class representing a possible cluster during clustering of the PXD It supports merging of different c...
size_t size() const
get the cluster size
ClusterCandidate * merge(ClusterCandidate &cls)
Merge the given cluster with this one.
void add(const Pixel &pixel)
Add a Pixel to the current cluster.
const std::vector< Pixel > & pixels() const
get a reference to all pixels in the cluster
Class to represent one pixel, used in clustering for fast access.
Abstract base class for different kinds of events.