Public Member Functions | Private Member Functions | List of all members
tss::SimpleClustering Class Reference

#include <SimpleClustering.h>

Public Member Functions

std::vector< tss::Cluster2Drun (const std::vector< tss::Hit2D > &inp) const
 
std::vector< tss::Cluster2Drun (const tss::Cluster2D &inp) const
 
bool hitsTouching (const tss::Hit2D &h1, const tss::Hit2D &h2) const
 
bool hitsTouching (const tss::Cluster2D &c1, const tss::Hit2D &h2) const
 
bool hitsTouching (const tss::Cluster2D &c1, const tss::Cluster2D &c2) const
 

Private Member Functions

void merge (std::vector< tss::Cluster2D > &clusters) const
 

Detailed Description

Definition at line 120 of file SimpleClustering.h.

Member Function Documentation

bool tss::SimpleClustering::hitsTouching ( const tss::Hit2D h1,
const tss::Hit2D h2 
) const

Definition at line 178 of file SimpleClustering.cxx.

179 {
180  if ((h1.Wire() == h2.Wire()) &&
181  (h1.PeakTime() == h2.PeakTime())) return false;
182 
183  bool touches = false;
184  if ((h1.Wire() >= h2.Wire() - 1) &&
185  (h1.Wire() <= h2.Wire() + 1))
186  {
187  if (((h2.StartTick() <= h1.StartTick()) && (h1.StartTick() <= h2.EndTick() + 1)) ||
188  ((h2.StartTick() <= h1.EndTick() + 1) && (h1.EndTick() <= h2.EndTick())) ||
189  ((h2.StartTick() >= h1.StartTick()) && (h1.EndTick() >= h2.EndTick())))
190  {
191  touches = true;
192  }
193  }
194  return touches;
195 }
unsigned int Wire() const
Definition: TssHit2D.h:57
int StartTick() const
Definition: TssHit2D.h:67
float PeakTime() const
Definition: TssHit2D.h:62
int EndTick() const
Definition: TssHit2D.h:72
bool tss::SimpleClustering::hitsTouching ( const tss::Cluster2D c1,
const tss::Hit2D h2 
) const

Definition at line 198 of file SimpleClustering.cxx.

199 {
200  for (size_t i = 0; i < c1.size(); i++)
201  {
202  if (hitsTouching(c1[i], h2)) return true;
203  }
204  return false;
205 }
bool hitsTouching(const tss::Hit2D &h1, const tss::Hit2D &h2) const
size_t size(void) const
bool tss::SimpleClustering::hitsTouching ( const tss::Cluster2D c1,
const tss::Cluster2D c2 
) const

Definition at line 208 of file SimpleClustering.cxx.

209 {
210  for (unsigned int i = 0; i < c1.size(); i++)
211  {
212  if (hitsTouching(c2, c1[i])) return true;
213  }
214  return false;
215 }
bool hitsTouching(const tss::Hit2D &h1, const tss::Hit2D &h2) const
size_t size(void) const
void tss::SimpleClustering::merge ( std::vector< tss::Cluster2D > &  clusters) const
private

Definition at line 218 of file SimpleClustering.cxx.

219 {
220  bool merged = true;
221  while (merged)
222  {
223  merged = false;
224 
225  size_t i = 0;
226  while (i < clusters.size() - 1)
227  {
228  size_t j = i + 1;
229  while (j < clusters.size())
230  {
231  if (hitsTouching(clusters[i], clusters[j]))
232  {
233  clusters[i].hits().reserve(clusters[i].size() + clusters[i].size());
234  for (size_t h = 0; h < clusters[j].size(); ++h)
235  clusters[i].hits().push_back(clusters[j].hits()[h]);
236  clusters.erase(clusters.begin() + j);
237  merged = true;
238  }
239  else ++j;
240  }
241  ++i;
242  }
243  }
244 }
decltype(auto) constexpr size(T &&obj)
ADL-aware version of std::size.
Definition: StdUtils.h:92
bool hitsTouching(const tss::Hit2D &h1, const tss::Hit2D &h2) const
std::vector< tss::Cluster2D > tss::SimpleClustering::run ( const std::vector< tss::Hit2D > &  inp) const

Definition at line 247 of file SimpleClustering.cxx.

248 {
249  std::vector< tss::Cluster2D > result;
250  for (size_t h = 0; h < inp.size(); ++h)
251  {
252  bool found = false;
253  for (size_t r = 0; r < result.size(); ++r)
254  if (hitsTouching(result[r], inp[h]))
255  {
256  result[r].hits().push_back(&(inp[h])); found = true; break;
257  }
258  if (!found)
259  {
260  result.push_back(tss::Cluster2D());
261  result.back().hits().push_back(&(inp[h]));
262  }
263  }
264  merge(result);
265 
266  return result;
267 }
static QCString result
void merge(std::vector< tss::Cluster2D > &clusters) const
bool hitsTouching(const tss::Hit2D &h1, const tss::Hit2D &h2) const
std::vector< tss::Cluster2D > tss::SimpleClustering::run ( const tss::Cluster2D inp) const

Definition at line 270 of file SimpleClustering.cxx.

271 {
272  std::vector< tss::Cluster2D > result;
273  for (size_t h = 0; h < inp.size(); ++h)
274  {
275  bool found = false;
276  for (size_t r = 0; r < result.size(); ++r)
277  if (hitsTouching(result[r], inp[h]))
278  {
279  result[r].hits().push_back(inp.hits()[h]); found = true; break;
280  }
281  if (!found)
282  {
283  result.push_back(tss::Cluster2D());
284  result.back().hits().push_back(inp.hits()[h]);
285  }
286  }
287  merge(result);
288 
289  return result;
290 }
static QCString result
const std::vector< const tss::Hit2D * > & hits(void) const
void merge(std::vector< tss::Cluster2D > &clusters) const
bool hitsTouching(const tss::Hit2D &h1, const tss::Hit2D &h2) const
size_t size(void) const

The documentation for this class was generated from the following files: