81void pruneOverpopulatedRofs(std::vector<VtxVec>& rofVertices, std::vector<LabVec>& rofLabels,
const float nSigma,
const int minContributors)
83 const int nRofs =
static_cast<int>(rofVertices.size());
84 if (nSigma <= 0.f || nRofs == 0) {
87 std::vector<int> counts(nRofs);
88 for (
int r = 0;
r < nRofs; ++
r) {
89 counts[
r] =
static_cast<int>(rofVertices[
r].size());
91 std::vector<int> sorted(counts);
92 std::sort(sorted.begin(), sorted.end());
95 for (
int i = 0;
i < nUsed; ++
i) {
98 const double mean =
sum / nUsed;
99 const double threshold = mean + nSigma * std::sqrt(mean + 1.);
100 for (
int r = 0;
r < nRofs; ++
r) {
101 if (counts[
r] <= threshold) {
104 auto& vtx = rofVertices[
r];
105 const bool withLabels =
static_cast<int>(rofLabels.size()) == nRofs && rofLabels[
r].
size() == vtx.size();
107 for (
size_t i = 1;
i < vtx.size(); ++
i) {
108 if (vtx[
i].getNContributors() >= minContributors) {
111 rofLabels[
r][out] = rofLabels[
r][
i];
116 LOGP(info,
"Seeding vertexer: overpopulated ROF {} pruned {} -> {} vertices (threshold {:.1f}, mean {:.2f} per ROF)",
r, vtx.size(), out, threshold, mean);
117 vtx.erase(vtx.begin() + out, vtx.end());
119 rofLabels[
r].erase(rofLabels[
r].begin() + out, rofLabels[
r].
end());
void pruneOverpopulatedRofs(std::vector< VtxVec > &rofVertices, std::vector< LabVec > &rofLabels, const float nSigma, const int minContributors)
Caps ROFs whose vertex count is an outlier of the TF.