From 73c63fc1071928fff15d5563f9717a89a31ca7c4 Mon Sep 17 00:00:00 2001
From: "s.zharko@gsi.de" <s.zharko@gsi.de>
Date: Thu, 12 May 2022 21:06:35 +0200
Subject: [PATCH] L1Algo: added fTrackingLevel, fGhostSuppression and
 fMomentumCutOff fields initialization

---
 reco/L1/CbmL1.cxx                |  5 +++++
 reco/L1/L1Algo/L1Algo.cxx        |  4 ++++
 reco/L1/L1Algo/L1InitManager.cxx | 36 ++++++++++++++++++++++++++++++++
 reco/L1/L1Algo/L1InitManager.h   | 33 ++++++++++++++++++++++++-----
 4 files changed, 73 insertions(+), 5 deletions(-)

diff --git a/reco/L1/CbmL1.cxx b/reco/L1/CbmL1.cxx
index 36dd5b6c96..0214095084 100644
--- a/reco/L1/CbmL1.cxx
+++ b/reco/L1/CbmL1.cxx
@@ -913,6 +913,7 @@ InitStatus CbmL1::Init()
 
   {
     if (fSTAPDataMode % 2 == 1) {  // 1,3
+      // TODO: Rewrite parameters i/o into L1InitManager (S.Zharko, 12.05.2022)
       WriteSTAPGeoData(geo);
     };
     //if(fSTAPDataMode >= 2){ // 2,3
@@ -923,6 +924,7 @@ InitStatus CbmL1::Init()
   }
 
   if (fSTAPDataMode >= 2) {  // 2,3
+    // TODO: Rewrite parameters i/o into L1InitManager (S.Zharko, 12.05.2022)
     int ind2, ind = geo.size();
     ReadSTAPGeoData(geo, ind2);
     if (ind2 != ind)
@@ -1249,6 +1251,9 @@ InitStatus CbmL1::Init()
       }
 
       // Set special cuts
