From 57917b9a67e82d0f7ac102a44cf5945d8c48a339 Mon Sep 17 00:00:00 2001
From: "s.zharko@gsi.de" <s.zharko@gsi.de>
Date: Thu, 12 May 2022 22:15:51 +0200
Subject: [PATCH] L1Algo: added fieldStatus field to the L1Station structure

---
 reco/L1/CbmL1.cxx                    |  6 +++-
 reco/L1/L1Algo/L1BaseStationInfo.cxx |  8 +++++
 reco/L1/L1Algo/L1BaseStationInfo.h   |  5 +++
 reco/L1/L1Algo/L1Station.cxx         | 50 +++-------------------------
 reco/L1/L1Algo/L1Station.h           | 26 +++++++--------
 5 files changed, 35 insertions(+), 60 deletions(-)

diff --git a/reco/L1/CbmL1.cxx b/reco/L1/CbmL1.cxx
index 0214095084..d79363f5db 100644
--- a/reco/L1/CbmL1.cxx
+++ b/reco/L1/CbmL1.cxx
@@ -983,6 +983,7 @@ InitStatus CbmL1::Init()
       stationInfo.SetStationType(1);
       // MVD // TODO: to be exchanged with specific flags (timeInfo, fieldInfo etc.) (S.Zh.)
       stationInfo.SetTimeInfo(0);
+      stationInfo.SetFieldStatus(fTrackingMode == L1Algo::TrackingMode::kMcbm ? 0 : 1);
       stationInfo.SetZ(t.z);
       stationInfo.SetMaterial(t.dz, t.RadLength);
       stationInfo.SetXmax(t.R);
@@ -1005,7 +1006,7 @@ InitStatus CbmL1::Init()
       // auto stsStation = std::make_unique<L1BaseStationInfo>(L1DetectorID::kSts, iSt);
       stationInfo->SetStationType(0);  // STS
       stationInfo->SetTimeInfo(1);
-
+      stationInfo->SetFieldStatus(fTrackingMode == L1Algo::TrackingMode::kMcbm ? 0 : 1);
       // Setup station geometry and material
       stationInfo->SetZ(cbmSts->GetZ());
       double stsXmax = cbmSts->GetXmax();
@@ -1036,6 +1037,7 @@ InitStatus CbmL1::Init()
       stationInfo.SetStationType(2);
       // MVD // TODO: to be exchanged with specific flags (timeInfo, fieldInfo etc.) (S.Zh.)
       stationInfo.SetTimeInfo(1);
+      stationInfo.SetFieldStatus(0);
       stationInfo.SetZ(layer->GetZ());
       stationInfo.SetMaterial(layer->GetDz(), 10);  // TODO: Why rad len is 0????? (S.Zh.)
       stationInfo.SetXmax(100.);
@@ -1062,6 +1064,7 @@ InitStatus CbmL1::Init()
       int stationType          = (iSt == 1 || iSt == 3) ? 6 : 3;
       stationInfo.SetStationType(stationType);
       stationInfo.SetTimeInfo(1);
+      stationInfo.SetFieldStatus(0);
       stationInfo.SetZ(module->GetZ());
       stationInfo.SetMaterial(2. * module->GetSizeZ(), 10.);
       stationInfo.SetXmax(module->GetSizeX());
@@ -1081,6 +1084,7 @@ InitStatus CbmL1::Init()
       auto stationInfo = L1BaseStationInfo(L1DetectorID::kTof, iSt);
       stationInfo.SetStationType(4);
       stationInfo.SetTimeInfo(1);
+      stationInfo.SetFieldStatus(0);
       stationInfo.SetZ(TofStationZ[iSt]);
       stationInfo.SetMaterial(10., 10.);  // TODO: add Tof width dz and rad. len
       stationInfo.SetXmax(20.);
