This is intended to find the medial skeleton given a list of input hit pairs.
154 typedef std::map<const reco::ClusterHit2D*, std::vector<const reco::ClusterHit3D*> > Hit2DtoHit3DMapU;
156 Hit2DtoHit3DMapU hit2DToHit3DMap[3];
158 for(
const auto& hitPair : hitPairList)
163 for(
const auto& hit2D : hitPair->getHits())
165 size_t view = hit2D->getHit().View();
167 hit2DToHit3DMap[view][hit2D].push_back(hitPair);
172 for(
size_t idx = 0; idx < 3; idx++)
174 for(
auto& mapPair : hit2DToHit3DMap[idx])
176 size_t numHitPairs = mapPair.second.size();
178 if (numHitPairs > 1) std::sort(mapPair.second.begin(), mapPair.second.end(), OrderHitsAlongWire(idx));
183 int nSkeletonPoints(0);
186 for(
const auto& hitPair : hitPairList)
192 if (hitPair->getHits().size() < 3)
continue;
206 size_t numHitPairs[3] = {0, 0, 0};
207 int deltaWires[3] = {0, 0, 0};
208 double viewDeltaT[3] = {0., 0., 0.};
209 double bestDeltaTicks[3] = {0., 0., 0.};
210 int wireNumByView[3] = {
int(hitPair->getHits()[0]->getHit().WireID().Wire),
211 int(hitPair->getHits()[1]->getHit().WireID().Wire),
212 int(hitPair->getHits()[2]->getHit().WireID().Wire)};
214 size_t bestViewIdx(0);
217 for(
size_t viewIdx = 0; viewIdx < 3; viewIdx++)
222 std::vector<const reco::ClusterHit3D*>& hitVec(hit2DToHit3DMap[viewIdx][hit2D]);
224 numHitPairs[viewIdx] = hitVec.size();
226 if (numHitPairs[viewIdx] > 1)
228 int viewToCheck = (viewIdx + 1) % 3;
234 wireNumByView[viewToCheck],
239 int deltaFirst = wireNumByView[viewToCheck] - firstWire;
240 int deltaLast = wireNumByView[viewToCheck] - lastWire;
245 deltaWires[viewIdx] = deltaFirst + deltaLast;
246 numHitPairs[viewIdx] = lastWire - firstWire + 1;
247 viewDeltaT[viewIdx] = fabs(hit2DTimeTicks - hitPair->getHits()[viewToCheck]->getTimeTicks());
252 if (numHitPairs[viewIdx] < numHitPairs[bestViewIdx])
254 bestViewIdx = viewIdx;
259 if (bestViewIdx < 3 && numHitPairs[bestViewIdx] > 0)
262 int maxBestWires = 0.05 * numHitPairs[bestViewIdx] + 1;
267 if (fabs(deltaWires[bestViewIdx]) < maxBestWires + 1)
279 int nextBestIdx = (bestViewIdx + 1) % 3;
281 for(
size_t idx = 0; idx < 3; idx++)
283 if (idx == bestViewIdx)
continue;
285 if (numHitPairs[idx] < numHitPairs[nextBestIdx]) nextBestIdx = idx;
290 std::cout <<
"***** invalid next best view: " << nextBestIdx <<
" *******" <<
std::endl;
294 if (viewDeltaT[bestViewIdx] < 1.01*bestDeltaTicks[bestViewIdx] && viewDeltaT[nextBestIdx] < 6.01*bestDeltaTicks[nextBestIdx])
304 return nSkeletonPoints;
float getTimeTicks() const
Hit has been rejected for any reason.
double FindFirstAndLastWires(std::vector< const reco::ClusterHit3D * > &hitVec, int viewToCheck, int referenceWire, double referenceTicks, int &firstWire, int &lastWire) const
A function to find the bounding wires in a given view.
QTextStream & endl(QTextStream &s)