This is intended to find the medial skeleton given a list of input hit pairs.
160 typedef std::map<const reco::ClusterHit2D*, std::vector<const reco::ClusterHit3D*> > Hit2DtoHit3DMapU;
162 Hit2DtoHit3DMapU hit2DToHit3DMap[3];
164 for(
const auto& hitPair : hitPairList)
170 unsigned status = hitPair->getStatusBits();
172 if ((status & 0x7) != 0x7)
continue;
174 for(
const auto& hit2D : hitPair->getHits())
176 size_t plane = hit2D->WireID().Plane;
178 hit2DToHit3DMap[plane][hit2D].push_back(hitPair);
183 for(
size_t idx = 0; idx < 3; idx++)
185 for(
auto& mapPair : hit2DToHit3DMap[idx])
187 size_t numHitPairs = mapPair.second.size();
188 int planeToCheck = (idx + 1) % 3;
190 if (numHitPairs > 1) std::sort(mapPair.second.begin(), mapPair.second.end(), OrderHitsAlongWire(planeToCheck));
195 int nSkeletonPoints(0);
198 for(
const auto& hitPair : hitPairList)
204 if ((hitPair->getStatusBits() & 0x7) != 7)
continue;
218 size_t numHitPairs[3] = {0, 0, 0};
219 int deltaWires[3] = {0, 0, 0};
220 double planeDeltaT[3] = {0., 0., 0.};
221 double bestDeltaTicks[3] = {0., 0., 0.};
222 int wireNumByPlane[3] = {int(hitPair->getHits()[0]->WireID().Wire),
223 int(hitPair->getHits()[1]->WireID().Wire),
224 int(hitPair->getHits()[2]->WireID().Wire)};
226 size_t bestPlaneIdx(0);
229 for(
size_t planeIdx = 0; planeIdx < 3; planeIdx++)
234 std::vector<const reco::ClusterHit3D*>& hitVec(hit2DToHit3DMap[planeIdx][hit2D]);
236 numHitPairs[planeIdx] = hitVec.size();
238 if (numHitPairs[planeIdx] > 1)
240 int planeToCheck = (planeIdx + 1) % 3;
246 wireNumByPlane[planeToCheck],
251 int deltaFirst = wireNumByPlane[planeToCheck] - firstWire;
252 int deltaLast = wireNumByPlane[planeToCheck] - lastWire;
257 deltaWires[planeIdx] = deltaFirst + deltaLast;
258 numHitPairs[planeIdx] = lastWire - firstWire + 1;
259 planeDeltaT[planeIdx] = fabs(hit2DTimeTicks - hitPair->getHits()[planeToCheck]->getTimeTicks());
264 if (numHitPairs[planeIdx] < numHitPairs[bestPlaneIdx])
266 bestPlaneIdx = planeIdx;
271 if (bestPlaneIdx < 3 && numHitPairs[bestPlaneIdx] > 0)
274 int maxBestWires = 0.05 * numHitPairs[bestPlaneIdx] + 1;
279 if (fabs(deltaWires[bestPlaneIdx]) < maxBestWires + 1)
291 int nextBestIdx = (bestPlaneIdx + 1) % 3;
293 for(
size_t idx = 0; idx < 3; idx++)
295 if (idx == bestPlaneIdx)
continue;
297 if (numHitPairs[idx] < numHitPairs[nextBestIdx]) nextBestIdx = idx;
302 std::cout <<
"***** invalid next best plane: " << nextBestIdx <<
" *******" << std::endl;
306 if (planeDeltaT[bestPlaneIdx] < 1.01*bestDeltaTicks[bestPlaneIdx] && planeDeltaT[nextBestIdx] < 6.01*bestDeltaTicks[nextBestIdx])
316 return nSkeletonPoints;
float getTimeTicks() const
Hit is an "edge" hit.
Hit has been rejected for any reason.
double FindFirstAndLastWires(std::vector< const reco::ClusterHit3D * > &hitVec, int planeToCheck, int referenceWire, double referenceTicks, int &firstWire, int &lastWire) const
A function to find the bounding wires in a given view.
Hit is a "skeleton" hit.
BEGIN_PROLOG could also be cout