From 3d61a7c283ce680f7e1ef274c310af2f0ac49faa Mon Sep 17 00:00:00 2001
From: Dominik Smith <smith@th.physik.uni-frankfurt.de>
Date: Tue, 31 Oct 2023 14:29:01 +0100
Subject: [PATCH] Small improvements to cbm::algo::tof::Clusterizer and
 cbm::algo::tof::Calibrate.

---
 algo/detectors/tof/Calibrate.cxx   | 4 ++--
 algo/detectors/tof/Clusterizer.cxx | 3 ++-
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/algo/detectors/tof/Calibrate.cxx b/algo/detectors/tof/Calibrate.cxx
index 720361658e..3c21997517 100644
--- a/algo/detectors/tof/Calibrate.cxx
+++ b/algo/detectors/tof/Calibrate.cxx
@@ -63,7 +63,7 @@ namespace cbm::algo::tof
       mChannelDeadTime[iAddr] = pDigi.GetTime() + rpcPar.channelDeadtime;
 
       // Create calibrated digi
-      CbmTofDigi pCalDigi(pDigi);
+      CbmTofDigi& pCalDigi = calDigiOut.emplace_back(pDigi);
 
       // calibrate Digi Time
       pCalDigi.SetTime(pCalDigi.GetTime() - chanPar.vCPTOff[Side]);
@@ -93,7 +93,6 @@ namespace cbm::algo::tof
         if (0 < iWx) { dWT -= dDTot * (walk[iWx - 1] - walk[iWx]); }
       }
       pCalDigi.SetTime(pCalDigi.GetTime() - dWT);  // calibrate Digi Time
-      calDigiOut.push_back(pCalDigi);
     }
 
     /// Sort the buffers of hits due to the time offsets applied
@@ -101,6 +100,7 @@ namespace cbm::algo::tof
               [](const CbmTofDigi& a, const CbmTofDigi& b) -> bool { return a.GetTime() < b.GetTime(); });
 
     monitor.fTime = xpu::pop_timer();
+    //L_(info) << MakeReport("CalibrateTime", monitor.fTime);
 
     return result;
   }
diff --git a/algo/detectors/tof/Clusterizer.cxx b/algo/detectors/tof/Clusterizer.cxx
index 640481411c..b71c1cace4 100644
--- a/algo/detectors/tof/Clusterizer.cxx
+++ b/algo/detectors/tof/Clusterizer.cxx
@@ -144,7 +144,7 @@ namespace cbm::algo::tof
         lastChan = chan;
         lastPosY = pos.Y();
         lastTime = time;
-        if (AddNextChan(input, lastChan, cluster, clustersOut, &lastChanPos)) { cluster.reset(); }
+        AddNextChan(input, lastChan, cluster, clustersOut, &lastChanPos);
       }                  // while( 1 < storDigi.size() )
       storDigi.clear();  //D.Smith 11.8.23: In rare cases, a single digi remains and is deleted here.
     }                    // for( int32_t chan = 0; chan < iNbCh; chan++ )
@@ -249,6 +249,7 @@ namespace cbm::algo::tof
     cluster.normalize(fParams.fTimeRes);
     cluster.finalize(detcell, fParams);
     clustersOut.push_back(cluster);
+    cluster.reset();
     return true;
   }
 
-- 
GitLab