14 fHits.reserve(hits.size());
15 for (
size_t h = 0;
h < hits.size(); ++
h)
fHits.push_back(hits[
h]);
22 if (idx < fHits.size())
25 fHits.erase(fHits.begin() + idx);
33 for (
size_t h = 0;
h < fHits.size(); ++
h)
36 fHits.erase(fHits.begin() +
h);
return true;
44 if (!fHits.size())
return 0;
48 for (
size_t h = 1;
h < fHits.size(); ++
h)
51 if (d < dmin) { dmin = d; hout = fHits[
h]; idx =
h; }
60 if (!fHits.size())
return 0;
62 TVector2
mean(0., 0.);
63 for (
size_t h = 0;
h < fHits.size(); ++
h)
65 mean += fHits[
h]->Point2D();
67 mean *= 1.0 / fHits.size();
71 for (
size_t h = 1;
h < fHits.size(); ++
h)
74 if (d > dmax) { dmax = d; hout = fHits[
h]; idx =
h; }
83 TVector2 minimum = fHits[0]->Point2D();
85 for (
size_t i = 1; i <
size(); ++i)
87 const TVector2
h = fHits[i]->Point2D();
89 if (h.X() < minimum.X()) minimum.Set(h.X(), h.Y());
90 if (h.Y() < minimum.Y()) minimum.Set(minimum.X(), h.Y());
101 TVector2 maximum = fHits[0]->Point2D();
103 for (
size_t i = 1; i <
size(); ++i)
105 const TVector2
h = fHits[i]->Point2D();
107 if (h.X() > maximum.X()) maximum.Set(h.X(), h.Y());
108 if (h.Y() > maximum.Y()) maximum.Set(maximum.X(), h.Y());
118 for (
size_t i = 0; i < fHits.size(); ++i)
119 if (fHits[i] == hit)
return true;
128 double d2, min_d2 =
pma::Dist2(fHits.front()->Point2D(), p2d);
129 for (
size_t i = 1; i < fHits.size(); ++i)
132 if (d2 < min_d2) { min_d2 = d2; }
145 double d2, min_d2 =
pma::Dist2(fHits.front()->Point2D(), p2d);
146 for (
size_t i = 1; i < fHits.size(); ++i)
149 if (d2 < min_d2) { min_d2 = d2; hIdx = i; }
161 double d2, min_d2 = clu.
dist2(fHits.front()->Point2D());
162 for (
size_t i = 1; i < fHits.size(); ++i)
164 d2 = clu.
dist2(fHits[i]->Point2D());
165 if (d2 < min_d2) { min_d2 = d2; }
183 bool touches =
false;
200 for (
size_t i = 0; i < c1.
size(); i++)
202 if (hitsTouching(c1[i], h2))
return true;
210 for (
unsigned int i = 0; i < c1.
size(); i++)
212 if (hitsTouching(c2, c1[i]))
return true;
226 while (i < clusters.size() - 1)
229 while (j < clusters.size())
231 if (hitsTouching(clusters[i], clusters[j]))
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);
249 std::vector< tss::Cluster2D > result;
250 for (
size_t h = 0;
h < inp.size(); ++
h)
253 for (
size_t r = 0;
r < result.size(); ++
r)
254 if (hitsTouching(result[
r], inp[
h]))
256 result[
r].hits().push_back(&(inp[h])); found =
true;
break;
261 result.back().hits().push_back(&(inp[h]));
272 std::vector< tss::Cluster2D > result;
273 for (
size_t h = 0;
h < inp.
size(); ++
h)
276 for (
size_t r = 0;
r < result.size(); ++
r)
277 if (hitsTouching(result[
r], inp[
h]))
279 result[
r].hits().push_back(inp.
hits()[
h]); found =
true;
break;
284 result.back().hits().push_back(inp.
hits()[
h]);
TVector2 const & Point2D() const
double Dist2(const TVector2 &v1, const TVector2 &v2)
unsigned int Wire() const
std::vector< const tss::Hit2D * > fHits
std::size_t size(FixedBins< T, C > const &) noexcept
const Hit2D * outermost(size_t &idx) const
double dist2(const TVector2 &p2d) const
const Hit2D * closest(const TVector2 &p2d, size_t &idx) const
const std::vector< const tss::Hit2D * > & hits(void) const
std::vector< tss::Cluster2D > run(const std::vector< tss::Hit2D > &inp) const
void merge(std::vector< tss::Cluster2D > &clusters) const
const Hit2D * release_at(size_t idx)
bool hitsTouching(const tss::Hit2D &h1, const tss::Hit2D &h2) const
double mean(const std::vector< short > &wf, size_t start, size_t nsample)
bool release(const tss::Hit2D *hit)
const TVector2 max(void) const
const TVector2 min(void) const
bool has(const tss::Hit2D *hit) const