From 8ae4ab87ed6b68b5b1fd9f8dd0c5e51700c5d25c Mon Sep 17 00:00:00 2001
From: Paul Schuetze <paul.schuetze@desy.de>
Date: Fri, 27 Mar 2020 14:19:24 +0100
Subject: [PATCH] Bugfix in Tracking4D, accepting tracks with an angle

---
 src/modules/Tracking4D/Tracking4D.cpp | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/src/modules/Tracking4D/Tracking4D.cpp b/src/modules/Tracking4D/Tracking4D.cpp
index cb8755422..4040486b4 100644
--- a/src/modules/Tracking4D/Tracking4D.cpp
+++ b/src/modules/Tracking4D/Tracking4D.cpp
@@ -289,14 +289,20 @@ StatusCode Tracking4D::run(std::shared_ptr<Clipboard> clipboard) {
                 double norm = (distanceX * distanceX) / (spatial_cuts_[det].x() * spatial_cuts_[det].x()) +
                               (distanceY * distanceY) / (spatial_cuts_[det].y() * spatial_cuts_[det].y());
 
-                if(norm > 1) {
-                    continue;
-                }
-
-                // If this is the closest keep it
-                if(distance < closestClusterDistance) {
+                // If this is the second cluster of the track, keep it for now
+                if(refTrack->nClusters() == 1 && ne == 0) {
                     closestClusterDistance = distance;
                     closestCluster = newCluster;
+                } else {
+                    if(norm > 1) {
+                        continue;
+                    }
+
+                    // If this is the closest keep it
+                    if(distance < closestClusterDistance) {
+                        closestClusterDistance = distance;
+                        closestCluster = newCluster;
+                    }
                 }
             }
 
-- 
GitLab