+      fpInitManager->SetGhostSuppression(fGhostSuppression);
+      fpInitManager->SetTrackingLevel(fTrackingLevel);
+      fpInitManager->SetMomentumCutOff(fMomentumCutOff);
     }
   }  // L1Algo new init: end
   /********************************************************************************************************************
diff --git a/reco/L1/L1Algo/L1Algo.cxx b/reco/L1/L1Algo/L1Algo.cxx
index b93b904e3b..407071e568 100644
--- a/reco/L1/L1Algo/L1Algo.cxx
+++ b/reco/L1/L1Algo/L1Algo.cxx
@@ -255,6 +255,10 @@ void L1Algo::Init(const L1Vector<fscal>& geo, const bool UseHitErrors, const Tra
 
   // Fill L1Station array
   fInitManager.TransferL1StationArray(fStations);
+  
+  fTrackingLevel = fInitManager.GetTrackingLevel();
+  fGhostSuppression = fInitManager.GetGhostSuppression();
+  fMomentumCutOff = fInitManager.GetMomentumCutOff();
 
   LOG(info) << "  ***********************";
   LOG(info) << "  *  L1Algo parameters  *";
diff --git a/reco/L1/L1Algo/L1InitManager.cxx b/reco/L1/L1Algo/L1InitManager.cxx
index b7c2f19c75..655d5cb058 100644
--- a/reco/L1/L1Algo/L1InitManager.cxx
+++ b/reco/L1/L1Algo/L1InitManager.cxx
@@ -195,6 +195,30 @@ void L1InitManager::SetFieldFunction(const L1FieldFunction_t& fieldFunction)
   }
 }
 
+//-----------------------------------------------------------------------------------------------------------------------
+//
+void L1InitManager::SetGhostSuppression(int ghostSuppression)
+{
+  if (fInitController.GetFlag(InitKey::keGhostSuppression)) {
+    LOG(warn) << "L1InitManager::SetGhostSuppression: attempt of reinitializating the ghost suppresion flag. Ignore";
+    return;
+  }
+  fGhostSuppression = ghostSuppression;
+  fInitController.SetFlag(InitKey::keGhostSuppression);
+}
+
+//-----------------------------------------------------------------------------------------------------------------------
+//
+void L1InitManager::SetMomentumCutOff(float momentumCutOff)
+{
+  if (fInitController.GetFlag(InitKey::keMomentumCutOff)) {
+    LOG(warn) << "L1InitManager::SetMomentumCutOff: attempt of reinitializating the momentum cutoff value. Ignore";
+    return;
+  }
+  fMomentumCutOff = momentumCutOff;
+  fInitController.SetFlag(InitKey::keMomentumCutOff);
+}
+
 //-----------------------------------------------------------------------------------------------------------------------
 //
 void L1InitManager::SetStationsNumberCrosscheck(L1DetectorID detectorID, int nStations)
@@ -235,6 +259,18 @@ void L1InitManager::SetTargetPosition(double x, double y, double z)
   fInitController.SetFlag(InitKey::keTargetPos);
 }
 
+//-----------------------------------------------------------------------------------------------------------------------
+//
+void L1InitManager::SetTrackingLevel(int trackingLevel)
+{
+  if (fInitController.GetFlag(InitKey::keTrackingLevel)) {
+    LOG(warn) << "L1InitManager::SetTrackingLevel: attempt of reinitialization the tracking level. Ignore";
+    return;
+  }
+  fTrackingLevel = trackingLevel;
+  fInitController.SetFlag(InitKey::keTrackingLevel);
+}
+
 //-----------------------------------------------------------------------------------------------------------------------
 //
 void L1InitManager::TransferL1StationArray(std::array<L1Station, L1Parameters::kMaxNstations>& destinationArray)
diff --git a/reco/L1/L1Algo/L1InitManager.h b/reco/L1/L1Algo/L1InitManager.h
index 8d01ccc1a7..410f625754 100644
--- a/reco/L1/L1Algo/L1InitManager.h
+++ b/reco/L1/L1Algo/L1InitManager.h
@@ -57,6 +57,7 @@ enum class L1DetectorID;
 ///
 /// 4. Initialize each station using L1BaseStationInfo:
 ///
+// TODO: Implement mechanism of reinitialization (S.Zharko)
 class L1InitManager {
 private:
   enum class InitKey
@@ -71,7 +72,10 @@ private:
     keStationsInfo,                  ///< 5) If all the planned stations were added to the manager
     keCAIterationsNumberCrosscheck,  ///< 6) If the number of CA track finder is initialized
     keCAIterations,                  ///< 7) If the CA track finder iterations were initialized
-    keEnd                            ///< 8 - number of entries in the enum
+    keTrackingLevel,                 ///< 8)
+    keGhostSuppression,              ///< 9)
+    keMomentumCutOff,                ///< 10) 
+    keEnd                            ///< 11) [technical] number of entries in the enum
   };
 
   using L1DetectorIDIntMap_t     = std::unordered_map<L1DetectorID, int, L1Utils::EnumClassHash>;
@@ -118,6 +122,10 @@ public:
   //
   /// Gets a set of actie detectors for this analysis
   const L1DetectorIDSet_t& GetActiveDetectorIDs() const { return fActiveDetectorIDs; }
+  /// Gets ghost suppression flag
+  int GetGhostSuppression() const { return fGhostSuppression; }
+  /// Gets momentum cutoff
+  float GetMomentumCutOff() const { return fMomentumCutOff; }
   /// Gets a const reference to L1ObjectInitController
   const L1ObjectInitController_t& GetInitController() const { return fInitController; }
   /// Gets a pointer to L1Parameters instance with a posibility of its fields modification
@@ -133,6 +141,8 @@ public:
   const L1FieldValue& GetTargetFieldValue() const { return fTargetFieldValue; }
   /// Gets a target position
   const std::array<double, 3>& GetTargetPosition() const { return fTargetPos; }
+  /// Gets tracking level
+  int GetTrackingLevel() const { return fTrackingLevel; }
 
   /// Calculates L1FieldValue and L1FieldReference values for a selected step in z coordinate from the target position
   /// \param zStep step between nodal points
@@ -160,6 +170,12 @@ public:
   void SetCAIterationsNumberCrosscheck(int nIterations);
   /// Sets a magnetic field function, which will be applied for all the stations
   void SetFieldFunction(const L1FieldFunction_t& fieldFcn);
+  ///
+  void SetGhostSuppression(int ghostSuppression);
+  ///
+  void SetMomentumCutOff(float momentumCutOff);
+  ///
+  void SetTrackingLevel(int trackingLevel);
   /// Sets a number of stations for a particular tracking detector ID to provide initialization cross-check
   void SetStationsNumberCrosscheck(L1DetectorID detectorID, int nStations);
   /// Sets target poisition
@@ -199,17 +215,24 @@ private:
 
   /* Vertex related fields */
 
-  L1FieldValue fTargetFieldValue {};    ///> L1FieldValue object at target
-  L1FieldRegion fTargetFieldRegion {};  ///> L1FieldRegion object at target
+  L1FieldValue fTargetFieldValue {};    ///< L1FieldValue object at target
+  L1FieldRegion fTargetFieldRegion {};  ///< L1FieldRegion object at target
 
   /* CA track finder iterations related */
 
-  //L1Vector<L1CAIteration> fCAIterationsContainer {};  ///> Container for CA track finder iterations
-  int fCAIterationsNumberCrosscheck {-1};  ///> Number of iterations to be passed (must be used for cross-checks)
+  //L1Vector<L1CAIteration> fCAIterationsContainer {};  ///< Container for CA track finder iterations
+  int fCAIterationsNumberCrosscheck {-1};  ///< Number of iterations to be passed (must be used for cross-checks)
 
   /// Pointer to L1Parameters object
   // NOTE: Owner of the object is L1Algo instance
   L1Parameters* fpParameters {nullptr};
+
+  int fTrackingLevel    {0};  ///< tracking level
+  int fGhostSuppression {0};  ///< flag: if true, ghost tracks are suppressed
+  float fMomentumCutOff {0};  ///< minimum momentum of tracks TODO: ?
+  
+ 
+
 };
 
 #endif
-- 
GitLab