diff --git a/reco/L1/L1Algo/L1BaseStationInfo.cxx b/reco/L1/L1Algo/L1BaseStationInfo.cxx
index 097e6e617b..05518eb21d 100644
--- a/reco/L1/L1Algo/L1BaseStationInfo.cxx
+++ b/reco/L1/L1Algo/L1BaseStationInfo.cxx
@@ -284,6 +284,14 @@ void L1BaseStationInfo::SetFieldSlice(const std::function<void(const double (&xy
   fInitController.SetFlag(InitKey::keFieldSlice);
 }
 
+//----------------------------------------------------------------------------------------------------------------------//
+//
+void L1BaseStationInfo::SetFieldStatus(int fieldStatus)
+{
+  fL1Station.fieldStatus = fieldStatus;
+  fInitController.SetFlag(InitKey::keFieldStatus);
+}
+
 //----------------------------------------------------------------------------------------------------------------------//
 //
 void L1BaseStationInfo::SetFrontBackStripsGeometry(double frontPhi, double frontSigma, double backPhi, double backSigma)
diff --git a/reco/L1/L1Algo/L1BaseStationInfo.h b/reco/L1/L1Algo/L1BaseStationInfo.h
index 9120ccd6d0..4dfb5b8ccb 100644
--- a/reco/L1/L1Algo/L1BaseStationInfo.h
+++ b/reco/L1/L1Algo/L1BaseStationInfo.h
@@ -38,6 +38,7 @@ public:
     // L1Station initialization
     keType,               ///< station type
     keTimeInfo,           ///< if time info is used (flag)
+    keFieldStatus,        ///< if station is placed in field (flag)
     keZ,                  ///< z coordinate of the station position
     keRmin,               ///< internal radius of station (gap size)
     keRmax,               ///< exteranl radius of station
@@ -99,6 +100,8 @@ public:
   const fvec* GetFieldSliceCy() const { return fL1Station.fieldSlice.cy; }
   /// Gets array of the coefficients for the field z-component approximation
   const fvec* GetFieldSliceCz() const { return fL1Station.fieldSlice.cz; }
+  /// Gets field status: 0 - station is outside the field, 1 - station is inside the field
+  int GetFieldStatus() const { return fL1Station.fieldStatus; }
   /// Gets a const reference to the L1ObjectInitController object
   const L1ObjectInitController_t& GetInitController() const { return fInitController; }
   /// Gets a reference to L1Station info field of the L1BaseStation info
@@ -141,6 +144,8 @@ public:
   //
   /// Sets detector ID
   void SetDetectorID(L1DetectorID inID);
+  /// Sets flag: true - station is placed in field, false - station is placed outside the field
+  void SetFieldStatus(int fieldStatus);
   /// Sets field approximation at the station plain
   /// \param Cx Array of approximation coefficients for x field component
   /// \param Cy Array of approximation coefficients for y field component
diff --git a/reco/L1/L1Algo/L1Station.cxx b/reco/L1/L1Algo/L1Station.cxx
index c6ca03183b..294be0724f 100644
--- a/reco/L1/L1Algo/L1Station.cxx
+++ b/reco/L1/L1Algo/L1Station.cxx
@@ -12,48 +12,7 @@
 // TODO: Improve log style (S.Zh.)
 void L1Station::Print(int verbosity) const
 {
-  // TODO: Probably, it would be nice to use constexpr char indent (S.Zh.)
-  LOG(info) << "\tL1Station object at " << this;
-  LOG(info) << "\t\tStation type ID:             " << type;
-  LOG(info) << "\t\tTime info ID:                " << timeInfo;
-  LOG(info) << "\t\tz position:                  " << z[0];
-  LOG(info) << "\t\tRmin:                        " << Rmin[0];
-  LOG(info) << "\t\tRmax:                        " << Rmax[0];
-  // TODO: Insert correct units (S.Zh.)
-  LOG(info) << "\t\tThickness (X)    :           " << materialInfo.thick[0];
-  LOG(info) << "\t\tRadiational length (X0):     " << materialInfo.RL[0];
-  if (verbosity > 0) {
-    LOG(info) << "\t\tX / X0:                      " << materialInfo.RadThick[0];
-    LOG(info) << "\t\tlog(X / X0):                 " << materialInfo.logRadThick[0];
-    LOG(info) << "\t\tField approximation coefficients:";
-    LOG(info) << "      idx         CX         CY         CZ";
-    for (int idx = 0; idx < L1Parameters::kMaxNFieldApproxCoefficients; ++idx) {
-      LOG(info) << std::setw(9) << std::setfill(' ') << idx << ' ' << std::setw(10) << std::setfill(' ')
-                << fieldSlice.cx[idx][0] << ' ' << std::setw(10) << std::setfill(' ') << fieldSlice.cy[idx][0] << ' '
-                << std::setw(10) << std::setfill(' ') << fieldSlice.cz[idx][0];
-    }
-    LOG(info) << "\t\tStrips geometry:";
-    LOG(info) << "\t\t\tFront:";
-    LOG(info) << "\t\t\t\tcos(phi):            " << frontInfo.cos_phi[0];
-    LOG(info) << "\t\t\t\tsin(phi):            " << frontInfo.sin_phi[0];
-    LOG(info) << "\t\t\t\tsigma2:              " << frontInfo.sigma2[0];
-    LOG(info) << "\t\t\tBack:";
-    LOG(info) << "\t\t\t\tcos(phi):            " << backInfo.cos_phi[0];
-    LOG(info) << "\t\t\t\tsin(phi):            " << backInfo.sin_phi[0];
-    LOG(info) << "\t\t\t\tsigma2:              " << backInfo.sigma2[0];
-    LOG(info) << "\t\t\tXY cov matrix:";
-    LOG(info) << "\t\t\t\tC00:                 " << XYInfo.C00[0];
-    LOG(info) << "\t\t\t\tC10:                 " << XYInfo.C10[0];
-    LOG(info) << "\t\t\t\tC11:                 " << XYInfo.C11[0];
-    LOG(info) << "\t\t\tX layer:";
-    LOG(info) << "\t\t\t\tcos(phi):            " << xInfo.cos_phi[0];
-    LOG(info) << "\t\t\t\tsin(phi):            " << xInfo.sin_phi[0];
-    LOG(info) << "\t\t\t\tsigma2:              " << xInfo.sigma2[0];
-    LOG(info) << "\t\t\tY layer:";
-    LOG(info) << "\t\t\t\tcos(phi):            " << yInfo.cos_phi[0];
-    LOG(info) << "\t\t\t\tsin(phi):            " << yInfo.sin_phi[0];
-    LOG(info) << "\t\t\t\tsigma2:              " << yInfo.sigma2[0];
-  }
+  LOG(info) << ToString(verbosity); 
 }
 
 std::string L1Station::ToString(int verbosityLevel, int indentLevel) const
@@ -63,14 +22,15 @@ std::string L1Station::ToString(int verbosityLevel, int indentLevel) const
   std::string indent(indentLevel, indentChar);
   if (verbosityLevel > 1) {
     // TODO: probably we can have verbosity level and address for each underlying object (S.Zharko)
-    aStream << indent << "Address: " << this << '\n';
+    aStream << '\n' << indent << "Address: " << this << '\n';
   }
   if (verbosityLevel == 0) {
-    aStream << indent << "- L1Station {z [cm], typeID} = " << std::setw(12) << std::setfill(' ') << z[0] << ", " << std::setw(4) << std::setfill(' ') << type;
+    aStream << indent << "- <z [cm], typeID> = " << std::setw(12) << std::setfill(' ') << z[0] << ", " << std::setw(4) << std::setfill(' ') << type;
   }
   else {
     aStream << indent << "Station type ID:  " << std::setw(12) << std::setfill(' ') << type << '\n';
-    aStream << indent << "If time info used:           " << std::setw(12) << std::setfill(' ') << timeInfo << '\n';
+    aStream << indent << "Is time info used:           " << std::setw(12) << std::setfill(' ') << timeInfo << '\n';
+    aStream << indent << "Is station placed in field:  " << std::setw(12) << std::setfill(' ') << fieldStatus << '\n';
     aStream << indent << "z position [cm]:             " << std::setw(12) << std::setfill(' ') << z[0] << '\n';
     aStream << indent << "Rmin [cm]:                   " << std::setw(12) << std::setfill(' ') << Rmin[0] << '\n';
     aStream << indent << "Rmax [cm]:                   " << std::setw(12) << std::setfill(' ') << Rmax[0] << '\n';
diff --git a/reco/L1/L1Algo/L1Station.h b/reco/L1/L1Algo/L1Station.h
index d422382cd6..38f5c5bfea 100644
--- a/reco/L1/L1Algo/L1Station.h
+++ b/reco/L1/L1Algo/L1Station.h
@@ -12,20 +12,16 @@
 #include "L1UMeasurementInfo.h"
 #include "L1XYMeasurementInfo.h"
 
-class L1Station {
-public:
-  // TODO: test this constructors
-  //L1Station(const L1Station &) = default;
-  //L1Station & operator=(const L1Station &) = default;
-  //L1Station(L1Station &&) = default;
-  //L1Station & operator=(L1Station &&) = default;
-
+/// Structure L1Station
+/// Contains a set of geometry parameters for a particular station
+///
+struct L1Station {
   int type {0};
-  int timeInfo {0};  ///< flag: if time information can be used
-  fvec z {0};        ///< z position of station
-  fvec Rmin {0};     ///< min radius of the station
-  fvec Rmax {0};     ///< max radius of the station
-  //fvec Sy {0};  // commented because is not used in the code (S.Zharko)
+  int timeInfo {0};   ///< flag: if time information can be used 
+  int fieldStatus {0};  ///< flag: 1 - station is INSIDE the field, 0 - station is OUTSIDE the field
+  fvec z {0};         ///< z position of station
+  fvec Rmin {0};      ///< min radius of the station
+  fvec Rmax {0};      ///< max radius of the station
   fvec dt {0};
   L1MaterialInfo materialInfo {};
   L1FieldSlice fieldSlice {};
@@ -36,9 +32,11 @@ public:
   L1XYMeasurementInfo XYInfo {};
 
   /// Prints object fields
+  /// \param verbosity  Verbosity level of the output
   void Print(int verbosity = 0) const;
   /// String representation of class contents
-  /// \param indentLevel    number of indent characters in the output
+  /// \param verbosityLevel  Verbosity level of the output
+  /// \param indentLevel     Number of indent characters in the output
   std::string ToString(int verbosityLevel = 0, int indentLevel = 0) const;
 
 } _fvecalignment;
-- 
GitLab