From 6d0de83eeac1917f5e3cd410c4d77c215739d0c8 Mon Sep 17 00:00:00 2001
From: "s.zharko@gsi.de" <s.zharko@gsi.de>
Date: Wed, 11 Oct 2023 16:40:11 +0200
Subject: [PATCH] CA: moving L1InputData and L1IODataManager: elimination of
 the L1IODataManager dependency from L1Algo

---
 reco/L1/CbmL1ReadEvent.cxx         |  2 +-
 reco/L1/L1Algo/L1IODataManager.cxx | 29 +++++++++++++----------------
 reco/L1/L1Algo/L1IODataManager.h   |  3 +++
 3 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/reco/L1/CbmL1ReadEvent.cxx b/reco/L1/CbmL1ReadEvent.cxx
index 241bec19da..82f19b7400 100644
--- a/reco/L1/CbmL1ReadEvent.cxx
+++ b/reco/L1/CbmL1ReadEvent.cxx
@@ -785,7 +785,7 @@ void CbmL1::ReadEvent(CbmEvent* event)
   if (1 == fSTAPDataMode) { WriteSTAPAlgoInputData(nCalls); }
   if (2 == fSTAPDataMode) { ReadSTAPAlgoInputData(nCalls); }
   // TODO: SZh: If we read data from file, we don't need to collect them above. This should be addressed
-  fpIODataManager->SendInputData(fpAlgo);
+  fpAlgo->ReceiveInputData(fpIODataManager->TakeInputData());
 
   if (fPerformance) {
     if (fVerbose >= 10) cout << "HitMatch is done." << endl;
diff --git a/reco/L1/L1Algo/L1IODataManager.cxx b/reco/L1/L1Algo/L1IODataManager.cxx
index ca2719d159..66bffd2d4f 100644
--- a/reco/L1/L1Algo/L1IODataManager.cxx
+++ b/reco/L1/L1Algo/L1IODataManager.cxx
@@ -14,20 +14,17 @@
 
 #include <fstream>
 
-#include "L1Algo.h"
-
-
 // ---------------------------------------------------------------------------------------------------------------------
 //
-bool L1IODataManager::SendInputData(L1Algo* pAlgo)
+bool L1IODataManager::SendInputData(L1InputData& destination)
 {
   // Set boundary hit indexes
   InitData();
 
   // Check data before input
   if (CheckInputData<constants::control::InputDataQaLevel>()) {
-    assert(pAlgo);
-    pAlgo->ReceiveInputData(std::move(fInputData));
+    destination = std::move(fInputData);
+    assert(this->GetNofHits() == 0);
     return true;
   }
   LOG(error) << "L1: Attempt to set up inconsistent input data";
@@ -36,19 +33,19 @@ bool L1IODataManager::SendInputData(L1Algo* pAlgo)
 
 // ---------------------------------------------------------------------------------------------------------------------
 //
-bool L1IODataManager::SendInputData(L1InputData& destination)
+L1InputData&& L1IODataManager::TakeInputData()
 {
-  // Set boundary hit indexes
+  // Init the input data
   InitData();
 
-  // Check data before input
-  if (CheckInputData<constants::control::InputDataQaLevel>()) {
-    destination = std::move(fInputData);
-    assert(this->GetNofHits() == 0);
-    return true;
-  }
-  LOG(error) << "L1: Attempt to set up inconsistent input data";
-  return false;
+  // Check the input data
+  // TODO: Provide assertion
+  // if (CheckInputData<constants::control::InputDataQaLevel>()) {
+  //   pAlgo->ReceiveInputData(std::move(fInputData));
+  //
+  // }
+
+  return std::move(fInputData);
 }
 
 // ---------------------------------------------------------------------------------------------------------------------
diff --git a/reco/L1/L1Algo/L1IODataManager.h b/reco/L1/L1Algo/L1IODataManager.h
index b37d409eda..2c80b3c86c 100644
--- a/reco/L1/L1Algo/L1IODataManager.h
+++ b/reco/L1/L1Algo/L1IODataManager.h
@@ -93,6 +93,9 @@ public:
   /// @param destination  Destination object of input data
   bool SendInputData(L1InputData& destination);
 
+  /// \brief Takes (moves) the instance of the input data object
+  L1InputData&& TakeInputData();
+
   /// Writes input data object to boost-serialized binary file
   /// \param  fileName  Name of input file
   void WriteInputData(const std::string& fileName) const;
-- 
GitLab