From f09b9e81ae03d27e152b15db0af28a5771ad21e3 Mon Sep 17 00:00:00 2001
From: "s.zharko@gsi.de" <s.zharko@gsi.de>
Date: Mon, 28 Aug 2023 11:05:58 +0200
Subject: [PATCH] CA: the life-time of L1ConfigRW object was limited

---
 reco/L1/L1Algo/L1InitManager.cxx | 13 ++++++++++++-
 reco/L1/L1Algo/L1InitManager.h   | 28 +++++++++++++++-------------
 2 files changed, 27 insertions(+), 14 deletions(-)

diff --git a/reco/L1/L1Algo/L1InitManager.cxx b/reco/L1/L1Algo/L1InitManager.cxx
index 00d5b610c8..0f0f49120e 100644
--- a/reco/L1/L1Algo/L1InitManager.cxx
+++ b/reco/L1/L1Algo/L1InitManager.cxx
@@ -18,6 +18,7 @@
 
 #include "L1Algo.h"
 #include "L1Assert.h"
+#include "L1ConfigRW.h"
 
 using L1Constants::clrs::kCL;   // end colored log
 using L1Constants::clrs::kGNb;  // bold green log
@@ -106,7 +107,7 @@ bool L1InitManager::FormParametersContainer()
   // Read configuration files
   LOG(info) << "L1InitManager: reading parameter configuration ...";
   try {
-    fConfigRW.Read();
+    this->ReadInputConfigs();
     LOG(info) << "L1InitManager: reading parameter configuration ... \033[1;32mdone\033[0m";
   }
   catch (const std::runtime_error& err) {
@@ -289,6 +290,16 @@ void L1InitManager::PushBackCAIteration(const L1CAIteration& iteration)
   fParameters.fCAIterations.push_back(iteration);
 }
 
+// ---------------------------------------------------------------------------------------------------------------------
+//
+void L1InitManager::ReadInputConfigs()
+{
+  L1ConfigRW configRW = L1ConfigRW(this, 4);
+  configRW.SetMainConfigPath(fsConfigInputMain);
+  configRW.SetUserConfigPath(fsConfigInputUser);
+  configRW.Read();
+}
+
 // ---------------------------------------------------------------------------------------------------------------------
 //
 void L1InitManager::ReadParametersObject(const std::string& fileName)
diff --git a/reco/L1/L1Algo/L1InitManager.h b/reco/L1/L1Algo/L1InitManager.h
index d61e1230d3..b73102b3fb 100644
--- a/reco/L1/L1Algo/L1InitManager.h
+++ b/reco/L1/L1Algo/L1InitManager.h
@@ -19,7 +19,6 @@
 
 #include "L1BaseStationInfo.h"
 #include "L1CAIteration.h"
-#include "L1ConfigRW.h"
 #include "L1Constants.h"
 #include "L1EArray.h"
 #include "L1Field.h"
@@ -139,10 +138,6 @@ public:
   /// \return  Success flag
   bool FormParametersContainer();
 
-  /// @brief Accessor to configuration module
-  /// @return  Reference to configuration module
-  L1ConfigRW& GetConfigRW() { return fConfigRW; }
-
   /// @brief  Gets name of the detector
   /// @param  detId Index of the detector
   /// @return Name of the detector
@@ -151,8 +146,11 @@ public:
   /// Gets ghost suppression flag
   int GetGhostSuppression() const { return fParameters.fGhostSuppression; }
 
-  /// Gets a name of the input configuration file
-  const std::string& GetInputConfigName() const { return fConfigInputName; }
+  /// @brief Gets a name of the main input configuration file
+  const std::string& GetInputConfigMain() const { return fsConfigInputMain; }
+
+  /// @brief Gets a name of the user input configuration file
+  const std::string& GetInputConfigUser() const { return fsConfigInputMain; }
 
   /// Gets a const reference to L1ObjectInitController
   const InitController_t& GetInitController() const { return fInitController; }
@@ -196,6 +194,9 @@ public:
   /// Pushes an CA track finder iteration into a sequence of iteration using std::unique_ptr
   void PushBackCAIteration(const std::unique_ptr<L1CAIteration>& puIteration) { PushBackCAIteration(*puIteration); }
 
+  /// @brief Reads main and user parameters configs
+  void ReadInputConfigs();
+
   /// Reads parameters object from boost-serialized binary file
   /// \param  fileName  Name of input file
   void ReadParametersObject(const std::string& fileName);
@@ -211,15 +212,15 @@ public:
   void SetCAIterationsNumberCrosscheck(int nIterations);
 
   /// @brief Sets base configuration file
-  /// @param baseConfig  Path to base configuration file
+  /// @param mainConfig  Path to main configuration file
   /// @note  The base configuraiton file is mandatory until the tracking configuration is initialized from
   ///        beforehand created L1Parameters file.
-  void SetConfigMain(const std::string& baseConfig) { fConfigRW.SetMainConfigPath(baseConfig); }
+  void SetConfigMain(const std::string& mainConfig) { fsConfigInputMain = mainConfig; }
 
   /// @brief Sets user configuration file
   /// @param userConfig  Path to user configuration file
   /// @note  The user configuraiton file is optional
-  void SetConfigUser(const std::string& userConfig) { fConfigRW.SetUserConfigPath(userConfig); }
+  void SetConfigUser(const std::string& userConfig) { fsConfigInputUser = userConfig; }
 
   /// @brief Sets detector names
   /// @param container  Container of the detector names
@@ -348,9 +349,10 @@ private:
   L1Parameters fParameters {};  ///< L1Algo parameters object
 
   // * Configuration related *
-  std::string fConfigInputName {""};              ///< name for the input configuration file
-  std::string fConfigOutputName {""};             ///< name for the output configuration file
-  L1ConfigRW fConfigRW {this, /*verbose = */ 4};  ///< configuration file reader and writer
+  std::string fsConfigInputMain = "";  ///< name for the input configuration file
+  std::string fsConfigInputUser = "";  ///< name for the input configuration file
+  std::string fConfigOutputName = "";  ///< name for the output configuration file
+  //L1ConfigRW fConfigRW {this, /*verbose = */ 4};  ///< configuration file reader and writer
 };
 
 #endif
-- 
GitLab