From bc79fd046f5885352650927165dd49a1460242c3 Mon Sep 17 00:00:00 2001
From: Dominik Smith <smith@th.physik.uni-frankfurt.de>
Date: Wed, 13 Sep 2023 10:50:32 +0200
Subject: [PATCH] cbm::algo::Clusterizer: Another performance improvement and
 minor bugfix.

---
 algo/detectors/tof/Clusterizer.cxx | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/algo/detectors/tof/Clusterizer.cxx b/algo/detectors/tof/Clusterizer.cxx
index 735ca8349d..6f504cc168 100644
--- a/algo/detectors/tof/Clusterizer.cxx
+++ b/algo/detectors/tof/Clusterizer.cxx
@@ -291,6 +291,8 @@ namespace cbm::algo::tof
         if (lastChanPos) { (*lastChanPos)[chan]++; }
         continue;
       }
+      if (xDigiA->GetTime() > cluster.weightedTime / cluster.weightsSum + fParams.fdMaxTimeDist) { break; }
+
       auto i2 = i1;
 
       while (++i2 < storDigi.end()) {
@@ -440,7 +442,7 @@ namespace cbm::algo::tof
             cluster.reset();
           }
         }
-        cluster.add(pos, time, totSum, totSum, storDigi[0].second, storDigi[1].second);
+        cluster.add(pos, time, totSum, totSum, digiIt->second, std::next(digiIt, 1)->second);
         digiIt += 2;
 
         lastChan = chan;
-- 
GitLab