Skip to content

Commit 68810a2

Browse files
committed
fix cylinder in skeletons and fix pu simtrackster
1 parent 23d93b4 commit 68810a2

File tree

2 files changed

+24
-8
lines changed

2 files changed

+24
-8
lines changed

RecoHGCal/TICL/plugins/SimTrackstersProducer.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ void SimTrackstersProducer::makePUTrackster(const std::vector<float>& inputClust
178178
Trackster tmpTrackster;
179179
for (size_t i = 0; i < output_mask.size(); i++) {
180180
const float remaining_fraction = output_mask[i];
181-
if (remaining_fraction > 0.) {
181+
if (remaining_fraction > std::numeric_limits<float>::epsilon()) {
182182
tmpTrackster.vertices().push_back(i);
183183
tmpTrackster.vertex_multiplicity().push_back(1. / remaining_fraction);
184184
}

RecoHGCal/TICL/plugins/TracksterLinkingbySkeletons.cc

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -170,14 +170,30 @@ std::array<ticl::Vector, 3> TracksterLinkingbySkeletons::findSkeletonNodes(
170170
bool isInCylinder(const std::array<ticl::Vector, 3> &mySkeleton,
171171
const std::array<ticl::Vector, 3> &otherSkeleton,
172172
const float radius_sqr) {
173-
const auto &center = mySkeleton[1];
173+
const auto &first = mySkeleton[0];
174+
const auto &last = mySkeleton[2];
174175
const auto &pointToCheck = otherSkeleton[0];
175-
const auto distance2_xy = (pointToCheck.x() - center.x()) * (pointToCheck.x() - center.x()) +
176-
(pointToCheck.y() - center.y()) * (pointToCheck.y() - center.y());
177-
LogDebug("TracksterLinkingbySkeletons") << " Distance XY " << distance2_xy << std::endl;
178-
bool isWithinZ = std::abs(pointToCheck.z()) >= std::abs(mySkeleton[0].z()) and
179-
std::abs(pointToCheck.z()) <= std::abs(mySkeleton[2].z());
180-
return (distance2_xy <= radius_sqr) && isWithinZ;
176+
177+
const auto &cylAxis = last - first;
178+
const auto &vecToPoint = pointToCheck - first;
179+
180+
auto axisNorm = cylAxis.Dot(cylAxis);
181+
auto projLength = vecToPoint.Dot(cylAxis) / axisNorm;
182+
bool isWithinLength = projLength >= 0 && projLength <= 1;
183+
184+
if (!isWithinLength)
185+
return false;
186+
187+
const auto &proj = cylAxis * projLength;
188+
189+
const auto &pointOnAxis = first + proj;
190+
191+
const auto &distance = pointToCheck - pointOnAxis;
192+
auto distance2 = distance.Dot(distance);
193+
194+
bool isWithinRadius = distance2 <= radius_sqr;
195+
196+
return isWithinRadius;
181197
}
182198

183199
bool TracksterLinkingbySkeletons::areCompatible(const ticl::Trackster &myTrackster,

0 commit comments

Comments
 (0)