From 3bbfcf2a88b395bb72f0eabbff2c27e170078d1f Mon Sep 17 00:00:00 2001
From: "se.gorbunov" <se.gorbunov@gsi.de>
Date: Tue, 10 Sep 2024 09:51:23 +0200
Subject: [PATCH] Ca: revert a wrong fix in branching logic introduced in
 cbb0c4fcaea1e8d16f39653d6aa5aa38adab8e73

---
 algo/ca/core/tracking/CaTrackFinderWindow.cxx | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/algo/ca/core/tracking/CaTrackFinderWindow.cxx b/algo/ca/core/tracking/CaTrackFinderWindow.cxx
index ed2b455cd4..ab40955282 100644
--- a/algo/ca/core/tracking/CaTrackFinderWindow.cxx
+++ b/algo/ca/core/tracking/CaTrackFinderWindow.cxx
@@ -504,7 +504,8 @@ void TrackFinderWindow::CreateTrackCandidates(WindowData& wData, TripletArray_t&
       ca::Branch& tr = fvTrackCandidates.back();
       tr.SetStation(istaF);
       tr.SetId(fvTrackCandidates.size() - 1);
-      tr.SetAlive(true);
+      // Mark the candidate as dead. To became alive it should first pass the competition in DoCompetitionLoop
+      tr.SetAlive(false);
       if constexpr (fDebug) {
         std::stringstream s;
         s << "iter " << wData.CurrentIteration()->GetName() << ", track candidate " << fvTrackCandidates.size() - 1
@@ -517,15 +518,14 @@ void TrackFinderWindow::CreateTrackCandidates(WindowData& wData, TripletArray_t&
       }
     }  // itrip
   }    // istaF
-
-  for (ca::Branch& tr : fvTrackCandidates) {
-    tr.SetAlive(false);
-  }
 }
 
 // ---------------------------------------------------------------------------------------------------------------------
 void TrackFinderWindow::DoCompetitionLoop(const WindowData& wData)
 {
+
+  // look at the dead track candidates in fvTrackCandidates pool; select the best ones and make them alive
+
   for (int iComp = 0; (iComp < 100); ++iComp) {
 
     bool repeatCompetition = false;
@@ -540,7 +540,7 @@ void TrackFinderWindow::DoCompetitionLoop(const WindowData& wData)
         auto updateStrip = [&](int& strip) {
           if ((strip >= 0) && (strip != tr.Id())) {  // strip is used by other candidate
             const auto& other = fvTrackCandidates[strip];
-            if (!other.IsAlive() || tr.IsBetterThan(other)) {
+            if (!other.IsAlive() && tr.IsBetterThan(other)) {
               strip = tr.Id();
             }
             else {
-- 
GitLab