9 #include "framework/logging/Logger.h"
10 #include "trg/cdc/NDFinderDefs.h"
11 #include "trg/cdc/Clusterizend.h"
19 if (entry[dim] > 0 || m_params.var_cyclic[dim]) {
24 cell_index Clusterizend::before(cell_index entry, ushort dim)
29 }
else if (m_params.var_cyclic[dim]) {
30 entry[dim] = m_valmax[dim];
33 B2ERROR(
"no before(), check with has_before");
38 bool Clusterizend::has_after(cell_index entry, ushort dim)
40 if (entry[dim] < m_valmax[dim] || m_params.var_cyclic[dim]) {
45 cell_index Clusterizend::after(cell_index entry, ushort dim)
47 if (entry[dim] < m_valmax[dim]) {
50 }
else if (m_params.var_cyclic[dim]) {
54 B2ERROR(
"no after(), check with has_before()");
60 void Clusterizend::blockcheck(vector<cell_index>* neighbors, cell_index elem, ushort dim)
63 B2ERROR(
"dim too large, dim=" << dim);
65 if (has_before(elem, dim)) {
66 cell_index ind = before(elem, dim);
67 ushort leftwe = (*m_houghVals)[ind[0]][ind[1]][ind[2]];
68 ushort leftvi = m_houghVisit[ind[0]][ind[1]][ind[2]];
69 if (leftwe > m_params.minweight && leftvi == 0) {
70 neighbors->push_back(ind);
72 if (m_params.diagonal && dim > 0) {
73 blockcheck(neighbors, ind, dim - 1);
76 if (has_after(elem, dim)) {
77 cell_index ind = after(elem, dim);
78 ushort rightwe = (*m_houghVals)[ind[0]][ind[1]][ind[2]];
79 ushort rightvi = m_houghVisit[ind[0]][ind[1]][ind[2]];
80 if (rightwe > m_params.minweight && rightvi == 0) {
81 neighbors->push_back(ind);
83 if (m_params.diagonal && dim > 0) {
84 blockcheck(neighbors, ind, dim - 1);
89 blockcheck(neighbors, elem, dim - 1);
94 Clusterizend::regionQuery(cell_index entry)
96 vector<cell_index> neighbours;
97 blockcheck(&neighbours, entry, m_dimsize - 1);
101 vector<SimpleCluster>
102 Clusterizend::dbscan()
104 vector<SimpleCluster> C;
105 vector<cell_index> candidates = getCandidates();
106 for (
unsigned long icand = 0; icand < candidates.size(); icand++) {
107 cell_index entry = candidates[icand];
108 c3index iom = entry[0];
109 c3index iph = entry[1];
110 c3index ith = entry[2];
112 if (m_houghVisit[iom][iph][ith] == 0) {
114 m_houghVisit[iom][iph][ith] = 1;
115 vector<cell_index> N = regionQuery(entry);
116 if (N.size() >= m_params.minpts) {
119 expandCluster(N, newcluster);
120 C.push_back(newcluster);
128 Clusterizend::expandCluster(vector<cell_index>& N,
SimpleCluster& C)
130 while (N.size() > 0) {
131 cell_index nextP = N.back();
133 ushort iom = nextP[0];
134 ushort iph = nextP[1];
135 ushort ith = nextP[2];
136 if (m_houghVisit[iom][iph][ith] == 0) {
137 m_houghVisit[iom][iph][ith] = 1;
138 if ((*m_houghVals)[iom][iph][ith] < m_params.minweight) {
141 vector<cell_index> nextN = regionQuery(nextP);
142 if (nextN.size() >= m_params.minpts) {
143 N.insert(N.end(), nextN.begin(), nextN.end());
154 vector<cell_index> candidates;
156 for (c3index iom = 0; iom < 40; iom++) {
157 for (c3index iph = 0; iph < 384; iph++) {
158 for (c3index ith = 0; ith < 9; ith++) {
159 if ((*m_houghVals)[iom][iph][ith] > m_params.minweight) {
160 cell_index elem = {iom, iph, ith};
161 candidates.push_back(elem);
bool has_before(cell_index entry, ushort dim)
Clustering logic.
std::vector< cell_index > getCandidates()
void append(cell_index next_entry)
Add a track-space cell to the cluster.
Abstract base class for different kinds of events.