From f3b02e92a76b772e3aec7638eea797824101c7ca Mon Sep 17 00:00:00 2001
From: Felix Weiglhofer <weiglhofer@fias.uni-frankfurt.de>
Date: Sat, 28 Oct 2023 13:25:50 +0200
Subject: [PATCH] algo: Initialize  tof::CalibrateChain.

---
 algo/detectors/tof/CalibratorChain.cxx | 3 ++-
 algo/detectors/tof/Hitfind.h           | 1 -
 algo/detectors/tof/HitfinderChain.cxx  | 1 -
 algo/global/Reco.cxx                   | 2 +-
 4 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/algo/detectors/tof/CalibratorChain.cxx b/algo/detectors/tof/CalibratorChain.cxx
index 4a9a35147a..6d1b30d489 100644
--- a/algo/detectors/tof/CalibratorChain.cxx
+++ b/algo/detectors/tof/CalibratorChain.cxx
@@ -19,6 +19,7 @@ CalibratorChain::ReturnType CalibratorChain::Run(gsl::span<CbmTofDigi> digis)
 {
   auto ret = (*fCalibrate)(digis);
 
-  L_(error) << "TOF Digis with unknown RPCs: " << std::get<1>(ret).fDigiCalibUnknownRPC;
+  auto nUnknownRPC = std::get<1>(ret).fDigiCalibUnknownRPC;
+  if (nUnknownRPC > 0) L_(error) << "TOF Digis with unknown RPCs: " << nUnknownRPC;
   return ret;
 }
diff --git a/algo/detectors/tof/Hitfind.h b/algo/detectors/tof/Hitfind.h
index 0b02d2d201..0d0fe25418 100644
--- a/algo/detectors/tof/Hitfind.h
+++ b/algo/detectors/tof/Hitfind.h
@@ -32,7 +32,6 @@ namespace cbm::algo::tof
     xpu::timings fTime;
     size_t fNumDigis            = 0;
     size_t fNumHits             = 0;
-    size_t fDigiCalibUnknownRPC = 0;
 
     std::string print() const
     {
diff --git a/algo/detectors/tof/HitfinderChain.cxx b/algo/detectors/tof/HitfinderChain.cxx
index d23e9aea52..9faaa9e600 100644
--- a/algo/detectors/tof/HitfinderChain.cxx
+++ b/algo/detectors/tof/HitfinderChain.cxx
@@ -21,6 +21,5 @@ HitfinderChain::ReturnType HitfinderChain::Run(gsl::span<CbmTofDigi> digis)
   auto ret = (*fHitfind)(digis);
 
   L_(info) << "TS contains " << std::get<0>(ret).NElements() << " TOF Hits";
-  L_(error) << "TOF Digis with unknown RPCs: " << std::get<1>(ret).fDigiCalibUnknownRPC;
   return ret;
 }
diff --git a/algo/global/Reco.cxx b/algo/global/Reco.cxx
index 83ebb30c9d..2392645e35 100644
--- a/algo/global/Reco.cxx
+++ b/algo/global/Reco.cxx
@@ -45,6 +45,7 @@ void Reco::Init(const Options& opts)
   SetContext(&fContext);
   fUnpack.SetContext(&fContext);
   fStsHitFinder.SetContext(&fContext);
+  fTofCalibrator.SetContext(&fContext);
   fTofHitFinder.SetContext(&fContext);
   fTracking.SetContext(&fContext);
 
@@ -293,7 +294,6 @@ void Reco::QueueTofRecoMetrics(const tof::HitfindMonitorData& mon)
                              {"tofRecoThroughput", mon.fTime.throughput()},
                              {"tofRecoNumDigisIn", mon.fNumDigis},
                              {"tofRecoNumHits", mon.fNumHits},
-                             {"tofRecoUnknownRPC", mon.fDigiCalibUnknownRPC},
                            });
 }
 
-- 
GitLab