Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion RecoHGCal/TICL/plugins/SimTrackstersProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ void SimTrackstersProducer::makePUTrackster(const std::vector<float>& inputClust
Trackster tmpTrackster;
for (size_t i = 0; i < output_mask.size(); i++) {
const float remaining_fraction = output_mask[i];
if (remaining_fraction > 0.) {
if (remaining_fraction > std::numeric_limits<float>::epsilon()) {
tmpTrackster.vertices().push_back(i);
tmpTrackster.vertex_multiplicity().push_back(1. / remaining_fraction);
}
Expand Down
30 changes: 23 additions & 7 deletions RecoHGCal/TICL/plugins/TracksterLinkingbySkeletons.cc
Original file line number Diff line number Diff line change
Expand Up @@ -170,14 +170,30 @@ std::array<ticl::Vector, 3> TracksterLinkingbySkeletons::findSkeletonNodes(
bool isInCylinder(const std::array<ticl::Vector, 3> &mySkeleton,
const std::array<ticl::Vector, 3> &otherSkeleton,
const float radius_sqr) {
const auto &center = mySkeleton[1];
const auto &first = mySkeleton[0];
const auto &last = mySkeleton[2];
const auto &pointToCheck = otherSkeleton[0];
const auto distance2_xy = (pointToCheck.x() - center.x()) * (pointToCheck.x() - center.x()) +
(pointToCheck.y() - center.y()) * (pointToCheck.y() - center.y());
LogDebug("TracksterLinkingbySkeletons") << " Distance XY " << distance2_xy << std::endl;
bool isWithinZ = std::abs(pointToCheck.z()) >= std::abs(mySkeleton[0].z()) and
std::abs(pointToCheck.z()) <= std::abs(mySkeleton[2].z());
return (distance2_xy <= radius_sqr) && isWithinZ;

const auto &cylAxis = last - first;
const auto &vecToPoint = pointToCheck - first;

auto axisNorm = cylAxis.Dot(cylAxis);
auto projLength = vecToPoint.Dot(cylAxis) / axisNorm;
bool isWithinLength = projLength >= 0 && projLength <= 1;

if (!isWithinLength)
return false;

const auto &proj = cylAxis * projLength;

const auto &pointOnAxis = first + proj;

const auto &distance = pointToCheck - pointOnAxis;
auto distance2 = distance.Dot(distance);

bool isWithinRadius = distance2 <= radius_sqr;

return isWithinRadius;
}

bool TracksterLinkingbySkeletons::areCompatible(const ticl::Trackster &myTrackster,
Expand Down