From 5abab33c44a1557536145db093daf7169d24db72 Mon Sep 17 00:00:00 2001
From: Dario Ramirez <d.ramirez@gsi.de>
Date: Mon, 14 Apr 2025 12:49:07 +0200
Subject: [PATCH 01/18] Add features: 1. CbmCutId + CbmCutMap: utilities to
 filter data based on user define cuts 2. CbmStsAnaBase: base class for STS
 analysis derived from FairTask - includes task independent histograming
 utilities 3. CbmStsAnalysis: derived class from FairRunAna to include used
 define analysis cuts 4. StsUtils: helper functions for STS data and
 histograming tools

---
 analysis/detectors/sts/CMakeLists.txt     |   7 +
 analysis/detectors/sts/CbmCut.h           |  87 ++++++++++++
 analysis/detectors/sts/CbmCutId.cxx       | 121 ++++++++++++++++
 analysis/detectors/sts/CbmCutId.h         | 160 ++++++++++++++++++++++
 analysis/detectors/sts/CbmCutMap.cxx      |  52 +++++++
 analysis/detectors/sts/CbmCutMap.h        | 101 ++++++++++++++
 analysis/detectors/sts/CbmStsAnaBase.cxx  | 126 +++++++++++++++++
 analysis/detectors/sts/CbmStsAnaBase.h    | 106 ++++++++++++++
 analysis/detectors/sts/CbmStsAnaLinkDef.h |   4 +
 analysis/detectors/sts/CbmStsAnalysis.cxx |  16 +++
 analysis/detectors/sts/CbmStsAnalysis.h   |  39 ++++++
 analysis/detectors/sts/CbmStsUtils.cxx    | 138 +++++++++++++++++++
 analysis/detectors/sts/CbmStsUtils.h      | 112 +++++++++++++++
 13 files changed, 1069 insertions(+)
 create mode 100644 analysis/detectors/sts/CbmCut.h
 create mode 100644 analysis/detectors/sts/CbmCutId.cxx
 create mode 100644 analysis/detectors/sts/CbmCutId.h
 create mode 100644 analysis/detectors/sts/CbmCutMap.cxx
 create mode 100644 analysis/detectors/sts/CbmCutMap.h
 create mode 100644 analysis/detectors/sts/CbmStsAnaBase.cxx
 create mode 100644 analysis/detectors/sts/CbmStsAnaBase.h
 create mode 100644 analysis/detectors/sts/CbmStsAnalysis.cxx
 create mode 100644 analysis/detectors/sts/CbmStsAnalysis.h
 create mode 100644 analysis/detectors/sts/CbmStsUtils.cxx
 create mode 100644 analysis/detectors/sts/CbmStsUtils.h

diff --git a/analysis/detectors/sts/CMakeLists.txt b/analysis/detectors/sts/CMakeLists.txt
index 6b4a0ac3ee..ed34b01e54 100644
--- a/analysis/detectors/sts/CMakeLists.txt
+++ b/analysis/detectors/sts/CMakeLists.txt
@@ -7,6 +7,12 @@ set(INCLUDE_DIRECTORIES
 
 set(SRCS
   CbmStsWkn.cxx
+
+  CbmCutId.cxx
+  CbmCutMap.cxx
+  CbmStsAnaBase.cxx
+  CbmStsUtils.cxx
+  CbmStsAnalysis.cxx
   )
 
 
@@ -14,6 +20,7 @@ set(LIBRARY_NAME CbmStsAna)
 set(LINKDEF ${LIBRARY_NAME}LinkDef.h)
 set(PUBLIC_DEPENDENCIES
   ROOT::Core
+  CbmStsBase
   )
 
 set(PRIVATE_DEPENDENCIES
diff --git a/analysis/detectors/sts/CbmCut.h b/analysis/detectors/sts/CbmCut.h
new file mode 100644
index 0000000000..87140fa5e8
--- /dev/null
+++ b/analysis/detectors/sts/CbmCut.h
@@ -0,0 +1,87 @@
+
+/* Copyright (C) 2022 Facility for Antiproton and Ion Research in Europe, Darmstadt
+   SPDX-License-Identifier: GPL-3.0-only
+   Authors: Dario Ramirez [committer] */
+
+#ifndef CBMCUT_H
+#define CBMCUT_H
+
+#include "CbmCutId.h"
+
+#include <type_traits>
+
+
+template<typename T>
+class CbmCut {
+ public:
+  /**
+   * @brief Default constructor
+   * Any check done to a non-configured object CbmCut will pass
+    */
+  CbmCut() {}
+
+  /**
+   * @brief Add a CbmTarget object to the list of targets with a key as trg_name.
+   * @param min Minimum value for the check
+   * @param max Maximum value for the check
+  * When this constructor is created, check will be done for each boundary
+    */
+  CbmCut(T min, T max)
+  {
+    SetMin(min);
+    SetMax(max);
+  }
+
+  /**
+   * @brief Check if the T is inside the configured ranges [min, max].
+   * @param a Object for which operators <= >= == is implemented
+   * @return true or false depending on two possible general cases
+   * Case 1
+   * -----------------########## TRUE ##########-----------------
+   *              @MIN                         @MAX
+   *
+   * Case 2
+   * #### TRUE ####--------------------------------#### TRUE ####
+   *              @MAX                         @MIN
+   */
+  bool Check(T a)
+  {
+    bool check_min_status = min_state_ ? a >= min_ : true;
+    bool check_max_status = max_state_ ? a <= max_ : true;
+    if (min_state_ && max_state_ && (max_ < min_)) return check_min_status || check_max_status;
+    return check_min_status && check_max_status;
+  }
+
+  void SetMin(T val)
+  {
+    min_       = val;
+    min_state_ = true;
+  }
+  void SetMax(T val)
+  {
+    max_       = val;
+    max_state_ = true;
+  }
+  void SetRange(T min_val, T max_val)
+  {
+    SetMin(min_val);
+    SetMax(max_val);
+  }
+
+  friend std::ostream& operator<<(std::ostream& out, const CbmCut<T>& obj)
+  {
+    std::string min_msg = obj.min_state_ ? std::to_string(obj.min_) : "none";
+    std::string max_msg = obj.max_state_ ? std::to_string(obj.max_) : "none";
+    out << "[Min: " << min_msg << " , Max: " << max_msg << "]";
+    return out;
+  }
+
+
+ private:
+  bool min_state_ = false;
+  bool max_state_ = false;
+  T min_;
+  T max_;
+};
+
+#endif
diff --git a/analysis/detectors/sts/CbmCutId.cxx b/analysis/detectors/sts/CbmCutId.cxx
new file mode 100644
index 0000000000..1f85eb8199
--- /dev/null
+++ b/analysis/detectors/sts/CbmCutId.cxx
@@ -0,0 +1,121 @@
+/* Copyright (C) 2022 Facility for Antiproton and Ion Research in Europe, Darmstadt
+   SPDX-License-Identifier: GPL-3.0-only
+   Authors: Dario Ramirez [committer] */
+
+#include "CbmCutId.h"
+
+static std::unordered_map<CbmCutId, std::string> cut_id_to_str_map = {
+  {CbmCutId::kBmonDigiChannel, "kBmonDigiChannel"},
+  {CbmCutId::kBmonDigiSide, "kBmonDigiSide"},
+  {CbmCutId::kMvdDigiChannel, "kMvdDigiChannel"},
+  {CbmCutId::kMvdDigiCharge, "kMvdDigiCharge"},
+  {CbmCutId::kMvdDigiTime, "kMvdDigiTime"},
+  {CbmCutId::kStsDigiChannel, "kStsDigiChannel"},
+  {CbmCutId::kStsDigiCharge, "kStsDigiCharge"},
+  {CbmCutId::kStsDigiTime, "kStsDigiTime"},
+  {CbmCutId::kRichDigiChannel, "kRichDigiChannel"},
+  {CbmCutId::kRichDigiCharge, "kRichDigiCharge"},
+  {CbmCutId::kRichDigiTime, "kRichDigiTime"},
+  {CbmCutId::kMuchigiChannel, "kMuchigiChannel"},
+  {CbmCutId::kMuchigiCharge, "kMuchigiCharge"},
+  {CbmCutId::kMuchigiTime, "kMuchigiTime"},
+  {CbmCutId::kTrdDigiChannel, "kTrdDigiChannel"},
+  {CbmCutId::kTrdDigiCharge, "kTrdDigiCharge"},
+  {CbmCutId::kTrdDigiTime, "kTrdDigiTime"},
+  {CbmCutId::kTofDigiChannel, "kTofDigiChannel"},
+  {CbmCutId::kTofDigiCharge, "kTofDigiCharge"},
+  {CbmCutId::kTofDigiTime, "kTofDigiTime"},
+  {CbmCutId::kStsClusterAddress, "kStsClusterAddress"},
+  {CbmCutId::kStsClusterTime, "kStsClusterTime"},
+  {CbmCutId::kStsClusterCharge, "kStsClusterCharge"},
+  {CbmCutId::kStsClusterSize, "kStsClusterSize"},
+  {CbmCutId::kStsClusterPosition, "kStsClusterPosition"},
+  {CbmCutId::kMvdHitAddress, "kMvdHitAddress"},
+  {CbmCutId::kMvdHitTime, "kMvdHitTime"},
+  {CbmCutId::kMvdHitCharge, "kMvdHitCharge"},
+  {CbmCutId::kMvdHitX, "kMvdHitX"},
+  {CbmCutId::kMvdHitY, "kMvdHitY"},
+  {CbmCutId::kMvdHitZ, "kMvdHitZ"},
+  {CbmCutId::kStsHitAddress, "kStsHitAddress"},
+  {CbmCutId::kStsHitTime, "kStsHitTime"},
+  {CbmCutId::kStsHitCharge, "kStsHitCharge"},
+  {CbmCutId::kStsHitQasym, "kStsHitQasym"},
+  {CbmCutId::kStsHitX, "kStsHitX"},
+  {CbmCutId::kStsHitY, "kStsHitY"},
+  {CbmCutId::kStsHitZ, "kStsHitZ"},
+  {CbmCutId::kRichHitAddress, "kRichHitAddress"},
+  {CbmCutId::kRichHitTime, "kRichHitTime"},
+  {CbmCutId::kRichHitCharge, "kRichHitCharge"},
+  {CbmCutId::kRichHitX, "kRichHitX"},
+  {CbmCutId::kRichHitY, "kRichHitY"},
+  {CbmCutId::kRichHitZ, "kRichHitZ"},
+  {CbmCutId::kMuchHitAddress, "kMuchHitAddress"},
+  {CbmCutId::kMuchHitTime, "kMuchHitTime"},
+  {CbmCutId::kMuchHitCharge, "kMuchHitCharge"},
+  {CbmCutId::kMuchHitX, "kMuchHitX"},
+  {CbmCutId::kMuchHitY, "kMuchHitY"},
+  {CbmCutId::kMuchHitZ, "kMuchHitZ"},
+  {CbmCutId::kTrdHitAddress, "kTrdHitAddress"},
+  {CbmCutId::kTrdHitTime, "kTrdHitTime"},
+  {CbmCutId::kTrdHitCharge, "kTrdHitCharge"},
+  {CbmCutId::kTrdHitX, "kTrdHitX"},
+  {CbmCutId::kTrdHitY, "kTrdHitY"},
+  {CbmCutId::kTrdHitZ, "kTrdHitZ"},
+  {CbmCutId::kTofHitAddress, "kTofHitAddress"},
+  {CbmCutId::kTofHitTime, "kTofHitTime"},
+  {CbmCutId::kTofHitCharge, "kTofHitCharge"},
+  {CbmCutId::kTofHitX, "kTofHitX"},
+  {CbmCutId::kTofHitY, "kTofHitY"},
+  {CbmCutId::kTofHitZ, "kTofHitZ"},
+  {CbmCutId::kEventNofMvdHit, "kEventNofMvdHit"},
+  {CbmCutId::kEventNofStsHit, "kEventNofStsHit"},
+  {CbmCutId::kEventNofRichHit, "kEventNofRichHit"},
+  {CbmCutId::kEventNofRichRing, "kEventNofRichRing"},
+  {CbmCutId::kEventNofMuchPixelHit, "kEventNofMuchPixelHit"},
+  {CbmCutId::kEventNofMuchStrawHit, "kEventNofMuchStrawHit"},
+  {CbmCutId::kEventNofTrdHit, "kEventNofTrdHit"},
+  {CbmCutId::kEventNofTofHit, "kEventNofTofHit"},
+  {CbmCutId::kEventNofGlobalTrack, "kEventNofGlobalTrack"},
+  {CbmCutId::kMvdTrackChi2, "kMvdTrackChi2"},
+  {CbmCutId::kMvdTrackSize, "kMvdTrackSize"},
+  {CbmCutId::kStsTrackChi2, "kStsTrackChi2"},
+  {CbmCutId::kStsTrackSize, "kStsTrackSize"},
+  {CbmCutId::kRichTrackChi2, "kRichTrackChi2"},
+  {CbmCutId::kRichTrackSize, "kRichTrackSize"},
+  {CbmCutId::kMuchTrackChi2, "kMuchTrackChi2"},
+  {CbmCutId::kMuchTrackSize, "kMuchTrackSize"},
+  {CbmCutId::kTrdTrackChi2, "kTrdTrackChi2"},
+  {CbmCutId::kTrdTrackSize, "kTrdTrackSize"},
+  {CbmCutId::kTofTrackChi2, "kTofTrackChi2"},
+  {CbmCutId::kTofTrackSize, "kTofTrackSize"},
+  {CbmCutId::kGlobalTrackChi2, "kGlobalTrackChi2"},
+  {CbmCutId::kGlobalTrackPval, "kGlobalTrackPval"},
+  {CbmCutId::kGlobalTrackSize, "kGlobalTrackSize"},
+  {CbmCutId::kGlobalTrackLength, "kGlobalTrackLength"},
+  {CbmCutId::kGlobalTrackMvdChi2, "kGlobalTrackMvdChi2"},
+  {CbmCutId::kGlobalTrackMvdSize, "kGlobalTrackMvdSize"},
+  {CbmCutId::kGlobalTrackStsChi2, "kGlobalTrackStsChi2"},
+  {CbmCutId::kGlobalTrackStsSize, "kGlobalTrackStsSize"},
+  {CbmCutId::kGlobalTrackRichChi2, "kGlobalTrackRichChi2"},
+  {CbmCutId::kGlobalTrackRichSize, "kGlobalTrackRichSize"},
+  {CbmCutId::kGlobalTrackMuchChi2, "kGlobalTrackMuchChi2"},
+  {CbmCutId::kGlobalTrackMuchSize, "kGlobalTrackMuchSize"},
+  {CbmCutId::kGlobalTrackTrdChi2, "kGlobalTrackTrdChi2"},
+  {CbmCutId::kGlobalTrackTrdSize, "kGlobalTrackTrdSize"},
+  {CbmCutId::kGlobalTrackTofChi2, "kGlobalTrackTofChi2"},
+  {CbmCutId::kGlobalTrackTofSize, "kGlobalTrackTofSize"}};
+
+std::string ToString(CbmCutId id)
+{
+  auto result = cut_id_to_str_map.find(id);
+  if (result == cut_id_to_str_map.end()) {
+    return "NotExist";
+  }
+  return result->second;
+};
+
+std::ostream& operator<<(std::ostream& strm, const CbmCutId& cut_id)
+{
+  strm << ToString(cut_id);
+  return strm;
+}
\ No newline at end of file
diff --git a/analysis/detectors/sts/CbmCutId.h b/analysis/detectors/sts/CbmCutId.h
new file mode 100644
index 0000000000..ece390f7bb
--- /dev/null
+++ b/analysis/detectors/sts/CbmCutId.h
@@ -0,0 +1,160 @@
+/** \file CbmCutId.h
+ * \brief Definition of the CbmCutId enum class and related functions.
+ *
+ * Copyright (C) 2022 Facility for Antiproton and Ion Research in Europe, Darmstadt
+ * SPDX-License-Identifier: GPL-3.0-only
+ * Authors: Dario Ramirez [committer]
+ */
+
+#ifndef CBMCUTID_H
+#define CBMCUTID_H
+
+#include <iostream>
+#include <unordered_map>
+
+/** \enum CbmCutId
+ * \brief Enumeration of cut identifiers for various observables.
+ */
+enum class CbmCutId : ushort
+{
+  // Digi
+  kBmonDigiChannel,
+  kBmonDigiSide,
+
+  kMvdDigiChannel,
+  kMvdDigiCharge,
+  kMvdDigiTime,
+
+  kStsDigiChannel,
+  kStsDigiCharge,
+  kStsDigiTime,
+
+  kRichDigiChannel,
+  kRichDigiCharge,
+  kRichDigiTime,
+
+  kMuchigiChannel,
+  kMuchigiCharge,
+  kMuchigiTime,
+
+  kTrdDigiChannel,
+  kTrdDigiCharge,
+  kTrdDigiTime,
+
+  kTofDigiChannel,
+  kTofDigiCharge,
+  kTofDigiTime,
+
+  // Cluster
+  kStsClusterAddress,
+  kStsClusterTime,
+  kStsClusterCharge,
+  kStsClusterSize,
+  kStsClusterPosition,
+
+  // Hit
+  kMvdHitAddress,
+  kMvdHitTime,
+  kMvdHitCharge,
+  kMvdHitX,
+  kMvdHitY,
+  kMvdHitZ,
+
+  kStsHitAddress,
+  kStsHitTime,
+  kStsHitCharge,
+  kStsHitQasym,
+  kStsHitX,
+  kStsHitY,
+  kStsHitZ,
+
+  kRichHitAddress,
+  kRichHitTime,
+  kRichHitCharge,
+  kRichHitX,
+  kRichHitY,
+  kRichHitZ,
+
+  kMuchHitAddress,
+  kMuchHitTime,
+  kMuchHitCharge,
+  kMuchHitX,
+  kMuchHitY,
+  kMuchHitZ,
+
+  kTrdHitAddress,
+  kTrdHitTime,
+  kTrdHitCharge,
+  kTrdHitX,
+  kTrdHitY,
+  kTrdHitZ,
+
+  kTofHitAddress,
+  kTofHitTime,
+  kTofHitCharge,
+  kTofHitX,
+  kTofHitY,
+  kTofHitZ,
+
+  // Event
+  kEventNofMvdHit,
+  kEventNofStsHit,
+  kEventNofRichHit,
+  kEventNofRichRing,
+  kEventNofMuchPixelHit,
+  kEventNofMuchStrawHit,
+  kEventNofTrdHit,
+  kEventNofTofHit,
+  kEventNofGlobalTrack,
+
+  // Detector tracks
+  kMvdTrackChi2,
+  kMvdTrackSize,
+
+  kStsTrackChi2,
+  kStsTrackSize,
+
+  kRichTrackChi2,
+  kRichTrackSize,
+
+  kMuchTrackChi2,
+  kMuchTrackSize,
+
+  kTrdTrackChi2,
+  kTrdTrackSize,
+
+  kTofTrackChi2,
+  kTofTrackSize,
+
+  // Global tracks
+  kGlobalTrackChi2,
+  kGlobalTrackPval,
+  kGlobalTrackSize,
+  kGlobalTrackLength,
+
+  kGlobalTrackMvdChi2,
+  kGlobalTrackMvdSize,
+
+  kGlobalTrackStsChi2,
+  kGlobalTrackStsSize,
+
+  kGlobalTrackRichChi2,
+  kGlobalTrackRichSize,
+
+  kGlobalTrackMuchChi2,
+  kGlobalTrackMuchSize,
+
+  kGlobalTrackTrdChi2,
+  kGlobalTrackTrdSize,
+
+  kGlobalTrackTofChi2,
+  kGlobalTrackTofSize
+};
+
+/** \brief Convert CbmCutId to a string representation.
+ *
+ * \param cutId The CbmCutId to convert.
+ * \return String representation of the CbmCutId.
+ */
+std::string ToString(CbmCutId);
+#endif
diff --git a/analysis/detectors/sts/CbmCutMap.cxx b/analysis/detectors/sts/CbmCutMap.cxx
new file mode 100644
index 0000000000..4527424618
--- /dev/null
+++ b/analysis/detectors/sts/CbmCutMap.cxx
@@ -0,0 +1,52 @@
+
+/* Copyright (C) 2022 Facility for Antiproton and Ion Research in Europe, Darmstadt
+   SPDX-License-Identifier: GPL-3.0-only
+   Authors: Dario Ramirez [committer] */
+
+#include "CbmCutMap.h"
+
+CbmCutMap::CbmCutMap() {}
+CbmCutMap::~CbmCutMap() {}
+
+CbmCut<float>* CbmCutMap::AddCbmCut(CbmCutId id) { return &cbm_cuts_[id]; }
+
+bool CbmCutMap::Check(CbmCutId id, double value)
+{
+  if (!cbm_cuts_.count(id)) {
+    failed_pass_counter_[id] = 0;  //HARDCODE: Why to create this cut??????
+    return true;
+  }
+  bool check_result        = cbm_cuts_[id].Check(value);
+  failed_pass_counter_[id] = check_result ? failed_pass_counter_[id] + 1 : failed_pass_counter_[id];
+  return check_result;
+}
+
+bool CbmCutMap::CheckStsHit(CbmStsHit* hit, TClonesArray* clu_array = nullptr)
+{
+  if (hit == nullptr) return false;
+  if (clu_array != nullptr) {
+    if (!Check(CbmCutId::kStsHitCharge, cbm_sts_utils::GetHitCharge(hit, clu_array))) {
+      return false;
+    }
+    if (!Check(CbmCutId::kStsHitQasym, cbm_sts_utils::GetHitChargeAsy(hit, clu_array))) {
+      return false;
+    }
+  }
+  return Check(CbmCutId::kStsHitTime, hit->GetTime()) && Check(CbmCutId::kStsHitX, hit->GetX())
+         && Check(CbmCutId::kStsHitY, hit->GetY()) && Check(CbmCutId::kStsHitZ, hit->GetZ());
+}
+
+bool CbmCutMap::CheckEvent(CbmEvent* evt)
+{
+  if (evt == nullptr) return false;
+
+  return Check(CbmCutId::kEventNofMvdHit, evt->GetNofData(ECbmDataType::kMvdHit))
+         && Check(CbmCutId::kEventNofStsHit, evt->GetNofData(ECbmDataType::kStsHit))
+         && Check(CbmCutId::kEventNofRichHit, evt->GetNofData(ECbmDataType::kRichHit))
+         && Check(CbmCutId::kEventNofRichRing, evt->GetNofData(ECbmDataType::kRichRing))
+         && Check(CbmCutId::kEventNofMuchPixelHit, evt->GetNofData(ECbmDataType::kMuchPixelHit))
+         && Check(CbmCutId::kEventNofMuchStrawHit, evt->GetNofData(ECbmDataType::kMuchStrawHit))
+         && Check(CbmCutId::kEventNofTrdHit, evt->GetNofData(ECbmDataType::kTrdHit))
+         && Check(CbmCutId::kEventNofTofHit, evt->GetNofData(ECbmDataType::kTofHit))
+         && Check(CbmCutId::kEventNofGlobalTrack, evt->GetNofData(ECbmDataType::kGlobalTrack));
+}
diff --git a/analysis/detectors/sts/CbmCutMap.h b/analysis/detectors/sts/CbmCutMap.h
new file mode 100644
index 0000000000..b7b31d38d9
--- /dev/null
+++ b/analysis/detectors/sts/CbmCutMap.h
@@ -0,0 +1,101 @@
+/** @file CbmCutMap.h
+ *  @brief CbmCutMap class header file.
+ *
+ *  @copyright (C) 2022 Facility for Antiproton and Ion Research in Europe, Darmstadt
+ *  SPDX-License-Identifier: GPL-3.0-only
+ *  Authors: Dario Ramirez [committer]
+ */
+
+
+#ifndef CBMCUTMAP_H
+#define CBMCUTMAP_H
+
+#include "CbmCut.h"
+#include "CbmEvent.h"
+#include "CbmStsHit.h"
+#include "CbmStsUtils.h"
+
+#include <TClonesArray.h>
+
+/**
+ * @class CbmCutMap
+ * @brief Manages a map of cuts associated with their IDs.
+ */
+class CbmCutMap {
+ public:
+  /**
+   * @brief Constructor for CbmCutMap.
+   */
+  CbmCutMap();
+
+  /**
+   * @brief Destructor for CbmCutMap.
+   */
+  virtual ~CbmCutMap();
+
+  /**
+   * @brief Get the map of cuts.
+   * @return The map of cuts.
+   */
+  std::unordered_map<CbmCutId, CbmCut<float>> GetMap() const { return cbm_cuts_; }
+
+  /**
+   * @brief Add a new cut to the map.
+   * @param id The ID of the cut.
+   * @return Pointer to the added CbmCut.
+   */
+  CbmCut<float>* AddCbmCut(CbmCutId id);
+
+  /**
+   * @brief Check if a value passes the cut with the given ID.
+   * @param id The ID of the cut to check.
+   * @param value The value to check against the cut.
+   * @return True if the value passes the cut, false otherwise.
+   */
+  bool Check(CbmCutId id, double value);
+
+  /**
+   * @brief Check if a CbmStsHit passes the cuts.
+   * @param hit Pointer to the CbmStsHit to check.
+   * @param array Pointer to the TClonesArray containing CbmStsCluster (for charge retrieving).
+   * @return True if the hit passes the cuts, false otherwise.
+   */
+  bool CheckStsHit(CbmStsHit*, TClonesArray*);
+
+  /**
+   * @brief Check if a CbmEvent passes the cuts.
+   * @param evt Pointer to the CbmEvent to check.
+   * @return True if the event passes the cuts, false otherwise.
+   */
+  bool CheckEvent(CbmEvent* evt);
+
+  /**
+   * @brief Overloaded stream insertion operator for CbmCutMap.
+   * @param out Output stream.
+   * @param obj CbmCutMap object to output.
+   * @return Reference to the output stream.
+   */
+  friend std::ostream& operator<<(std::ostream& out, const CbmCutMap& obj)
+  {
+    for (auto& [id, cut] : obj.GetMap()) {
+      out << ToString(id) << "\t" << cut << std::endl;
+    }
+    return out;
+  }
+
+  /**
+   * @brief Print the cuts and failed pass counters.
+   */
+  void Print()
+  {
+    for (auto& [id, cut] : cbm_cuts_) {
+      std::cout << int(id) << ": " << cut << "\tFailed: " << failed_pass_counter_[id] << std::endl;
+    }
+  }
+
+ private:
+  std::unordered_map<CbmCutId, CbmCut<float>> cbm_cuts_;
+  std::unordered_map<CbmCutId, unsigned long int> failed_pass_counter_;
+};
+
+#endif
diff --git a/analysis/detectors/sts/CbmStsAnaBase.cxx b/analysis/detectors/sts/CbmStsAnaBase.cxx
new file mode 100644
index 0000000000..d758be372f
--- /dev/null
+++ b/analysis/detectors/sts/CbmStsAnaBase.cxx
@@ -0,0 +1,126 @@
+/* Copyright (C) 2022 Facility for Antiproton and Ion Research in Europe, Darmstadt
+   SPDX-License-Identifier: GPL-3.0-only
+   Authors: Dario Ramirez [committer] */
+
+// #define NDEBUG
+#include "FairRootManager.h"
+
+#include "CbmStsAnaBase.h"
+
+#include "CbmStsModule.h"
+#include "CbmStsStation.h"
+
+#include <TGeoBBox.h>          // for Geometry loading from file
+#include <TGeoManager.h>       // for Geometry loading from file
+#include <TGeoMatrix.h>        // for Geometry loading from file
+#include <TGeoNode.h>          // for Geometry loading from file
+#include <TGeoPhysicalNode.h>  // for Geometry loading from file
+#include <TGeoVolume.h>        // for Geometry loading from file
+
+#include <cassert>
+
+
+CbmStsAnaBase::CbmStsAnaBase() {}
+CbmStsAnaBase::~CbmStsAnaBase() {}
+
+void CbmStsAnaBase::SetCutMap(CbmCutMap* cuts_map)
+{
+  assert(cuts_map != nullptr);
+  analysis_cut_ = cuts_map;
+}
+
+void CbmStsAnaBase::LoadSetup()
+{
+  CbmStsSetup* sts_setup = CbmStsSetup::Instance();
+  if (!sts_setup->IsInit()) {
+    sts_setup->Init(nullptr);
+  }
+
+  if (sts_setup == nullptr) {
+    LOG(warning) << "Something is wrong with the setup ...";
+    return;
+  }
+
+  nb_sts_station_ = sts_setup->GetNofStations();
+  assert(nb_sts_station_ != 0);
+
+  for (unsigned short unit_idx = 0; unit_idx < nb_sts_station_; unit_idx++) {
+    CbmStsStation* sts_unit    = sts_setup->GetStation(unit_idx);
+    sts_geo_info_[unit_idx]    = std::vector<double>(5, 0);
+    sts_geo_info_[unit_idx][0] = sts_unit->GetXmin();
+    sts_geo_info_[unit_idx][1] = sts_unit->GetXmax();
+    sts_geo_info_[unit_idx][2] = sts_unit->GetYmin();
+    sts_geo_info_[unit_idx][3] = sts_unit->GetYmax();
+    sts_geo_info_[unit_idx][4] = sts_unit->GetZ();
+  }
+
+  for (unsigned short module_idx = 0; module_idx < sts_setup->GetNofModules(); module_idx++) {  // Loop over modules
+    CbmStsModule* sts_module = sts_setup->GetModule(module_idx);
+    assert(sts_module);
+    int32_t address = sts_module->GetAddress();
+    assert(sts_module->GetNofDaughters() == 1);
+
+    CbmStsElement* sts_sensor     = sts_module->GetDaughter(0);
+    TGeoPhysicalNode* sensor_node = sts_sensor->GetPnode();
+    TGeoVolume* sensor_volume     = sensor_node->GetVolume();
+    TGeoBBox* sensor_shape        = (TGeoBBox*) sensor_volume->GetShape();
+    TGeoMatrix* sensor_matrix     = sensor_node->GetMatrix();
+
+    // const double* local = sensor_shape->GetOrigin();
+    const double* trans       = sensor_matrix->GetTranslation();
+    sts_geo_info_[address]    = std::vector<double>(6, 0);
+    sts_geo_info_[address][0] = trans[0] - sensor_shape->GetDX();  // Xmin
+    sts_geo_info_[address][1] = trans[0] + sensor_shape->GetDX();  // Xmax
+    sts_geo_info_[address][2] = trans[1] - sensor_shape->GetDY();  // Ymin
+    sts_geo_info_[address][3] = trans[1] + sensor_shape->GetDY();  // Ymax
+    sts_geo_info_[address][4] = trans[2] - sensor_shape->GetDZ();  // Zmin
+    sts_geo_info_[address][5] = trans[2] + sensor_shape->GetDZ();  // Zmax
+
+    if (address > 8) {
+      switch (2 * (int) sensor_shape->GetDY()) {
+        case  2: first_z_strip_[address] = 2048 -  32; break;
+        case  4: first_z_strip_[address] = 2048 -  88; break;
+        case  6: first_z_strip_[address] = 2048 - 134; break;
+        case 12: first_z_strip_[address] = 2048 - 274; break;
+        default:
+          LOG(warning) << Form("Unknown sensor shape 0x%x: [%0.3f , %0.3f , %0.3f]", address, sensor_shape->GetDX(),
+                             sensor_shape->GetDY(), sensor_shape->GetDZ());
+          break;
+      }
+    }
+  }
+
+  for (auto& [address, geo] : sts_geo_info_) {
+    LOG(info) << Form("Loaded setup information:\n0x%x: [%+0.3f, %+0.3f] ^ [%+0.3f, %+0.3f] ^ [%+0.3f, %+0.3f]", address, geo[0], geo[1], geo[2], geo[3], geo[4], geo[5]);
+  }
+}
+
+void CbmStsAnaBase::SaveToFile()
+{
+  FairRootManager* ioman = FairRootManager::Instance();
+  auto sink = ioman->GetSink();
+
+  if (!sink) {
+    LOG(fatal) << "Check the configuration: sink is invalid!";
+    return;
+  }
+
+  LOG(info) << Form("Task histograms will be saved to %s ...", sink->GetFileName().Data());
+
+  for (auto& [name, gr] : g1_) {
+    if (gr == nullptr) continue;
+    sink->WriteObject(gr.get(), name.c_str());
+  }
+  for (auto& [name, h] : h1_) {
+    if (h == nullptr) continue;
+    sink->WriteObject(h.get(), name.c_str());
+  }
+  for (auto& [name, h] : h2_) {
+    if (h == nullptr) continue;
+    sink->WriteObject(h.get(), name.c_str());
+  }
+  for (auto& [name, h] : h2_s) {
+    if (h == nullptr) continue;
+    sink->WriteObject(h.get(), name.c_str());
+  }
+}
diff --git a/analysis/detectors/sts/CbmStsAnaBase.h b/analysis/detectors/sts/CbmStsAnaBase.h
new file mode 100644
index 0000000000..f162330860
--- /dev/null
+++ b/analysis/detectors/sts/CbmStsAnaBase.h
@@ -0,0 +1,106 @@
+/** @file CbmStsAnaBase.h
+ *  @brief CbmStsAnaBase class header file.
+ *
+ *  @copyright (C) 2022 Facility for Antiproton and Ion Research in Europe, Darmstadt
+ *  SPDX-License-Identifier: GPL-3.0-only
+ *  Authors: Dario Ramirez [committer]
+ */
+
+#ifndef CBMSTSANABASE_H
+#define CBMSTSANABASE_H
+
+#include <optional>
+#include <cstring>
+#include <map>
+#include <unordered_set>
+
+#include "CbmCutMap.h"
+#include "CbmDefs.h"
+#include "CbmStsSetup.h"
+#include "CbmStsUtils.h"
+
+#include <Logger.h>
+
+#include <FairRootManager.h>
+#include <TCanvas.h>
+#include <TClonesArray.h>
+#include <TFile.h>
+#include <TGraphErrors.h>
+#include <TH1D.h>
+#include <TH2D.h>
+#include <TSystem.h>
+
+
+
+
+enum InputType {kMCEventMode, kMCTimeMode, kEventMode, kTimeMode};
+
+/**
+ * @class CbmStsAnaBase
+ * @brief Base class for STS analysis.
+ *
+ * This class provides a base for STS (Silicon Tracking System) analysis. It contains
+ * common functionalities and data members used by derived analysis classes.
+ */
+class CbmStsAnaBase {
+ public:
+  /** Constructor */
+  CbmStsAnaBase();
+
+  /** Destructor */
+  virtual ~CbmStsAnaBase();
+
+  /**
+   * @brief Set the cut map for analysis.
+   * @param cutMap Pointer to the CbmCutMap object.
+   */
+  void SetCutMap(CbmCutMap* map);
+
+  /**
+   * @brief User defined sensor translations.
+   * @param user_mat Input translations.
+   */
+  void UserAlignment(const std::map<int32_t, std::vector<double>>& user_mat) {
+    user_align_ = user_mat;
+  }
+
+  /**
+   * @brief Virtual function to draw analysis results.
+   */
+  virtual void DrawResults() {}
+
+ protected:
+  uint entry_{0};
+  std::unique_ptr<TFile> report_file_;
+  std::unordered_set<int32_t> address_book_;
+  std::map<std::string, std::unique_ptr<TGraphErrors>> g1_; // Map of TGraphErrors objects.
+  std::map<std::string, std::unique_ptr<TH1D>> h1_;         // Map of TH1D objects.
+  std::map<std::string, std::unique_ptr<TH2D>> h2_;         // Map of TH2D objects.
+  std::map<std::string, std::shared_ptr<TH2D>> h2_s;        // Map of TH2D objects.
+  std::map<std::string, std::unique_ptr<TCanvas>> canvas_;  // Map of TH2D objects.
+
+  int nb_sts_station_{8};                                         // Number of STS stations.
+  std::unordered_map<int32_t, std::vector<double>> sts_geo_info_; // Map of STS geometry information.
+
+  std::map<int32_t, std::vector<double>> user_align_; // Stores the user-defined alignment information.
+
+  std::unordered_map<int32_t, int> first_z_strip_;
+
+  CbmCutMap* analysis_cut_{nullptr};
+
+  int run_id_{-1};
+
+  /**
+   * @brief Load the STS setup and fill the map with XYZ boundaries for each STS setup element.
+   * It maps the first z strip for each module depending on the size of the sensor.
+   */
+  void LoadSetup();
+
+  /**
+   * @brief It write all mapped objects to the FairRunAna sink file
+   */
+  void SaveToFile();
+
+  ClassDef(CbmStsAnaBase, 1);
+};
+#endif
diff --git a/analysis/detectors/sts/CbmStsAnaLinkDef.h b/analysis/detectors/sts/CbmStsAnaLinkDef.h
index 6b334db830..1ebb444a0c 100644
--- a/analysis/detectors/sts/CbmStsAnaLinkDef.h
+++ b/analysis/detectors/sts/CbmStsAnaLinkDef.h
@@ -10,5 +10,9 @@
 
 #pragma link C++ class CbmStsWkn + ;
 
+#pragma link C++ class CbmCutMap + ;
+#pragma link C++ class CbmStsAnaBase + ;
+#pragma link C++ namespace CbmStsUtils + ;
+#pragma link C++ class CbmStsAnalysis + ;
 
 #endif /* __CINT__ */
diff --git a/analysis/detectors/sts/CbmStsAnalysis.cxx b/analysis/detectors/sts/CbmStsAnalysis.cxx
new file mode 100644
index 0000000000..c14df72551
--- /dev/null
+++ b/analysis/detectors/sts/CbmStsAnalysis.cxx
@@ -0,0 +1,16 @@
+/* Copyright (C) 2022 Facility for Antiproton and Ion Research in Europe, Darmstadt
+   SPDX-License-Identifier: GPL-3.0-only
+   Authors: Dario Ramirez [committer] */
+
+#include "CbmStsAnalysis.h"
+
+#include "TList.h"
+
+#include <cassert>
+#include <iomanip>
+
+
+CbmStsAnalysis::CbmStsAnalysis() { LOG(debug) << "Creating an instance of CbmStsAnalysis ..."; }
+CbmStsAnalysis::~CbmStsAnalysis() {}
+
+void CbmStsAnalysis::SetAnalysisCuts(CbmCutMap* cuts_map) { ana_cuts_map_ = cuts_map; }
diff --git a/analysis/detectors/sts/CbmStsAnalysis.h b/analysis/detectors/sts/CbmStsAnalysis.h
new file mode 100644
index 0000000000..9dca153c17
--- /dev/null
+++ b/analysis/detectors/sts/CbmStsAnalysis.h
@@ -0,0 +1,39 @@
+/* Copyright (C) 2022 Facility for Antiproton and Ion Research in Europe, Darmstadt
+   SPDX-License-Identifier: GPL-3.0-only
+   Authors: Dario Ramirez [committer] */
+
+#ifndef CBMSTSANALYSIS_H
+#define CBMSTSANALYSIS_H
+
+// Includes from C/C++
+#include <unordered_map>
+#include <unordered_set>
+
+// Includes from FairRoot
+#include <FairRunAna.h>
+#include <Logger.h>
+
+// Includes from CbmRoot
+#include "CbmStsAnaBase.h"
+#include "CbmStsDigi.h"
+
+// Includes from ROOT
+#include <TClonesArray.h>
+#include <TFile.h>
+#include <TSystem.h>
+#include <TTree.h>
+
+class CbmStsAnalysis : public FairRunAna {
+ public:
+  CbmStsAnalysis();
+  virtual ~CbmStsAnalysis();
+
+  void SetAnalysisCuts(CbmCutMap*);
+
+ private:
+  CbmCutMap* ana_cuts_map_{nullptr};
+
+  ClassDef(CbmStsAnalysis, 1);
+};
+
+#endif
diff --git a/analysis/detectors/sts/CbmStsUtils.cxx b/analysis/detectors/sts/CbmStsUtils.cxx
new file mode 100644
index 0000000000..836c285645
--- /dev/null
+++ b/analysis/detectors/sts/CbmStsUtils.cxx
@@ -0,0 +1,138 @@
+/* Copyright (C) 2022 Facility for Antiproton and Ion Research in Europe, Darmstadt
+   SPDX-License-Identifier: GPL-3.0-only
+   Authors: Dario Ramirez [committer] */
+
+#include "CbmStsUtils.h"
+
+#include "CbmStsAddress.h"
+#include "CbmStsCluster.h"
+#include "CbmStsParSetModule.h"
+
+int32_t cbm_sts_utils::GetHitCluSizeF(CbmStsHit* hit, TClonesArray* sts_clu_array)
+{
+  if (hit == nullptr || sts_clu_array == nullptr) {
+    return -1;
+  }
+  return ((CbmStsCluster*) sts_clu_array->UncheckedAt(hit->GetFrontClusterId()))->GetSize();
+}
+int32_t cbm_sts_utils::GetHitCluSizeB(CbmStsHit* hit, TClonesArray* sts_clu_array)
+{
+  if (hit == nullptr || sts_clu_array == nullptr) {
+    return -1;
+  }
+  return ((CbmStsCluster*) sts_clu_array->UncheckedAt(hit->GetBackClusterId()))->GetSize();
+}
+/* Get StsHit charge as average of front and back cluster charges */
+double cbm_sts_utils::GetHitChargeF(CbmStsHit* hit, TClonesArray* sts_clu_array)
+{
+  if (hit == nullptr || sts_clu_array == nullptr) {
+    return -1;
+  }
+  return ((CbmStsCluster*) sts_clu_array->UncheckedAt(hit->GetFrontClusterId()))->GetCharge();
+}
+
+double cbm_sts_utils::GetHitChargeB(CbmStsHit* hit, TClonesArray* sts_clu_array)
+{
+  if (hit == nullptr || sts_clu_array == nullptr) {
+    return -1;
+  }
+  return ((CbmStsCluster*) sts_clu_array->UncheckedAt(hit->GetBackClusterId()))->GetCharge();
+}
+
+/* Get StsHit cluster time */
+double cbm_sts_utils::GetHitTimeF(CbmStsHit* hit, TClonesArray* sts_clu_array)
+{
+  if (hit == nullptr || sts_clu_array == nullptr) {
+    return -1;
+  }
+  return ((CbmStsCluster*) sts_clu_array->UncheckedAt(hit->GetFrontClusterId()))->GetTime();
+}
+
+double cbm_sts_utils::GetHitTimeB(CbmStsHit* hit, TClonesArray* sts_clu_array)
+{
+  if (hit == nullptr || sts_clu_array == nullptr) {
+    return -1;
+  }
+  return ((CbmStsCluster*) sts_clu_array->UncheckedAt(hit->GetBackClusterId()))->GetTime();
+}
+/* ---- ------------- ---- */
+
+double cbm_sts_utils::GetHitCharge(CbmStsHit* hit, TClonesArray* sts_clu_array)
+{
+  if (hit == nullptr || sts_clu_array == nullptr) {
+    return -1;
+  }
+  double cluster_charge_f = GetHitChargeF(hit, sts_clu_array);
+  double cluster_charge_b = GetHitChargeB(hit, sts_clu_array);
+  return 0.5 * (cluster_charge_f + cluster_charge_b);
+}
+
+/* Get charge asymmetry */
+double cbm_sts_utils::GetHitChargeAsy(CbmStsHit* hit, TClonesArray* sts_clu_array)
+{
+  if (hit == nullptr || sts_clu_array == nullptr) {
+    return -1;
+  }
+  double cluster_charge_f = GetHitChargeF(hit, sts_clu_array);
+  double cluster_charge_b = GetHitChargeB(hit, sts_clu_array);
+  return (cluster_charge_f - cluster_charge_b) / (cluster_charge_f + cluster_charge_b);
+}
+
+/** \brief Get the charge asymmetry of a hit **/
+std::pair<cbm_sts_utils::HBinning, cbm_sts_utils::HBinning>
+cbm_sts_utils::ChargeBinning(const CbmStsParModule& par_module, const uint32_t max_clu_size)
+{
+  auto par_asic = par_module.GetAsicParams();
+
+  double n_side_q_thr = par_asic[0].GetThreshold();
+  double n_side_q_dyn = par_asic[0].GetDynRange();
+  double p_side_q_thr = par_asic[8].GetThreshold();
+  double p_side_q_dyn = par_asic[8].GetDynRange();
+
+  for (int asic_idx = 0; asic_idx < 16; asic_idx++) {
+    auto asic = par_asic[asic_idx];
+    if (asic_idx < 7) {  // n-side
+      n_side_q_thr = std::min(n_side_q_thr, asic.GetThreshold());
+      n_side_q_dyn = std::max(n_side_q_dyn, asic.GetDynRange());
+    }
+    else {  // p-side
+      p_side_q_thr = std::min(p_side_q_thr, asic.GetThreshold());
+      p_side_q_dyn = std::max(p_side_q_dyn, asic.GetDynRange());
+    }
+  }
+
+  double n_side_q_bin = n_side_q_dyn / 31;
+  double p_side_q_bin = p_side_q_dyn / 31;
+
+  double n_side_q_min = n_side_q_thr;
+  double p_side_q_min = p_side_q_thr;
+
+  double n_side_q_max = (n_side_q_dyn * (31.5 / 31) + 0.5 * n_side_q_bin) * max_clu_size + n_side_q_min;
+  double p_side_q_max = (p_side_q_dyn * (31.5 / 31) + 0.5 * p_side_q_bin) * max_clu_size + p_side_q_min;
+
+  uint32_t n_side_n_bin = 32 * max_clu_size;
+  uint32_t p_side_n_bin = 32 * max_clu_size;
+
+  return std::make_pair(cbm_sts_utils::HBinning{n_side_n_bin, n_side_q_min, n_side_q_max},
+                        cbm_sts_utils::HBinning{p_side_n_bin, p_side_q_min, p_side_q_max});
+}
+
+
+
+std::set<int> cbm_sts_utils::GetUnits(const std::vector<int32_t> addresses) {
+  std::set<int> units;
+  for (int32_t address : addresses){
+    units.insert(CbmStsAddress::GetElementId(address, kStsUnit));
+  }
+  return units;
+}
+
+std::vector<int32_t> cbm_sts_utils::GetUnitModules(const std::vector<int32_t> addresses, const uint32_t unit) {
+  std::vector<int32_t> unit_modules;
+  for (int32_t address : addresses){
+    if (CbmStsAddress::GetElementId(address, kStsUnit) == unit){
+      unit_modules.push_back(address);
+    }
+  }
+  return unit_modules;
+}
\ No newline at end of file
diff --git a/analysis/detectors/sts/CbmStsUtils.h b/analysis/detectors/sts/CbmStsUtils.h
new file mode 100644
index 0000000000..0369023ff2
--- /dev/null
+++ b/analysis/detectors/sts/CbmStsUtils.h
@@ -0,0 +1,112 @@
+/** \file CbmStsUtils.h
+ * \brief Definition of utility functions for STS detector.
+ *
+ * Copyright (C) 2022 Facility for Antiproton and Ion Research in Europe, Darmstadt
+ * SPDX-License-Identifier: GPL-3.0-only
+ * Authors: Dario Ramirez [committer]
+ */
+#ifndef CBMSTSUTILS_H
+#define CBMSTSUTILS_H
+
+#include "CbmStsHit.h"
+#include "TClonesArray.h"
+
+#include <set>
+
+class CbmStsParModule;
+
+/** \namespace cbm_sts_utils
+ * \brief Namespace containing utility functions for STS detector.
+ */
+namespace cbm_sts_utils
+{
+  static const double kStsClock = 3.125;
+  static const double kStsDx   = 6. / 1024;
+  static const double kStsDy   = kStsDx / std::tan(7.5 * TMath::Pi() / 180);
+  static const double kStsErrX = kStsDx / sqrt(12);
+  static const double kStsErrY = kStsDy / sqrt(12);
+
+  /** \brief Get the cluster size of a hit from the front side
+   *  \param hit Pointer to the STS hit
+   *  \param clusters Pointer to the TClonesArray of clusters
+   *  \return Cluster size on the front side
+   */
+  int32_t GetHitCluSizeF(CbmStsHit* hit = nullptr, TClonesArray* clusters = nullptr);
+
+  /** \brief Get the cluster size of a hit from the back side
+   *  \param hit Pointer to the STS hit
+   *  \param clusters Pointer to the TClonesArray of clusters
+   *  \return Cluster size on the back side
+   */
+  int32_t GetHitCluSizeB(CbmStsHit* hit = nullptr, TClonesArray* clusters = nullptr);
+
+  /** \brief Get the charge of a hit as the average of front and back cluster charges
+   *  \param hit Pointer to the STS hit
+   *  \param clusters Pointer to the TClonesArray of clusters
+   *  \return Average charge of the hit
+   */
+  double GetHitCharge(CbmStsHit* hit = nullptr, TClonesArray* clusters = nullptr);
+
+  /** \brief Get the charge of a hit from the back side
+   *  \param hit Pointer to the STS hit
+   *  \param clusters Pointer to the TClonesArray of clusters
+   *  \return Charge of the hit on the back side
+   */
+  double GetHitChargeB(CbmStsHit* hit = nullptr, TClonesArray* clusters = nullptr);
+
+  /** \brief Get the charge of a hit from the front side
+   *  \param hit Pointer to the STS hit
+   *  \param clusters Pointer to the TClonesArray of clusters
+   *  \return Charge of the hit on the front side
+   */
+  double GetHitChargeF(CbmStsHit* hit = nullptr, TClonesArray* clusters = nullptr);
+
+  /** \brief Get the charge of a hit from the back side
+   *  \param hit Pointer to the STS hit
+   *  \param clusters Pointer to the TClonesArray of clusters
+   *  \return Charge of the hit on the back side
+   */
+  double GetHitTimeB(CbmStsHit* hit = nullptr, TClonesArray* clusters = nullptr);
+
+  /** \brief Get the charge of a hit from the front side
+   *  \param hit Pointer to the STS hit
+   *  \param clusters Pointer to the TClonesArray of clusters
+   *  \return Charge of the hit on the front side
+   */
+  double GetHitTimeF(CbmStsHit* hit = nullptr, TClonesArray* clusters = nullptr);
+
+  /** \brief Get the size asymmetry of a hit
+   *  \param hit Pointer to the STS hit
+   *  \param clusters Pointer to the TClonesArray of clusters
+   *  \return Charge asymmetry of the hit
+   */
+  double GetHitSizeAsy(CbmStsHit* hit = nullptr, TClonesArray* clusters = nullptr);
+
+  /** \brief Get the charge asymmetry of a hit
+   *  \param hit Pointer to the STS hit
+   *  \param clusters Pointer to the TClonesArray of clusters
+   *  \return Charge asymmetry of the hit
+   */
+  double GetHitChargeAsy(CbmStsHit* hit = nullptr, TClonesArray* clusters = nullptr);
+
+  /**
+   * \brief Structure to hold the binning for 1D histogram
+  **/
+  struct HBinning {
+    uint32_t n_of_bins{0};
+    double x_min{0};
+    double x_max{0};
+  };
+
+  /** \brief Generate the charge binning from module config obj
+   *  \param par_module Obj containing the module configuration
+   *  \param max_clu_size maximum cluster size to sample
+   *  \return pair binning structure for n(p)-side
+   */
+  std::pair<HBinning, HBinning> ChargeBinning(const CbmStsParModule& par_module, const uint32_t max_clu_size = 1);
+
+  std::set<int> GetUnits(const std::vector<int32_t> addresses);
+
+  std::vector<int32_t> GetUnitModules(const std::vector<int32_t> addresses, const uint32_t unit);
+};  // namespace cbm_sts_utils
+#endif
-- 
GitLab


From 7cd27629b649f497821fe888ef92a005dec7efaf Mon Sep 17 00:00:00 2001
From: Dario Ramirez <d.ramirez@gsi.de>
Date: Mon, 14 Apr 2025 13:54:11 +0200
Subject: [PATCH 02/18] Add Task: CbmSpillCheck

Given a reference detector, output the In|Off spill based on user define percent threshold of the maximum detector rate per TS
---
 analysis/detectors/sts/CMakeLists.txt     |  1 +
 analysis/detectors/sts/CbmSpillCheck.cxx  | 91 +++++++++++++++++++++++
 analysis/detectors/sts/CbmSpillCheck.h    | 66 ++++++++++++++++
 analysis/detectors/sts/CbmStsAnaLinkDef.h |  1 +
 4 files changed, 159 insertions(+)
 create mode 100644 analysis/detectors/sts/CbmSpillCheck.cxx
 create mode 100644 analysis/detectors/sts/CbmSpillCheck.h

diff --git a/analysis/detectors/sts/CMakeLists.txt b/analysis/detectors/sts/CMakeLists.txt
index ed34b01e54..d7433a248c 100644
--- a/analysis/detectors/sts/CMakeLists.txt
+++ b/analysis/detectors/sts/CMakeLists.txt
@@ -13,6 +13,7 @@ set(SRCS
   CbmStsAnaBase.cxx
   CbmStsUtils.cxx
   CbmStsAnalysis.cxx
+  CbmSpillCheck.cxx
   )
 
 
diff --git a/analysis/detectors/sts/CbmSpillCheck.cxx b/analysis/detectors/sts/CbmSpillCheck.cxx
new file mode 100644
index 0000000000..5a53382984
--- /dev/null
+++ b/analysis/detectors/sts/CbmSpillCheck.cxx
@@ -0,0 +1,91 @@
+/* Copyright (C) 2022 Facility for Antiproton and Ion Research in Europe, Darmstadt
+	SPDX-License-Identifier: GPL-3.0-only
+	Authors: Dario Ramirez [committer] */
+#include "CbmSpillCheck.h"
+
+#include <TFitResult.h>
+
+#include <ctime>
+#include <iostream>
+#include <typeinfo>
+
+CbmSpillCheck::CbmSpillCheck() : ref_system{ECbmModuleId::kBmon},
+                                 rate_min_percnt{0.2},
+                                 rate_max_percnt{0.5}
+{
+  LOG(debug) << "Creating an instance of CbmSpillCheck ...";
+}
+
+CbmSpillCheck::CbmSpillCheck(ECbmModuleId ref, double lvl_min, double lvl_max) : ref_system{ref},
+                                                                                 rate_min_percnt{lvl_min},
+                                                                                 rate_max_percnt{lvl_max}
+{
+  LOG(debug) << "Creating an instance of CbmSpillCheck ...";
+}
+
+void CbmSpillCheck::BookHistograms(ECbmModuleId system)
+{
+  std::string h_name = Form("%s Digi Rate", ToString(system).c_str());
+  LOG(debug) << "Booking rate for : " << h_name;
+  g1_[h_name] = std::make_unique<TGraphErrors>();
+}
+
+InitStatus CbmSpillCheck::Init()
+{
+  FairRootManager* ioman = FairRootManager::Instance();
+  if (ioman != nullptr) {
+    digi_manager = CbmDigiManager::Instance();
+    digi_manager->Init();
+
+    if (!digi_manager->IsPresent(ref_system)) {
+      LOG(fatal) << GetName() << ": No " << ToString(ref_system) << " branch in input!";
+    }
+
+    for (ECbmModuleId system = ECbmModuleId::kRef; system != ECbmModuleId::kLastModule; ++system) {
+      if (digi_manager->IsPresent(system)) BookHistograms(system);
+    }
+
+    return kSUCCESS;
+  }
+  return kERROR;
+}
+
+CbmSpillCheck::~CbmSpillCheck() {}
+
+void CbmSpillCheck::Exec(Option_t*)
+{
+  LOG(info) << "Running CbmSpillCheck ...";
+
+  size_t nb_ref_digis = digi_manager->GetNofDigis(ref_system);
+  rate_min_           = rate_min_ == -1 ? nb_ref_digis : std::min(nb_ref_digis, size_t(rate_min_));
+  rate_max_           = rate_max_ == -1 ? nb_ref_digis : std::max(nb_ref_digis, size_t(rate_max_));
+  ref_rate_.push_back(nb_ref_digis);
+
+  for (ECbmModuleId system = ECbmModuleId::kRef; system != ECbmModuleId::kLastModule; ++system) {
+    if (digi_manager->IsPresent(system)) {
+      size_t n_of_digis  = digi_manager->GetNofDigis(system);
+      std::string h_name = Form("%s Digi Rate", ToString(system).c_str());
+      g1_[h_name]->SetPoint(n_of_pts_, n_of_pts_, n_of_digis);
+    }
+  }
+  n_of_pts_++;
+}
+
+void CbmSpillCheck::Finish()
+{
+  double spill_lvl_off = rate_min_ + rate_min_percnt * (rate_max_ - rate_min_);
+  double spill_lvl_on  = rate_min_ + rate_max_percnt * (rate_max_ - rate_min_);
+  spill_status_        = std::vector<int>(ref_rate_.size(), 0);
+  for (size_t ts_idx = 0; ts_idx < ref_rate_.size(); ts_idx++) {
+    spill_status_[ts_idx] = ref_rate_[ts_idx] <= spill_lvl_off ? -1 : (ref_rate_[ts_idx] <= spill_lvl_on ? 0 : 1);
+    std::cout << spill_status_[ts_idx] << std::endl;
+  }
+
+  std::cout << spill_lvl_off << std::endl;
+  std::cout << spill_lvl_on << std::endl;
+
+  SaveToFile();
+  g1_.clear();
+  h1_.clear();
+  h2_.clear();
+}
diff --git a/analysis/detectors/sts/CbmSpillCheck.h b/analysis/detectors/sts/CbmSpillCheck.h
new file mode 100644
index 0000000000..fd3d151d5d
--- /dev/null
+++ b/analysis/detectors/sts/CbmSpillCheck.h
@@ -0,0 +1,66 @@
+/** \file CbmSpillCheck.h
+ * \brief Definition of the CbmSpillCheck class for spill status checking.
+ *
+ * Copyright (C) 2022 Facility for Antiproton and Ion Research in Europe, Darmstadt
+ * SPDX-License-Identifier: GPL-3.0-only
+ * Authors: Dario Ramirez [committer]
+ */
+
+#ifndef CBMSPILLCHECK_H
+#define CBMSPILLCHECK_H
+
+#include "CbmDefs.h"
+#include "CbmDigiManager.h"
+#include "CbmStsAnaBase.h"
+
+#include <FairTask.h>
+
+#include <unordered_set>
+
+/** \class CbmSpillCheck
+ * \brief Task for checking the spill status based on a reference module.
+ *
+ * This class inherits from FairTask and CbmStsAnaBase.
+ * It provides functionality for checking the spill status based on the Digis rate of a reference module.
+ */
+class CbmSpillCheck : public FairTask, public CbmStsAnaBase {
+ public:
+  /** \brief Default constructor */
+  CbmSpillCheck();
+
+  /** \brief Parameterized constructor
+   *
+   * \param ref The ECbmModuleId representing the reference module for spill checking.
+   * \param spill_off_prcnt The percentage threshold for spill-off detection (default: 0.2).
+   * \param spill_on_prcnt The percentage threshold for spill-on detection (default: 0.5).
+   */
+  CbmSpillCheck(ECbmModuleId ref = ECbmModuleId::kBmon, double spill_off_prcnt = 0.2, double spill_on_prcnt = 0.5);
+
+  /** \brief Destructor */
+  virtual ~CbmSpillCheck();
+
+  InitStatus Init();
+
+  void Exec(Option_t*);
+
+  void Finish();
+
+ private:
+  ECbmModuleId ref_system;
+  double rate_min_percnt;
+  double rate_max_percnt;
+  int rate_max_{-1};
+  int rate_min_{-1};
+  int n_of_pts_{0};
+  std::vector<int> ref_rate_;
+  std::vector<int> spill_status_;
+
+
+  CbmDigiManager* digi_manager{nullptr};
+
+  /** \brief Book histograms for a specific module */
+  void BookHistograms(ECbmModuleId);
+
+  ClassDef(CbmSpillCheck, 1);
+};
+#endif
diff --git a/analysis/detectors/sts/CbmStsAnaLinkDef.h b/analysis/detectors/sts/CbmStsAnaLinkDef.h
index 1ebb444a0c..1387246f94 100644
--- a/analysis/detectors/sts/CbmStsAnaLinkDef.h
+++ b/analysis/detectors/sts/CbmStsAnaLinkDef.h
@@ -14,5 +14,6 @@
 #pragma link C++ class CbmStsAnaBase + ;
 #pragma link C++ namespace CbmStsUtils + ;
 #pragma link C++ class CbmStsAnalysis + ;
+#pragma link C++ class CbmSpillCheck + ;
 
 #endif /* __CINT__ */
-- 
GitLab


From d1eadb64923085cefa7cc039431dd468307c0592 Mon Sep 17 00:00:00 2001
From: Dario Ramirez <d.ramirez@gsi.de>
Date: Mon, 14 Apr 2025 14:17:07 +0200
Subject: [PATCH 03/18] Add task: CbmStsChannelQA

---
 analysis/detectors/sts/CMakeLists.txt      |   1 +
 analysis/detectors/sts/CbmStsAnaLinkDef.h  |   1 +
 analysis/detectors/sts/CbmStsChannelQA.cxx | 323 +++++++++++++++++++++
 analysis/detectors/sts/CbmStsChannelQA.h   | 147 ++++++++++
 4 files changed, 472 insertions(+)
 create mode 100644 analysis/detectors/sts/CbmStsChannelQA.cxx
 create mode 100644 analysis/detectors/sts/CbmStsChannelQA.h

diff --git a/analysis/detectors/sts/CMakeLists.txt b/analysis/detectors/sts/CMakeLists.txt
index d7433a248c..9985105200 100644
--- a/analysis/detectors/sts/CMakeLists.txt
+++ b/analysis/detectors/sts/CMakeLists.txt
@@ -14,6 +14,7 @@ set(SRCS
   CbmStsUtils.cxx
   CbmStsAnalysis.cxx
   CbmSpillCheck.cxx
+  CbmStsChannelQA.cxx
   )
 
 
diff --git a/analysis/detectors/sts/CbmStsAnaLinkDef.h b/analysis/detectors/sts/CbmStsAnaLinkDef.h
index 1387246f94..8ca4fec579 100644
--- a/analysis/detectors/sts/CbmStsAnaLinkDef.h
+++ b/analysis/detectors/sts/CbmStsAnaLinkDef.h
@@ -15,5 +15,6 @@
 #pragma link C++ namespace CbmStsUtils + ;
 #pragma link C++ class CbmStsAnalysis + ;
 #pragma link C++ class CbmSpillCheck + ;
+#pragma link C++ class CbmStsChannelQA + ;
 
 #endif /* __CINT__ */
diff --git a/analysis/detectors/sts/CbmStsChannelQA.cxx b/analysis/detectors/sts/CbmStsChannelQA.cxx
new file mode 100644
index 0000000000..2faaa2971c
--- /dev/null
+++ b/analysis/detectors/sts/CbmStsChannelQA.cxx
@@ -0,0 +1,323 @@
+/* Copyright (C) 2022 Facility for Antiproton and Ion Research in Europe, Darmstadt
+	SPDX-License-Identifier: GPL-3.0-only
+	Authors: Dario Ramirez [committer] */
+
+#include "CbmStsChannelQA.h"
+
+#include "CbmStsDigi.h"
+#include "TArrow.h"
+#include "TBox.h"
+#include "TPaveLabel.h"
+#include "TPaveText.h"
+#include "TText.h"
+
+#include <TParameter.h>
+
+#include <ctime>
+#include <iostream>
+#include <typeinfo>
+
+CbmStsChannelQA::CbmStsChannelQA() { LOG(debug) << "Creating an instance of CbmStsChannelQA ..."; }
+
+CbmStsChannelQA::CbmStsChannelQA(int dead_threshold) : active_min_entries_(dead_threshold)
+{
+  LOG(debug) << "Creating an instance of CbmStsChannelQA ...";
+}
+CbmStsChannelQA::CbmStsChannelQA(int dead_threshold, double noise_threshold,
+                                 std::optional<std::pair<size_t, size_t>> spill_on_off_threshold)
+  : active_min_entries_(dead_threshold)
+  , sb_ratio_threshold_(noise_threshold)
+  , spill_on_off_threshold_(spill_on_off_threshold)
+{
+  assert(noise_threshold > 0);
+  if (spill_on_off_threshold_.has_value()) {
+    assert(spill_on_off_threshold_->first <= spill_on_off_threshold_->second);
+    spill_sections_ = {":ramp", ":spill_on", ":spill_off"};
+  }
+  LOG(debug) << "Creating an instance of CbmStsChannelQA ...";
+}
+
+CbmStsChannelQA::~CbmStsChannelQA() {}
+
+InitStatus CbmStsChannelQA::Init()
+{
+  FairRootManager* ioman = FairRootManager::Instance();
+  if (ioman != nullptr) {
+    digi_manager = CbmDigiManager::Instance();
+    digi_manager->Init();
+
+    if (!digi_manager->IsPresent(ECbmModuleId::kSts)) LOG(fatal) << GetName() << ": No StsDigi branch in input!";
+
+    LOG(info) << "Report lvl:                     " << report_level_;
+    LOG(info) << "Active channel minimum entries: " << active_min_entries_;
+    LOG(info) << "Noisy channel S/B thresholds:    " << sb_ratio_threshold_;
+    LOG_IF(info, !spill_on_off_threshold_.has_value()) << "No Spill section defined. Using all time slices";
+    LOG_IF(info, spill_on_off_threshold_.has_value())
+      << Form("Spill OFF: RefDet_DigiRate < %lu", spill_on_off_threshold_->first);
+    LOG_IF(info, spill_on_off_threshold_.has_value())
+      << Form("Spill  ON: RefDet_DigiRate > %lu", spill_on_off_threshold_->second);
+
+    return kSUCCESS;
+  }
+  return kERROR;
+}
+
+
+void CbmStsChannelQA::BookHistograms(int32_t address)
+{
+  LOG(debug) << Form("Booking histograms for module_addr: 0x%x", address);
+
+  double dt_max = 120; // HARDCODE
+  auto t_binning = cbm_sts_utils::HBinning{uint32_t(dt_max / 3.125), 0, dt_max};
+
+  std::string h_name;
+  for (auto modifier : spill_sections_) {
+    h_name = Form("0x%x_charge_vs_channel%s", address, modifier);
+    LOG(debug) << h_name;
+    h2_[h_name] = std::make_unique<TH2D>(h_name.c_str(), h_name.c_str(), 2048, 0, 2048, 31, 1, 32);
+    h2_[h_name]->GetXaxis()->SetTitle("Channel_{StsDigi}");
+    h2_[h_name]->GetYaxis()->SetTitle("Charge_{StsDigi} [ADC]");
+
+    LOG(debug) << h_name;
+    h_name = Form("0x%x_dt_vs_charge%s", address, modifier);
+    h2_[h_name] = std::make_unique<TH2D>(h_name.c_str(), h_name.c_str(),
+      31, 1, 32,
+      t_binning.n_of_bins, t_binning.x_min, t_binning.x_max);
+    h2_[h_name]->GetYaxis()->SetTitle("Charge_{StsDigi} [ADC]");
+    h2_[h_name]->GetYaxis()->SetTitle("Time difference [ns]");
+
+    LOG(debug) << h_name;
+    h_name = Form("0x%x_dt_vs_channel%s", address, modifier);
+    h2_[h_name] = std::make_unique<TH2D>(h_name.c_str(), h_name.c_str(),
+      2048, 0, 2048,
+      t_binning.n_of_bins, t_binning.x_min, t_binning.x_max);
+    h2_[h_name]->GetXaxis()->SetTitle("Channel_{StsDigi}");
+    h2_[h_name]->GetYaxis()->SetTitle("Time difference [ns]");
+  }
+
+  address_book_.insert(address);
+}
+
+void CbmStsChannelQA::ResetLastTime(){
+  for (auto &[address, time] : last_digi_time_){
+    for (int chn = 0 ; chn < 2048 ; chn++){
+      time[chn] = -1;
+    }
+  }
+}
+
+void CbmStsChannelQA::Exec(Option_t*)
+{
+  LOG(info) << "Running CbmStsChannelQA ...";
+
+  // Get Spill status
+  size_t nb_ref_digis = digi_manager->GetNofDigis(ECbmModuleId::kBmon);
+
+  /**
+   * -1 Off spill
+   *  0 Spill ramp
+   * +1 On spill
+  **/
+  int spill_status_ = 0;
+  if (spill_on_off_threshold_.has_value()) {
+    spill_status_ =
+      nb_ref_digis <= spill_on_off_threshold_->first ? -1 : (nb_ref_digis <= spill_on_off_threshold_->second ? 0 : 1);
+  }
+
+  std::string str_spill;
+  switch (spill_status_) {
+    case +1: {
+      nb_spill_on_++;
+      str_spill = spill_sections_[1];
+      break;
+    }
+    case -1: {
+      nb_spill_off_++;
+      str_spill = spill_sections_[2];
+      break;
+    }
+    default: {
+      str_spill = spill_sections_[0];
+      break;
+    }
+  }
+
+  LOG(info) << Form("TS %d\t-\t Spill section: %s", entry_, str_spill.c_str());
+
+
+  auto sts_digis_     = digi_manager->GetArray<CbmStsDigi>();
+  size_t nb_sts_digis = digi_manager->GetNofDigis(ECbmModuleId::kSts);
+  for (size_t sts_digi_idx = 0; sts_digi_idx < nb_sts_digis; sts_digi_idx++) {  // sts digi loop
+    const CbmStsDigi* sts_digi = &sts_digis_[sts_digi_idx];
+    int32_t sts_digi_addr      = sts_digi->GetAddress();
+    int32_t sts_digi_chan      = sts_digi->GetChannel();
+    int32_t sts_digi_char      = sts_digi->GetCharge();
+    double sts_digi_time       = sts_digi->GetTime();
+
+    if (!address_book_.count(sts_digi_addr)) {
+      BookHistograms(sts_digi_addr);
+
+      for (int chn = 0 ; chn < 2048 ; chn++){
+        last_digi_time_[sts_digi_addr][chn] = -1;
+      }
+    }
+
+    h2_[Form("0x%x_charge_vs_channel%s", sts_digi_addr, str_spill.c_str())]->Fill(sts_digi_chan, sts_digi_char);
+
+    if (last_digi_time_[sts_digi_addr][sts_digi_chan] > 0){
+      h2_[Form("0x%x_dt_vs_charge%s",  sts_digi_addr, str_spill.c_str())]->Fill(sts_digi_char, sts_digi_time - last_digi_time_[sts_digi_addr][sts_digi_chan]);
+      h2_[Form("0x%x_dt_vs_channel%s", sts_digi_addr, str_spill.c_str())]->Fill(sts_digi_chan, sts_digi_time - last_digi_time_[sts_digi_addr][sts_digi_chan]);
+    }
+
+    last_digi_time_[sts_digi_addr][sts_digi_chan] = sts_digi_time;
+
+  }  // end sts digi loop
+
+  ResetLastTime();
+  entry_++;
+}
+
+void CbmStsChannelQA::CheckDeadChannels()
+{
+  const char* mod = spill_on_off_threshold_.has_value() ? spill_sections_[1] : spill_sections_[0];
+  for (auto& module_addr : address_book_) {
+    auto h = (TH1D*) h2_[Form("0x%x_charge_vs_channel%s", module_addr, mod)]->ProjectionX();
+    for (int chn = 0; chn < 2048; chn++) {
+      double entries = h->GetBinContent(chn + 1);
+
+      if (entries < active_min_entries_) {
+        dead_channel_list_[module_addr].push_back(chn);
+      }
+    }
+  }
+}
+
+void CbmStsChannelQA::CheckNoisyChannels()
+{
+  for (auto& module_addr : address_book_) {
+    TH1D* h_sgn = h2_[Form("0x%x_charge_vs_channel:spill_on", module_addr)]->ProjectionX();
+    TH1D* h_bkg = h2_[Form("0x%x_charge_vs_channel:spill_off", module_addr)]->ProjectionX();
+
+    h_sgn->Scale(1. / nb_spill_on_);
+    h_bkg->Scale(1. / nb_spill_off_);
+    h_sgn->Add(h_bkg, -1);
+
+    for (int chn = 0; chn < 2048; chn++) {
+      double sgn = h_sgn->GetBinContent(chn + 1);
+      double bkg = h_bkg->GetBinContent(chn + 1);
+
+      if (bkg == 0) continue;
+
+      double sb_ratio = sgn / bkg;
+
+      if (sb_ratio < sb_ratio_threshold_) {
+        LOG(debug) << Form("Noisy channel 0x%x: %d, \tS/B: %0.4f", module_addr, chn, sb_ratio);
+        noisy_channel_list_[module_addr].push_back(chn);
+      }
+    }
+  }
+}
+
+void CbmStsChannelQA::GenerateReport()
+{
+  std::string f_name                 = "cbm_sts_channel_qa_report.root";
+  std::unique_ptr<TFile> o_root_file = std::make_unique<TFile>(f_name.c_str(), "RECREATE");
+  int pad_size_x                     = 1000;
+  int pad_size_y                     = 1000;
+  for (auto& module_addr : address_book_) {
+    std::string c_name         = Form("0x%x_channel", module_addr);
+    std::unique_ptr<TCanvas> c = std::make_unique<TCanvas>(c_name.c_str(), c_name.c_str(), pad_size_x, pad_size_y);
+    TH1D* h_sgn                = h2_[Form("0x%x_charge_vs_channel:spill_on", module_addr)]->ProjectionX();
+    TH1D* h_bkg                = h2_[Form("0x%x_charge_vs_channel:spill_off", module_addr)]->ProjectionX();
+
+    LOG(debug) << Form("Building report for 0x%x", module_addr);
+    h_sgn->Scale(1. / nb_spill_on_);
+    h_bkg->Scale(1. / nb_spill_off_);
+
+    h_sgn->SetLineColor(kRed);
+    h_bkg->SetLineColor(kBlack);
+
+    h_sgn->SetTitle("");
+    h_bkg->SetTitle("");
+
+    h_sgn->SetFillColorAlpha(kRed, 0.2);
+    h_bkg->SetFillColorAlpha(kBlack, 0.2);
+
+    double h_sgn_max = h_sgn->GetMaximum();
+    double h_bkg_max = h_bkg->GetMaximum();
+    double max       = std::max(h_sgn_max, h_bkg_max);
+
+    h_sgn->SetMaximum(1.05 * max);
+    h_bkg->SetMaximum(1.05 * max);
+
+    c->cd(1);
+    gPad->SetLogy(1);
+    gPad->SetLeftMargin(0.15);
+    gPad->SetBottomMargin(0.12);
+    gPad->SetTopMargin(0.10);
+    gPad->SetRightMargin(0.12);
+
+    h_sgn->Draw("histo");
+    h_bkg->Draw("histo same");
+
+    // Draw a line for bad channels
+    if (report_level_ > 1) {
+      LOG(debug) << Form("Drawing %d noisy channel markers: %lu", module_addr, noisy_channel_list_[module_addr].size());
+      for (auto& chn : noisy_channel_list_[module_addr]) {
+        TBox chn_box = TBox(chn + 0.2, 0.99 * max, chn + 0.8, 1.01 * max);
+        chn_box.SetLineColor(kBlue);
+        chn_box.SetFillColor(kBlue);
+        chn_box.DrawClone();
+      }
+    }
+
+    c->Write(Form("0x%x_channel:spill_on_vs_off.png", module_addr));
+  }
+}
+
+
+void CbmStsChannelQA::SetReportLevel(int lvl) { report_level_ = lvl; }
+
+void CbmStsChannelQA::Finish()
+{
+  CheckDeadChannels();
+  if (spill_on_off_threshold_.has_value()) CheckNoisyChannels();
+
+  if (report_level_) GenerateReport();
+
+  SaveToFile();
+
+  h1_.clear();
+  h2_.clear();
+
+  // Write normalization factor to file
+  std::unique_ptr<TFile> out_file = std::make_unique<TFile>("cbm_sts_channel_qa.root", "UPDATE");
+  TParameter<int>("nb_spill_on_", nb_spill_on_).Write();
+  TParameter<int>("nb_spill_off_", nb_spill_off_).Write();
+
+  std::ofstream dead_info("sts_dead_channels.info");
+  std::ofstream dead_par("sts_dead_channels.par");
+  dead_info << Form("# Module\t Number of dead channels\n");
+  int n_of_dead_chn = 0;
+  for (auto& [module_addr, list] : dead_channel_list_) {
+    dead_info << Form("0x%x\t%lu\n", module_addr, list.size());
+    for (int& dead_chn : list) {
+      dead_par << module_addr << "\t" << dead_chn << std::endl;
+    }
+    n_of_dead_chn += list.size();
+  }
+  dead_info << Form("# Total Number of dead channels: %d\n", n_of_dead_chn);
+
+  std::ofstream noisy_info("sts_noisy_channels.info");
+  std::ofstream noisy_par("sts_noisy_channels.par");
+  noisy_info << Form("# Module\t Number of noisy channels\n");
+  int n_of_noisy_chn = 0;
+  for (auto& [module_addr, list] : noisy_channel_list_) {
+    noisy_info << Form("0x%x\t%lu\n", module_addr, list.size());
+    for (int& noisy_chn : list) {
+      noisy_par << module_addr << "\t" << noisy_chn << std::endl;
+    }
+    n_of_noisy_chn += list.size();
+  }
+  noisy_info << Form("# Total Number of noisy channels: %d\n", n_of_noisy_chn);
+}
diff --git a/analysis/detectors/sts/CbmStsChannelQA.h b/analysis/detectors/sts/CbmStsChannelQA.h
new file mode 100644
index 0000000000..138fae0e2a
--- /dev/null
+++ b/analysis/detectors/sts/CbmStsChannelQA.h
@@ -0,0 +1,147 @@
+/* Copyright (C) 2022 Facility for Antiproton and Ion Research in Europe, Darmstadt
+   SPDX-License-Identifier: GPL-3.0-only
+   Authors: Dario Ramirez [committer] */
+
+/**
+ * @file CbmStsChannelQA.h
+ * @brief Declaration of CbmStsChannelQA class.
+ */
+
+
+/**
+ * @class CbmStsChannelQA
+ * @brief FairTask for StsChannelQa.
+ *
+ * It processes StsDigis to produce two sets of output files:
+ * - sts_dead_channels.info: Summary of the amount of dead channels for each STS module (.par file with two columns <module_address> <dead_channel>).
+ * - sts_noisy_channels.info: Summary of the amount of noisy channels for each STS module (.par file with two columns <module_address> <noisy_channel>).
+ *
+ * Moreover, all the histograms/graphs generated will be dumped to: cbm_sts_channel_qa.root.
+ */
+
+#ifndef CBMSTSCHANNELQA_H
+#define CBMSTSCHANNELQA_H
+
+#include "CbmDigiManager.h"
+#include "CbmStsAnaBase.h"
+
+#include <FairTask.h>
+
+#include <TClonesArray.h>
+
+#include <cstring>
+#include <map>
+#include <unordered_set>
+
+/**
+ * @class CbmStsChannelQA
+ * @brief Quality assurance task for STS channel monitoring.
+ *
+ * This class inherits from FairTask and CbmStsAnaBase, and provides tools
+ * to analyze and monitor the behavior of STS channels during data processing.
+ *
+ * The main functions of this class include:
+ *
+ * - **Dead Channel Detection**:
+ *   Identifies channels with an entry count below a minimum threshold,
+ *   classifying them as non-functional or "dead".
+ *
+ * - **Noisy Channel Detection**:
+ *   Evaluates the signal-to-background (S/B) ratio using the ratio of
+ *   entries in-spill versus off-spill. Channels with an user-defined
+ *   S/B ratio are marked as noisy.
+ *
+ * - **Charge vs. Channel Histograms**:
+ *   Generates 2D histograms of charge versus channel, split by spill sections (see CbmSpillCheck documentation):
+ *   - All events : if not spill information is provided
+ *   - Ramp section: between the lower and upper thresholds
+ *   - In-spill section : bellow the lower threshold
+ *   - Off-spill section : above the upper threshold
+ *
+ * If spill information is provided the number of in|off spill TS analyzed are save to enable normalization
+ *
+ * Output files are produced:
+ * - **Summary files**:
+ *   - sts_dead_channels.info: Summary of the amount of dead channels for each STS module (.par file with two columns <module_address> <dead_channel>).
+ *   - sts_noisy_channels.info: Summary of the amount of noisy channels for each STS module (.par file with two columns <module_address> <noisy_channel>).
+ * - **Extendend information**:
+ *   - cbm_sts_channel_qa.root: Contains all the histograms/graphs generated.
+ *   - sts_dead_channels.par: Contains the list of dead channels for each module.
+ *   - sts_noisy_channels.par: Contains the list of noisy channels for each module.
+ */
+class CbmStsChannelQA : public FairTask, public CbmStsAnaBase {
+ public:
+  /**
+   * @brief Default constructor.
+   */
+  CbmStsChannelQA();
+
+  /**
+   * @brief Constructor with threshold for inactive channels.
+   * @param dead_threshold Minimum amount of entries to consider a channel active.
+   * Useful to generate the channel masking map for MC input
+   */
+  CbmStsChannelQA(int dead_threshold);
+
+  /**
+   * @brief Constructor with thresholds for dead and noisy channels. Additionally set thresholds
+   * to define OFF | Rise-Fall | ON spill status base on RefDet digi rate
+   * @param dead_threshold Minimum amount of entries to consider a channel alive.
+   * @param noise_threshold Minimum value for Signal/Background ratio to consider a channel to be noisy
+   * @param spill_on_off_threshold (Minimum,Maximum) value for RefDet digi rate to consider spill (ON,OFF) [optional analysis branching]
+   */
+  CbmStsChannelQA(int dead_threshold, double noise_threshold, const std::optional<std::pair<size_t, size_t>>);
+
+  /**
+   * @brief Destructor.
+   */
+  virtual ~CbmStsChannelQA();
+
+  InitStatus Init();
+  void Exec(Option_t*);
+  void Finish();
+
+  void SetReportLevel(int lvl = 0);
+
+ private:
+  int report_level_{0};
+  const int active_min_entries_{1};
+  const double sb_ratio_threshold_{0.5};
+  const std::optional<std::pair<size_t, size_t>> spill_on_off_threshold_{std::nullopt};
+
+  std::vector<const char*> spill_sections_ = {":all"};
+
+  int nb_spill_on_{0};
+  int nb_spill_off_{0};
+
+  std::map<int32_t, std::vector<int>> dead_channel_list_;
+  std::map<int32_t, std::vector<int>> noisy_channel_list_;
+
+  std::map<int32_t, double[2048]> last_digi_time_;
+  void ResetLastTime();
+
+  CbmDigiManager* digi_manager{nullptr};
+
+  /**
+   * @brief Book histograms.
+   * @param address The module address for which histograms will be booked.
+   */
+  void BookHistograms(int32_t);
+
+  /**
+   * @brief Check for dead channels.
+   * Fills dead_channel_list_ map
+   */
+  void CheckDeadChannels();
+
+  /**
+   * @brief Check for dead channels.
+   * Fills noisy_channel_list_ map
+   */
+  void CheckNoisyChannels();
+
+  void GenerateReport();
+
+  ClassDef(CbmStsChannelQA, 1);
+};
+#endif
-- 
GitLab


From d3998866321cef362cae832b14cf5588377888d2 Mon Sep 17 00:00:00 2001
From: Dario Ramirez <d.ramirez@gsi.de>
Date: Mon, 14 Apr 2025 14:42:41 +0200
Subject: [PATCH 04/18] Add trask: CbmStsTimeCal

Add the class and the macro to perform STS time calibration at Digi-level
---
 analysis/detectors/sts/CMakeLists.txt     |   5 +-
 analysis/detectors/sts/CbmStsAnaLinkDef.h |   1 +
 analysis/detectors/sts/CbmStsTimeCal.cxx  | 608 ++++++++++++++++++++++
 analysis/detectors/sts/CbmStsTimeCal.h    | 179 +++++++
 macro/sts/sts_time.C                      |  56 ++
 5 files changed, 847 insertions(+), 2 deletions(-)
 create mode 100644 analysis/detectors/sts/CbmStsTimeCal.cxx
 create mode 100644 analysis/detectors/sts/CbmStsTimeCal.h
 create mode 100644 macro/sts/sts_time.C

diff --git a/analysis/detectors/sts/CMakeLists.txt b/analysis/detectors/sts/CMakeLists.txt
index 9985105200..41383ec422 100644
--- a/analysis/detectors/sts/CMakeLists.txt
+++ b/analysis/detectors/sts/CMakeLists.txt
@@ -7,20 +7,21 @@ set(INCLUDE_DIRECTORIES
 
 set(SRCS
   CbmStsWkn.cxx
-
   CbmCutId.cxx
   CbmCutMap.cxx
-  CbmStsAnaBase.cxx
   CbmStsUtils.cxx
+  CbmStsAnaBase.cxx
   CbmStsAnalysis.cxx
   CbmSpillCheck.cxx
   CbmStsChannelQA.cxx
+  CbmStsTimeCal.cxx
   )
 
 
 set(LIBRARY_NAME CbmStsAna)
 set(LINKDEF ${LIBRARY_NAME}LinkDef.h)
 set(PUBLIC_DEPENDENCIES
+  Algo
   ROOT::Core
   CbmStsBase
   )
diff --git a/analysis/detectors/sts/CbmStsAnaLinkDef.h b/analysis/detectors/sts/CbmStsAnaLinkDef.h
index 8ca4fec579..9852b9c38b 100644
--- a/analysis/detectors/sts/CbmStsAnaLinkDef.h
+++ b/analysis/detectors/sts/CbmStsAnaLinkDef.h
@@ -16,5 +16,6 @@
 #pragma link C++ class CbmStsAnalysis + ;
 #pragma link C++ class CbmSpillCheck + ;
 #pragma link C++ class CbmStsChannelQA + ;
+#pragma link C++ class CbmStsTimeCal + ;
 
 #endif /* __CINT__ */
diff --git a/analysis/detectors/sts/CbmStsTimeCal.cxx b/analysis/detectors/sts/CbmStsTimeCal.cxx
new file mode 100644
index 0000000000..d2cae864f6
--- /dev/null
+++ b/analysis/detectors/sts/CbmStsTimeCal.cxx
@@ -0,0 +1,608 @@
+/* Copyright (C) 2022 Facility for Antiproton and Ion Research in Europe, Darmstadt
+	SPDX-License-Identifier: GPL-3.0-only
+	Authors: Dario Ramirez [committer] */
+#include "CbmStsTimeCal.h"
+
+#include "CbmBmonDigi.h"
+#include "CbmFsdDigi.h"
+#include "CbmMuchDigi.h"
+#include "CbmMvdDigi.h"
+#include "CbmRichDigi.h"
+#include "CbmStsDigi.h"
+#include "CbmTofDigi.h"
+#include "CbmTrdDigi.h"
+
+#include <TColor.h>
+#include <TDirectory.h>
+#include <TF1.h>
+#include <TFitResult.h>
+#include <TPaveText.h>
+#include <TLine.h>
+#include <TStyle.h>
+
+#include <cassert>
+#include <ctime>
+#include <fstream>
+#include <iostream>
+#include <typeinfo>
+
+#include <fmt/core.h>
+#include <yaml-cpp/emitter.h>
+#include <yaml-cpp/emittermanip.h>
+#include <yaml-cpp/node/node.h>
+
+CbmStsTimeCal::CbmStsTimeCal() { LOG(debug) << "Creating an instance of CbmStsTimeCal ..."; }
+CbmStsTimeCal::CbmStsTimeCal(ECbmModuleId ref_sys, double t_min, double t_max)
+{
+  time_window_min_ = t_min;
+  time_window_max_ = t_max;
+  time_ref_system_ = ref_sys;
+}
+
+CbmStsTimeCal::CbmStsTimeCal(int run_id, ECbmModuleId ref_sys, double t_min, double t_max)
+{
+  run_id_          = run_id;
+  time_window_min_ = t_min;
+  time_window_max_ = t_max;
+  time_ref_system_ = ref_sys;
+}
+
+
+InitStatus CbmStsTimeCal::Init()
+{
+  FairRootManager* ioman = FairRootManager::Instance();
+  if (ioman != nullptr) {
+    digi_manager = CbmDigiManager::Instance();
+    digi_manager->Init();
+
+    cbm_evt_array_ = (TClonesArray*) ioman->GetObject("CbmEvent");
+
+    if (!digi_manager->IsPresent(ECbmModuleId::kSts)) LOG(fatal) << GetName() << ": No StsDigi branch in input!";
+    if (!digi_manager->IsPresent(time_ref_system_))
+      LOG(fatal) << GetName() << ": No " << ToString(time_ref_system_) << " branch in input!";
+
+    LoadWalkFromFile();
+
+    o_path_ = run_id_ > 0 ? Form("%d", run_id_) : ".";
+    if (gSystem->AccessPathName(o_path_.c_str(), kFileExists)) {
+      if (system(("mkdir -p " + o_path_).c_str())) {  // Check output folder
+        LOG(warning) << "Could not create output directory\n Setting output path at current location:\n";
+      }
+    }
+    offset_file_       = std::make_unique<TFile>(Form("%s/cbm_sts_time_cal_offset.root", o_path_.c_str()), "RECREATE");
+    report_file_       = std::make_unique<TFile>(Form("%s/cbm_sts_time_cal_report.root", o_path_.c_str()), "RECREATE");
+    fit_file_          = std::make_unique<TFile>(Form("%s/cbm_sts_time_cal_fits.root",   o_path_.c_str()), "RECREATE");
+
+    return kSUCCESS;
+  }
+  return kERROR;
+}
+
+void CbmStsTimeCal::InitTimeWalkMap(int32_t address)
+{
+  for (unsigned int asic_idx = 0; asic_idx < 16; asic_idx++) {
+    tw_map[address][asic_idx] = std::vector<double>(32, 0);
+    auto loaded_par = time_walk_map.Get(address, asic_idx);
+    if (loaded_par.size() == 31){
+      for (int adc = 1 ; adc <= 31; adc++) {
+        tw_map[address][asic_idx][adc] = loaded_par[adc-1];
+      }
+    }
+  }
+}
+
+void CbmStsTimeCal::SetWalkFile(std::string f_name)
+{
+  LOG(debug) << Form("Setting user define time calibration file: %s", f_name.c_str());
+  par_file_ = f_name;
+}
+
+void CbmStsTimeCal::LoadWalkFromFile()
+{
+  if (!par_file_.length()) return;
+
+  if (TString(par_file_.c_str()).EndsWith(".yaml") || TString(par_file_.c_str()).EndsWith(".yml")) {
+    LOG(info) << Form("Loading time calibration from parameter file: %s", par_file_.c_str());
+    time_walk_map = cbm::algo::yaml::ReadFromFile<cbm::algo::sts::WalkMap>(par_file_);
+    global_time_offset_ = time_walk_map.GetSystemTimeOffset();
+    LOG(info) << "Current system offset: " << global_time_offset_ << " ns";
+  }
+}
+
+CbmStsTimeCal::~CbmStsTimeCal() {}
+
+
+void CbmStsTimeCal::BookHistograms(int32_t address)
+{
+  LOG(debug) << Form("Booking histograms for module: 0x%x", address);
+
+  std::string h_name, h_title;
+  int nb_time_bins = (std::abs(time_window_max_ - time_window_min_) + kStsClock) / kStsClock;
+
+  int unit               = CbmStsAddress::GetElementId(address, kStsUnit);
+  int ladd               = CbmStsAddress::GetElementId(address, kStsLadder);
+  int modu               = CbmStsAddress::GetElementId(address, kStsModule);
+  std::string smart_name = Form("U%d_L%d_M%d", unit, ladd, modu);
+
+  for (int asic_idx = 0; asic_idx < 16; asic_idx++) {
+    h_name  = Form("0x%x_%02d", address, asic_idx);
+    h_title = Form("%s_%02d", smart_name.c_str(), asic_idx);
+
+    h2_[h_name] =
+      std::make_unique<TH2D>(h_name.c_str(), h_title.c_str(), nb_time_bins, time_window_min_ - 0.5 * kStsClock,
+                             time_window_max_ + 0.5 * kStsClock, 31, 1, 32);
+
+    h2_[h_name]->GetXaxis()->SetTitle(Form("t_{%s} - t_{StsDigi} [ns]", ToString(time_ref_system_).c_str()));
+    h2_[h_name]->GetYaxis()->SetTitle("Charge_{StsDigi} [ADC]");
+  }
+
+  h_name      = Form("0x%x_dt_vs_channel", address);
+  h_title     = smart_name;
+  h2_[h_name] = std::make_unique<TH2D>(h_name.c_str(), h_title.c_str(), 2048, 0, 2048, nb_time_bins,
+                                       time_window_min_ - 0.5 * kStsClock, time_window_max_ + 0.5 * kStsClock);
+
+  h2_[h_name]->GetYaxis()->SetTitle(Form("t_{%s} - t_{StsDigi} [ns]", ToString(time_ref_system_).c_str()));
+  h2_[h_name]->GetXaxis()->SetTitle("Channel_{StsDigi}");
+
+  address_book_.insert(address);
+}
+
+void CbmStsTimeCal::Exec(Option_t*)
+{
+  LOG(info) << "Running CbmStsTimeCal - Entry " << entry_;
+
+  if (time_ref_system_ == ECbmModuleId::kBmon) CheckTiming<CbmBmonDigi>();
+  if (time_ref_system_ == ECbmModuleId::kTof) CheckTiming<CbmTofDigi>();
+  if (time_ref_system_ == ECbmModuleId::kRich) CheckTiming<CbmRichDigi>();
+
+  entry_++;
+}
+
+template<class Digi>
+void CbmStsTimeCal::CheckTiming()
+{
+  auto sts_digis_ = digi_manager->GetArray<CbmStsDigi>();
+  auto ref_digis_ = digi_manager->GetArray<Digi>();
+
+  size_t nb_sts_digis = digi_manager->GetNofDigis(ECbmModuleId::kSts);
+  size_t nb_ref_digis = digi_manager->GetNofDigis(Digi::GetSystem());
+
+  LOG(info) << nb_sts_digis << "\t" << nb_ref_digis;
+
+  // Loops over Ref Detector
+  for (size_t ref_digi_idx = 0; ref_digi_idx < nb_ref_digis - 1; ref_digi_idx++) {
+    const Digi* ref_digi = &ref_digis_[ref_digi_idx];
+    double ref_digi_time = ref_digi->GetTime();
+
+    if (analysis_cut_ != nullptr
+        && !analysis_cut_->Check(CbmCutId::kBmonDigiSide, CbmTofAddress::GetChannelSide(ref_digi->GetAddress())))
+      continue;
+
+    double first_digi_in_window = ref_digi_time + time_window_min_;
+    double last_digi_in_window  = ref_digi_time + time_window_max_;
+    // Find first_digi_in_window
+    int lo = 0, hi = nb_sts_digis - 1;
+    while (lo < hi) {
+      int m = (lo + hi) / 2;
+      if (sts_digis_[m].GetTime() >= first_digi_in_window) {
+        hi = m;
+      }
+      else {
+        lo = m + 1;
+      }
+    }
+    int lower_hitB = lo;
+
+    // Find last_digi_in_window
+    lo = 0, hi = nb_sts_digis - 1;
+    while (lo < hi) {
+      int m = (lo + hi + 1) / 2;
+      if (sts_digis_[m].GetTime() <= last_digi_in_window) {
+        lo = m;
+      }
+      else {
+        hi = m - 1;
+      }
+    }
+    int upper_hitB = lo;
+    if (lower_hitB > upper_hitB) {
+      LOG(debug) << "Not time match found for the current hit within the time window";
+      continue;
+    }
+
+    for (int sts_digi_idx = lower_hitB; sts_digi_idx < upper_hitB; sts_digi_idx++) {
+      const CbmStsDigi* sts_digi = &sts_digis_[sts_digi_idx];
+      int32_t sts_digi_addr      = sts_digi->GetAddress();
+
+      if (!address_book_.count(sts_digi_addr)) {
+        BookHistograms(sts_digi_addr);
+        InitTimeWalkMap(sts_digi_addr);
+      }
+
+      int32_t sts_digi_chan = sts_digi->GetChannel();
+      int32_t sts_digi_char = sts_digi->GetCharge();
+      int32_t asic_idx      = sts_digi_chan / 128;
+      double sts_digi_time  = sts_digi->GetTime();
+
+      h2_[Form("0x%x_%02d", sts_digi_addr, asic_idx)]->Fill(ref_digi_time - sts_digi_time, sts_digi_char);
+      h2_[Form("0x%x_dt_vs_channel", sts_digi_addr)]->Fill(sts_digi_chan, ref_digi_time - sts_digi_time);
+    }  // end sts loop
+  }    // end ref loop
+}
+
+
+struct FitStsTime {
+  std::unique_ptr<TH1> h_x;
+  std::unique_ptr<TF1> f_x;
+  std::unique_ptr<TF1> f_peak;
+  std::unique_ptr<TF1> f_bkgd;
+  TFitResultPtr fit_ptr;
+  bool use_fit_result{false};
+  double time_offset{0};
+
+  TCanvas* Draw()
+  {
+    if (h_x == nullptr) {
+      return nullptr;
+    }
+    int pad_x = 1024;
+    int pad_y = 1024;
+
+    std::unique_ptr<TCanvas> canvas = std::make_unique<TCanvas>("_c0", "", pad_x, pad_y);
+    canvas->cd();
+
+    double line_width     = 0.06;
+    double pave0_top_edge = 0.95;
+    double pave0_bot_edge = pave0_top_edge - line_width * 3;
+    double pave1_top_edge = pave0_bot_edge;
+    double pave1_bot_edge = pave1_top_edge - line_width * 3;
+
+    h_x->SetLineStyle(1);
+    h_x->SetLineWidth((0.002 * pad_y));
+    h_x->SetLineColor(kBlack);
+    h_x->DrawClone("histo");
+
+    if (use_fit_result) {
+      f_x->SetTitle("Fitted function");
+      f_x->SetLineStyle(1);
+      f_x->SetLineWidth((0.002 * pad_y));
+      f_x->SetLineColor(kRed);
+      f_x->DrawClone("same");
+    }
+
+    if (use_fit_result) {
+      f_peak->SetTitle("Peak");
+      f_peak->SetLineStyle(kDotted);
+      f_peak->SetLineWidth((0.002 * pad_y));
+      f_peak->SetLineColor(kBlue);
+      f_peak->DrawClone("same");
+      std::unique_ptr<TPaveText> pave = std::make_unique<TPaveText>(0.16, pave0_bot_edge, 0.45, pave0_top_edge, "NDC");
+      pave->SetBorderSize(1);
+      pave->SetFillColor(0);
+      pave->SetTextAlign(12);
+      pave->AddText(Form("p0 = %.3f", f_peak->GetParameter(0)))->SetTextColor(kBlue);
+      pave->AddText(Form("p1 = %.3f", f_peak->GetParameter(1)))->SetTextColor(kBlue);
+      pave->AddText(Form("p2 = %.3f", f_peak->GetParameter(2)))->SetTextColor(kBlue);
+      pave->DrawClone();
+    }
+
+    if (use_fit_result) {
+      f_bkgd->SetTitle("Background");
+      f_bkgd->SetLineStyle(kDotted);
+      f_bkgd->SetLineWidth((0.002 * pad_y));
+      f_bkgd->SetLineColor(kOrange);
+      f_bkgd->DrawClone("same");
+      std::unique_ptr<TPaveText> pave = std::make_unique<TPaveText>(0.16, pave1_bot_edge, 0.45, pave1_top_edge, "NDC");
+      pave->SetBorderSize(1);
+      pave->SetFillColor(0);
+      pave->SetTextAlign(12);
+      pave->AddText(Form("p0 = %.3f", f_bkgd->GetParameter(0)))->SetTextColor(kOrange);
+      pave->AddText(Form("p1 = %.3f", f_bkgd->GetParameter(1)))->SetTextColor(kOrange);
+      pave->AddText(Form("p2 = %.3f", f_bkgd->GetParameter(2)))->SetTextColor(kOrange);
+      pave->DrawClone();
+    }
+
+    TLine offset(time_offset, h_x->GetMinimum(), time_offset, h_x->GetMaximum());
+    offset.SetLineWidth(0.004 * pad_y);
+    offset.SetLineColor(kGray);
+    offset.SetLineStyle(kDotted);
+    offset.DrawClone();
+
+    // Fit convergence
+    std::unique_ptr<TPaveText> fit_pave = std::make_unique<TPaveText>(0.65, 0.75, 0.95, 0.95, "NDC");
+    fit_pave->SetBorderSize(1);
+    fit_pave->SetFillColor(0);
+    fit_pave->SetTextAlign(12);
+    fit_pave->AddText(Form("NDF   = %d", fit_ptr->Ndf()));
+    fit_pave->AddText(Form("Chi2  = %.3f", fit_ptr->Chi2()));
+    fit_pave->AddText(Form("PRob  = %E", fit_ptr->Prob()));
+    fit_pave->DrawClone();
+
+    return (TCanvas*) canvas->Clone();
+  }
+
+  FitStsTime(TH1D* h)
+  {
+    if (h == nullptr) {
+      return;
+    }
+    h_x = std::make_unique<TH1D>(*h);
+    h_x->Scale(1. / h_x->Integral());
+
+    // Fit configuration
+    double time_resolution = 4.8;
+    double h_max           = h_x->GetBinCenter(h_x->GetMaximumBin());
+    double fit_x_min       = h_max - 10. * time_resolution;
+    double fit_x_max       = h_max + 10. * time_resolution;
+
+    f_x    = std::make_unique<TF1>("f_x", "[0]*TMath::Gaus(x, [1], [2]) + [3] + [4]*x + [5]*x*x", fit_x_min, fit_x_max);
+    f_peak = std::make_unique<TF1>("f_peak", "[0]*TMath::Gaus(x, [1], [2])", fit_x_min, fit_x_max);
+    f_bkgd = std::make_unique<TF1>("f_bkgd", "[0] + [1]*x + [2]*x*x", fit_x_min, fit_x_max);
+
+    // Initial values
+    f_x->SetParameter(0, 0.5);
+    f_x->SetParameter(1, h_max);
+    f_x->SetParameter(2, time_resolution);
+    f_x->SetParameter(5, -1e-4);
+
+    // Limits
+    f_x->SetParLimits(0, 0.0, 1.0);
+    f_x->SetParLimits(1, h_max - 2. * time_resolution, h_max + 2. * time_resolution);
+    f_x->SetParLimits(2, 3.125, 25);
+    f_x->SetParLimits(5, -1, 0.0);
+
+
+    fit_ptr = h_x->Fit("f_x", "SQN0", "", fit_x_min, fit_x_max);
+
+    f_x->SetParameters(fit_ptr->GetParams());
+    f_peak->SetParameter(0, fit_ptr->Parameter(0));
+    f_peak->SetParameter(1, fit_ptr->Parameter(1));
+    f_peak->SetParameter(2, fit_ptr->Parameter(2));
+    f_bkgd->SetParameter(0, fit_ptr->Parameter(3));
+    f_bkgd->SetParameter(1, fit_ptr->Parameter(4));
+    f_bkgd->SetParameter(2, fit_ptr->Parameter(5));
+
+    bool par_out_of_limits =
+      fit_ptr->Parameter(1) < h_max - 2. * time_resolution || h_max + 2. * time_resolution < fit_ptr->Parameter(1);
+
+    use_fit_result = !fit_ptr && fit_ptr->IsValid() && !par_out_of_limits;
+
+    if (use_fit_result) {
+      time_offset = f_peak->GetParameter(1);
+    }
+    else {
+      time_offset = h_max;
+    }
+  }
+};
+
+double CbmStsTimeCal::FindModuleOffset(int32_t address)
+{
+
+  double module_offset = 0;
+  TH2D* dt_vs_chn      = h2_[Form("0x%x_dt_vs_channel", address)].get();
+  if (dt_vs_chn != nullptr) {
+    TH1D* p_y = (TH1D*) dt_vs_chn->ProjectionY();
+
+    double peak = p_y->GetBinCenter(p_y->GetMaximumBin());
+
+    FitStsTime offset_fit(p_y);
+    TCanvas* drawing = offset_fit.Draw();
+    if (drawing != nullptr) {
+      offset_file_->cd();
+      drawing->Write(Form("0x%x_offset", address));
+    }
+
+    if (offset_fit.use_fit_result) {
+      module_offset = offset_fit.time_offset;
+    }
+    else {
+      module_offset = peak;
+    }
+  }
+  return module_offset;
+}
+
+void CbmStsTimeCal::CheckTimeWalk()
+{
+  /* This function can be optimized by parallelizing the loop over modules or ASIC idx, depending on the ratio
+		* For mCBM case, there are usually less than 16 modules so it makes more sense to parallelize the ASIC idx loop
+		* but for the full CBM case, the amount of modules greatly exceeds the number of ASIC per modules (16)
+		*/
+  for (int32_t module : address_book_) {  // loop over modules
+    double module_offset = FindModuleOffset(module);
+    for (unsigned int asic_idx = 0; asic_idx < 16; asic_idx++) {  // loop over ASICs
+
+      double adc_channel[32];
+      double adc_channel_err[32];
+      double time_offset[32];
+      double time_offset_err[32];
+      int n_pts = 0;
+
+      std::string h_name = Form("0x%x_%02d", module, asic_idx);
+      if (!h2_.count(h_name)) return;
+
+      auto h = h2_[h_name].get();
+
+      for (int adc = 1; adc <= 31; adc++) {
+        TH1D* h_x = h->ProjectionX(Form("%s_dt", h_name.c_str()), adc, adc);
+
+        FitStsTime offset_fit(h_x);
+        TCanvas* drawing = offset_fit.Draw();
+        if (drawing != nullptr) {
+          std::string fit_folder = Form("0x%x/%02d", module, asic_idx);
+          TDirectory* dir        = (TDirectory*) fit_file_->Get(fit_folder.c_str());
+          if (!dir) {
+            dir = fit_file_->mkdir(fit_folder.c_str());
+          }
+          dir->cd();
+          drawing->Write(Form("0x%x_%02d_%02d", module, asic_idx, adc));
+        }
+
+        if (offset_fit.use_fit_result) {
+          time_offset[n_pts]     = offset_fit.fit_ptr->Parameter(1);
+          time_offset_err[n_pts] = offset_fit.fit_ptr->Parameter(2);
+        }
+        else {
+          /* If the fitting for individual ADC of the ASIC was unsuccessful
+           * the time offset is taken as the one estimated for the whole module
+           */
+          time_offset[n_pts]     = module_offset;
+          time_offset_err[n_pts] = h_x->GetRMS();
+        }
+        adc_channel[n_pts]     = adc;
+        adc_channel_err[n_pts] = 0;
+
+        // Update time walk map
+        tw_map[module][asic_idx][adc] += time_offset[n_pts];
+
+        n_pts++;
+
+      }  // ---- end ADC loop ----
+
+      g1_[h_name] = std::make_unique<TGraphErrors>(n_pts, adc_channel, time_offset, adc_channel_err, time_offset_err);
+      g1_[h_name]->SetTitle(Form("%s : StsDigi_0x%x time off-set", ToString(time_ref_system_).c_str(), module));
+      g1_[h_name]->GetXaxis()->SetTitle("Charge_{StsDigi} [ADC]");
+      g1_[h_name]->GetYaxis()->SetTitle(Form("t_{%s} - t_{StsDigi} [ns]", ToString(time_ref_system_).c_str()));
+      g1_[h_name]->SetMinimum(time_window_min_);
+      g1_[h_name]->SetMaximum(time_window_max_);
+
+    }  // ---- end module loop ----
+  }    // ---- end ASICs loop ----
+}
+
+double CbmStsTimeCal::FindGlobalOffset()
+{
+  double setup_offset  = 0;
+  double min_sum_sigma = 999;
+  for (int32_t module : address_book_) { // module loop
+    double module_avg_sigma  = 0;
+    double module_avg_offset = 0;
+    int n_of_values          = 0;
+
+    for (unsigned int asic_idx = 0; asic_idx < 16; asic_idx++) { // asic loop
+      std::string h_name = Form("0x%x_%02d", module, asic_idx);
+      auto g             = g1_[h_name].get();
+
+      int n_of_pto    = g->GetN();
+      int lower_bound = n_of_pto > 5 ? n_of_pto - 5 : 0;
+
+      // Calculate the average value of the sigma for the last ADC
+      for (int pto = n_of_pto; pto > lower_bound - 5; pto--) {
+        double offset = g->GetPointY(pto);
+        double sigma  = g->GetErrorY(pto);
+        if (sigma) {
+          module_avg_sigma += sigma;
+          module_avg_offset += offset;
+          n_of_values++;
+        }
+      }
+    } // end asic loop
+
+    module_avg_sigma  = n_of_values ? module_avg_sigma / n_of_values : -1;
+    module_avg_offset = n_of_values ? module_avg_offset / n_of_values : -1;
+
+    if (module_avg_sigma && module_avg_sigma < min_sum_sigma) {
+      min_sum_sigma = module_avg_sigma;
+      setup_offset  = module_avg_offset;
+    }
+  } // end module loop
+
+  return setup_offset;
+}
+
+void CbmStsTimeCal::WriteYAML(){
+  std::string o_yaml_file = o_path_ + "/StsTimeCalibration.yaml";
+  LOG(info) << "Writing parameter file to:" << o_yaml_file;
+
+  YAML::Emitter walk_map;
+  walk_map << YAML::BeginMap;
+  walk_map << YAML::Key << "timeOffset";
+  walk_map << YAML::Value << (int)global_time_offset_;
+  walk_map << YAML::Key << "WalkMap";
+  walk_map << YAML::Value << YAML::BeginMap;
+  for (const auto& [module, asics] : tw_map) {
+    walk_map << YAML::Key << fmt::format("0x{:x}", module);
+    walk_map << YAML::Value << YAML::BeginSeq;
+    for (const auto& [asic, pars] : asics) {
+      // Begin a flow sequence
+      walk_map << YAML::Flow << YAML::BeginSeq;
+      for (const auto& value : pars) {
+          walk_map << fmt::format("{:+.3f}", value);  // Add '+' for positive numbers
+      }
+      // End the flow sequence
+      walk_map << YAML::EndSeq;
+    }
+    walk_map << YAML::EndSeq;
+  }
+  walk_map << YAML::EndMap << YAML::EndMap;
+  assert(walk_map.good());
+
+  std::ofstream walk_map_out(o_yaml_file);
+  assert(walk_map_out.is_open());
+
+  walk_map_out << walk_map.c_str();
+  walk_map_out.close();
+}
+
+void CbmStsTimeCal::Finish()
+{
+  CheckTimeWalk();
+
+  // resize ADC offset vector to 31 channels from 0 [0-30`]
+  for (auto& [module, asics] : tw_map) {        // Loop over modules
+    for (auto& [asic_idx, asic_par] : asics) {  // Loop over ASICs
+      for (int adc = 1; adc <= 31; adc++) {  // loop over ADC channels 31 channels [1 - 31]
+        asic_par[adc-1] = asic_par[adc];
+      }
+      asic_par.pop_back();
+    }
+  }
+
+  WriteYAML();
+
+  DrawResults();
+  SaveToFile();
+
+
+  h1_.clear();
+  h2_.clear();
+}
+
+
+void CbmStsTimeCal::DrawResults()
+{
+  std::unique_ptr<TCanvas> adc_vs_dt_1d =
+    std::make_unique<TCanvas>("adc_vs_dt_1d", "adc_vs_dt_1d", 10, 10, 4 * 1024, 4 * 1024);
+  adc_vs_dt_1d->Divide(4, 4);
+
+  std::unique_ptr<TCanvas> adc_vs_dt_2d =
+    std::make_unique<TCanvas>("adc_vs_dt_2d", "adc_vs_dt_2d", 10, 10, 4 * 1024, 4 * 1024);
+  adc_vs_dt_2d->Divide(4, 4);
+
+  std::unique_ptr<TCanvas> dt_vs_chn = std::make_unique<TCanvas>("dt_vs_chn", "dt_vs_chn", 10, 10, 1024, 1024);
+
+  report_file_->cd();
+  for (int32_t sensor : address_book_) {
+    for (int asic_idx = 0; asic_idx < 16; asic_idx++) {
+      adc_vs_dt_1d->cd(asic_idx + 1);
+      if (g1_[Form("0x%x_%02d", sensor, asic_idx)] != nullptr) {
+        g1_[Form("0x%x_%02d", sensor, asic_idx)]->Draw("APL");
+      }
+
+      adc_vs_dt_2d->cd(asic_idx + 1);
+      if (h2_[Form("0x%x_%02d", sensor, asic_idx)] != nullptr) {
+        h2_[Form("0x%x_%02d", sensor, asic_idx)]->Draw("colz");
+      }
+    }
+
+    dt_vs_chn->cd();
+    if (h2_[Form("0x%x_dt_vs_channel", sensor)] != nullptr) {
+      h2_[Form("0x%x_dt_vs_channel", sensor)]->Draw("colz");
+    }
+
+    adc_vs_dt_1d->Write(Form("adc_vs_dt_1d_0x%x", sensor));
+    adc_vs_dt_2d->Write(Form("adc_vs_dt_2d_0x%x", sensor));
+    dt_vs_chn->Write(Form("dt_vs_chn_0x%x", sensor));
+  }
+}
diff --git a/analysis/detectors/sts/CbmStsTimeCal.h b/analysis/detectors/sts/CbmStsTimeCal.h
new file mode 100644
index 0000000000..e2040cba62
--- /dev/null
+++ b/analysis/detectors/sts/CbmStsTimeCal.h
@@ -0,0 +1,179 @@
+/** \file CbmStsTimeCal.h
+ * \brief Definition of the CbmStsTimeCal class.
+ *
+ * Copyright (C) 2022 Facility for Antiproton and Ion Research in Europe, Darmstadt
+ * SPDX-License-Identifier: GPL-3.0-only
+ * Authors: Dario Ramirez [committer]
+ */
+
+#ifndef CBMSTSTIMECAL_H
+#define CBMSTSTIMECAL_H
+
+#include "CbmDefs.h"
+#include "CbmDigiManager.h"
+#include "CbmStsAnaBase.h"
+#include "CbmStsUtils.h"
+
+#include "yaml/Yaml.h"
+#include "detectors/sts/WalkMap.h"
+
+#include <FairTask.h>
+
+#include <TClonesArray.h>
+
+#include <cstring>
+#include <map>
+#include <unordered_set>
+
+/** \class CbmStsTimeCal
+ * \brief Task for time calibration of STS hits.
+ *
+ * This class inherits from FairTask and CbmStsAnaBase.
+ * It provides functionality for calibrating the time of STS hits.
+ */
+
+/**
+ * @class CbmStsTimeCal
+ * @brief STS Digi-level time calibration task for ASIC and ADC synchronization.
+ *
+ * This class derives from FairTask and CbmStsAnaBase, and performs
+ * time calibration of the STS (Silicon Tracking System) by determining
+ * precise time offsets for each ASIC and ADC. The calibration removes
+ * time walk effects to improve timing accuracy.
+ *
+ * Key features:
+ *
+ * - **Time Offset Calculation**:
+ *  Individual time offset values are found from the time difference distribution t_StsDigi - t_RefDigi (whole combinatoric inside search window).
+ *    1. Pre-determination of the time offset is obtained as the mean value of the time correlatiion peak for a given module
+ *    2. Further refining is attempted by fitting the time difference distribution with a N(dt,mu, sigma) + P_2(dt, p0,p1,p2).
+ *    3. ASIC ADC granularity is attemped. If failed, module offset is used.
+ *
+ * - **Reference Detector Selection**:
+ *   A reference detector system can be specified.
+ *   By default, the BMon (Beam Monitor) system is used.
+ *
+ * - **Reporting and Diagnostics**:
+ *   Generates a set of reporting histograms that illustrate the timing
+ *   distribution and calibration results.
+ *
+ * - **Organized Output by Run ID**:
+ *   When a run ID is provided, all output files (e.g., parameters,
+ *   histograms, reports) are stored in a dedicated folder named after
+ *   the run ID, ensuring organized data handling.
+ *
+ * - **Output File Generation**:
+ *   The task generates a YAML parameter file containing the individual time offset
+ *   for each ASIC ADC.
+ *
+ * - **Using pre-existing time calibration**:
+ *   Pre-existing YAML parameter files should be provided IF THE INPUT DATA WAS UNPACKED using such file.
+ *
+ * - **Time windows**:
+ *  The time window for the calibration can be set using the lower and upper limits.
+ *   - Very large windows can slow down the code due to high combinatorics.
+ *   - To smmal windows can lead to biased result. The search windows should not be smaller than 25 ns.
+ *
+ * This task is essential for achieving precise timing synchronization
+ * across all readout electronics in the STS subsystem.
+ */
+class CbmStsTimeCal : public FairTask, public CbmStsAnaBase {
+ public:
+  /** \brief Constructor */
+  CbmStsTimeCal();
+
+  /** \brief Parameterized constructor
+   * @param system reference detector for time
+   * @param lower_lim lower boundary for time difference between @param system digis and STS digis (default: -60).
+   * @param upper_lim lower boundary for time difference between @param system digis and STS digis (default: +60).
+   */
+  CbmStsTimeCal(ECbmModuleId system, double lower_lim = -60, double upper_lim = +60);
+
+  /** \brief Parameterized constructor
+   * @param system reference detector for time
+   * @param lower_lim lower boundary for time difference between @param system digis and STS digis (default: -60).
+   * @param upper_lim lower boundary for time difference between @param system digis and STS digis (default: +60).
+   */
+  CbmStsTimeCal(int run_id, ECbmModuleId system, double lower_lim, double upper_lim);
+
+  /** \brief Destructor */
+  virtual ~CbmStsTimeCal();
+
+  /**
+   * @brief Set parameter file used during unpacking
+   * @param file_name full/relative path to the parameters file
+   */
+  void SetWalkFile(std::string par_file);
+
+  InitStatus Init();
+  void Exec(Option_t*);
+  void Finish();
+
+
+ private:
+  double global_time_offset_{0};
+  double time_window_min_{-60};
+  double time_window_max_{+60};
+  const double kStsClock{3.125};
+  std::string par_file_{""};
+  std::string o_path_{""};
+
+  std::map<int /* Module */, std::map<int /* ASIC */, std::vector<double> /* ADC offset */>> tw_map;
+  cbm::algo::sts::WalkMap time_walk_map;
+
+  std::unique_ptr<TFile> offset_file_;
+  std::unique_ptr<TFile> fit_file_;
+
+  ECbmModuleId time_ref_system_{ECbmModuleId::kBmon};
+
+  CbmDigiManager* digi_manager{nullptr};
+
+  TClonesArray* cbm_evt_array_{nullptr};
+
+  /**
+   * @brief Book histograms.
+   * @param address The module address for which histograms will be booked.
+   */
+  void BookHistograms(int32_t address);
+
+  /** \brief Extract Time Walk parameters */
+  void CheckTimeWalk();
+
+  /** \brief Extract Time general offset for a given module */
+  double FindModuleOffset(int32_t);
+
+  /** \brief Find a common offset for STS setup.
+   * It is taken as the average of the time offset for ADC > 25
+   * for the setup module with the narrower dt distribution
+  */
+  double FindGlobalOffset();
+
+  /** \brief Check timing for a specific digi type
+   * It fills StsDigi time difference respect to ref_system Digis histograms
+  */
+  template<class Digi>
+  void CheckTiming();
+
+  /**
+   * @brief Initialized the Time Walk map
+   * @param address The module address for which the initialization is done
+   */
+  void InitTimeWalkMap(int32_t address);
+
+  /**
+   * @brief Load the time calibration parameters from user define file
+   */
+  void LoadWalkFromFile();
+
+  /**
+   * @brief Write parameters file in YAML format
+   * @param o_path output folder where to save the file
+   */
+  void WriteYAML();
+
+  void DrawResults();
+
+  ClassDef(CbmStsTimeCal, 1);
+
+};
+#endif
diff --git a/macro/sts/sts_time.C b/macro/sts/sts_time.C
new file mode 100644
index 0000000000..455df4139d
--- /dev/null
+++ b/macro/sts/sts_time.C
@@ -0,0 +1,56 @@
+
+void sts_time(
+    int run_id = 2984,
+    int n_of_ts = 2,
+    std::string raw_file = "",
+    std::string out_file = "cbm_sts_time_cal.root"
+){
+    // -----   Timer   --------------------------------------------------------
+    TStopwatch timer;
+    timer.Start();
+
+    // --- Logger settings ----------------------------------------------------
+    TString logLevel     = "DEBUG";
+    TString logVerbosity = "veryhigh";
+            logLevel     = "INFO";
+            logVerbosity = "low";
+
+    FairLogger::GetLogger()->SetLogScreenLevel(logLevel.Data());
+    FairLogger::GetLogger()->SetLogVerbosityLevel(logVerbosity.Data());
+    // ------------------------------------------------------------------------
+
+
+    // -----   Environment   --------------------------------------------------
+    std::string srcDir = gSystem->Getenv("VMCWORKDIR");  // top source directory
+    // ------------------------------------------------------------------------
+
+    std::unique_ptr<CbmStsAnalysis> run = std::make_unique<CbmStsAnalysis>();
+    FairFileSource* inputSource = new FairFileSource(raw_file.c_str());
+    FairRootFileSink* outputSink = new FairRootFileSink(out_file.c_str());
+
+    run->SetSource(inputSource);
+    run->SetSink(outputSink);
+
+    // ------------------------------------------------------------------------
+    // Configure Analysis filters
+    // ------------------------------------------------------------------------
+    CbmCutMap ana_filter;
+    ana_filter.AddCbmCut(CbmCutId::kBmonDigiSide)->SetRange(1, 1);
+
+    CbmStsTimeCal* sts_time = new CbmStsTimeCal(run_id, ECbmModuleId::kBmon, -100, 100);
+    sts_time->SetCutMap(&ana_filter);
+    sts_time->SetWalkFile(Form("%s/parameters/online/StsWalkMap_mcbm2024.yaml", srcDir.c_str()));
+    run->AddTask(sts_time);
+
+    run->Init();
+    run->Run(0,n_of_ts);
+
+    // ------------------------------------------------------------------------
+    timer.Stop();
+    Double_t rtime = timer.RealTime();
+    Double_t ctime = timer.CpuTime();
+    cout << endl << endl;
+    cout << "Macro finished successfully." << endl;
+    cout << "Real time " << rtime << " s, CPU time " << ctime << " s" << endl;
+    cout << endl;
+}
\ No newline at end of file
-- 
GitLab


From 78e0c26f876c44db94f0bb46e410ab2bb09bfa52 Mon Sep 17 00:00:00 2001
From: Dario Ramirez <d.ramirez@gsi.de>
Date: Mon, 14 Apr 2025 16:21:38 +0200
Subject: [PATCH 05/18] Add method to load STS charge calibration from ASCII
 file

---
 core/detectors/sts/CbmStsParSetModule.cxx | 78 +++++++++++++++++++++++
 core/detectors/sts/CbmStsParSetModule.h   |  7 +-
 2 files changed, 84 insertions(+), 1 deletion(-)

diff --git a/core/detectors/sts/CbmStsParSetModule.cxx b/core/detectors/sts/CbmStsParSetModule.cxx
index b9439025c7..8a4f4363bf 100644
--- a/core/detectors/sts/CbmStsParSetModule.cxx
+++ b/core/detectors/sts/CbmStsParSetModule.cxx
@@ -15,6 +15,7 @@
 #include <cassert>  // for assert
 #include <sstream>  // for operator<<, basic_ostream, stringstream
 #include <string>   // for char_traits
+#include <fstream>  // for reading parameters from ASCII file
 
 
 ClassImp(CbmStsParSetModule)
@@ -64,6 +65,83 @@ Bool_t CbmStsParSetModule::getParams(FairParamList*)
 }
 // --------------------------------------------------------------------------
 
+// -----   Read parameters from ASCII file   --------------------------------
+Bool_t CbmStsParSetModule::LoadParASCII(std::string file_name)
+{
+  std::ifstream input(file_name);
+  if (!input.is_open()) {
+    LOG(error) << Form("[STS Charge Calibration] Error opening file: %s", file_name.c_str());
+    ;
+    return kFALSE;
+  }
+
+  LOG(info) << Form("[STS Charge Calibration] Loading configuration from file: %s", file_name.c_str());
+
+  int32_t address, side, asic_idx, nb_channels, nb_adc;
+  double dyn_range, threshold, time_res, dead_time, noise, znr;
+
+  // Default ASIC values
+  std::unique_ptr<CbmStsParAsic> default_asic =
+    std::make_unique<CbmStsParAsic>(128, 31, 75000., 3000., 5., 800., 1000., 3.9789e-3);
+
+  // Default module configuration
+  std::unique_ptr<CbmStsParModule> default_module = std::make_unique<CbmStsParModule>(2048, 128);
+  default_module->SetAllAsics(*default_asic);
+
+  std::string line;
+  while (std::getline(input, line)) {
+
+    // Skip commented lines
+    if (line[0] == '#') {
+      continue;
+    }
+    std::istringstream str_stream(line);
+    str_stream >> std::hex >> address >> std::dec >> side >> asic_idx >> nb_channels >> nb_adc >> dyn_range >> threshold
+      >> time_res >> dead_time >> noise >> znr;
+
+    // Initialize map entry with default configuration
+    if (!fParams.count(address)){
+      fParams[address] = *default_module;
+    }
+
+    // Custom ASIC loaded from file
+    std::unique_ptr<CbmStsParAsic> custom_asic =
+      std::make_unique<CbmStsParAsic>(nb_channels, nb_adc, dyn_range, threshold, time_res, dead_time, noise, znr);
+
+    if (asic_idx == -1) {  // Same configuration for all ASIC in the given side
+      if (side == -1) {    // Same configuration for both sides
+        LOG(info) << Form("[STS Charge Calibration] Using same configuration for all ASICs in module 0x%x", address);
+        fParams[address].SetAllAsics(*custom_asic);
+      }
+      else {
+        // Configure ASIC all for given side
+        LOG(info) << Form("[STS Charge Calibration] Using same configuration for all ASICs in module 0x%x, side %u",
+                           address, side);
+        for (int idx = 0; idx < 8; idx++) {
+          fParams[address].SetAsic(idx + 8 * side, *custom_asic);
+        }
+      }
+    }
+    else {
+      if (side == -1) {
+        fParams[address].SetAsic(asic_idx, *custom_asic);
+        fParams[address].SetAsic(asic_idx + 8, *custom_asic);
+      }
+      else {
+        fParams[address].SetAsic(asic_idx + 8 * side, *custom_asic);
+      }
+    }
+  }
+
+  if (fParams.size() == 1 && fParams.begin()->first == -1) {
+    LOG(info) << "[STS Charge Calibration] Using same configuration for all modules";
+    SetGlobalPar(fParams.begin()->second);
+    fParams.clear();
+  }
+
+  return kTRUE;
+}
+// --------------------------------------------------------------------------
 
 // -----   Get condition parameters of a module   ---------------------------
 const CbmStsParModule& CbmStsParSetModule::GetParModule(UInt_t address)
diff --git a/core/detectors/sts/CbmStsParSetModule.h b/core/detectors/sts/CbmStsParSetModule.h
index 3f516fc4f4..d4c6026be6 100644
--- a/core/detectors/sts/CbmStsParSetModule.h
+++ b/core/detectors/sts/CbmStsParSetModule.h
@@ -62,7 +62,12 @@ public:
      **
      ** An ASCII I/O is not implemented. The method throws an error.
      **/
-  virtual Bool_t getParams(FairParamList* parList);
+    virtual Bool_t getParams(FairParamList* parList);
+
+   /** @brief Reading parameters from ASCII.
+    * * @param file_name  path to the parameters file
+       **/
+   Bool_t LoadParASCII(std::string file_name);
 
 
   /** @brief Get condition parameters of a sensor
-- 
GitLab


From 409cdcfd7fff24d3840290bbb9aa4a683b67bde2 Mon Sep 17 00:00:00 2001
From: Dario Ramirez <d.ramirez@gsi.de>
Date: Mon, 14 Apr 2025 16:44:26 +0200
Subject: [PATCH 06/18] CbmStsHitAna: STS hit analysis

Correlation among charge, size and time among hit cluster sides and filtering by hit belonging to tracks
---
 analysis/detectors/sts/CMakeLists.txt     |   1 +
 analysis/detectors/sts/CbmStsAnaLinkDef.h |   1 +
 analysis/detectors/sts/CbmStsHitAna.cxx   | 250 ++++++++++++++++++++++
 analysis/detectors/sts/CbmStsHitAna.h     | 115 ++++++++++
 macro/sts/sts_hit_ana.C                   | 100 +++++++++
 5 files changed, 467 insertions(+)
 create mode 100644 analysis/detectors/sts/CbmStsHitAna.cxx
 create mode 100644 analysis/detectors/sts/CbmStsHitAna.h
 create mode 100644 macro/sts/sts_hit_ana.C

diff --git a/analysis/detectors/sts/CMakeLists.txt b/analysis/detectors/sts/CMakeLists.txt
index 41383ec422..29c3801b35 100644
--- a/analysis/detectors/sts/CMakeLists.txt
+++ b/analysis/detectors/sts/CMakeLists.txt
@@ -15,6 +15,7 @@ set(SRCS
   CbmSpillCheck.cxx
   CbmStsChannelQA.cxx
   CbmStsTimeCal.cxx
+  CbmStsHitAna.cxx
   )
 
 
diff --git a/analysis/detectors/sts/CbmStsAnaLinkDef.h b/analysis/detectors/sts/CbmStsAnaLinkDef.h
index 9852b9c38b..ad2faeaaba 100644
--- a/analysis/detectors/sts/CbmStsAnaLinkDef.h
+++ b/analysis/detectors/sts/CbmStsAnaLinkDef.h
@@ -17,5 +17,6 @@
 #pragma link C++ class CbmSpillCheck + ;
 #pragma link C++ class CbmStsChannelQA + ;
 #pragma link C++ class CbmStsTimeCal + ;
+#pragma link C++ class CbmStsHitAna + ;
 
 #endif /* __CINT__ */
diff --git a/analysis/detectors/sts/CbmStsHitAna.cxx b/analysis/detectors/sts/CbmStsHitAna.cxx
new file mode 100644
index 0000000000..2c92c198ac
--- /dev/null
+++ b/analysis/detectors/sts/CbmStsHitAna.cxx
@@ -0,0 +1,250 @@
+/* Copyright (C) 2022 Facility for Antiproton and Ion Research in Europe, Darmstadt
+   SPDX-License-Identifier: GPL-3.0-only
+   Authors: Dario Ramirez [committer] */
+#include "CbmStsHitAna.h"
+
+#include <CbmStsTrack.h>
+
+#include <ctime>
+#include <iostream>
+#include <typeinfo>
+
+CbmStsHitAna::CbmStsHitAna() : hit_modifier_({":all"}) { LOG(debug) << "Creating an instance of CbmStsHitAna ..."; }
+
+CbmStsHitAna::CbmStsHitAna(std::string cal_par_file) : hit_modifier_({":all"}), calibration_file_(cal_par_file)
+{
+  LOG(debug) << "Creating an instance of CbmStsHitAna ...";
+}
+
+CbmStsHitAna::~CbmStsHitAna() {}
+
+InitStatus CbmStsHitAna::Init()
+{
+  if (module_par_set_ == nullptr) {
+    LOG(debug) << "Loading charge calibration ...";
+    module_par_set_ = std::make_unique<CbmStsParSetModule>("CbmParSetModule", "STS parameters", "Default");
+    module_par_set_->LoadParASCII(calibration_file_);
+  }
+
+  FairRootManager* ioman = FairRootManager::Instance();
+  if (ioman == nullptr) return kERROR;
+
+  cbm_evt_array_ = (TClonesArray*) ioman->GetObject("CbmEvent");
+
+  glb_trk_array_ = (TClonesArray*) ioman->GetObject("GlobalTrack");
+  sts_trk_array_ = (TClonesArray*) ioman->GetObject("StsTrack");
+  rch_trk_array_ = (TClonesArray*) ioman->GetObject("RichTrack");
+  mch_trk_array_ = (TClonesArray*) ioman->GetObject("MuchTrack");
+  trd_trk_array_ = (TClonesArray*) ioman->GetObject("TrdTrack");
+  tof_trk_array_ = (TClonesArray*) ioman->GetObject("TofTrack");
+
+  sts_hit_array_ = (TClonesArray*) ioman->GetObject("StsHit");
+  sts_clu_array_ = (TClonesArray*) ioman->GetObject("StsCluster");
+
+  if (glb_trk_array_) hit_modifier_.push_back(":trk");
+
+  LoadSetup();
+
+  return kSUCCESS;
+}
+
+void CbmStsHitAna::BookHistograms(int32_t address)
+{
+  LOG(debug) << Form("Booking histograms for module: 0x%x", address);
+
+  const CbmStsParModule& par_module           = module_par_set_->GetParModule(address);
+  const auto [n_side_binning, p_side_binning] = cbm_sts_utils::ChargeBinning(par_module, max_clu_size_);
+
+  std::string h_name;
+
+  double x_min = sts_geo_info_.count(address) ? sts_geo_info_[address][0] : -15;
+  double x_max = sts_geo_info_.count(address) ? sts_geo_info_[address][1] : +15;
+  double y_min = sts_geo_info_.count(address) ? sts_geo_info_[address][2] : -15;
+  double y_max = sts_geo_info_.count(address) ? sts_geo_info_[address][3] : +15;
+
+  double t_min = - 150 - 0.5*cbm_sts_utils::kStsClock;
+  double t_max = + 150 + 0.5*cbm_sts_utils::kStsClock;
+
+  auto x_binning = cbm_sts_utils::HBinning{uint32_t((x_max - x_min) / cbm_sts_utils::kStsDx), x_min, x_max};
+  auto y_binning = cbm_sts_utils::HBinning{uint32_t((y_max - y_min) / cbm_sts_utils::kStsDy), y_min, y_max};
+  auto t_binning = cbm_sts_utils::HBinning{uint32_t((t_max - t_min) / cbm_sts_utils::kStsClock), t_min, t_max};
+
+  for (const char* mod : hit_modifier_) {
+    h_name      = Form("0x%x_Q_asymmetry%s", address, mod);
+    h1_[h_name] = std::make_unique<TH1D>(h_name.c_str(), h_name.c_str(), 1000, -1.01, +1.01);
+
+    h_name      = Form("0x%x_Qp_vs_Qn%s", address, mod);
+    h2_[h_name] = std::make_unique<TH2D>(h_name.c_str(), h_name.c_str(), n_side_binning.n_of_bins, n_side_binning.x_min,
+                                         n_side_binning.x_max, p_side_binning.n_of_bins, p_side_binning.x_min,
+                                         p_side_binning.x_max);
+
+    h_name      = Form("0x%x_Qp_vs_size%s", address, mod);
+    h2_[h_name] = std::make_unique<TH2D>(h_name.c_str(), h_name.c_str(), p_side_binning.n_of_bins, p_side_binning.x_min,
+                                         p_side_binning.x_max, max_clu_size_, 1, max_clu_size_ + 1);
+
+    h_name      = Form("0x%x_Qn_vs_size%s", address, mod);
+    h2_[h_name] = std::make_unique<TH2D>(h_name.c_str(), h_name.c_str(), n_side_binning.n_of_bins, n_side_binning.x_min,
+                                         n_side_binning.x_max, max_clu_size_, 1, max_clu_size_ + 1);
+
+    h_name      = Form("0x%x_psize_vs_nsize%s", address, mod);
+    h2_[h_name] = std::make_unique<TH2D>(h_name.c_str(), h_name.c_str(), max_clu_size_, 1, max_clu_size_ + 1,
+                                         max_clu_size_, 1, max_clu_size_ + 1);
+
+    h_name      = Form("0x%x_y_vs_x%s", address, mod);
+    h2_[h_name] = std::make_unique<TH2D>(h_name.c_str(), h_name.c_str(),
+      x_binning.n_of_bins, x_binning.x_min, x_binning.x_max,
+      y_binning.n_of_bins, y_binning.x_min, y_binning.x_max);
+
+    h_name      = Form("0x%x_cluster_dt%s", address, mod);
+    h1_[h_name] = std::make_unique<TH1D>(h_name.c_str(), h_name.c_str(),
+      t_binning.n_of_bins, t_binning.x_min, t_binning.x_max);
+  }
+}
+
+void CbmStsHitAna::ProcessEvent(CbmEvent* evt)
+{
+  if (analysis_cut_ != nullptr && !analysis_cut_->CheckEvent(evt)) return;
+
+  int nb_sts_hits = evt->GetNofData(ECbmDataType::kStsHit);
+  for (int hit_evt_idx = 0; hit_evt_idx < nb_sts_hits; hit_evt_idx++) {
+    int sts_hit_idx = evt->GetIndex(ECbmDataType::kStsHit, hit_evt_idx);
+    CbmStsHit* hit  = (CbmStsHit*) sts_hit_array_->UncheckedAt(sts_hit_idx);
+    ProcessHit(hit, false);
+  }
+
+  int nb_of_glob_trk = evt->GetNofData(ECbmDataType::kGlobalTrack);
+  for (int evt_glob_trk_idx = 0; evt_glob_trk_idx < nb_of_glob_trk; evt_glob_trk_idx++) {
+    int glob_trk_idx         = evt->GetIndex(ECbmDataType::kGlobalTrack, evt_glob_trk_idx);
+    CbmGlobalTrack* glob_trk = (CbmGlobalTrack*) glb_trk_array_->UncheckedAt(glob_trk_idx);
+    ProcessGlobalTrack(glob_trk);
+  }
+}
+
+void CbmStsHitAna::ProcessHit(CbmStsHit* hit, bool belong_to_trk)
+{
+  if (hit == nullptr) return;
+  int32_t address = hit->GetAddress();
+
+  if (analysis_cut_ != nullptr && !analysis_cut_->CheckStsHit(hit, sts_clu_array_)) {
+    return;
+  }
+
+  if (!address_book_.count(address)) {
+    address_book_.insert(address);
+    BookHistograms(address);
+  }
+
+  double q_n = cbm_sts_utils::GetHitChargeF(hit, sts_clu_array_);
+  double q_p = cbm_sts_utils::GetHitChargeB(hit, sts_clu_array_);
+
+  int32_t size_n = cbm_sts_utils::GetHitCluSizeF(hit, sts_clu_array_);
+  int32_t size_p = cbm_sts_utils::GetHitCluSizeB(hit, sts_clu_array_);
+
+  const char* mod = hit_modifier_[belong_to_trk];
+
+  h1_[Form("0x%x_Q_asymmetry%s", address, mod)]->Fill(cbm_sts_utils::GetHitChargeAsy(hit, sts_clu_array_));
+  h2_[Form("0x%x_Qp_vs_Qn%s", address, mod)]->Fill(q_n, q_p);
+  h2_[Form("0x%x_Qp_vs_size%s", address, mod)]->Fill(q_p, size_p);
+  h2_[Form("0x%x_Qn_vs_size%s", address, mod)]->Fill(q_n, size_n);
+  h2_[Form("0x%x_psize_vs_nsize%s", address, mod)]->Fill(size_p, size_n);
+  h2_[Form("0x%x_y_vs_x%s", address, mod)]->Fill(hit->GetX(), hit->GetY());
+  h1_[Form("0x%x_cluster_dt%s", address, mod)]->Fill(cbm_sts_utils::GetHitTimeF(hit, sts_clu_array_) - cbm_sts_utils::GetHitTimeB(hit, sts_clu_array_));
+}
+
+void CbmStsHitAna::ProcessGlobalTrack(CbmGlobalTrack* trk)
+{
+  auto sts_trk_idx  = trk->GetStsTrackIndex();
+  auto rich_trk_idx = trk->GetRichRingIndex();
+  auto much_trk_idx = trk->GetMuchTrackIndex();
+  auto trd_trk_idx  = trk->GetTrdTrackIndex();
+  auto tof_trk_idx  = trk->GetTofTrackIndex();
+  float trk_p_val   = TMath::Prob(trk->GetChi2(), trk->GetNDF());
+
+  // Apply GlobalTracks cuts
+  int32_t mvd_trk_size = sts_trk_idx != -1 && sts_trk_array_ != nullptr
+                           ? ((CbmStsTrack*) sts_trk_array_->UncheckedAt(sts_trk_idx))->GetNofMvdHits()
+                           : 0;
+
+  int32_t sts_trk_size = sts_trk_idx != -1 && sts_trk_array_ != nullptr
+                           ? ((CbmStsTrack*) sts_trk_array_->UncheckedAt(sts_trk_idx))->GetNofStsHits()
+                           : 0;
+
+  int32_t rich_trk_size = rich_trk_idx != -1 && rch_trk_array_ != nullptr
+                            ? ((CbmTrack*) rch_trk_array_->UncheckedAt(rich_trk_idx))->GetNofHits()
+                            : 0;
+
+  int32_t much_trk_size = much_trk_idx != -1 && mch_trk_array_ != nullptr
+                            ? ((CbmTrack*) mch_trk_array_->UncheckedAt(much_trk_idx))->GetNofHits()
+                            : 0;
+
+  int32_t trd_trk_size = trd_trk_idx != -1 && trd_trk_array_ != nullptr
+                           ? ((CbmTrack*) trd_trk_array_->UncheckedAt(trd_trk_idx))->GetNofHits()
+                           : 0;
+
+  int32_t tof_trk_size = tof_trk_idx != -1 && tof_trk_array_ != nullptr
+                           ? ((CbmTrack*) tof_trk_array_->UncheckedAt(tof_trk_idx))->GetNofHits()
+                           : 0;
+
+  if (analysis_cut_ != nullptr
+      && (!analysis_cut_->Check(CbmCutId::kGlobalTrackMvdSize, mvd_trk_size)
+          || !analysis_cut_->Check(CbmCutId::kGlobalTrackStsSize, sts_trk_size)
+          || !analysis_cut_->Check(CbmCutId::kGlobalTrackRichSize, rich_trk_size)
+          || !analysis_cut_->Check(CbmCutId::kGlobalTrackMuchSize, much_trk_size)
+          || !analysis_cut_->Check(CbmCutId::kGlobalTrackTrdSize, trd_trk_size)
+          || !analysis_cut_->Check(CbmCutId::kGlobalTrackTofSize, tof_trk_size)
+          || !analysis_cut_->Check(CbmCutId::kGlobalTrackChi2, trk->GetChi2())
+          || !analysis_cut_->Check(CbmCutId::kGlobalTrackPval, trk_p_val))) {
+    return;
+  }
+  LOG(debug) << Form("Processing %d StsHit that were attached to a CATrack", sts_trk_size);
+  CbmStsTrack* sts_track = (CbmStsTrack*) sts_trk_array_->UncheckedAt(sts_trk_idx);
+
+  // ------------------------------------
+  // Process StsHit attached to a CATrack
+  // ------------------------------------
+  for (int hit_idx = 0; hit_idx < sts_trk_size; hit_idx++) {
+    uint32_t sts_hit_idx = sts_track->GetStsHitIndex(hit_idx);
+    CbmStsHit* sts_hit   = (CbmStsHit*) sts_hit_array_->UncheckedAt(sts_hit_idx);
+    ProcessHit(sts_hit, true);
+  }
+  // ------------------------------------
+}
+
+void CbmStsHitAna::Exec(Option_t*)
+{
+  if (cbm_evt_array_ != nullptr) {
+    uint32_t nb_events = cbm_evt_array_->GetEntriesFast();
+    double avg_nb_sts_hits = 0;
+    double avg_nb_of_glob_trk = 0;
+    for (uint32_t evt_idx = 0; evt_idx < nb_events; evt_idx++) {
+      ProcessEvent((CbmEvent*) cbm_evt_array_->UncheckedAt(evt_idx));
+      avg_nb_sts_hits    += ((CbmEvent*) cbm_evt_array_->UncheckedAt(evt_idx))->GetNofData(ECbmDataType::kStsHit);
+      avg_nb_of_glob_trk += ((CbmEvent*) cbm_evt_array_->UncheckedAt(evt_idx))->GetNofData(ECbmDataType::kGlobalTrack);
+    }
+    LOG_IF(info, nb_events) << "Running CbmStsHitAna - Event-like - Entry: " << entry_
+      << "\tEvents: " << nb_events
+      << "\tAvg StsHit/Events: "  << avg_nb_sts_hits / nb_events
+      << "\tAvg GlobalTrk/Events: " << avg_nb_of_glob_trk / nb_events;
+    LOG_IF(info, !nb_events) << "Running CbmStsHitAna - Event-like - Entry: " << entry_
+      << "\tEvents: " << nb_events;
+  }
+  else {
+    uint32_t n_of_hits = sts_hit_array_->GetEntriesFast();
+    LOG(info) << "Running CbmStsHitAna - Time-like - Entry: " << entry_ << "\tStsHits: " << n_of_hits;
+    for (uint32_t hit_idx = 0; hit_idx < n_of_hits; hit_idx++) {
+      CbmStsHit* sts_hit = (CbmStsHit*) sts_hit_array_->UncheckedAt(hit_idx);
+      ProcessHit(sts_hit, false);
+    }
+  }
+  entry_++;
+}
+
+void CbmStsHitAna::Finish()
+{
+  for (auto& [sensor, pair] : cal_sampled) {
+    std::cout << Form("0x%x %f\t%f\t%f\t%f\n", sensor, pair[0], pair[1], pair[2], pair[3]);
+  }
+  SaveToFile();
+  h1_.clear();
+  h2_.clear();
+}
diff --git a/analysis/detectors/sts/CbmStsHitAna.h b/analysis/detectors/sts/CbmStsHitAna.h
new file mode 100644
index 0000000000..a391086ce0
--- /dev/null
+++ b/analysis/detectors/sts/CbmStsHitAna.h
@@ -0,0 +1,115 @@
+/** \file CbmStsHitAna.h
+ * \brief Definition of the CbmStsHitAna class.
+ *
+ * Copyright (C) 2022 Facility for Antiproton and Ion Research in Europe, Darmstadt
+ * SPDX-License-Identifier: GPL-3.0-only
+ * Authors: Dario Ramirez [committer]
+ */
+
+#ifndef CBMSTSHITANA_H
+#define CBMSTSHITANA_H
+
+#include "CbmEvent.h"
+#include "CbmGlobalTrack.h"
+#include "CbmStsAnaBase.h"
+#include "CbmStsCluster.h"
+#include "CbmStsHit.h"
+#include "CbmStsParSetModule.h"
+#include "CbmStsUtils.h"
+
+#include <FairTask.h>
+
+#include <TClonesArray.h>
+
+#include <cstring>
+#include <map>
+#include <unordered_set>
+
+/**
+ * @class CbmStsHitAna
+ * @brief Task for detailed charge-size analysis of STS hits.
+ *
+ * This class inherits from FairTask and CbmStsAnaBase and is designed to
+ * perform detailed analysis of charge and size correlations in STS (Silicon Tracking System) hits.
+ *
+ * Key functionalities include:
+ *
+ * - **Charge Correlation**:
+ *   Analyzes the correlation of charge between the p-side and n-side of STS sensors.
+ *
+ * - **Time Correlation**:
+ *   Analyzes the correlation of time between the p-side and n-side cluster forming a hit.
+ *
+ * - **Cluster Size Correlation**:
+ *   Evaluates the size correlation between p-side and n-side clusters.
+ *
+ * - **Charge vs. Size Analysis**:
+ *   Performs charge versus cluster size studies separately for each sensor side.
+ *
+ * - **Hit Type Separation**:
+ *   All analyses are performed separately for:
+ *   - **All hits** (`all`) — includes all reconstructed hits.
+ *   - **Track hits** (`trk`) — includes only hits associated with reconstructed tracks.
+  */
+
+class CbmStsHitAna : public FairTask, public CbmStsAnaBase {
+ public:
+  /** \brief Constructor */
+  CbmStsHitAna();
+
+  /** \brief Constructor
+   * \param cal_par_file charge calibration file
+  */
+  CbmStsHitAna(std::string cal_par_file);
+
+  /** \brief Destructor */
+  virtual ~CbmStsHitAna();
+
+  InitStatus Init();
+  void Exec(Option_t*);
+  void Finish();
+
+ private:
+  uint32_t max_clu_size_{10};
+  std::vector<const char*> hit_modifier_;
+
+  std::unique_ptr<CbmStsParSetModule> module_par_set_;
+  std::string calibration_file_;
+
+  TClonesArray* cbm_evt_array_{nullptr};
+
+  TClonesArray* glb_trk_array_{nullptr};
+  TClonesArray* sts_trk_array_{nullptr};
+  TClonesArray* rch_trk_array_{nullptr};
+  TClonesArray* mch_trk_array_{nullptr};
+  TClonesArray* trd_trk_array_{nullptr};
+  TClonesArray* tof_trk_array_{nullptr};
+
+  TClonesArray* sts_hit_array_{nullptr};
+  TClonesArray* sts_clu_array_{nullptr};
+
+  void BookHistograms(int32_t);
+
+  /** \brief Process an Cbm events
+   * It filters event based on the provided CbmCutMap
+  */
+  void ProcessEvent(CbmEvent*);
+
+  /** \brief Process an STS hit
+   * It filters hits based on the provided CbmCutMap and fill the corresponding histogram
+   * \param hit StsHit to proccess
+   * \param belong_to_trk Specify that the hit belongs to a track, branching the histogram filling
+  */
+  void ProcessHit(CbmStsHit* hit, bool belong_to_trk = false);
+
+  /** \brief Process an STS hit attached to a Track
+   * It filters hits based on the provided CbmCutMap
+   * and check the track filters
+  */
+  void ProcessGlobalTrack(CbmGlobalTrack*);
+
+  std::map<int32_t, double[4]> cal_sampled;
+
+  ClassDef(CbmStsHitAna, 1);
+};
+#endif
diff --git a/macro/sts/sts_hit_ana.C b/macro/sts/sts_hit_ana.C
new file mode 100644
index 0000000000..4f764f1e91
--- /dev/null
+++ b/macro/sts/sts_hit_ana.C
@@ -0,0 +1,100 @@
+
+void sts_hit_ana(
+    int n_of_ts = -1,
+    std::string geo_setup_tag = "mcbm_beam_2024_05_08_nickel",
+    std::string raw_file = "",
+    std::string rec_file = "",
+    std::string geo_file = "",
+    std::string out_file = "cbm_sts_hit_ana.root",
+    bool bAli = true
+){
+    // -----   Timer   --------------------------------------------------------
+    TStopwatch timer;
+    timer.Start();
+
+    // --- Logger settings ----------------------------------------------------
+    TString logLevel     = "DEBUG";
+    TString logVerbosity = "veryhigh";
+            logLevel     = "INFO";
+            logVerbosity = "low";
+
+    FairLogger::GetLogger()->SetLogScreenLevel(logLevel.Data());
+    FairLogger::GetLogger()->SetLogVerbosityLevel(logVerbosity.Data());
+    // ------------------------------------------------------------------------
+
+
+    // -----   Environment   --------------------------------------------------
+    std::string srcDir = gSystem->Getenv("VMCWORKDIR");  // top source directory
+    // ------------------------------------------------------------------------
+
+    std::unique_ptr<CbmStsAnalysis> run = std::make_unique<CbmStsAnalysis>();
+
+    FairFileSource* inputSource = new FairFileSource(rec_file.c_str());
+    inputSource->AddFriend(raw_file.c_str());
+
+    FairRootFileSink* outputSink = new FairRootFileSink(out_file.c_str());
+
+
+    if (bAli) {
+        TString alignmentMatrixFileName = srcDir + "/parameters/mcbm/AlignmentMatrices_" + geo_setup_tag + ".root";
+        if (alignmentMatrixFileName.Length() != 0) {
+            std::map<std::string, TGeoHMatrix>* matrices{nullptr};
+            TFile* misalignmentMatrixRootfile = new TFile(alignmentMatrixFileName, "READ");
+            if (misalignmentMatrixRootfile->IsOpen()) {
+                gDirectory->GetObject("MisalignMatrices", matrices);
+                misalignmentMatrixRootfile->Close();
+            }
+            else {
+                LOG(error) << "Could not open file " << alignmentMatrixFileName << "\n Exiting";
+                exit(1);
+            }
+
+            if (matrices) {
+                run->AddAlignmentMatrices(*matrices);
+            }
+            else {
+                LOG(error) << "Alignment required but no matrices found."
+                << "\n Exiting";
+                exit(1);
+            }
+        }
+    }
+
+    run->SetGeomFile(geo_file.c_str());
+    run->SetSource(inputSource);
+    run->SetSink(outputSink);
+
+
+    // ------------------------------------------------------------------------
+    // Configure Analysis filters
+    // ------------------------------------------------------------------------
+    CbmCutMap ana_filter;
+    // Filter for all STS hits
+    ana_filter.AddCbmCut(CbmCutId::kStsHitQasym)->SetRange(-0.8, +0.8);
+    ana_filter.AddCbmCut(CbmCutId::kStsHitCharge)->SetMin(10000);
+
+    // Filter for track to extract STS hits tracks
+    ana_filter.AddCbmCut(CbmCutId::kGlobalTrackStsSize)->SetMin(2);
+    ana_filter.AddCbmCut(CbmCutId::kGlobalTrackTrdSize)->SetMin(1);
+    ana_filter.AddCbmCut(CbmCutId::kGlobalTrackTofSize)->SetMin(1);
+
+    // ------------------------------------------------------------------------
+    // Configure Charge Analysis
+    // ------------------------------------------------------------------------
+    CbmStsHitAna* sts_hit = new CbmStsHitAna(Form("%s/parameters/sts/sts_charge_cal_v24a.par", srcDir.c_str()));
+
+    sts_hit->SetCutMap(&ana_filter);
+    run->AddTask(sts_hit);
+
+    run->Init();
+    run->Run(0, n_of_ts);
+
+    // ------------------------------------------------------------------------
+    timer.Stop();
+    Double_t rtime = timer.RealTime();
+    Double_t ctime = timer.CpuTime();
+    cout << endl << endl;
+    cout << "Macro finished successfully." << endl;
+    cout << "Real time " << rtime << " s, CPU time " << ctime << " s" << endl;
+    cout << endl;
+}
\ No newline at end of file
-- 
GitLab


From f06b937b868c25c18db51c3898733b76ccf21345 Mon Sep 17 00:00:00 2001
From: Dario Ramirez <d.ramirez@gsi.de>
Date: Tue, 15 Apr 2025 10:57:50 +0200
Subject: [PATCH 07/18] CbmStsCorrelation: STS hit correlation

Use hit combinatoric from different STS stations to build correlation plots
---
 analysis/detectors/sts/CMakeLists.txt        |   1 +
 analysis/detectors/sts/CbmStsAnaLinkDef.h    |   1 +
 analysis/detectors/sts/CbmStsCorrelation.cxx | 208 +++++++++++++++++++
 analysis/detectors/sts/CbmStsCorrelation.h   |  72 +++++++
 macro/sts/sts_correlation.C                  |  92 ++++++++
 5 files changed, 374 insertions(+)
 create mode 100644 analysis/detectors/sts/CbmStsCorrelation.cxx
 create mode 100644 analysis/detectors/sts/CbmStsCorrelation.h
 create mode 100644 macro/sts/sts_correlation.C

diff --git a/analysis/detectors/sts/CMakeLists.txt b/analysis/detectors/sts/CMakeLists.txt
index 29c3801b35..577ea5b244 100644
--- a/analysis/detectors/sts/CMakeLists.txt
+++ b/analysis/detectors/sts/CMakeLists.txt
@@ -16,6 +16,7 @@ set(SRCS
   CbmStsChannelQA.cxx
   CbmStsTimeCal.cxx
   CbmStsHitAna.cxx
+  CbmStsCorrelation.cxx
   )
 
 
diff --git a/analysis/detectors/sts/CbmStsAnaLinkDef.h b/analysis/detectors/sts/CbmStsAnaLinkDef.h
index ad2faeaaba..5f9bd7ea76 100644
--- a/analysis/detectors/sts/CbmStsAnaLinkDef.h
+++ b/analysis/detectors/sts/CbmStsAnaLinkDef.h
@@ -18,5 +18,6 @@
 #pragma link C++ class CbmStsChannelQA + ;
 #pragma link C++ class CbmStsTimeCal + ;
 #pragma link C++ class CbmStsHitAna + ;
+#pragma link C++ class CbmStsCorrelation + ;
 
 #endif /* __CINT__ */
diff --git a/analysis/detectors/sts/CbmStsCorrelation.cxx b/analysis/detectors/sts/CbmStsCorrelation.cxx
new file mode 100644
index 0000000000..4eeb643137
--- /dev/null
+++ b/analysis/detectors/sts/CbmStsCorrelation.cxx
@@ -0,0 +1,208 @@
+/* Copyright (C) 2022 Facility for Antiproton and Ion Research in Europe, Darmstadt
+   SPDX-License-Identifier: GPL-3.0-only
+   Authors: Dario Ramirez [committer] */
+
+#include "CbmStsCorrelation.h"
+
+#include "CbmPixelHit.h"
+#include "CbmStsAddress.h"
+#include "TPaveStats.h"
+#include "TStyle.h"
+
+CbmStsCorrelation::CbmStsCorrelation() { LOG(debug) << "Creating an instance of CbmStsCorrelation ..."; }
+CbmStsCorrelation::~CbmStsCorrelation() {}
+
+void CbmStsCorrelation::BookHistograms()
+{
+
+  for (auto& [element_i, geo_i] : sts_geo_info_) {
+    for (auto& [element_j, geo_j] : sts_geo_info_) {
+
+      std::string h_name_base = "";
+      std::string obj_x, obj_y;
+      if (element_i < 8 && element_j < 8) {
+        if (element_i >= element_j) continue;
+        obj_x       = Form("Sts%d", element_i);
+        obj_y       = Form("Sts%d", element_j);
+        h_name_base = Form("Sts%d:Sts%d", element_i, element_j);
+      }
+      else if (element_i > 8 && element_j > 8) {
+        int32_t unit_i = CbmStsAddress::GetElementId(element_i, kStsUnit);
+        int32_t unit_j = CbmStsAddress::GetElementId(element_j, kStsUnit);
+
+        if (unit_i >= unit_j) continue;
+
+        obj_x       = Form("Sts0x%x", element_i);
+        obj_y       = Form("Sts0x%x", element_j);
+        h_name_base = Form("Sts0x%x:Sts0x%x", element_i, element_j);
+      }
+
+      if (!h_name_base.length()) continue;
+      LOG(debug) << Form("Booking for %s", h_name_base.c_str());
+
+      double x_min_i = geo_i[0];
+      double x_max_i = geo_i[1];
+      double y_min_i = geo_i[2];
+      double y_max_i = geo_i[3];
+
+      unsigned int nb_bins_x_i = (x_max_i - x_min_i) / cbm_sts_utils::kStsDx;
+      unsigned int nb_bins_y_i = (y_max_i - y_min_i) / cbm_sts_utils::kStsDy;
+
+      double x_min_j = geo_j[0];
+      double x_max_j = geo_j[1];
+      double y_min_j = geo_j[2];
+      double y_max_j = geo_j[3];
+
+      LOG(debug) << Form("XX_[%0.3f, %0.3f]:[%0.3f, %0.3f]", x_min_i, x_max_i, x_min_j, x_max_j);
+      LOG(debug) << Form("YY_[%0.3f, %0.3f]:[%0.3f, %0.3f]", y_min_i, y_max_i, y_min_j, y_max_j);
+
+      unsigned int nb_bins_x_j = (x_max_j - x_min_j) / cbm_sts_utils::kStsDx;
+      unsigned int nb_bins_y_j = (y_max_j - y_min_j) / cbm_sts_utils::kStsDy;
+
+      std::string h_name;
+      h_name = Form("%s_XX", h_name_base.c_str());
+      h2_[h_name] =
+        std::make_unique<TH2D>(h_name.c_str(), "", nb_bins_x_i, x_min_i, x_max_i, nb_bins_x_j, x_min_j, x_max_j);
+      h2_[h_name]->GetXaxis()->SetTitle(Form("X_{%s} [cm]", obj_x.c_str()));
+      h2_[h_name]->GetYaxis()->SetTitle(Form("X_{%s} [cm]", obj_y.c_str()));
+      h2_[h_name]->GetXaxis()->CenterTitle(true);
+      h2_[h_name]->GetYaxis()->CenterTitle(true);
+
+      h_name = Form("%s_YY", h_name_base.c_str());
+      h2_[h_name] =
+        std::make_unique<TH2D>(h_name.c_str(), "", nb_bins_y_i, y_min_i, y_max_i, nb_bins_y_j, y_min_j, y_max_j);
+      h2_[h_name]->GetXaxis()->SetTitle(Form("Y_{%s} [cm]", obj_x.c_str()));
+      h2_[h_name]->GetYaxis()->SetTitle(Form("Y_{%s} [cm]", obj_y.c_str()));
+      h2_[h_name]->GetXaxis()->CenterTitle(true);
+      h2_[h_name]->GetYaxis()->CenterTitle(true);
+    }
+  }
+}
+
+void CbmStsCorrelation::BuildCorrelation()
+{
+  bool is_mc_data = false;
+  if (!sts_hits_.size()) return;
+  for (int sts_unit_i = 0; sts_unit_i < nb_sts_station_ - 1; sts_unit_i++) {
+    for (int sts_unit_j = sts_unit_i + 1; sts_unit_j < nb_sts_station_; sts_unit_j++) {
+      LOG(debug) << Form("Building correlations for STS%d:STS%d: %ld\t%ld", sts_unit_i, sts_unit_j,
+                         sts_hits_[sts_unit_i].size(), sts_hits_[sts_unit_j].size());
+      for (auto sts_hit_i : sts_hits_[sts_unit_i]) {
+        int32_t sts_address_i = sts_hit_i->GetAddress();
+        double sts_i_x        = sts_hit_i->GetX();
+        double sts_i_y        = sts_hit_i->GetY();
+
+        CbmStsHit* closest_hit = nullptr;
+        double abs_time_diff   = 999;
+        for (auto sts_hit_j : sts_hits_[sts_unit_j]) {
+
+          if (is_mc_data) {
+            int32_t sts_address_j = sts_hit_j->GetAddress();
+            double sts_j_x        = sts_hit_j->GetX();
+            double sts_j_y        = sts_hit_j->GetY();
+
+            h2_[Form("Sts%d:Sts%d_YY", sts_unit_i, sts_unit_j)]->Fill(sts_i_y, sts_j_y);
+            h2_[Form("Sts%d:Sts%d_XX", sts_unit_i, sts_unit_j)]->Fill(sts_i_x, sts_j_x);
+            h2_[Form("Sts0x%x:Sts0x%x_YY", sts_address_i, sts_address_j)]->Fill(sts_i_y, sts_j_y);
+            h2_[Form("Sts0x%x:Sts0x%x_XX", sts_address_i, sts_address_j)]->Fill(sts_i_x, sts_j_x);
+          }
+          else {
+
+            double dt = std::abs(sts_hit_i->GetTime() - sts_hit_j->GetTime());
+            if (abs_time_diff > dt) {
+              abs_time_diff = dt;
+              closest_hit   = sts_hit_j;
+            }
+          }
+        }
+        if (!is_mc_data && closest_hit != nullptr) {
+          int32_t sts_address_j = closest_hit->GetAddress();
+          double sts_j_x        = closest_hit->GetX();
+          double sts_j_y        = closest_hit->GetY();
+
+          h2_[Form("Sts%d:Sts%d_YY", sts_unit_i, sts_unit_j)]->Fill(sts_i_y, sts_j_y);
+          h2_[Form("Sts%d:Sts%d_XX", sts_unit_i, sts_unit_j)]->Fill(sts_i_x, sts_j_x);
+          h2_[Form("Sts0x%x:Sts0x%x_YY", sts_address_i, sts_address_j)]->Fill(sts_i_y, sts_j_y);
+          h2_[Form("Sts0x%x:Sts0x%x_XX", sts_address_i, sts_address_j)]->Fill(sts_i_x, sts_j_x);
+        }
+      }
+    }
+  }
+  sts_hits_.clear();
+}
+
+void CbmStsCorrelation::ProcessEvent(CbmEvent* evt)
+{
+  if (analysis_cut_ != nullptr && !analysis_cut_->CheckEvent(evt)) return;
+
+  int nb_sts_hits = evt->GetNofData(ECbmDataType::kStsHit);
+  LOG(debug) << Form("Processing event with %d StsHit", nb_sts_hits);
+  for (int hit_evt_idx = 0; hit_evt_idx < nb_sts_hits; hit_evt_idx++) {
+    int sts_hit_idx = evt->GetIndex(ECbmDataType::kStsHit, hit_evt_idx);
+    CbmStsHit* hit  = (CbmStsHit*) sts_hit_array_->UncheckedAt(sts_hit_idx);
+    ProcessHit(hit);
+  }
+}
+
+void CbmStsCorrelation::ProcessHit(CbmStsHit* hit)
+{
+  if (hit == nullptr) return;
+
+  if (analysis_cut_ != nullptr && !analysis_cut_->CheckStsHit(hit, sts_clu_array_)) return;
+
+  int32_t address = hit->GetAddress();
+  int32_t unit    = CbmStsAddress::GetElementId(address, kStsUnit);
+
+  sts_hits_[unit].push_back(hit);
+}
+
+void CbmStsCorrelation::Exec(Option_t*)
+{
+  // Check if CbmEvent
+  if (cbm_evt_array_ != nullptr) {
+    uint32_t nb_events = cbm_evt_array_->GetEntriesFast();
+    LOG(info) << Form("Running event-like Entry: %d\t%d CbmEvents", entry_, nb_events);
+    for (uint32_t evt_idx = 0; evt_idx < nb_events; evt_idx++) {
+      CbmEvent* event = (CbmEvent*) cbm_evt_array_->UncheckedAt(evt_idx);
+      ProcessEvent(event);
+      BuildCorrelation();
+    }
+  }
+  else {
+
+    LOG(debug) << "Running time-like ...";
+    uint32_t n_of_hits = sts_hit_array_->GetEntriesFast();
+    for (uint32_t hit_idx = 0; hit_idx < n_of_hits; hit_idx++) {
+      CbmStsHit* sts_hit = (CbmStsHit*) sts_hit_array_->UncheckedAt(hit_idx);
+      ProcessHit(sts_hit);
+    }
+    BuildCorrelation();
+  }
+  entry_++;
+}
+
+InitStatus CbmStsCorrelation::Init()
+{
+  LOG(debug) << "Init CbmStsCorrelation ...";
+
+  FairRootManager* ioman = FairRootManager::Instance();
+  if (ioman != nullptr) {
+    cbm_evt_array_ = (TClonesArray*) ioman->GetObject("CbmEvent");
+    sts_hit_array_ = (TClonesArray*) ioman->GetObject("StsHit");
+    sts_clu_array_ = (TClonesArray*) ioman->GetObject("StsCluster");
+  }
+
+  LoadSetup();
+
+  BookHistograms();
+
+  return kSUCCESS;
+}
+
+
+void CbmStsCorrelation::Finish()
+{
+  SaveToFile();
+  h1_.clear();
+  h2_.clear();
+}
diff --git a/analysis/detectors/sts/CbmStsCorrelation.h b/analysis/detectors/sts/CbmStsCorrelation.h
new file mode 100644
index 0000000000..19093511a8
--- /dev/null
+++ b/analysis/detectors/sts/CbmStsCorrelation.h
@@ -0,0 +1,72 @@
+/** \file CbmStsCorrelation.h
+ * \brief Definition of the CbmStsCorrelation class.
+ *
+ * Copyright (C) 2022 Facility for Antiproton and Ion Research in Europe, Darmstadt
+ * SPDX-License-Identifier: GPL-3.0-only
+ * Authors: Dario Ramirez [committer]
+ */
+
+#ifndef CBMSTSCORRELATION_H
+#define CBMSTSCORRELATION_H
+
+#include "CbmEvent.h"
+#include "CbmStsAnaBase.h"
+#include "CbmStsCluster.h"
+#include "CbmStsHit.h"
+#include "CbmStsUtils.h"
+
+#include <FairTask.h>
+
+#include <TClonesArray.h>
+
+#include <cstring>
+#include <map>
+#include <unordered_map>
+#include <unordered_set>
+
+/** \class CbmStsCorrelation
+ * \brief Task for correlation analysis of STS hits.
+ *
+ * This class inherits from FairTask and CbmStsAnaBase.
+ * It provides functionality for analyzing correlations
+ * among STS hits.
+ */
+class CbmStsCorrelation : public FairTask, public CbmStsAnaBase {
+ public:
+  /** \brief Constructor */
+  CbmStsCorrelation();
+
+  /** \brief Destructor */
+  virtual ~CbmStsCorrelation();
+
+  InitStatus Init();
+  void Exec(Option_t*);
+  void Finish();
+
+ private:
+  std::map<int32_t, std::vector<CbmStsHit*>> sts_hits_;
+
+  TClonesArray* cbm_evt_array_;
+  TClonesArray* sts_hit_array_;
+  TClonesArray* sts_clu_array_;
+
+  void BookHistograms();
+
+  /** \brief Process an Cbm events
+   * It filters event based on the provided CbmCutMap
+  */
+  void ProcessEvent(CbmEvent*);
+
+  /** \brief Process an STS hit
+   * It filters hits based on the provided CbmCutMap
+  */
+  void ProcessHit(CbmStsHit*);
+
+  /** \brief Build the correlation
+   * Using filtered hit build the combinatorial among different station sensors
+   */
+  void BuildCorrelation();
+
+  ClassDef(CbmStsCorrelation, 1);
+};
+#endif
diff --git a/macro/sts/sts_correlation.C b/macro/sts/sts_correlation.C
new file mode 100644
index 0000000000..866351b603
--- /dev/null
+++ b/macro/sts/sts_correlation.C
@@ -0,0 +1,92 @@
+void sts_correlation(
+    int n_of_ts = -1,
+    std::string geo_setup_tag = "mcbm_beam_2024_05_08_nickel",
+    std::string raw_file = "",
+    std::string rec_file = "",
+    std::string geo_file = "",
+    std::string out_file = "cbm_sts_correlation.root",
+    bool bAli = true
+){
+    // -----   Timer   --------------------------------------------------------
+    TStopwatch timer;
+    timer.Start();
+
+    // --- Logger settings ----------------------------------------------------
+    TString logLevel     = "DEBUG";
+    TString logVerbosity = "veryhigh";
+            logLevel     = "INFO";
+            logVerbosity = "low";
+
+    FairLogger::GetLogger()->SetLogScreenLevel(logLevel.Data());
+    FairLogger::GetLogger()->SetLogVerbosityLevel(logVerbosity.Data());
+    // ------------------------------------------------------------------------
+
+
+    // -----   Environment   --------------------------------------------------
+    std::string srcDir = gSystem->Getenv("VMCWORKDIR");  // top source directory
+    // ------------------------------------------------------------------------
+
+    std::unique_ptr<CbmStsAnalysis> run = std::make_unique<CbmStsAnalysis>();
+
+    FairFileSource* inputSource = new FairFileSource(rec_file.c_str());
+    inputSource->AddFriend(raw_file.c_str());
+
+    FairRootFileSink* outputSink = new FairRootFileSink(out_file.c_str());
+
+
+    if (bAli) {
+        TString alignmentMatrixFileName = srcDir + "/parameters/mcbm/AlignmentMatrices_" + geo_setup_tag + ".root";
+        if (alignmentMatrixFileName.Length() != 0) {
+            std::map<std::string, TGeoHMatrix>* matrices{nullptr};
+            TFile* misalignmentMatrixRootfile = new TFile(alignmentMatrixFileName, "READ");
+            if (misalignmentMatrixRootfile->IsOpen()) {
+                gDirectory->GetObject("MisalignMatrices", matrices);
+                misalignmentMatrixRootfile->Close();
+            }
+            else {
+                LOG(error) << "Could not open file " << alignmentMatrixFileName << "\n Exiting";
+                exit(1);
+            }
+
+            if (matrices) {
+                run->AddAlignmentMatrices(*matrices);
+            }
+            else {
+                LOG(error) << "Alignment required but no matrices found."
+                << "\n Exiting";
+                exit(1);
+            }
+        }
+    }
+
+    run->SetGeomFile(geo_file.c_str());
+    run->SetSource(inputSource);
+    run->SetSink(outputSink);
+
+
+    // ------------------------------------------------------------------------
+    // Configure Analysis filters
+    // ------------------------------------------------------------------------
+    CbmCutMap ana_filter;
+    ana_filter.AddCbmCut(CbmCutId::kStsHitCharge)->SetMin(10000);
+    ana_filter.AddCbmCut(CbmCutId::kEventNofStsHit)->SetMin(2);
+
+    // ------------------------------------------------------------------------
+    // Configure Correlation
+    // ------------------------------------------------------------------------
+    CbmStsCorrelation* sts_corr = new CbmStsCorrelation();
+    sts_corr->SetCutMap(&ana_filter);
+    run->AddTask(sts_corr);
+
+    run->Init();
+    run->Run(0,n_of_ts);
+
+    // ------------------------------------------------------------------------
+    timer.Stop();
+    Double_t rtime = timer.RealTime();
+    Double_t ctime = timer.CpuTime();
+    cout << endl << endl;
+    cout << "Macro finished successfully." << endl;
+    cout << "Real time " << rtime << " s, CPU time " << ctime << " s" << endl;
+    cout << endl;
+}
\ No newline at end of file
-- 
GitLab


From 50ed428607f2a4e1b87cdf70b480355626c799d3 Mon Sep 17 00:00:00 2001
From: Dario Ramirez <d.ramirez@gsi.de>
Date: Tue, 15 Apr 2025 11:33:05 +0200
Subject: [PATCH 08/18] CbmStsRecoBeamSpot:

Beam spot reconstruction at arbitrary target plane using STS hit combinatorial
---
 analysis/detectors/sts/CMakeLists.txt         |   4 +-
 analysis/detectors/sts/CbmStsAnaLinkDef.h     |   1 +
 analysis/detectors/sts/CbmStsRecoBeamSpot.cxx | 210 ++++++++++++++++++
 analysis/detectors/sts/CbmStsRecoBeamSpot.h   | 120 ++++++++++
 macro/sts/sts_beam_spot.C                     | 125 +++++++++++
 5 files changed, 459 insertions(+), 1 deletion(-)
 create mode 100644 analysis/detectors/sts/CbmStsRecoBeamSpot.cxx
 create mode 100644 analysis/detectors/sts/CbmStsRecoBeamSpot.h
 create mode 100644 macro/sts/sts_beam_spot.C

diff --git a/analysis/detectors/sts/CMakeLists.txt b/analysis/detectors/sts/CMakeLists.txt
index 577ea5b244..5c4874320b 100644
--- a/analysis/detectors/sts/CMakeLists.txt
+++ b/analysis/detectors/sts/CMakeLists.txt
@@ -17,6 +17,7 @@ set(SRCS
   CbmStsTimeCal.cxx
   CbmStsHitAna.cxx
   CbmStsCorrelation.cxx
+  CbmStsRecoBeamSpot.cxx
   )
 
 
@@ -24,8 +25,9 @@ set(LIBRARY_NAME CbmStsAna)
 set(LINKDEF ${LIBRARY_NAME}LinkDef.h)
 set(PUBLIC_DEPENDENCIES
   Algo
-  ROOT::Core
+  CbmSimBase
   CbmStsBase
+  ROOT::Core
   )
 
 set(PRIVATE_DEPENDENCIES
diff --git a/analysis/detectors/sts/CbmStsAnaLinkDef.h b/analysis/detectors/sts/CbmStsAnaLinkDef.h
index 5f9bd7ea76..a935e816f9 100644
--- a/analysis/detectors/sts/CbmStsAnaLinkDef.h
+++ b/analysis/detectors/sts/CbmStsAnaLinkDef.h
@@ -19,5 +19,6 @@
 #pragma link C++ class CbmStsTimeCal + ;
 #pragma link C++ class CbmStsHitAna + ;
 #pragma link C++ class CbmStsCorrelation + ;
+#pragma link C++ class CbmStsRecoBeamSpot + ;
 
 #endif /* __CINT__ */
diff --git a/analysis/detectors/sts/CbmStsRecoBeamSpot.cxx b/analysis/detectors/sts/CbmStsRecoBeamSpot.cxx
new file mode 100644
index 0000000000..394bfe63f8
--- /dev/null
+++ b/analysis/detectors/sts/CbmStsRecoBeamSpot.cxx
@@ -0,0 +1,210 @@
+/* Copyright (C) 2022 Facility for Antiproton and Ion Research in Europe, Darmstadt
+	 SPDX-License-Identifier: GPL-3.0-only
+	 Authors: Dario Ramirez [committer] */
+
+#include "CbmStsRecoBeamSpot.h"
+
+#include "CbmStsAddress.h"
+
+CbmStsRecoBeamSpot::CbmStsRecoBeamSpot() { LOG(debug) << "Creating an instance of CbmStsRecoBeamSpot ..."; }
+
+CbmStsRecoBeamSpot::~CbmStsRecoBeamSpot() {}
+
+void CbmStsRecoBeamSpot::AddTarget(CbmTarget* trg) { AddTarget("", trg); }
+void CbmStsRecoBeamSpot::AddTarget(std::string trg_name, CbmTarget* trg)
+{
+  if (trg_name.length() == 0) {
+    trg_name = Form("target_%ld", targets_.size());
+  }
+  targets_[trg_name] = trg;
+}
+
+void CbmStsRecoBeamSpot::BookHistograms()
+{
+  std::string h_name;
+  std::string h_name_base = "";
+  for (auto& [element_i, geo_i] : sts_geo_info_) {
+    if (element_i < 8) continue;
+
+    for (auto& [element_j, geo_j] : sts_geo_info_) {
+      if (element_j < 8) continue;
+      int32_t unit_i = CbmStsAddress::GetElementId(element_i, kStsUnit);
+      int32_t unit_j = CbmStsAddress::GetElementId(element_j, kStsUnit);
+
+      if (unit_i >= unit_j) continue;
+
+      for (auto& [trg_name, trg] : targets_) {
+        h_name_base = Form("0x%x:0x%x_%s", element_i, element_j, trg_name.c_str());
+
+        bs_range_x_min_ = trg->GetPosition().Px() - 10.;  // HARDCODE
+        bs_range_x_max_ = trg->GetPosition().Px() + 10.;  // HARDCODE
+        bs_range_y_min_ = trg->GetPosition().Py() - 10.;  // HARDCODE
+        bs_range_y_max_ = trg->GetPosition().Py() + 10.;  // HARDCODE
+        bs_range_z_min_ = trg->GetPosition().Pz() - 10.;  // HARDCODE
+        bs_range_z_max_ = trg->GetPosition().Pz() + 10.;  // HARDCODE
+
+
+        unsigned int nb_bins_x = (bs_range_x_max_ - bs_range_x_min_) / bs_resolution_x_;
+        unsigned int nb_bins_y = (bs_range_y_max_ - bs_range_y_min_) / bs_resolution_y_;
+        unsigned int nb_bins_z = (bs_range_z_max_ - bs_range_z_min_) / bs_resolution_z_;
+
+        h_name      = Form("%s_Y_vs_X", h_name_base.c_str());
+        h2_[h_name] = std::make_unique<TH2D>(h_name.c_str(), h_name.c_str(), nb_bins_x, bs_range_x_min_,
+                                             bs_range_x_max_, nb_bins_y, bs_range_y_min_, bs_range_y_max_);
+        h2_[h_name]->GetXaxis()->SetTitle("X [cm]");
+        h2_[h_name]->GetYaxis()->SetTitle("Y [cm]");
+
+        h_name      = Form("%s_X_vs_Z", h_name_base.c_str());
+        h2_[h_name] = std::make_unique<TH2D>(h_name.c_str(), h_name.c_str(), nb_bins_z, bs_range_z_min_,
+                                             bs_range_z_max_, nb_bins_x, bs_range_x_min_, bs_range_x_max_);
+        h2_[h_name]->GetXaxis()->SetTitle("Z [cm]");
+        h2_[h_name]->GetYaxis()->SetTitle("X [cm]");
+
+        h_name      = Form("%s_Y_vs_Z", h_name_base.c_str());
+        h2_[h_name] = std::make_unique<TH2D>(h_name.c_str(), h_name.c_str(), nb_bins_z, bs_range_z_min_,
+                                             bs_range_z_max_, nb_bins_y, bs_range_y_min_, bs_range_y_max_);
+        h2_[h_name]->GetXaxis()->SetTitle("Z [cm]");
+        h2_[h_name]->GetYaxis()->SetTitle("Y [cm]");
+
+        h_name      = Form("%s_Y_beam_vs_X_beam", h_name_base.c_str());
+        h2_[h_name] = std::make_unique<TH2D>(h_name.c_str(), h_name.c_str(), nb_bins_x, bs_range_x_min_,
+                                             bs_range_x_max_, nb_bins_y, bs_range_y_min_, bs_range_y_max_);
+        h2_[h_name]->GetXaxis()->SetTitle("X_beam [cm]");
+        h2_[h_name]->GetYaxis()->SetTitle("Y_beam [cm]");
+
+      }  // end targets loop
+    }    // end sts_i modules loop
+  }      // end sts_j modules loop
+}
+
+TVector3 CbmStsRecoBeamSpot::ExtrapolateTrackTo(CbmPixelHit* hit_0, CbmPixelHit* hit_1, CbmTarget* trg)
+{
+  TVector3 n0 = trg->GetPosition();
+  TVector3 n1(.0, .0, 1.);
+  n1.RotateY(trg->GetRotation());
+
+  TVector3 l0(hit_0->GetX(), hit_0->GetY(), hit_0->GetZ());
+  TVector3 l1(hit_1->GetX() - hit_0->GetX(), hit_1->GetY() - hit_0->GetY(), hit_1->GetZ() - hit_0->GetZ());
+
+  double l1_dot_n1 = l1.Dot(n1);
+  if (l1_dot_n1 <= 1e-6) {  // tracklet is parallel (or close to it) to target plane
+    throw std::invalid_argument("Track-let parallel to target plane");
+  }
+
+  double t = (n0 - l0).Dot(n1) / l1.Dot(n1);
+  return l0 + t * l1;
+}
+
+void CbmStsRecoBeamSpot::BeamSpotReco()
+{
+  if (!sts_hits_.size()) return;
+  for (int sts_unit_i = 0; sts_unit_i < nb_sts_station_ - 1; sts_unit_i++) {
+    for (int sts_unit_j = sts_unit_i + 1; sts_unit_j < nb_sts_station_; sts_unit_j++) {
+      for (auto sts_hit_i : sts_hits_[sts_unit_i]) {
+        for (auto sts_hit_j : sts_hits_[sts_unit_j]) {
+          int32_t sts_address_i = sts_hit_i->GetAddress();
+          int32_t sts_address_j = sts_hit_j->GetAddress();
+
+          for (auto& [trg_name, trg] : targets_) {
+            TVector3 sol            = ExtrapolateTrackTo(sts_hit_i, sts_hit_j, trg);
+            std::string h_name_base = Form("0x%x:0x%x_%s", sts_address_i, sts_address_j, trg_name.c_str());
+
+            std::string h_name = Form("%s_X_vs_Z", h_name_base.c_str());
+            h2_[h_name]->Fill(sol.Pz(), sol.Px());
+
+            h_name = Form("%s_Y_vs_Z", h_name_base.c_str());
+            h2_[h_name]->Fill(sol.Pz(), sol.Py());
+
+            h_name = Form("%s_Y_vs_X", h_name_base.c_str());
+            h2_[h_name]->Fill(sol.Px(), sol.Py());
+
+            TVector3 sol_beam = sol - trg->GetPosition();
+
+            double x_beam = sol_beam.Px() / cos(trg->GetRotation());
+            double y_beam = sol_beam.Py();
+            h_name        = Form("%s_Y_beam_vs_X_beam", h_name_base.c_str());
+            h2_[h_name]->Fill(x_beam, y_beam);
+          }
+        }
+      }
+    }
+  }
+  sts_hits_.clear();
+}
+
+
+void CbmStsRecoBeamSpot::FinishTask() { SaveToFile(); }
+
+
+void CbmStsRecoBeamSpot::ProcessEvent(CbmEvent* evt)
+{
+  int nb_sts_hits = evt->GetNofData(ECbmDataType::kStsHit);
+  if (nb_sts_hits > 0)
+    for (int hit_evt_idx = 0; hit_evt_idx < nb_sts_hits; hit_evt_idx++) {
+      int sts_hit_idx = evt->GetIndex(ECbmDataType::kStsHit, hit_evt_idx);
+      CbmStsHit* hit  = (CbmStsHit*) sts_hit_array_->UncheckedAt(sts_hit_idx);
+      ProcessHit(hit);
+
+    }
+}
+
+void CbmStsRecoBeamSpot::ProcessHit(CbmStsHit* hit)
+{
+  if (hit == nullptr) return;
+  int32_t address = hit->GetAddress();
+  int32_t unit    = CbmStsAddress::GetElementId(address, kStsUnit);
+
+  if (analysis_cut_ != nullptr && analysis_cut_->CheckStsHit(hit, sts_clu_array_)) {
+    sts_hits_[unit].push_back(hit);
+  }
+}
+
+void CbmStsRecoBeamSpot::Exec(Option_t*)
+{
+
+  // Check if CbmEvent
+  if (cbm_evt_array_ != nullptr) {
+
+    uint32_t nb_events = cbm_evt_array_->GetEntriesFast();
+    LOG(info) << "Running CbmStsRecoBeamSpot - Event like - Entry:" << entry_ << "\tEvents: " << nb_events;
+    for (uint32_t evt_idx = 0; evt_idx < nb_events; evt_idx++) {
+      CbmEvent* event = (CbmEvent*) cbm_evt_array_->UncheckedAt(evt_idx);
+      if (analysis_cut_ != nullptr && analysis_cut_->CheckEvent(event)) {
+        ProcessEvent(event);
+        BeamSpotReco();
+      }
+    }
+  }
+  else {
+
+    uint32_t n_of_hits = sts_hit_array_->GetEntriesFast();
+    LOG(info) << "Running CbmStsRecoBeamSpot - Time like - Entry:" << entry_ << "\tStsHit: " << n_of_hits;
+    for (uint32_t hit_idx = 0; hit_idx < n_of_hits; hit_idx++) {
+      CbmStsHit* sts_hit = (CbmStsHit*) sts_hit_array_->UncheckedAt(hit_idx);
+      ProcessHit(sts_hit);
+    }
+    BeamSpotReco();
+  }
+  entry_++;
+}
+
+InitStatus CbmStsRecoBeamSpot::Init()
+{
+  LOG(debug) << "Init CbmStsRecoBeamSpot ...";
+
+  FairRootManager* ioman = FairRootManager::Instance();
+  if (ioman == nullptr) return kERROR;
+
+  cbm_evt_array_ = (TClonesArray*) ioman->GetObject("CbmEvent");
+  sts_hit_array_ = (TClonesArray*) ioman->GetObject("StsHit");
+  sts_clu_array_ = (TClonesArray*) ioman->GetObject("StsCluster");
+
+  for (auto& [trg_name, trg] : targets_) {
+    LOG(debug) << trg_name << ": " << trg->ToString();
+  }
+
+  LoadSetup();
+  BookHistograms();
+
+  return kSUCCESS;
+}
diff --git a/analysis/detectors/sts/CbmStsRecoBeamSpot.h b/analysis/detectors/sts/CbmStsRecoBeamSpot.h
new file mode 100644
index 0000000000..5b11986ba9
--- /dev/null
+++ b/analysis/detectors/sts/CbmStsRecoBeamSpot.h
@@ -0,0 +1,120 @@
+/** \file CbmStsRecoBeamSpot.h
+ * \brief Definition of the CbmStsRecoBeamSpot class.
+ *
+ * Copyright (C) 2022 Facility for Antiproton and Ion Research in Europe, Darmstadt
+ * SPDX-License-Identifier: GPL-3.0-only
+ * Authors: Dario Ramirez [committer]
+ */
+
+#ifndef CBMSTSRECOBEAMSPOT_H
+#define CBMSTSRECOBEAMSPOT_H
+
+#include "CbmEvent.h"
+#include "CbmGlobalTrack.h"
+#include "CbmStsAnaBase.h"
+#include "CbmStsCluster.h"
+#include "CbmStsHit.h"
+#include "CbmStsTrack.h"
+#include "CbmStsUtils.h"
+#include "CbmTarget.h"
+#include "CbmTrack.h"
+
+#include <FairTask.h>
+
+#include <TClonesArray.h>
+#include <TVector3.h>
+
+#include <cstring>
+#include <map>
+#include <unordered_map>
+#include <unordered_set>
+
+/** \class CbmStsRecoBeamSpot
+ * \brief Task for reconstructing the beam spot using STS hits.
+ *
+ * This class inherits from FairTask and CbmStsAnaBase.
+ * It provides functionality for reconstructing the beam spot at
+ * different planes defined by CbmTarget
+ * using STS hits.
+ */
+class CbmStsRecoBeamSpot : public FairTask, public CbmStsAnaBase {
+ public:
+  /** \brief Constructor */
+  CbmStsRecoBeamSpot();
+
+  /** \brief Destructor */
+  virtual ~CbmStsRecoBeamSpot();
+
+  /**
+   * @brief Add a CbmTarget object to the list of targets.
+   *
+   * Position and rotation are the only relevant members of such class for this task.
+   *
+   * @param target CbmTarget ptr to be added
+   */
+
+  void AddTarget(CbmTarget* target = nullptr);
+
+  /**
+   * @brief Add a CbmTarget object to the list of targets with a key as trg_name.
+   *
+   * @param trg_name key under which the @param target will be stored.
+   * If the key is an empty string, added targets will be named as target_<n_of_targets>.
+   */
+  void AddTarget(std::string trg_name = "", CbmTarget* target = nullptr);
+
+  void Exec(Option_t*);
+  InitStatus Init();
+  void FinishTask();
+
+ private:
+  /* Beam Spot sampling range
+   * It is dynamically caculate when multiple targets planes are provided
+   */
+  double bs_range_x_min_{-10}; // cm
+  double bs_range_x_max_{+10}; // cm
+  double bs_range_y_min_{-10}; // cm
+  double bs_range_y_max_{+10}; // cm
+  double bs_range_z_min_{-10}; // cm
+  double bs_range_z_max_{+10}; // cm
+
+  /* Bin width for Beam Spot 2D histograms */
+  double bs_resolution_x_{0.01};
+  double bs_resolution_y_{0.01};
+  double bs_resolution_z_{0.01};
+
+  std::vector<CbmStsTrack*> sts_trks_;
+  std::map<int32_t, std::vector<CbmStsHit*>> sts_hits_;
+
+  std::map<std::string, CbmTarget*> targets_;
+
+
+  TClonesArray* cbm_evt_array_{nullptr};
+  TClonesArray* sts_trk_array_{nullptr};
+  TClonesArray* sts_hit_array_{nullptr};
+  TClonesArray* sts_clu_array_{nullptr};
+
+  /** \brief Reconstruct the beam spot at each target planes */
+  void BeamSpotReco();
+
+  void BookHistograms();
+
+  /** \brief Extrapolate a track-let to a target plane*/
+  TVector3 ExtrapolateTrackTo(CbmPixelHit*, CbmPixelHit*, CbmTarget*);
+
+  /** \brief Process an Cbm events
+   * It filters event based on the provided CbmCutMap
+  */
+  void ProcessEvent(CbmEvent*);
+
+  /** \brief Process an STS track */
+  void ProcessStsTrack(CbmGlobalTrack*);
+
+  /** \brief Process an STS hit
+   * It filters hits based on the provided CbmCutMap
+  */
+  void ProcessHit(CbmStsHit*);
+
+  ClassDef(CbmStsRecoBeamSpot, 1);
+};
+#endif
diff --git a/macro/sts/sts_beam_spot.C b/macro/sts/sts_beam_spot.C
new file mode 100644
index 0000000000..676aa83499
--- /dev/null
+++ b/macro/sts/sts_beam_spot.C
@@ -0,0 +1,125 @@
+
+void sts_beam_spot(
+    int n_of_ts = -1,
+    std::string geo_setup_tag = "mcbm_beam_2024_05_08_nickel",
+    std::string raw_file = "",
+    std::string rec_file = "",
+    std::string geo_file = "",
+    std::string out_file = "sts_beam_spot.root",
+    bool bAli = true
+){
+    // -----   Timer   --------------------------------------------------------
+    TStopwatch timer;
+    timer.Start();
+
+    // --- Logger settings ----------------------------------------------------
+    TString logLevel     = "DEBUG";
+    TString logVerbosity = "veryhigh";
+            logLevel     = "INFO";
+            logVerbosity = "low";
+
+    FairLogger::GetLogger()->SetLogScreenLevel(logLevel.Data());
+    FairLogger::GetLogger()->SetLogVerbosityLevel(logVerbosity.Data());
+    // ------------------------------------------------------------------------
+
+
+    // -----   Environment   --------------------------------------------------
+    std::string srcDir = gSystem->Getenv("VMCWORKDIR");  // top source directory
+    // ------------------------------------------------------------------------
+
+    std::unique_ptr<CbmStsAnalysis> run = std::make_unique<CbmStsAnalysis>();
+
+    FairFileSource* inputSource = new FairFileSource(rec_file.c_str());
+    inputSource->AddFriend(raw_file.c_str());
+
+    FairRootFileSink* outputSink = new FairRootFileSink(out_file.c_str());
+
+
+    if (bAli) {
+        TString alignmentMatrixFileName = srcDir + "/parameters/mcbm/AlignmentMatrices_" + geo_setup_tag + ".root";
+        if (alignmentMatrixFileName.Length() != 0) {
+            std::map<std::string, TGeoHMatrix>* matrices{nullptr};
+            TFile* misalignmentMatrixRootfile = new TFile(alignmentMatrixFileName, "READ");
+            if (misalignmentMatrixRootfile->IsOpen()) {
+                gDirectory->GetObject("MisalignMatrices", matrices);
+                misalignmentMatrixRootfile->Close();
+            }
+            else {
+                LOG(error) << "Could not open file " << alignmentMatrixFileName << "\n Exiting";
+                exit(1);
+            }
+
+            if (matrices) {
+                run->AddAlignmentMatrices(*matrices);
+            }
+            else {
+                LOG(error) << "Alignment required but no matrices found."
+                << "\n Exiting";
+                exit(1);
+            }
+        }
+    }
+
+    run->SetGeomFile(geo_file.c_str());
+    run->SetSource(inputSource);
+    run->SetSink(outputSink);
+
+
+    // ------------------------------------------------------------------------
+    // Configure Analysis filters
+    // ------------------------------------------------------------------------
+    CbmCutMap ana_filter;
+    ana_filter.AddCbmCut(CbmCutId::kStsHitCharge)->SetMin(10000);
+    ana_filter.AddCbmCut(CbmCutId::kEventNofStsHit)->SetMin(2);
+
+    // ------------------------------------------------------------------------
+    // Configure mCBM target planes
+    // ------------------------------------------------------------------------
+    double l_k0 = 38.45;
+    double l_k1 = l_k0 + 0.86 + 11.8 + 1.3 + 0.7;
+    double l_b1 = l_k0 + 4.99 + 1.2 + 0.75;
+
+    double beam_rot_y = (25.)*TMath::DegToRad();
+    CbmTarget Ni;
+    Ni.SetPosition(0, 0, 0);
+    Ni.SetRotation(beam_rot_y);
+
+    CbmTarget T0;
+    T0.SetPosition(-20*sin(beam_rot_y), 0, -20*cos(beam_rot_y));
+    T0.SetRotation(beam_rot_y);
+
+    CbmTarget K0;
+    K0.SetPosition(-l_k0*sin(beam_rot_y), 0, -l_k0*cos(beam_rot_y));
+    K0.SetRotation(beam_rot_y);
+
+    CbmTarget B1;
+    B1.SetPosition(-l_b1*sin(beam_rot_y), 0, -l_b1*cos(beam_rot_y));
+    B1.SetRotation(beam_rot_y);
+
+    CbmTarget K1;
+    K1.SetPosition(-l_k1*sin(beam_rot_y), 0, -l_k1*cos(beam_rot_y));
+    K1.SetRotation(beam_rot_y);
+    // ------------------------------------------------------------------------
+
+    CbmStsRecoBeamSpot* sts_bs = new CbmStsRecoBeamSpot();
+    sts_bs->SetCutMap(&ana_filter);
+    sts_bs->AddTarget("Ni",&Ni);
+    sts_bs->AddTarget("T0",&T0);
+    sts_bs->AddTarget("K0",&K0);
+    sts_bs->AddTarget("B1",&B1);
+    sts_bs->AddTarget("K1",&K1);
+
+    run->AddTask(sts_bs);
+
+    run->Init();
+    run->Run(0,n_of_ts);
+
+    // ------------------------------------------------------------------------
+    timer.Stop();
+    Double_t rtime = timer.RealTime();
+    Double_t ctime = timer.CpuTime();
+    cout << endl << endl;
+    cout << "Macro finished successfully." << endl;
+    cout << "Real time " << rtime << " s, CPU time " << ctime << " s" << endl;
+    cout << endl;
+}
\ No newline at end of file
-- 
GitLab


From 0e39760f8e212ad1e74986c6f62d4fb3e0f3505a Mon Sep 17 00:00:00 2001
From: Dario Ramirez <d.ramirez@gsi.de>
Date: Tue, 15 Apr 2025 11:59:43 +0200
Subject: [PATCH 09/18] CbmDcaVertexFinder: average PCA track pairing

---
 analysis/detectors/sts/CbmDcaVertexFinder.cxx | 118 ++++++++++++++++++
 analysis/detectors/sts/CbmDcaVertexFinder.h   |  75 +++++++++++
 2 files changed, 193 insertions(+)
 create mode 100644 analysis/detectors/sts/CbmDcaVertexFinder.cxx
 create mode 100644 analysis/detectors/sts/CbmDcaVertexFinder.h

diff --git a/analysis/detectors/sts/CbmDcaVertexFinder.cxx b/analysis/detectors/sts/CbmDcaVertexFinder.cxx
new file mode 100644
index 0000000000..9226ca0f75
--- /dev/null
+++ b/analysis/detectors/sts/CbmDcaVertexFinder.cxx
@@ -0,0 +1,118 @@
+#include <Logger.h>
+
+#include "CbmDcaVertexFinder.h"
+
+#include "CbmVertex.h"
+#include "CbmGlobalTrack.h"
+
+/** \brief Default constructor
+ * \param tracks
+*/
+CbmDcaVertexFinder::CbmDcaVertexFinder()
+    : max_dca_(0.1), tracks_(std::vector<CbmGlobalTrack*>()), n_of_pairs_(0), qa_(std::nullopt)
+{
+    LOG(debug) << "Creating CbmDcaVertexFinder ...";
+    cov_matrix_.ResizeTo(3,3);
+}
+
+CbmDcaVertexFinder::CbmDcaVertexFinder(double max_dca)
+    : max_dca_(max_dca), tracks_(std::vector<CbmGlobalTrack*>()), n_of_pairs_(0), qa_(std::nullopt)
+{
+    LOG(debug) << "Creating CbmDcaVertexFinder ...";
+    cov_matrix_.ResizeTo(3,3);
+}
+
+/** \brief Default constructor
+ * \param tracks
+*/
+CbmDcaVertexFinder::CbmDcaVertexFinder(const std::vector<CbmGlobalTrack*> tracks)
+    : max_dca_(0.1), tracks_(tracks), n_of_pairs_(0), qa_(std::nullopt)
+{
+    LOG(debug) << "Creating CbmDcaVertexFinder ...";
+    cov_matrix_.ResizeTo(3,3);
+}
+
+/** \brief Default constructor
+ * \param tracks
+*/
+CbmDcaVertexFinder::CbmDcaVertexFinder(const std::vector<CbmGlobalTrack*> tracks, const double max_dca)
+    : max_dca_(max_dca), tracks_(tracks), n_of_pairs_(0), qa_(std::nullopt)
+{
+    LOG(debug) << "Creating CbmDcaVertexFinder ...";
+    cov_matrix_.ResizeTo(3,3);
+}
+
+CbmDcaVertexFinder::~CbmDcaVertexFinder() {}
+
+void CbmDcaVertexFinder::SetTracks(const std::vector<CbmGlobalTrack*> tracks) {
+    tracks_.clear();
+    tracks_ = tracks;
+}
+
+/** \brief find vertex using input tracks
+ */
+std::optional<CbmVertex> CbmDcaVertexFinder::FindVertex() {
+    // Reset the number of track pair used
+    n_of_pairs_ = 0;
+    int n_of_trk = tracks_.size();
+    LOG(debug) << "- PCA - Find event vertex using CbmGlobalTracks: " << n_of_trk;
+    TVector3 vtx;
+    for (int trk_i_idx = 0; trk_i_idx < n_of_trk - 1; trk_i_idx++) {
+        for (int trk_j_idx = trk_i_idx + 1; trk_j_idx < n_of_trk; trk_j_idx++) {
+            auto pca = FindPca(tracks_[trk_i_idx], tracks_[trk_j_idx]);
+            if (pca.has_value() && pca->d_trk < max_dca_) {
+                TVector3 pca_i_j = pca->point;
+                vtx += pca_i_j;
+                n_of_pairs_++;
+
+                if (qa_.has_value()){
+                    qa_->pca_y_vs_x->Fill(pca_i_j[0], pca_i_j[1]);
+                    qa_->pca_x_vs_z->Fill(pca_i_j[2], pca_i_j[0]);
+                    qa_->pca_y_vs_z->Fill(pca_i_j[2], pca_i_j[1]);
+                }
+            }
+        }
+    }
+    if (!n_of_pairs_)
+        return std::nullopt;
+
+    vtx *= 1. / n_of_pairs_;
+
+    // WARNING LINE
+    return CbmVertex("EventVertex", "EventVertex", vtx[0], vtx[1], vtx[2], 0, 0, n_of_pairs_, cov_matrix_);
+}
+
+std::optional<CbmDcaVertexFinder::PCA> CbmDcaVertexFinder::FindPca(CbmGlobalTrack* trk_i, CbmGlobalTrack* trk_j)
+{
+    TVector3 r1(trk_i->GetParamFirst()->GetX(), trk_i->GetParamFirst()->GetY(),
+                trk_i->GetParamFirst()->GetZ());
+    TVector3 e1(trk_i->GetParamFirst()->GetTx(), trk_i->GetParamFirst()->GetTy(), 1);
+
+    TVector3 r2(trk_j->GetParamFirst()->GetX(), trk_j->GetParamFirst()->GetY(),
+                trk_j->GetParamFirst()->GetZ());
+    TVector3 e2(trk_j->GetParamFirst()->GetTx(), trk_j->GetParamFirst()->GetTy(), 1);
+
+    TVector3 n = e1.Cross(e2);  // Directional vector for segment of the pca
+
+    float nn = n.Dot(n);
+    if (nn != 0) {  // Non-Parallel tracks
+
+        TVector3 e1n = e1.Cross(n);
+        TVector3 e2n = e1.Cross(n);
+        TVector3 r21 = r2 - r1;
+
+        float t1 = e2n.Dot(r21) / nn;
+        float t2 = e1n.Dot(r21) / nn;
+
+        TVector3 p1  = r1 + t1 * e1;  // Closest point on track 1
+        TVector3 p2  = r2 + t2 * e2;  // Closest point on track 2
+        TVector3 p21 = p2 - p1;
+
+        TVector3 point  = 0.5 * (p1 + p2);
+        double d_trk  = 0.5 * p21.Mag();
+
+        return std::make_optional<PCA>({point, d_trk});
+    }
+    return std::nullopt;
+}
+
diff --git a/analysis/detectors/sts/CbmDcaVertexFinder.h b/analysis/detectors/sts/CbmDcaVertexFinder.h
new file mode 100644
index 0000000000..6f17aac2f1
--- /dev/null
+++ b/analysis/detectors/sts/CbmDcaVertexFinder.h
@@ -0,0 +1,75 @@
+#ifndef CBMDCAVERTEXFINDER_H
+#define CBMDCAVERTEXFINDER_H
+
+#include <optional>
+#include "TVector3.h"
+#include "TH2.h"
+#include "TMatrixFSym.h"
+class CbmVertex;
+class CbmGlobalTrack;
+
+/** \class CbmDcaVertexFinder
+ * \brief Estimates a common vertex from multiple straight GlobalTracks
+ *
+ * The algorithm consist in averaging the PCA of all valid pair of tracks.
+ * A valid pair is defined but a cut in the maximum value for DCA
+ */
+class CbmDcaVertexFinder{
+public:
+    struct Qa{
+        std::shared_ptr<TH2> pca_y_vs_x;
+        std::shared_ptr<TH2> pca_x_vs_z;
+        std::shared_ptr<TH2> pca_y_vs_z;
+    };
+
+    /** Holds PCA analysis for a pair of straight tracks */
+    struct PCA {
+        TVector3 point;
+        double d_trk;
+    };
+
+    /** \brief Default constructor
+    */
+    CbmDcaVertexFinder();
+
+    /** \brief Constructor setting maximum DCA for track pair */
+    CbmDcaVertexFinder(double max_dca);
+
+    /** \brief Constructor using input set of track */
+    CbmDcaVertexFinder(const std::vector<CbmGlobalTrack*> tracks);
+
+    /** \brief Constructor using input set of track, and maximum DCA for track pair */
+    CbmDcaVertexFinder(const std::vector<CbmGlobalTrack*> tracks, const double max_dca);
+
+    /** \brief Set input track */
+    void SetTracks(const std::vector<CbmGlobalTrack*> tracks);
+
+    ~CbmDcaVertexFinder();
+
+    /** \brief Calculate the Point of Closest Approach of two straight tracks
+     * if tracks are parallel it return a nullopt
+     * \param trk_i, trk_j pointer to CbmGlobal tracks
+     */
+    std::optional<CbmDcaVertexFinder::PCA> FindPca(CbmGlobalTrack* trk_i, CbmGlobalTrack* trk_j);
+
+    /** \brief Run algorithm to find vertex
+     * \return std::optional<CbmVertex>:
+     *  - std::nullopt if algorithm fails or no vertex was found under present configuration
+     */
+    std::optional<CbmVertex> FindVertex();
+
+    void EnableQa(Qa qa) {
+        qa_ = std::make_optional<Qa>(qa);
+    }
+
+private:
+    const double max_dca_;
+    std::vector<CbmGlobalTrack*> tracks_;
+    double n_of_pairs_;
+    std::optional<Qa> qa_;
+
+    TMatrixFSym cov_matrix_;
+
+};
+
+#endif
\ No newline at end of file
-- 
GitLab


From e4a714485c68853981dc5a8e36c4f63dcbba9642 Mon Sep 17 00:00:00 2001
From: Dario Ramirez <d.ramirez@gsi.de>
Date: Tue, 15 Apr 2025 12:52:01 +0200
Subject: [PATCH 10/18] CbmStsEfficiency

Track based hit reconstruction efficiency analysis
---
 analysis/detectors/sts/CMakeLists.txt       |   2 +
 analysis/detectors/sts/CbmStsAnaLinkDef.h   |   3 +
 analysis/detectors/sts/CbmStsEfficiency.cxx | 588 ++++++++++++++++++++
 analysis/detectors/sts/CbmStsEfficiency.h   | 123 ++++
 macro/sts/sts_efficiency.C                  | 108 ++++
 5 files changed, 824 insertions(+)
 create mode 100644 analysis/detectors/sts/CbmStsEfficiency.cxx
 create mode 100644 analysis/detectors/sts/CbmStsEfficiency.h
 create mode 100755 macro/sts/sts_efficiency.C

diff --git a/analysis/detectors/sts/CMakeLists.txt b/analysis/detectors/sts/CMakeLists.txt
index 5c4874320b..02e5d00b29 100644
--- a/analysis/detectors/sts/CMakeLists.txt
+++ b/analysis/detectors/sts/CMakeLists.txt
@@ -18,6 +18,8 @@ set(SRCS
   CbmStsHitAna.cxx
   CbmStsCorrelation.cxx
   CbmStsRecoBeamSpot.cxx
+  CbmDcaVertexFinder.cxx
+  CbmStsEfficiency.cxx
   )
 
 
diff --git a/analysis/detectors/sts/CbmStsAnaLinkDef.h b/analysis/detectors/sts/CbmStsAnaLinkDef.h
index a935e816f9..8b3fccb5b2 100644
--- a/analysis/detectors/sts/CbmStsAnaLinkDef.h
+++ b/analysis/detectors/sts/CbmStsAnaLinkDef.h
@@ -20,5 +20,8 @@
 #pragma link C++ class CbmStsHitAna + ;
 #pragma link C++ class CbmStsCorrelation + ;
 #pragma link C++ class CbmStsRecoBeamSpot + ;
+#pragma link C++ class CbmDcaVertexFinder + ;
+#pragma link C++ class CbmStsEfficiency + ;
+
 
 #endif /* __CINT__ */
diff --git a/analysis/detectors/sts/CbmStsEfficiency.cxx b/analysis/detectors/sts/CbmStsEfficiency.cxx
new file mode 100644
index 0000000000..63b3edfc83
--- /dev/null
+++ b/analysis/detectors/sts/CbmStsEfficiency.cxx
@@ -0,0 +1,588 @@
+/* Copyright (C) 2022 Facility for Antiproton and Ion Research in Europe, Darmstadt
+   SPDX-License-Identifier: GPL-3.0-only
+   Authors: Dario Ramirez [committer] */
+
+#include "CbmStsEfficiency.h"
+
+#include "CbmStsAddress.h"
+
+#include "CbmStsUtils.h"
+
+CbmStsEfficiency::CbmStsEfficiency() { LOG(debug) << "Creating an instance of CbmStsEfficiency ..."; }
+
+CbmStsEfficiency::CbmStsEfficiency(uint32_t layer_idx)
+  : test_layer_(layer_idx)
+{
+  LOG(debug) << "Creating an instance of CbmStsEfficiency ...";
+}
+CbmStsEfficiency::CbmStsEfficiency(uint32_t test_layer, double max_dis_trg_vtx, double max_dca_trk_vtx, double default_residual)
+  : test_layer_(test_layer),
+    max_dis_trg_vtx_(max_dis_trg_vtx),
+    max_dca_trk_vtx_(max_dca_trk_vtx),
+    default_residual_(default_residual)
+{
+  LOG(debug) << "Creating an instance of CbmStsEfficiency ...";
+}
+CbmStsEfficiency::~CbmStsEfficiency() {}
+
+void CbmStsEfficiency::BookHistograms()
+{
+  // ---- Binning configuration ----
+  // Vertex
+  double vertex_x_min = -15;
+  double vertex_x_max = +15;
+  double vertex_y_min = -15;
+  double vertex_y_max = +15;
+  double vertex_z_min = -15;
+  double vertex_z_max = +15;
+  double vertex_dx    = 0.1;
+  double vertex_dy    = 0.1;
+  double vertex_dz    = 0.1;
+
+  auto x_vtx_binning = cbm_sts_utils::HBinning{uint32_t((vertex_x_max - vertex_x_min) / vertex_dx), vertex_x_min, vertex_x_max};
+  auto y_vtx_binning = cbm_sts_utils::HBinning{uint32_t((vertex_y_max - vertex_y_min) / vertex_dy), vertex_y_min, vertex_y_max};
+  auto z_vtx_binning = cbm_sts_utils::HBinning{uint32_t((vertex_z_max - vertex_z_min) / vertex_dz), vertex_z_min, vertex_z_max};
+
+  // DCA
+  double dca_dx = .001; // 10 um
+  double dca_min = -2.5 - 0.5 * dca_dx;
+  double dca_max = +2.5 + 0.5 * dca_dx;
+  auto r_dca_binning = cbm_sts_utils::HBinning{uint32_t((dca_max - dca_min) / dca_dx), dca_min, dca_max};
+
+  // Residuals track - hit
+  double res_dx    = +0.001; // 10 um
+  double res_min = -2.50 - 0.5*res_dx;
+  double res_max = +2.50 + 0.5*res_dx;
+  auto r_sen_binning = cbm_sts_utils::HBinning{uint32_t((res_max - res_min) / res_dx), res_min, res_max};
+  // ---- --------------------- ----
+
+  std::string h_name;
+  for (auto& [element, geo] : sts_geo_info_) {
+    std::string h_name_base = "";
+    if (element == test_layer_) {
+      h_name_base = Form("Sts%d", element);
+    }
+    else if (element > 8) {
+      if (CbmStsAddress::GetElementId(element, kStsUnit) != test_layer_) continue;
+      sensors_under_test_.push_back(element);
+      h_name_base = Form("Sts0x%x", element);
+    }
+
+    if (!h_name_base.length()) continue;
+
+    auto x_sen_binning = cbm_sts_utils::HBinning{uint32_t((geo[1] - geo[0]) / cbm_sts_utils::kStsDx), geo[0], geo[1]};
+    auto y_sen_binning = cbm_sts_utils::HBinning{uint32_t((geo[3] - geo[2]) / cbm_sts_utils::kStsDy), geo[2], geo[3]};
+
+    // ---- efficiency ----
+    h_name = Form("%s_found", h_name_base.c_str());
+    h2_[h_name] = std::make_unique<TH2D>(h_name.c_str(), h_name.c_str(),
+      x_sen_binning.n_of_bins, x_sen_binning.x_min, x_sen_binning.x_max,
+      y_sen_binning.n_of_bins, y_sen_binning.x_min, y_sen_binning.x_max);
+    h2_[h_name]->GetXaxis()->SetTitle("StsHit^{rec}_{X} [cm]");
+    h2_[h_name]->GetYaxis()->SetTitle("StsHit^{rec}_{Y} [cm]");
+
+    h_name = Form("%s_track", h_name_base.c_str());
+    h2_[h_name] = std::make_unique<TH2D>(h_name.c_str(), h_name.c_str(),
+      x_sen_binning.n_of_bins, x_sen_binning.x_min, x_sen_binning.x_max,
+      y_sen_binning.n_of_bins, y_sen_binning.x_min, y_sen_binning.x_max);
+    h2_[h_name]->GetXaxis()->SetTitle("StsHit^{ext}_{X} [cm]");
+    h2_[h_name]->GetYaxis()->SetTitle("StsHit^{ext}_{Y} [cm]");
+
+    h_name = Form("%s_hit_map", h_name_base.c_str());
+    h2_[h_name] = std::make_unique<TH2D>(h_name.c_str(), h_name.c_str(),
+      x_sen_binning.n_of_bins, x_sen_binning.x_min, x_sen_binning.x_max,
+      y_sen_binning.n_of_bins, y_sen_binning.x_min, y_sen_binning.x_max);
+    h2_[h_name]->GetXaxis()->SetTitle("StsHit_{X} [cm]");
+    h2_[h_name]->GetYaxis()->SetTitle("StsHit_{Y} [cm]");
+    // ---- ---------- ----
+
+    // ---- residuals ----
+    for (const char* di : {"x", "y"}){
+      h_name      = Form("%s_d%s_vs_x", h_name_base.c_str(), di);
+      h2_[h_name] = std::make_unique<TH2D>(h_name.c_str(), h_name.c_str(),
+        r_sen_binning.n_of_bins, r_sen_binning.x_min, r_sen_binning.x_max,
+        x_sen_binning.n_of_bins, x_sen_binning.x_min, x_sen_binning.x_max);
+      h2_[h_name]->GetYaxis()->SetTitle("X [cm]");
+      h2_[h_name]->GetXaxis()->SetTitle(Form("\\rho_{%s} [cm]", di));
+
+      h_name      = Form("%s_d%s_vs_y", h_name_base.c_str(), di);
+      h2_[h_name] = std::make_unique<TH2D>(h_name.c_str(), h_name.c_str(),
+        r_sen_binning.n_of_bins, r_sen_binning.x_min, r_sen_binning.x_max,
+        y_sen_binning.n_of_bins, y_sen_binning.x_min, y_sen_binning.x_max);
+      h2_[h_name]->GetYaxis()->SetTitle("Y [cm]");
+      h2_[h_name]->GetXaxis()->SetTitle(Form("\\rho_{%s} [cm]", di));
+    }
+    // ---- --------- ----
+  } // end geo loop
+
+  // ----     3D vertex      ----
+  h_name      = "vertex_y_vs_x";
+  h2_[h_name] = std::make_unique<TH2D>(h_name.c_str(), h_name.c_str(),
+    x_vtx_binning.n_of_bins, x_vtx_binning.x_min, x_vtx_binning.x_max,
+    y_vtx_binning.n_of_bins, y_vtx_binning.x_min, y_vtx_binning.x_max);
+  h2_[h_name]->GetXaxis()->SetTitle("Vertex_{X} [cm]");
+  h2_[h_name]->GetYaxis()->SetTitle("Vertex_{Y} [cm]");
+
+  h_name      = "vertex_x_vs_z";
+  h2_[h_name] = std::make_unique<TH2D>(h_name.c_str(), h_name.c_str(),
+    z_vtx_binning.n_of_bins, z_vtx_binning.x_min, z_vtx_binning.x_max,
+    x_vtx_binning.n_of_bins, x_vtx_binning.x_min, x_vtx_binning.x_max);
+  h2_[h_name]->GetXaxis()->SetTitle("Vertex_{Z} [cm]");
+  h2_[h_name]->GetYaxis()->SetTitle("Vertex_{X} [cm]");
+
+  h_name      = "vertex_y_vs_z";
+  h2_[h_name] = std::make_unique<TH2D>(h_name.c_str(), h_name.c_str(),
+    z_vtx_binning.n_of_bins, z_vtx_binning.x_min, z_vtx_binning.x_max,
+    y_vtx_binning.n_of_bins, y_vtx_binning.x_min, y_vtx_binning.x_max);
+  h2_[h_name]->GetXaxis()->SetTitle("Vertex_{Z} [cm]");
+  h2_[h_name]->GetYaxis()->SetTitle("Vertex_{Y} [cm]");
+  // ---- ------------------ ----
+
+  // ----        DCA         ----
+  for (const char* di : {"x", "y", "z"}){
+    h_name      = Form("dca_d%s_vs_x", di);
+    h2_[h_name] = std::make_unique<TH2D>(h_name.c_str(), h_name.c_str(),
+      r_dca_binning.n_of_bins, r_dca_binning.x_min, r_dca_binning.x_max,
+      x_vtx_binning.n_of_bins, x_vtx_binning.x_min, x_vtx_binning.x_max);
+    h2_[h_name]->GetYaxis()->SetTitle("X [cm]");
+    h2_[h_name]->GetXaxis()->SetTitle(Form("DCA_{%s} [cm]", di));
+
+    h_name      = Form("dca_d%s_vs_y", di);
+    h2_[h_name] = std::make_unique<TH2D>(h_name.c_str(), h_name.c_str(),
+      r_dca_binning.n_of_bins, r_dca_binning.x_min, r_dca_binning.x_max,
+      y_vtx_binning.n_of_bins, y_vtx_binning.x_min, y_vtx_binning.x_max);
+    h2_[h_name]->GetYaxis()->SetTitle("Y [cm]");
+    h2_[h_name]->GetXaxis()->SetTitle(Form("DCA_{%s} [cm]", di));
+
+    h_name      = Form("dca_d%s_vs_z", di);
+    h2_[h_name] = std::make_unique<TH2D>(h_name.c_str(), h_name.c_str(),
+      r_dca_binning.n_of_bins, r_dca_binning.x_min, r_dca_binning.x_max,
+      z_vtx_binning.n_of_bins, z_vtx_binning.x_min, z_vtx_binning.x_max);
+    h2_[h_name]->GetYaxis()->SetTitle(Form("Z [cm]"));
+    h2_[h_name]->GetXaxis()->SetTitle(Form("DCA_{%s} [cm]", di));
+  }
+  // ---- ------------------ ----
+
+  // ---- Track multiplicity ----
+  for (const char* mod : {":all", ":sel"}){
+    h_name      = Form("ca_track_multiplicity%s", mod);
+    h1_[h_name] = std::make_unique<TH1D>(h_name.c_str(), h_name.c_str(), 50, 0, 50); // HARDCODE
+    h1_[h_name]->GetXaxis()->SetTitle("N_{CATrack}");
+    h1_[h_name]->GetYaxis()->SetTitle("Entries");
+
+    h_name      = Form("ca_track_chi2%s", mod);
+    h1_[h_name] = std::make_unique<TH1D>(h_name.c_str(), h_name.c_str(), 10000, 0, 10); // HARDCODE
+    h1_[h_name]->GetXaxis()->SetTitle("Chi2");
+    h1_[h_name]->GetYaxis()->SetTitle("Entries");
+  }
+  // ---- ------------------ ----
+}
+
+void CbmStsEfficiency::CheckEfficiency()
+{
+  LOG(debug) << "Checking efficiency of STS station " << test_layer_ << " using " << glb_trks_.size() << " CbmGlobalTracks";
+  vertex_finder_->SetTracks(glb_trks_);
+  const std::optional<CbmVertex> vertex = vertex_finder_->FindVertex();
+
+  if (!vertex.has_value()) return;
+
+  if (std::abs(vertex->GetZ()) > max_dis_trg_vtx_) return;
+
+  h2_["vertex_y_vs_x"]->Fill(vertex->GetX(), vertex->GetY());
+  h2_["vertex_x_vs_z"]->Fill(vertex->GetZ(), vertex->GetX());
+  h2_["vertex_y_vs_z"]->Fill(vertex->GetZ(), vertex->GetY());
+
+  TVector3 vtx(vertex->GetX(), vertex->GetY(), vertex->GetZ());
+  std::map<int32_t, std::vector<bool>> hit_used;
+  for (auto trk : glb_trks_) {
+    double trk_tx       = trk->GetParamFirst()->GetTx();
+    double trk_ty       = trk->GetParamFirst()->GetTy();
+    double trk_x0       = trk->GetParamFirst()->GetX();
+    double trk_y0       = trk->GetParamFirst()->GetY();
+    double trk_z0       = trk->GetParamFirst()->GetZ();
+
+    // Check if tack comes from vertex
+    TVector3 p(trk_x0, trk_y0, trk_z0);
+    TVector3 e(trk_tx, trk_ty, 1);
+    TVector3 trk_to_vtx    = ((vtx - p).Cross(e)) * (1. / e.Mag());
+
+    h2_["dca_dx_vs_x"]->Fill(trk_to_vtx.Px(), vtx.Px());
+    h2_["dca_dx_vs_y"]->Fill(trk_to_vtx.Px(), vtx.Py());
+    h2_["dca_dx_vs_z"]->Fill(trk_to_vtx.Px(), vtx.Pz());
+
+    h2_["dca_dy_vs_x"]->Fill(trk_to_vtx.Py(), vtx.Px());
+    h2_["dca_dy_vs_y"]->Fill(trk_to_vtx.Py(), vtx.Py());
+    h2_["dca_dy_vs_z"]->Fill(trk_to_vtx.Py(), vtx.Pz());
+
+    h2_["dca_dz_vs_x"]->Fill(trk_to_vtx.Pz(), vtx.Px());
+    h2_["dca_dz_vs_y"]->Fill(trk_to_vtx.Pz(), vtx.Py());
+    h2_["dca_dz_vs_z"]->Fill(trk_to_vtx.Pz(), vtx.Pz());
+
+    if (trk_to_vtx.Mag() > max_dca_trk_vtx_) continue;
+
+    for(int32_t & sensor : sensors_under_test_) {
+      auto hits = sts_hits_[sensor];
+      size_t n_of_hits = hits.size();
+
+      // Extrapolate to the current sensor z-plane
+      double sensor_z    = 0.5 * (sts_geo_info_[sensor][4] + sts_geo_info_[sensor][5]);
+      double predicted_x = trk_x0 + trk_tx * (sensor_z - trk_z0);
+      double predicted_y = trk_y0 + trk_ty * (sensor_z - trk_z0);
+
+      // Check if the sensor contain the space point
+      if (predicted_x < sts_geo_info_[sensor][0] || predicted_x > sts_geo_info_[sensor][1]
+        || predicted_y < sts_geo_info_[sensor][2] || predicted_y > sts_geo_info_[sensor][3]) {
+        continue;
+      }
+
+      int unit = CbmStsAddress::GetElementId(sensor, kStsUnit);
+      h2_[Form("Sts%d_track", unit)]->Fill(predicted_x, predicted_y);
+      h2_[Form("Sts0x%x_track", sensor)]->Fill(predicted_x, predicted_y);
+
+      if (n_of_hits){
+        /* Block to search in available hits */
+        double closest_id = 0;
+        double dx = hits[0]->GetX() - predicted_x - residuals_[sensor].mean.Px();
+        double dy = hits[0]->GetY() - predicted_y - residuals_[sensor].mean.Py();
+        double closest_rho = dx*dx + dy*dy;
+
+        for (size_t idx = 1 ; idx < n_of_hits ; idx++) {
+          dx  = hits[idx]->GetX() - predicted_x - residuals_[sensor].mean.Px();
+          dy  = hits[idx]->GetY() - predicted_y - residuals_[sensor].mean.Py();
+          double rho = dx*dx + dy*dy;
+
+          if (rho < closest_rho) {
+            closest_id = idx;
+            closest_rho = rho;
+          }
+        }
+
+        dx  = hits[closest_id]->GetX() - predicted_x - residuals_[sensor].mean.Px();
+        dy  = hits[closest_id]->GetY() - predicted_y - residuals_[sensor].mean.Py();
+
+        h2_[Form("Sts%d_dx_vs_x", unit)]->Fill(dx, hits[closest_id]->GetX());
+        h2_[Form("Sts%d_dy_vs_x", unit)]->Fill(dy, hits[closest_id]->GetX());
+        h2_[Form("Sts%d_dx_vs_y", unit)]->Fill(dx, hits[closest_id]->GetY());
+        h2_[Form("Sts%d_dy_vs_y", unit)]->Fill(dy, hits[closest_id]->GetY());
+
+        h2_[Form("Sts0x%x_dx_vs_x", sensor)]->Fill(dx, hits[closest_id]->GetX());
+        h2_[Form("Sts0x%x_dy_vs_x", sensor)]->Fill(dy, hits[closest_id]->GetX());
+        h2_[Form("Sts0x%x_dx_vs_y", sensor)]->Fill(dx, hits[closest_id]->GetY());
+        h2_[Form("Sts0x%x_dy_vs_y", sensor)]->Fill(dy, hits[closest_id]->GetY());
+
+        double sensor_resolution = residuals_[sensor].sigma.Mag() != 0 ? residuals_[sensor].sigma.Mag() : default_residual_;
+        if (closest_rho <= 3.0 * sensor_resolution) {
+          h2_[Form("Sts%d_found", unit)]->Fill(predicted_x, predicted_y);
+          h2_[Form("Sts0x%x_found", sensor)]->Fill(predicted_x, predicted_y);
+        }
+      }
+
+
+      /* Block to search in avaliable hit */
+
+    } // end sensor under test lopp
+  }// end track loop
+}
+
+TH2D* FindInactiveArea(TH2D* h, int dead_size_x = 10, int dead_size_y = 10)
+{
+  TH2D* dead = (TH2D*) h->Clone();
+  dead->Reset();
+
+  for (int bin_y = 1; bin_y < dead->GetNbinsY(); bin_y++) {
+    for (int bin_x = dead_size_x; bin_x < dead->GetNbinsX() - dead_size_x; bin_x++) {
+
+      bool all_dead = true;
+      for (int test_bin = -dead_size_x; test_bin <= +dead_size_x; test_bin++) {
+        if (h->GetBinContent(bin_x + test_bin, bin_y)) {
+          all_dead = false;
+          break;
+        }
+      }
+      if (all_dead) {
+        for (int test_bin = -dead_size_x; test_bin <= +dead_size_x; test_bin++)
+          dead->SetBinContent(bin_x + test_bin, bin_y, 1);
+      }
+    }
+  }
+
+  for (int bin_x = 1; bin_x < dead->GetNbinsX(); bin_x++) {
+    for (int bin_y = dead_size_y; bin_y < dead->GetNbinsY() - dead_size_y; bin_y++) {
+
+      bool all_dead = true;
+      for (int test_bin = -dead_size_y; test_bin <= +dead_size_y; test_bin++) {
+        if (h->GetBinContent(bin_x, bin_y + test_bin)) {
+          all_dead = false;
+          break;
+        }
+      }
+      if (all_dead) {
+        for (int test_bin = -dead_size_y; test_bin <= +dead_size_y; test_bin++)
+          dead->SetBinContent(bin_x, bin_y + test_bin, 1);
+      }
+    }
+  }
+
+  return dead;
+}
+
+void CbmStsEfficiency::Efficiency(uint32_t sensor)
+{
+  std::string h_name_base = "";
+  if (sensor == test_layer_) {
+    h_name_base = Form("Sts%d", sensor);
+  }
+  else if (sensor > 8) {
+    if (CbmStsAddress::GetElementId(sensor, kStsUnit) != test_layer_) return;
+    h_name_base = Form("Sts0x%x", sensor);
+  }
+  auto found = h2_[Form("%s_found", h_name_base.c_str())].get();
+  auto track = h2_[Form("%s_track", h_name_base.c_str())].get();
+
+  if (found == nullptr || track == nullptr) return;
+
+  TH2D* inactive_area = FindInactiveArea(h2_[Form("%s_hit_map", h_name_base.c_str())].get(), 50, 50);
+
+  // Manual integration
+  int n_of_found = 0;
+  int n_of_track = 0;
+  std::vector<double> samples;
+
+  for (int bin_y = 50; bin_y < inactive_area->GetNbinsY() - 50; bin_y++) {
+    for (int bin_x = 50; bin_x < inactive_area->GetNbinsX() - 50; bin_x++) {
+      if (!inactive_area->GetBinContent(bin_x, bin_y)) {
+        n_of_found += found->GetBinContent(bin_x, bin_y);
+        n_of_track += track->GetBinContent(bin_x, bin_y);
+      }
+    }
+  }
+  LOG(debug) << n_of_found << "\t" << n_of_track;
+  double efficiency = n_of_track != 0 ? double(n_of_found) / n_of_track : -1;
+  if (efficiency != -1) {
+    samples.push_back(efficiency);
+  }
+
+  double mean  = 0;
+  double sigma = 0;
+  int n        = samples.size();
+  if (n == 0) {
+    return;
+  }
+
+  // Take efficiency as mean value
+  for (double& val : samples) {
+    mean += val;
+  }
+  mean = double(mean / n);
+
+  // Take error as RMS of the values
+  for (double& val : samples) {
+    sigma += (val - mean) * (val - mean);
+  }
+  sigma = sqrt(double(sigma / n));
+
+  std::cout << Form("0x%x:\t%0.4f\t%0.4f\n", sensor, mean, sigma);
+}
+
+void CbmStsEfficiency::FinishTask()
+{
+  for (auto& [element, geo] : sts_geo_info_) {
+    Efficiency(element);
+  }
+
+  SaveToFile();
+}
+
+
+void CbmStsEfficiency::ProcessEvent(CbmEvent* evt)
+{
+  int nb_sts_hits = evt->GetNofData(ECbmDataType::kStsHit);
+
+  for (int hit_evt_idx = 0; hit_evt_idx < nb_sts_hits; hit_evt_idx++) {
+    int sts_hit_idx = evt->GetIndex(ECbmDataType::kStsHit, hit_evt_idx);
+    CbmStsHit* hit  = (CbmStsHit*) sts_hit_array_->UncheckedAt(sts_hit_idx);
+    ProcessHit(hit);
+  }
+
+  int nb_of_glob_trk = evt->GetNofData(ECbmDataType::kGlobalTrack);
+  for (int evt_glob_trk_idx = 0; evt_glob_trk_idx < nb_of_glob_trk; evt_glob_trk_idx++) {
+    int glob_trk_idx         = evt->GetIndex(ECbmDataType::kGlobalTrack, evt_glob_trk_idx);
+    CbmGlobalTrack* glob_trk = (CbmGlobalTrack*) glb_trk_array_->UncheckedAt(glob_trk_idx);
+    ProcessGlobalTrack(glob_trk);
+  }
+
+  h1_["ca_track_multiplicity:all"]->Fill(nb_of_glob_trk);
+  h1_["ca_track_multiplicity:sel"]->Fill(glb_trks_.size());
+
+  if (glb_trks_.size()) CheckEfficiency();
+
+  glb_trks_.clear();
+  sts_hits_.clear();
+}
+
+void CbmStsEfficiency::ProcessGlobalTrack(CbmGlobalTrack* trk)
+{
+  auto sts_trk_idx  = trk->GetStsTrackIndex();
+  auto rich_trk_idx = trk->GetRichRingIndex();
+  auto much_trk_idx = trk->GetMuchTrackIndex();
+  auto trd_trk_idx  = trk->GetTrdTrackIndex();
+  auto tof_trk_idx  = trk->GetTofTrackIndex();
+  double trk_p_val   = TMath::Prob(trk->GetChi2(), trk->GetNDF());
+  h1_["ca_track_chi2:all"]->Fill(trk->GetChi2());
+
+  // Apply GlobalTracks cuts
+  int32_t mvd_trk_size = sts_trk_idx != -1 && sts_trk_array_ != nullptr
+                           ? ((CbmStsTrack*) sts_trk_array_->UncheckedAt(sts_trk_idx))->GetNofMvdHits()
+                           : 0;
+
+  int32_t sts_trk_size = sts_trk_idx != -1 && sts_trk_array_ != nullptr
+                           ? ((CbmStsTrack*) sts_trk_array_->UncheckedAt(sts_trk_idx))->GetNofStsHits()
+                           : 0;
+
+  int32_t rich_trk_size = rich_trk_idx != -1 && rch_trk_array_ != nullptr
+                            ? ((CbmTrack*) rch_trk_array_->UncheckedAt(rich_trk_idx))->GetNofHits()
+                            : 0;
+
+  int32_t much_trk_size = much_trk_idx != -1 && mch_trk_array_ != nullptr
+                            ? ((CbmTrack*) mch_trk_array_->UncheckedAt(much_trk_idx))->GetNofHits()
+                            : 0;
+
+  int32_t trd_trk_size = trd_trk_idx != -1 && trd_trk_array_ != nullptr
+                           ? ((CbmTrack*) trd_trk_array_->UncheckedAt(trd_trk_idx))->GetNofHits()
+                           : 0;
+
+  int32_t tof_trk_size = tof_trk_idx != -1 && tof_trk_array_ != nullptr
+                           ? ((CbmTrack*) tof_trk_array_->UncheckedAt(tof_trk_idx))->GetNofHits()
+                           : 0;
+
+  if (analysis_cut_ != nullptr
+      && (!analysis_cut_->Check(CbmCutId::kGlobalTrackMvdSize, mvd_trk_size)
+          || !analysis_cut_->Check(CbmCutId::kGlobalTrackStsSize, sts_trk_size)
+          || !analysis_cut_->Check(CbmCutId::kGlobalTrackRichSize, rich_trk_size)
+          || !analysis_cut_->Check(CbmCutId::kGlobalTrackMuchSize, much_trk_size)
+          || !analysis_cut_->Check(CbmCutId::kGlobalTrackTrdSize, trd_trk_size)
+          || !analysis_cut_->Check(CbmCutId::kGlobalTrackTofSize, tof_trk_size)
+          || !analysis_cut_->Check(CbmCutId::kGlobalTrackChi2, trk->GetChi2())
+          || !analysis_cut_->Check(CbmCutId::kGlobalTrackPval, trk_p_val))) {
+    return;
+  }
+
+  h1_["ca_track_chi2:sel"]->Fill(trk->GetChi2());
+  glb_trks_.push_back(trk);
+}
+
+void CbmStsEfficiency::ProcessHit(CbmStsHit* hit)
+{
+  if (hit == nullptr) return;
+  uint32_t address = hit->GetAddress();
+  uint32_t unit    = CbmStsAddress::GetElementId(address, kStsUnit);
+
+  if (unit != test_layer_) return;
+
+  if (analysis_cut_ != nullptr && !analysis_cut_->CheckStsHit(hit, sts_clu_array_)) return;
+
+  sts_hits_[address].push_back(hit);
+  h2_[Form("Sts%u_hit_map", unit)]->Fill(hit->GetX(), hit->GetY());
+  h2_[Form("Sts0x%x_hit_map", address)]->Fill(hit->GetX(), hit->GetY());
+
+}
+
+void CbmStsEfficiency::Exec(Option_t*)
+{
+  // Check if CbmEvent
+  if (cbm_evt_array_ != nullptr) {
+    LOG(info) << "Running CbmStsEfficiency - Event-like - " << entry_;
+
+    uint32_t nb_events = cbm_evt_array_->GetEntriesFast();
+    for (uint32_t evt_idx = 0; evt_idx < nb_events; evt_idx++) {
+      CbmEvent* event = (CbmEvent*) cbm_evt_array_->UncheckedAt(evt_idx);
+      if (analysis_cut_ != nullptr && !analysis_cut_->CheckEvent(event)) continue;
+      LOG(debug) << Form("Process CbmEvent %d / %d", evt_idx, nb_events);
+      ProcessEvent(event);
+    }
+  }
+  else {
+
+    LOG(info) << "Running CbmStsEfficiency - TS-like - ";
+    uint32_t n_of_hits = sts_hit_array_->GetEntriesFast();
+    for (uint32_t hit_idx = 0; hit_idx < n_of_hits; hit_idx++) {
+      CbmStsHit* sts_hit = (CbmStsHit*) sts_hit_array_->UncheckedAt(hit_idx);
+      ProcessHit(sts_hit);
+    }
+    uint32_t nb_of_glob_trk = glb_trk_array_->GetEntriesFast();
+    LOG(debug) << Form("Number of GlobalTracks: %u", nb_of_glob_trk);
+    for (uint32_t glob_trk_idx = 0; glob_trk_idx < nb_of_glob_trk; glob_trk_idx++) {
+      CbmGlobalTrack* glob_trk = (CbmGlobalTrack*) glb_trk_array_->UncheckedAt(glob_trk_idx);
+      ProcessGlobalTrack(glob_trk);
+    }
+
+    if (glb_trks_.size()) CheckEfficiency();
+
+    glb_trks_.clear();
+    sts_hits_.clear();
+  }
+  entry_++;
+}
+
+InitStatus CbmStsEfficiency::Init()
+{
+  LOG(debug) << "Init CbmStsEfficiency ...";
+
+  FairRootManager* ioman = FairRootManager::Instance();
+  if (ioman != nullptr) {
+    cbm_evt_array_ = (TClonesArray*) ioman->GetObject("CbmEvent");
+
+    glb_trk_array_ = (TClonesArray*) ioman->GetObject("GlobalTrack");
+
+    sts_trk_array_ = (TClonesArray*) ioman->GetObject("StsTrack");
+    rch_trk_array_ = (TClonesArray*) ioman->GetObject("RichTrack");
+    mch_trk_array_ = (TClonesArray*) ioman->GetObject("MuchTrack");
+    trd_trk_array_ = (TClonesArray*) ioman->GetObject("TrdTrack");
+    tof_trk_array_ = (TClonesArray*) ioman->GetObject("TofTrack");
+
+    sts_hit_array_ = (TClonesArray*) ioman->GetObject("StsHit");
+
+    sts_clu_array_ = (TClonesArray*) ioman->GetObject("StsCluster");
+  }
+
+  LoadSetup();
+
+  BookHistograms();
+
+  std::stringstream ss;
+  for (auto s : sensors_under_test_){
+    ss << Form("\t\t0x%x - U%d L%d M%d\n",
+      s,
+      CbmStsAddress::GetElementId(s, kStsUnit),
+      CbmStsAddress::GetElementId(s, kStsLadder),
+      CbmStsAddress::GetElementId(s, kStsModule));
+  }
+
+  LOG(info) << "Max vtx target dz: " << max_dis_trg_vtx_;
+  LOG(info) << "Max trk vtx DCA: " << max_dca_trk_vtx_;
+  LOG(info) << "Default residual: " << default_residual_;
+  LOG(info) << "Test layer: " << test_layer_;
+  LOG(info) << "Layer modules:\n" << ss.str();
+
+  return kSUCCESS;
+}
+
+void CbmStsEfficiency::SetSensorResidual(int32_t address, TVector3 m, TVector3 s)
+{
+  residuals_[address] = Residual(m, s);
+}
+
+void CbmStsEfficiency::SetResidual(std::string file_name)
+{
+  std::ifstream in(file_name);
+  int32_t sensor;
+  double mean_x, mean_y, sigma_x, sigma_y;
+  while (in >> std::hex >> sensor >> std::dec >> mean_x >> mean_y >> sigma_x >> sigma_y) {
+    SetSensorResidual(sensor, TVector3(mean_x, mean_y, 0), TVector3(sigma_x, sigma_y, 0));
+  }
+}
+
+
+void CbmStsEfficiency::SetVertexFinder(CbmDcaVertexFinder* vtx_finder){
+  vertex_finder_ = vtx_finder;
+}
\ No newline at end of file
diff --git a/analysis/detectors/sts/CbmStsEfficiency.h b/analysis/detectors/sts/CbmStsEfficiency.h
new file mode 100644
index 0000000000..4597439272
--- /dev/null
+++ b/analysis/detectors/sts/CbmStsEfficiency.h
@@ -0,0 +1,123 @@
+/** \file CbmStsEfficiency.h
+ * \brief Definition of the CbmStsEfficiency class.
+ *
+ * Copyright (C) 2022 Facility for Antiproton and Ion Research in Europe, Darmstadt
+ * SPDX-License-Identifier: GPL-3.0-only
+ * Authors: Dario Ramirez [committer]
+ */
+
+#ifndef CBMSTSEFFICIENCY_H
+#define CBMSTSEFFICIENCY_H
+
+#include "CbmEvent.h"
+#include "CbmGlobalTrack.h"
+#include "CbmStsAnaBase.h"
+#include "CbmStsCluster.h"
+#include "CbmStsHit.h"
+#include "CbmStsTrack.h"
+#include "CbmStsUtils.h"
+#include "CbmTrack.h"
+
+#include <FairTask.h>
+
+#include <TClonesArray.h>
+#include <TVector3.h>
+
+#include <cstring>
+#include <map>
+#include <unordered_map>
+#include <unordered_set>
+
+#include "CbmDcaVertexFinder.h"
+
+struct Residual {
+  TVector3 mean;
+  TVector3 sigma;
+  Residual() {}
+  Residual(TVector3 m, TVector3 s)
+  {
+    mean  = m;
+    sigma = s;
+  }
+};
+
+/** \class CbmStsEfficiency
+ * \brief Task for Hit Reconstruction Efficiency (HRE) analysis of STS hits.
+ *
+ * This class inherits from FairTask and CbmStsAnaBase.
+ * It provides functionality for analyzing the CA Tracking based HRE
+ * of STS hits.
+ */
+class CbmStsEfficiency : public FairTask, public CbmStsAnaBase {
+ public:
+  /** \brief Default constructor */
+  CbmStsEfficiency();
+
+  /** \brief Parameterized constructor */
+  CbmStsEfficiency(uint32_t);
+
+  /** \brief Parameterized constructor */
+  CbmStsEfficiency(uint32_t, double, double, double);
+
+  /** \brief Destructor */
+  virtual ~CbmStsEfficiency();
+
+  InitStatus Init();
+  void Exec(Option_t*);
+  void FinishTask();
+
+  void SetSensorResidual(int32_t, TVector3, TVector3);
+  void SetResidual(std::string);
+
+  void SetVertexFinder(CbmDcaVertexFinder*);
+
+  bool draw_opt_{true};
+
+ private:
+  uint32_t test_layer_{0};
+  std::vector<int32_t> sensors_under_test_;
+  double max_dis_trg_vtx_{0.25};
+  double max_dca_trk_vtx_{0.25};
+  double default_residual_{0.12};
+  std::map<int32_t, Residual> residuals_;
+
+
+  CbmDcaVertexFinder* vertex_finder_;
+
+  std::vector<CbmGlobalTrack*> glb_trks_;
+  std::map<int32_t, std::vector<CbmStsHit*>> sts_hits_;
+
+  TClonesArray* cbm_evt_array_{nullptr};
+  TClonesArray* glb_trk_array_{nullptr};
+  TClonesArray* sts_trk_array_{nullptr};
+  TClonesArray* rch_trk_array_{nullptr};
+  TClonesArray* mch_trk_array_{nullptr};
+  TClonesArray* trd_trk_array_{nullptr};
+  TClonesArray* tof_trk_array_{nullptr};
+  TClonesArray* sts_hit_array_{nullptr};
+  TClonesArray* sts_clu_array_{nullptr};
+
+  void BookHistograms();
+
+  void Efficiency(uint32_t);
+
+  /** \brief Process an Cbm events
+   * It filters event based on the provided CbmCutMap
+  */
+  void ProcessEvent(CbmEvent*);
+
+  /** \brief Process an Global tracks
+   * It filters the tracks based on the provided CbmCutMap
+  */
+  void ProcessGlobalTrack(CbmGlobalTrack*);
+
+  /** \brief Process an STS hit
+   * It filters hits based on the provided CbmCutMap
+  */
+  void ProcessHit(CbmStsHit*);
+
+  void CheckEfficiency();
+
+  ClassDef(CbmStsEfficiency, 1);
+};
+#endif
diff --git a/macro/sts/sts_efficiency.C b/macro/sts/sts_efficiency.C
new file mode 100755
index 0000000000..74f1eb84f4
--- /dev/null
+++ b/macro/sts/sts_efficiency.C
@@ -0,0 +1,108 @@
+void sts_efficiency(
+    int n_of_ts = -1,
+    std::string geo_setup_tag = "mcbm_beam_2024_05_08_nickel",
+    std::string raw_file = "",
+    std::string rec_file = "",
+    std::string geo_file = "",
+    std::string out_file = "cbm_sts_efficiency.root",
+    bool bAli = true
+){
+    // -----   Timer   --------------------------------------------------------
+    TStopwatch timer;
+    timer.Start();
+
+    // --- Logger settings ----------------------------------------------------
+    TString logLevel     = "DEBUG";
+    TString logVerbosity = "veryhigh";
+            logLevel     = "INFO";
+            logVerbosity = "low";
+
+    FairLogger::GetLogger()->SetLogScreenLevel(logLevel.Data());
+    FairLogger::GetLogger()->SetLogVerbosityLevel(logVerbosity.Data());
+    // ------------------------------------------------------------------------
+
+
+    // -----   Environment   --------------------------------------------------
+    std::string srcDir = gSystem->Getenv("VMCWORKDIR");  // top source directory
+    // ------------------------------------------------------------------------
+
+    std::unique_ptr<CbmStsAnalysis> run = std::make_unique<CbmStsAnalysis>();
+
+    FairFileSource* inputSource = new FairFileSource(rec_file.c_str());
+    inputSource->AddFriend(raw_file.c_str());
+
+    FairRootFileSink* outputSink = new FairRootFileSink(out_file.c_str());
+
+
+    if (bAli) {
+        TString alignmentMatrixFileName = srcDir + "/parameters/mcbm/AlignmentMatrices_" + geo_setup_tag + ".root";
+        if (alignmentMatrixFileName.Length() != 0) {
+            std::map<std::string, TGeoHMatrix>* matrices{nullptr};
+            TFile* misalignmentMatrixRootfile = new TFile(alignmentMatrixFileName, "READ");
+            if (misalignmentMatrixRootfile->IsOpen()) {
+                gDirectory->GetObject("MisalignMatrices", matrices);
+                misalignmentMatrixRootfile->Close();
+            }
+            else {
+                LOG(error) << "Could not open file " << alignmentMatrixFileName << "\n Exiting";
+                exit(1);
+            }
+
+            if (matrices) {
+                run->AddAlignmentMatrices(*matrices);
+            }
+            else {
+                LOG(error) << "Alignment required but no matrices found."
+                << "\n Exiting";
+                exit(1);
+            }
+        }
+    }
+
+    run->SetGeomFile(geo_file.c_str());
+    run->SetSource(inputSource);
+    run->SetSink(outputSink);
+
+
+    // ------------------------------------------------------------------------
+    // Configure Analysis filters
+    // ------------------------------------------------------------------------
+    CbmCutMap ana_filter;
+    ana_filter.AddCbmCut(CbmCutId::kStsHitCharge)->SetMin(10000);
+    ana_filter.AddCbmCut(CbmCutId::kEventNofStsHit)->SetMin(2);
+    ana_filter.AddCbmCut(CbmCutId::kGlobalTrackStsSize)->SetMin(2);
+    ana_filter.AddCbmCut(CbmCutId::kGlobalTrackTrdSize)->SetMin(1);
+    ana_filter.AddCbmCut(CbmCutId::kGlobalTrackTofSize)->SetMin(1);
+    // ana_filter.AddCbmCut(CbmCutId::kGlobalTrackPval)->SetMax(0.005);
+
+    // ------------------------------------------------------------------------
+    // Configure Vertex Finder
+    // ------------------------------------------------------------------------
+    std::shared_ptr<CbmDcaVertexFinder> vertex_finder = std::make_shared<CbmDcaVertexFinder>(0.2);
+
+    // ------------------------------------------------------------------------
+    // Configure Efficiency
+    // ------------------------------------------------------------------------
+    CbmStsEfficiency* sts_eff1 = new CbmStsEfficiency(  1,      // test_layer_(layer_idx)
+                                                        0.25,   // max_dis_trg_vtx_(cut_trg_vtx)
+                                                        0.25,   // max_dca_trk_vtx_(cut_trk_vtx)
+                                                        0.005    // default_residual(def_res)
+    );
+
+    sts_eff1->SetCutMap(&ana_filter);
+    sts_eff1->SetVertexFinder(vertex_finder.get());
+    // sts_eff1->SetResidual("Ref_Sts10_residuals.info");
+    run->AddTask(sts_eff1);
+
+    run->Init();
+    run->Run(0,n_of_ts);
+
+    // ------------------------------------------------------------------------
+    timer.Stop();
+    Double_t rtime = timer.RealTime();
+    Double_t ctime = timer.CpuTime();
+    cout << endl << endl;
+    cout << "Macro finished successfully." << endl;
+    cout << "Real time " << rtime << " s, CPU time " << ctime << " s" << endl;
+    cout << endl;
+}
\ No newline at end of file
-- 
GitLab


From fb8a1c06ae8a5fb94f89f96d8d2faba55cf4ce78 Mon Sep 17 00:00:00 2001
From: Dario Ramirez <d.ramirez@gsi.de>
Date: Tue, 15 Apr 2025 13:33:07 +0200
Subject: [PATCH 11/18] CbmStsResolution

Analysis class to build track-hit residual to posterior STS spatial resolution estimation
---
 analysis/detectors/sts/CMakeLists.txt       |   1 +
 analysis/detectors/sts/CbmStsAnaLinkDef.h   |   1 +
 analysis/detectors/sts/CbmStsResolution.cxx | 362 ++++++++++++++++++++
 analysis/detectors/sts/CbmStsResolution.h   | 145 ++++++++
 macro/sts/sts_resolution.C                  | 103 ++++++
 5 files changed, 612 insertions(+)
 create mode 100644 analysis/detectors/sts/CbmStsResolution.cxx
 create mode 100644 analysis/detectors/sts/CbmStsResolution.h
 create mode 100755 macro/sts/sts_resolution.C

diff --git a/analysis/detectors/sts/CMakeLists.txt b/analysis/detectors/sts/CMakeLists.txt
index 02e5d00b29..c1c438d165 100644
--- a/analysis/detectors/sts/CMakeLists.txt
+++ b/analysis/detectors/sts/CMakeLists.txt
@@ -20,6 +20,7 @@ set(SRCS
   CbmStsRecoBeamSpot.cxx
   CbmDcaVertexFinder.cxx
   CbmStsEfficiency.cxx
+  CbmStsResolution.cxx
   )
 
 
diff --git a/analysis/detectors/sts/CbmStsAnaLinkDef.h b/analysis/detectors/sts/CbmStsAnaLinkDef.h
index 8b3fccb5b2..e08f26d068 100644
--- a/analysis/detectors/sts/CbmStsAnaLinkDef.h
+++ b/analysis/detectors/sts/CbmStsAnaLinkDef.h
@@ -22,6 +22,7 @@
 #pragma link C++ class CbmStsRecoBeamSpot + ;
 #pragma link C++ class CbmDcaVertexFinder + ;
 #pragma link C++ class CbmStsEfficiency + ;
+#pragma link C++ class CbmStsResolution + ;
 
 
 #endif /* __CINT__ */
diff --git a/analysis/detectors/sts/CbmStsResolution.cxx b/analysis/detectors/sts/CbmStsResolution.cxx
new file mode 100644
index 0000000000..aa0f3c7c06
--- /dev/null
+++ b/analysis/detectors/sts/CbmStsResolution.cxx
@@ -0,0 +1,362 @@
+/* Copyright (C) 2022 Facility for Antiproton and Ion Research in Europe, Darmstadt
+   SPDX-License-Identifier: GPL-3.0-only
+   Authors: Dario Ramirez [committer] */
+
+#include "CbmStsResolution.h"
+
+#include "CbmPixelHit.h"
+#include "CbmStsAddress.h"
+#include "TPaveStats.h"
+#include "TStyle.h"
+
+#include "CbmStsTrack.h"
+
+CbmStsResolution::CbmStsResolution() : d_max_trk_trg_(-1)
+{ LOG(debug) << "Creating an instance of CbmStsResolution ..."; }
+
+CbmStsResolution::CbmStsResolution(double d_max) : d_max_trk_trg_(d_max)
+{ LOG(debug) << "Creating an instance of CbmStsResolution ..."; }
+CbmStsResolution::~CbmStsResolution() {}
+
+void CbmStsResolution::BookHistograms()
+{
+  for (auto& [element, geo] : sts_geo_info_) {
+    std::string h_name_base = element < 8 ? Form("Sts%d", element) : Form("Sts0x%x", element);
+
+    LOG(debug) << Form("Booking for %s", h_name_base.c_str());
+
+    double x_min = geo[0];
+    double x_max = geo[1];
+    double y_min = geo[2];
+    double y_max = geo[3];
+
+    unsigned int nb_bins_x = (x_max - x_min) / cbm_sts_utils::kStsDx;
+    unsigned int nb_bins_y = (y_max - y_min) / cbm_sts_utils::kStsDy;
+
+
+    double dr = 5e-4;
+    double r_min = -2.7 - 0.5 * dr;
+    double r_max = +2.7 + 0.5 * dr;
+    unsigned int nb_bins_r = (r_max - r_min) / dr;
+
+    for (auto mod : {":all", ":trk"}){
+      std::string h_name;
+      h_name = Form("%s_dx_vs_x%s", h_name_base.c_str(), mod);
+      h2_[h_name] =
+      std::make_unique<TH2D>(h_name.c_str(), "", nb_bins_r, r_min, r_max, nb_bins_x, x_min, x_max);
+      h2_[h_name]->GetXaxis()->SetTitle(Form("X_{trk} - X_{hit} [cm]"));
+      h2_[h_name]->GetYaxis()->SetTitle("X_{hit} [cm]");
+      h2_[h_name]->GetXaxis()->CenterTitle(true);
+      h2_[h_name]->GetYaxis()->CenterTitle(true);
+
+      h_name = Form("%s_dx_vs_y%s", h_name_base.c_str(), mod);
+      h2_[h_name] =
+      std::make_unique<TH2D>(h_name.c_str(), "", nb_bins_r, r_min, r_max, nb_bins_y, y_min, y_max);
+      h2_[h_name]->GetXaxis()->SetTitle(Form("X_{trk} - X_{hit} [cm]"));
+      h2_[h_name]->GetYaxis()->SetTitle("Y_{hit} [cm]");
+      h2_[h_name]->GetXaxis()->CenterTitle(true);
+      h2_[h_name]->GetYaxis()->CenterTitle(true);
+
+      h_name = Form("%s_dy_vs_x%s", h_name_base.c_str(), mod);
+      h2_[h_name] =
+      std::make_unique<TH2D>(h_name.c_str(), "", nb_bins_r, r_min, r_max, nb_bins_x, x_min, x_max);
+      h2_[h_name]->GetXaxis()->SetTitle(Form("Y_{trk} - Y_{hit} [cm]"));
+      h2_[h_name]->GetYaxis()->SetTitle("X_{hit} [cm]");
+      h2_[h_name]->GetXaxis()->CenterTitle(true);
+      h2_[h_name]->GetYaxis()->CenterTitle(true);
+
+      h_name = Form("%s_dy_vs_y%s", h_name_base.c_str(), mod);
+      h2_[h_name] =
+      std::make_unique<TH2D>(h_name.c_str(), "", nb_bins_r, r_min, r_max, nb_bins_y, y_min, y_max);
+      h2_[h_name]->GetXaxis()->SetTitle(Form("Y_{trk} - Y_{hit} [cm]"));
+      h2_[h_name]->GetYaxis()->SetTitle("Y_{hit} [cm]");
+      h2_[h_name]->GetXaxis()->CenterTitle(true);
+      h2_[h_name]->GetYaxis()->CenterTitle(true);
+
+    }
+    if (element < 8){
+      std::string h_name = Form("Sts%d_ref_hits", element);
+      h2_[h_name] = std::make_unique<TH2D>(h_name.c_str(), "", nb_bins_x, x_min, x_max, nb_bins_y, y_min, y_max);
+      h2_[h_name]->GetXaxis()->SetTitle(Form("X_{TrkHit} [cm]"));
+      h2_[h_name]->GetYaxis()->SetTitle("Y_{TrkHit} [cm]");
+      h2_[h_name]->GetXaxis()->CenterTitle(true);
+      h2_[h_name]->GetYaxis()->CenterTitle(true);
+    }
+  }
+}
+
+void CbmStsResolution::ProcessEvent(CbmEvent* evt)
+{
+  if (analysis_cut_ != nullptr && !analysis_cut_->CheckEvent(evt)) return;
+
+  int nb_sts_hits = evt->GetNofData(ECbmDataType::kStsHit);
+  LOG(debug) << Form("Processing event with %d StsHit", nb_sts_hits);
+  for (int hit_evt_idx = 0; hit_evt_idx < nb_sts_hits; hit_evt_idx++) {
+    int sts_hit_idx = evt->GetIndex(ECbmDataType::kStsHit, hit_evt_idx);
+    CbmStsHit* hit  = (CbmStsHit*) sts_hit_array_->UncheckedAt(sts_hit_idx);
+    ProcessHit(hit);
+  }
+  int nb_of_glob_trk = evt->GetNofData(ECbmDataType::kGlobalTrack);
+  for (int evt_glob_trk_idx = 0; evt_glob_trk_idx < nb_of_glob_trk; evt_glob_trk_idx++) {
+    int glob_trk_idx         = evt->GetIndex(ECbmDataType::kGlobalTrack, evt_glob_trk_idx);
+    CbmGlobalTrack* glob_trk = (CbmGlobalTrack*) glb_trk_array_->UncheckedAt(glob_trk_idx);
+    ProcessGlobalTrack(glob_trk);
+  }
+  BuildResidual();
+}
+
+void CbmStsResolution::BuildResidual() {
+  int n_of_units = sts_hits_.size();
+
+  for (auto trk : glb_trks_) {
+    auto sts_trk_idx  = trk->GetStsTrackIndex();
+    if (sts_trk_idx == -1) continue;
+
+    CbmStsTrack* sts_track = (CbmStsTrack*) sts_trk_array_->UncheckedAt(sts_trk_idx);
+    if (((CbmStsTrack*) sts_trk_array_->UncheckedAt(sts_trk_idx))->GetNofStsHits() != 2) continue;
+
+    CbmStsHit* hit_i = (CbmStsHit*) sts_hit_array_->UncheckedAt(sts_track->GetStsHitIndex(0));
+    CbmStsHit* hit_j = (CbmStsHit*) sts_hit_array_->UncheckedAt(sts_track->GetStsHitIndex(1));
+
+    // Charge cut to Sts track hits
+    if (trk_hit_q_min_ > 0 && (cbm_sts_utils::GetHitCharge(hit_i, sts_clu_array_) < trk_hit_q_min_ || cbm_sts_utils::GetHitCharge(hit_j, sts_clu_array_) < trk_hit_q_min_)) continue;
+
+    int unit_i = CbmStsAddress::GetElementId(hit_i->GetAddress(), kStsUnit);
+    int unit_j = CbmStsAddress::GetElementId(hit_j->GetAddress(), kStsUnit);
+
+    // Checkk track crossed eneabled sensors
+    if (active_ref_sensors_.size()){
+      if (std::find(active_ref_sensors_.begin(), active_ref_sensors_.end(), hit_i->GetAddress()) == active_ref_sensors_.end()) continue;
+      if (std::find(active_ref_sensors_.begin(), active_ref_sensors_.end(), hit_j->GetAddress()) == active_ref_sensors_.end()) continue;
+    }
+
+    double x_i = hit_i->GetX();
+    double y_i = hit_i->GetY();
+    double z_i = hit_i->GetZ();
+
+    double x_j = hit_j->GetX();
+    double y_j = hit_j->GetY();
+    double z_j = hit_j->GetZ();
+
+    h2_[Form("Sts%d_ref_hits", unit_i)]->Fill(x_i, y_i);
+    h2_[Form("Sts%d_ref_hits", unit_j)]->Fill(x_j, y_j);
+
+    double x_0,y_0,t_x,t_y;
+    if (tracking_use_two_sts_) {
+      t_x = (x_i - x_j) / (z_i - z_j);
+      t_y = (y_i - y_j) / (z_i - z_j);
+      x_0 = x_i - t_x * z_i;
+      y_0 = y_i - t_y * z_i;
+    }else{
+      t_x = trk->GetParamFirst()->GetTx();
+      t_y = trk->GetParamFirst()->GetTy();
+      x_0 = x_i - t_x * z_i;
+      y_0 = y_i - t_y * z_i;
+    }
+
+    double d_trk_trg = TMath::Sqrt(x_0 * x_0 + y_0 * y_0);
+
+    if (d_max_trk_trg_ > 0 && d_max_trk_trg_ < d_trk_trg) continue;
+
+    for (int uut = 0; uut < n_of_units ; uut++){
+      if (uut == unit_i || uut == unit_j) continue;
+
+      CbmStsHit* closest_hit = nullptr;
+      double min_dist = 1e+6;
+      for (auto hit_dut : sts_hits_[uut]) {
+        double x_dut = hit_dut->GetX();
+        double y_dut = hit_dut->GetY();
+        double z_dut = hit_dut->GetZ();
+
+        double x_trk = x_i + t_x * (z_dut - z_i);
+        double y_trk = y_i + t_y * (z_dut - z_i);
+
+        double dx = x_trk - x_dut;
+        double dy = y_trk - y_dut;
+
+        h2_[Form("Sts0x%x_dx_vs_x:all", hit_dut->GetAddress())]->Fill(dx, x_dut);
+        h2_[Form("Sts0x%x_dx_vs_y:all", hit_dut->GetAddress())]->Fill(dx, y_dut);
+        h2_[Form("Sts0x%x_dy_vs_x:all", hit_dut->GetAddress())]->Fill(dy, x_dut);
+        h2_[Form("Sts0x%x_dy_vs_y:all", hit_dut->GetAddress())]->Fill(dy, y_dut);
+
+        h2_[Form("Sts%d_dx_vs_x:all", uut)]->Fill(dx, x_dut);
+        h2_[Form("Sts%d_dx_vs_y:all", uut)]->Fill(dx, y_dut);
+        h2_[Form("Sts%d_dy_vs_x:all", uut)]->Fill(dy, x_dut);
+        h2_[Form("Sts%d_dy_vs_y:all", uut)]->Fill(dy, y_dut);
+
+        if (min_dist > dx * dx + dy * dy) {
+          min_dist = dx * dx + dy * dy;
+          closest_hit = hit_dut;
+        }
+      } // hit_dut loop
+
+      if (closest_hit) {
+        double x_dut = closest_hit->GetX();
+        double y_dut = closest_hit->GetY();
+        double z_dut = closest_hit->GetZ();
+
+        double x_trk = x_i + t_x * (z_dut - z_i);
+        double y_trk = y_i + t_y * (z_dut - z_i);
+
+        double dx = x_trk - x_dut;
+        double dy = y_trk - y_dut;
+
+        h2_[Form("Sts0x%x_dx_vs_x:trk", closest_hit->GetAddress())]->Fill(dx, x_dut);
+        h2_[Form("Sts0x%x_dx_vs_y:trk", closest_hit->GetAddress())]->Fill(dx, y_dut);
+        h2_[Form("Sts0x%x_dy_vs_x:trk", closest_hit->GetAddress())]->Fill(dy, x_dut);
+        h2_[Form("Sts0x%x_dy_vs_y:trk", closest_hit->GetAddress())]->Fill(dy, y_dut);
+
+        h2_[Form("Sts%d_dx_vs_x:trk", uut)]->Fill(dx, x_dut);
+        h2_[Form("Sts%d_dx_vs_y:trk", uut)]->Fill(dx, y_dut);
+        h2_[Form("Sts%d_dy_vs_x:trk", uut)]->Fill(dy, x_dut);
+        h2_[Form("Sts%d_dy_vs_y:trk", uut)]->Fill(dy, y_dut);
+      }
+    } // uut loop
+  } // track loop
+
+  sts_hits_.clear();
+  glb_trks_.clear();
+}
+
+void CbmStsResolution::ProcessHit(CbmStsHit* hit)
+{
+  if (hit == nullptr) return;
+
+  if (analysis_cut_ != nullptr && !analysis_cut_->CheckStsHit(hit, sts_clu_array_)) return;
+
+  int32_t address = hit->GetAddress();
+  int32_t unit    = CbmStsAddress::GetElementId(address, kStsUnit);
+
+  sts_hits_[unit].push_back(hit);
+}
+
+void CbmStsResolution::EnableRefSensor(int32_t address) {
+  active_ref_sensors_.push_back(address);
+}
+
+void CbmStsResolution::ProcessGlobalTrack(CbmGlobalTrack* trk)
+{
+  if (trk == nullptr) return;
+
+  auto sts_trk_idx  = trk->GetStsTrackIndex();
+  auto rich_trk_idx = trk->GetRichRingIndex();
+  auto much_trk_idx = trk->GetMuchTrackIndex();
+  auto trd_trk_idx  = trk->GetTrdTrackIndex();
+  auto tof_trk_idx  = trk->GetTofTrackIndex();
+  float trk_p_val   = TMath::Prob(trk->GetChi2(), trk->GetNDF());
+
+  // Apply GlobalTracks cuts
+  int32_t mvd_trk_size = sts_trk_idx != -1 && sts_trk_array_ != nullptr
+                           ? ((CbmStsTrack*) sts_trk_array_->UncheckedAt(sts_trk_idx))->GetNofMvdHits()
+                           : 0;
+
+  int32_t sts_trk_size = sts_trk_idx != -1 && sts_trk_array_ != nullptr
+                           ? ((CbmStsTrack*) sts_trk_array_->UncheckedAt(sts_trk_idx))->GetNofStsHits()
+                           : 0;
+
+  int32_t rich_trk_size = rich_trk_idx != -1 && rch_trk_array_ != nullptr
+                            ? ((CbmTrack*) rch_trk_array_->UncheckedAt(rich_trk_idx))->GetNofHits()
+                            : 0;
+
+  int32_t much_trk_size = much_trk_idx != -1 && mch_trk_array_ != nullptr
+                            ? ((CbmTrack*) mch_trk_array_->UncheckedAt(much_trk_idx))->GetNofHits()
+                            : 0;
+
+  int32_t trd_trk_size = trd_trk_idx != -1 && trd_trk_array_ != nullptr
+                           ? ((CbmTrack*) trd_trk_array_->UncheckedAt(trd_trk_idx))->GetNofHits()
+                           : 0;
+
+  int32_t tof_trk_size = tof_trk_idx != -1 && tof_trk_array_ != nullptr
+                           ? ((CbmTrack*) tof_trk_array_->UncheckedAt(tof_trk_idx))->GetNofHits()
+                           : 0;
+
+  if (analysis_cut_ != nullptr
+      && (!analysis_cut_->Check(CbmCutId::kGlobalTrackMvdSize, mvd_trk_size)
+          || !analysis_cut_->Check(CbmCutId::kGlobalTrackStsSize, sts_trk_size)
+          || !analysis_cut_->Check(CbmCutId::kGlobalTrackRichSize, rich_trk_size)
+          || !analysis_cut_->Check(CbmCutId::kGlobalTrackMuchSize, much_trk_size)
+          || !analysis_cut_->Check(CbmCutId::kGlobalTrackTrdSize, trd_trk_size)
+          || !analysis_cut_->Check(CbmCutId::kGlobalTrackTofSize, tof_trk_size)
+          || !analysis_cut_->Check(CbmCutId::kGlobalTrackChi2, trk->GetChi2())
+          || !analysis_cut_->Check(CbmCutId::kGlobalTrackPval, trk_p_val))) {
+    return;
+  }
+
+  glb_trks_.push_back(trk);
+}
+
+void CbmStsResolution::Exec(Option_t*)
+{
+  switch (input_type) {
+    case kEventMode : {
+      if (cbm_evt_array_ == nullptr) {
+        LOG(error) << "Invalid branch for event-mode: Branch CbmEvent -> nullptr";
+        break;
+      }
+
+      uint32_t nb_events = cbm_evt_array_->GetEntriesFast();
+      LOG(info) << "Processing entry " << entry_ << "\tCbmEvent: " << nb_events;
+
+      for (uint32_t evt_idx = 0; evt_idx < nb_events; evt_idx++) {
+        CbmEvent* event = (CbmEvent*) cbm_evt_array_->UncheckedAt(evt_idx);
+        ProcessEvent(event);
+      }
+      break;
+    }
+    case kMCTimeMode : {
+      break;
+    }
+    case kMCEventMode :
+    case kTimeMode :
+    default : {
+        uint32_t n_of_hits = sts_hit_array_->GetEntriesFast();
+        uint32_t n_of_glb_trk = glb_trk_array_->GetEntriesFast();
+        LOG(info) << "Processing entry " << entry_ << "\tStsHit: " << n_of_hits << "\tGlobalTrack: " << n_of_glb_trk;
+
+        for (uint32_t hit_idx = 0; hit_idx < n_of_hits; hit_idx++) {
+          ProcessHit((CbmStsHit*) sts_hit_array_->UncheckedAt(hit_idx));
+        }
+
+        for (uint32_t glb_trk_idx = 0; glb_trk_idx < n_of_glb_trk; glb_trk_idx++) {
+          ProcessGlobalTrack((CbmGlobalTrack*) glb_trk_array_->UncheckedAt(glb_trk_idx));
+        }
+
+        BuildResidual();
+      break;
+    }
+  }
+  entry_++;
+}
+
+InitStatus CbmStsResolution::Init()
+{
+  LOG(debug) << "Init CbmStsResolution ...";
+
+  FairRootManager* ioman = FairRootManager::Instance();
+  if (ioman != nullptr) {
+
+  cbm_evt_array_ = (TClonesArray*) ioman->GetObject("CbmEvent");
+
+  glb_trk_array_ = (TClonesArray*) ioman->GetObject("GlobalTrack");
+  sts_trk_array_ = (TClonesArray*) ioman->GetObject("StsTrack");
+  rch_trk_array_ = (TClonesArray*) ioman->GetObject("RichTrack");
+  mch_trk_array_ = (TClonesArray*) ioman->GetObject("MuchTrack");
+  trd_trk_array_ = (TClonesArray*) ioman->GetObject("TrdTrack");
+  tof_trk_array_ = (TClonesArray*) ioman->GetObject("TofTrack");
+
+  sts_hit_array_ = (TClonesArray*) ioman->GetObject("StsHit");
+  sts_clu_array_ = (TClonesArray*) ioman->GetObject("StsCluster");
+
+  }
+
+  LoadSetup();
+
+  BookHistograms();
+
+  return kSUCCESS;
+}
+
+void CbmStsResolution::Finish()
+{
+  SaveToFile();
+}
diff --git a/analysis/detectors/sts/CbmStsResolution.h b/analysis/detectors/sts/CbmStsResolution.h
new file mode 100644
index 0000000000..9b4aac5e18
--- /dev/null
+++ b/analysis/detectors/sts/CbmStsResolution.h
@@ -0,0 +1,145 @@
+/** \file CbmStsResolution.h
+ * \brief Definition of the CbmStsResolution class.
+ *
+ * Copyright (C) 2022 Facility for Antiproton and Ion Research in Europe, Darmstadt
+ * SPDX-License-Identifier: GPL-3.0-only
+ * Authors: Dario Ramirez [committer]
+ */
+
+#ifndef CBMSTSRESOLUTION_H
+#define CBMSTSRESOLUTION_H
+
+#include "CbmEvent.h"
+#include "CbmStsAnaBase.h"
+#include "CbmStsCluster.h"
+#include "CbmGlobalTrack.h"
+#include "CbmStsHit.h"
+#include "CbmStsUtils.h"
+
+#include <FairTask.h>
+
+#include <TClonesArray.h>
+
+#include <cstring>
+#include <map>
+#include <unordered_map>
+#include <unordered_set>
+
+
+/**
+ * \class CbmStsResolution
+ * \brief Task for estimating the spatial resolution of the STS detector using track-hit residuals.
+ *
+ * The `CbmStsResolution` class is responsible for calculating the residuals between the hits
+ * in the Silicon Tracking System (STS) and the corresponding reconstructed tracks. These
+ * residuals are used to estimate the spatial resolution of the STS detector.
+ *
+ * ## Output:
+ * The class produces a set of 2D histograms showing the distribution of residuals
+ * as a function of the reconstructed hit coordinates. These histograms provide insight into
+ * the detector's resolution performance across different spatial regions.
+ *
+ * If functon EnableRefSensor() is called during analysis configuration, the residuals will be only produced
+ * when the track hit the selected sensors. This is especially useful to restrict bad performing sensors.
+ *
+ * ## Track Extrapolation Modes:
+ * The residuals can be computed using two approaches:
+ *
+ * 1. **Local STS-based extrapolation:** Uses only two STS hits to form a straight-line
+ *    extrapolation to calculate the expected hit position.
+ *
+ * 2. **Global track-based extrapolation:** Utilizes the full set of global track parameters
+ *    obtained from the reconstruction process to extrapolate the expected position at the hit.
+ *
+ * ## The residual are calculated in two modes:alignas
+ *  - `":all"`: All hits are used for the residual calculation. (large combinatoric)
+ *  - `":trk"`: Only the hits clsosest to the extrapolation point is used (selection bias, less combinatoric).
+ *
+ * ## Track selection:
+ *  It can be configured using the `CbmCutMap` class.
+ *  Additionally, the user can set a minimum charge threshold for the STS hits attached to the track
+ *  and set a cut to the maximun value for the impact parameter.
+ *
+ * ## Future Extension:
+ * The class is planned to be extended with functionality to support **track refitting using
+ * only STS hits**, which would allow for improved and more localized resolution studies
+ * decoupled from the global tracking performance.
+ *
+ * Inherits from:
+ * - `FairTask`: Base class for FairRoot tasks, enabling integration with the FAIR framework.
+ * - `CbmStsAnaBase`: Provides STS-specific analysis utilities and interfaces.
+ *
+ */
+class CbmStsResolution : public FairTask, public CbmStsAnaBase {
+ public:
+  /** \brief Constructor */
+  CbmStsResolution();
+
+  /** \brief Constructor */
+  CbmStsResolution(double);
+
+  /** \brief Destructor */
+  virtual ~CbmStsResolution();
+
+  InitStatus Init();
+  void Exec(Option_t*);
+  void Finish();
+
+  void SetInputType(InputType type) {
+    input_type = type;
+  };
+
+  void EnableRefSensor(int32_t);
+
+  void SetMinTrkHitQ(double q) {
+    trk_hit_q_min_ = q;
+  }
+
+  void TrackUseTwoSts() {
+    tracking_use_two_sts_ = true;
+  }
+
+ private:
+  double d_max_trk_trg_{-1};
+  double trk_hit_q_min_{-1};
+
+  std::vector<CbmGlobalTrack*> glb_trks_;
+  std::map<int32_t, std::vector<CbmStsHit*>> sts_hits_;
+
+  InputType input_type = InputType::kEventMode;
+
+  bool tracking_use_two_sts_{false};
+
+  std::vector<int32_t> active_ref_sensors_;
+
+  TClonesArray* cbm_evt_array_{nullptr};
+
+  TClonesArray* glb_trk_array_{nullptr};
+  TClonesArray* sts_trk_array_{nullptr};
+  TClonesArray* rch_trk_array_{nullptr};
+  TClonesArray* mch_trk_array_{nullptr};
+  TClonesArray* trd_trk_array_{nullptr};
+  TClonesArray* tof_trk_array_{nullptr};
+
+  TClonesArray* sts_hit_array_{nullptr};
+  TClonesArray* sts_clu_array_{nullptr};
+
+  void BookHistograms();
+
+  /** \brief Process an Cbm events
+   * It filters event based on the provided CbmCutMap
+  */
+  void ProcessEvent(CbmEvent*);
+
+  /** \brief Process an STS hit
+   * It filters hits based on the provided CbmCutMap
+  */
+  void ProcessHit(CbmStsHit*);
+
+  void ProcessGlobalTrack(CbmGlobalTrack* trk);
+
+  void BuildResidual();
+
+  ClassDef(CbmStsResolution, 1);
+};
+#endif
diff --git a/macro/sts/sts_resolution.C b/macro/sts/sts_resolution.C
new file mode 100755
index 0000000000..5941f39bc1
--- /dev/null
+++ b/macro/sts/sts_resolution.C
@@ -0,0 +1,103 @@
+void sts_resolution(
+    int n_of_ts = -1,
+    std::string geo_setup_tag = "mcbm_beam_2024_05_08_nickel",
+    std::string raw_file = "",
+    std::string rec_file = "",
+    std::string geo_file = "",
+    std::string out_file = "cbm_sts_correlation.root",
+    bool bAli = true
+){
+    // -----   Timer   --------------------------------------------------------
+    TStopwatch timer;
+    timer.Start();
+
+    // --- Logger settings ----------------------------------------------------
+    TString logLevel     = "DEBUG";
+    TString logVerbosity = "veryhigh";
+            logLevel     = "INFO";
+            logVerbosity = "low";
+
+    FairLogger::GetLogger()->SetLogScreenLevel(logLevel.Data());
+    FairLogger::GetLogger()->SetLogVerbosityLevel(logVerbosity.Data());
+    // ------------------------------------------------------------------------
+
+
+    // -----   Environment   --------------------------------------------------
+    std::string srcDir = gSystem->Getenv("VMCWORKDIR");  // top source directory
+    // ------------------------------------------------------------------------
+
+    std::unique_ptr<CbmStsAnalysis> run = std::make_unique<CbmStsAnalysis>();
+
+    FairFileSource* inputSource = new FairFileSource(rec_file.c_str());
+    inputSource->AddFriend(raw_file.c_str());
+
+    FairRootFileSink* outputSink = new FairRootFileSink(out_file.c_str());
+
+
+    if (bAli) {
+        TString alignmentMatrixFileName = srcDir + "/parameters/mcbm/AlignmentMatrices_" + geo_setup_tag + ".root";
+        if (alignmentMatrixFileName.Length() != 0) {
+            std::map<std::string, TGeoHMatrix>* matrices{nullptr};
+            TFile* misalignmentMatrixRootfile = new TFile(alignmentMatrixFileName, "READ");
+            if (misalignmentMatrixRootfile->IsOpen()) {
+                gDirectory->GetObject("MisalignMatrices", matrices);
+                misalignmentMatrixRootfile->Close();
+            }
+            else {
+                LOG(error) << "Could not open file " << alignmentMatrixFileName << "\n Exiting";
+                exit(1);
+            }
+
+            if (matrices) {
+                run->AddAlignmentMatrices(*matrices);
+            }
+            else {
+                LOG(error) << "Alignment required but no matrices found."
+                << "\n Exiting";
+                exit(1);
+            }
+        }
+    }
+
+    run->SetGeomFile(geo_file.c_str());
+    run->SetSource(inputSource);
+    run->SetSink(outputSink);
+
+
+    // ------------------------------------------------------------------------
+    // Configure filters
+    // ------------------------------------------------------------------------
+    CbmCutMap ana_filter;
+    ana_filter.AddCbmCut(CbmCutId::kEventNofGlobalTrack)->SetMin(1);
+    ana_filter.AddCbmCut(CbmCutId::kGlobalTrackStsSize)->SetMin(2);
+    ana_filter.AddCbmCut(CbmCutId::kGlobalTrackTrdSize)->SetMin(1);
+    ana_filter.AddCbmCut(CbmCutId::kGlobalTrackTofSize)->SetMin(1);
+    ana_filter.AddCbmCut(CbmCutId::kGlobalTrackPval)->SetMax(0.5);
+
+    // ------------------------------------------------------------------------
+    // Configure analysis
+    // ------------------------------------------------------------------------
+    CbmStsResolution* sts_resolution = new CbmStsResolution(0.5);
+    sts_resolution->SetCutMap(&ana_filter);
+
+    sts_resolution->EnableRefSensor(0x10000002); // U0 L0 U0
+    // sts_resolution->EnableRefSensor(0x10008422); // U1 L1 U0
+    sts_resolution->EnableRefSensor(0x10018422); // U1 L1 U1
+
+    sts_resolution->SetMinTrkHitQ(10000);
+
+    run->AddTask(sts_resolution);
+
+    run->Init();
+    run->Run(0,n_of_ts);
+
+    ana_filter.Print();
+    // ------------------------------------------------------------------------
+    timer.Stop();
+    Double_t rtime = timer.RealTime();
+    Double_t ctime = timer.CpuTime();
+    cout << endl << endl;
+    cout << "Macro finished successfully." << endl;
+    cout << "Real time " << rtime << " s, CPU time " << ctime << " s" << endl;
+    cout << endl;
+}
\ No newline at end of file
-- 
GitLab


From 77c0ef43aecbac18e293ddcee4cc5fe8dfa8ad8c Mon Sep 17 00:00:00 2001
From: Dario Ramirez <d.ramirez@gsi.de>
Date: Tue, 15 Apr 2025 14:00:36 +0200
Subject: [PATCH 12/18] CbmEventVertexDca

QA analysis for DCA vertex finder
---
 analysis/detectors/sts/CMakeLists.txt        |   2 +-
 analysis/detectors/sts/CbmEventVertexDca.cxx | 359 +++++++++++++++++++
 analysis/detectors/sts/CbmEventVertexDca.h   |  88 +++++
 analysis/detectors/sts/CbmStsAnaLinkDef.h    |   1 +
 macro/sts/cbm_vertex.C                       | 102 ++++++
 5 files changed, 551 insertions(+), 1 deletion(-)
 create mode 100644 analysis/detectors/sts/CbmEventVertexDca.cxx
 create mode 100644 analysis/detectors/sts/CbmEventVertexDca.h
 create mode 100755 macro/sts/cbm_vertex.C

diff --git a/analysis/detectors/sts/CMakeLists.txt b/analysis/detectors/sts/CMakeLists.txt
index c1c438d165..7dd38aee66 100644
--- a/analysis/detectors/sts/CMakeLists.txt
+++ b/analysis/detectors/sts/CMakeLists.txt
@@ -21,9 +21,9 @@ set(SRCS
   CbmDcaVertexFinder.cxx
   CbmStsEfficiency.cxx
   CbmStsResolution.cxx
+  CbmEventVertexDca.cxx
   )
 
-
 set(LIBRARY_NAME CbmStsAna)
 set(LINKDEF ${LIBRARY_NAME}LinkDef.h)
 set(PUBLIC_DEPENDENCIES
diff --git a/analysis/detectors/sts/CbmEventVertexDca.cxx b/analysis/detectors/sts/CbmEventVertexDca.cxx
new file mode 100644
index 0000000000..d93613d10a
--- /dev/null
+++ b/analysis/detectors/sts/CbmEventVertexDca.cxx
@@ -0,0 +1,359 @@
+/* Copyright (C) 2022 Facility for Antiproton and Ion Research in Europe, Darmstadt
+   SPDX-License-Identifier: GPL-3.0-only
+   Authors: Dario Ramirez [committer] */
+
+
+#include "CbmEventVertexDca.h"
+
+#include "CbmStsAddress.h"
+
+#include <gsl/gsl_blas.h>
+#include <gsl/gsl_linalg.h>
+
+CbmEventVertexDca::CbmEventVertexDca(){}
+
+CbmEventVertexDca::~CbmEventVertexDca() {}
+
+void CbmEventVertexDca::BookHistograms()
+{
+  std::string h_name;
+
+  // ---- Binning configuration ----
+  // 3D Vertex
+  double vertex_dx    = 0.01;
+  double vertex_dy    = 0.01;
+  double vertex_dz    = 0.01;
+  double vertex_x_min = -35 + 0.5 * vertex_dx;
+  double vertex_x_max = +35 + 0.5 * vertex_dx;
+  double vertex_y_min = -35 + 0.5 * vertex_dy;
+  double vertex_y_max = +35 + 0.5 * vertex_dy;
+  double vertex_z_min = -65 + 0.5 * vertex_dz;
+  double vertex_z_max = +65 + 0.5 * vertex_dz;
+
+  auto x_vtx_binning = cbm_sts_utils::HBinning{uint32_t((vertex_x_max - vertex_x_min) / vertex_dx), vertex_x_min, vertex_x_max};
+  auto y_vtx_binning = cbm_sts_utils::HBinning{uint32_t((vertex_y_max - vertex_y_min) / vertex_dy), vertex_y_min, vertex_y_max};
+  auto z_vtx_binning = cbm_sts_utils::HBinning{uint32_t((vertex_z_max - vertex_z_min) / vertex_dz), vertex_z_min, vertex_z_max};
+
+  // DCA
+  double dca_dx = .001; // 10 um
+  double dca_min = -2.5 - 0.5 * dca_dx;
+  double dca_max = +2.5 + 0.5 * dca_dx;
+  auto r_dca_binning = cbm_sts_utils::HBinning{uint32_t((dca_max - dca_min) / dca_dx), dca_min, dca_max};
+  // ---- --------------------- ----
+
+  // ---- 3D Vertex 2D projections ----
+  h_name      = "vertex_y_vs_x";
+  h2_[h_name] = std::make_unique<TH2D>(h_name.c_str(), h_name.c_str(),
+    x_vtx_binning.n_of_bins, x_vtx_binning.x_min, x_vtx_binning.x_max,
+    y_vtx_binning.n_of_bins, y_vtx_binning.x_min, y_vtx_binning.x_max);
+  h2_[h_name]->GetXaxis()->SetTitle("Vertex_{X} [cm]");
+  h2_[h_name]->GetYaxis()->SetTitle("Vertex_{Y} [cm]");
+
+  h_name      = "vertex_x_vs_z";
+  h2_[h_name] = std::make_unique<TH2D>(h_name.c_str(), h_name.c_str(),
+    z_vtx_binning.n_of_bins, z_vtx_binning.x_min, z_vtx_binning.x_max,
+    x_vtx_binning.n_of_bins, x_vtx_binning.x_min, x_vtx_binning.x_max);
+  h2_[h_name]->GetXaxis()->SetTitle("Vertex_{Z} [cm]");
+  h2_[h_name]->GetYaxis()->SetTitle("Vertex_{X} [cm]");
+
+  h_name      = "vertex_y_vs_z";
+  h2_[h_name] = std::make_unique<TH2D>(h_name.c_str(), h_name.c_str(),
+    z_vtx_binning.n_of_bins, z_vtx_binning.x_min, z_vtx_binning.x_max,
+    y_vtx_binning.n_of_bins, y_vtx_binning.x_min, y_vtx_binning.x_max);
+  h2_[h_name]->GetXaxis()->SetTitle("Vertex_{Z} [cm]");
+  h2_[h_name]->GetYaxis()->SetTitle("Vertex_{Y} [cm]");
+  // ---- ------------------------ ----
+
+  // ---- PCA 2D projections ----
+  if (vertex_finder_){
+    h_name      = "pca_y_vs_x";
+    h2_s[h_name] = std::make_shared<TH2D>(h_name.c_str(), h_name.c_str(),
+      x_vtx_binning.n_of_bins, x_vtx_binning.x_min, x_vtx_binning.x_max,
+      y_vtx_binning.n_of_bins, y_vtx_binning.x_min, y_vtx_binning.x_max);
+    h2_s[h_name]->GetXaxis()->SetTitle("Vertex_{X} [cm]");
+    h2_s[h_name]->GetYaxis()->SetTitle("Vertex_{Y} [cm]");
+
+    h_name      = "pca_x_vs_z";
+    h2_s[h_name] = std::make_shared<TH2D>(h_name.c_str(), h_name.c_str(),
+      z_vtx_binning.n_of_bins, z_vtx_binning.x_min, z_vtx_binning.x_max,
+      x_vtx_binning.n_of_bins, x_vtx_binning.x_min, x_vtx_binning.x_max);
+    h2_s[h_name]->GetXaxis()->SetTitle("Vertex_{Z} [cm]");
+    h2_s[h_name]->GetYaxis()->SetTitle("Vertex_{X} [cm]");
+
+    h_name      = "pca_y_vs_z";
+    h2_s[h_name] = std::make_shared<TH2D>(h_name.c_str(), h_name.c_str(),
+      z_vtx_binning.n_of_bins, z_vtx_binning.x_min, z_vtx_binning.x_max,
+      y_vtx_binning.n_of_bins, y_vtx_binning.x_min, y_vtx_binning.x_max);
+    h2_s[h_name]->GetXaxis()->SetTitle("Vertex_{Z} [cm]");
+    h2_s[h_name]->GetYaxis()->SetTitle("Vertex_{Y} [cm]");
+
+    std::cout << " - DcaVertexFinder - Enabling QA" << std::endl;
+    vertex_finder_->EnableQa({h2_s["pca_y_vs_x"], h2_s["pca_x_vs_z"], h2_s["pca_y_vs_z"]});
+  }
+  // ---- ------------------------ ----
+
+  // ----        DCA         ----
+  for (const char* di : {"x", "y", "z"}){
+    h_name      = Form("dca_d%s_vs_x", di);
+    h2_[h_name] = std::make_unique<TH2D>(h_name.c_str(), h_name.c_str(),
+      r_dca_binning.n_of_bins, r_dca_binning.x_min, r_dca_binning.x_max,
+      x_vtx_binning.n_of_bins, x_vtx_binning.x_min, x_vtx_binning.x_max);
+    h2_[h_name]->GetYaxis()->SetTitle("X [cm]");
+    h2_[h_name]->GetXaxis()->SetTitle(Form("DCA_{%s} [cm]", di));
+
+    h_name      = Form("dca_d%s_vs_y", di);
+    h2_[h_name] = std::make_unique<TH2D>(h_name.c_str(), h_name.c_str(),
+      r_dca_binning.n_of_bins, r_dca_binning.x_min, r_dca_binning.x_max,
+      y_vtx_binning.n_of_bins, y_vtx_binning.x_min, y_vtx_binning.x_max);
+    h2_[h_name]->GetYaxis()->SetTitle("Y [cm]");
+    h2_[h_name]->GetXaxis()->SetTitle(Form("DCA_{%s} [cm]", di));
+
+    h_name      = Form("dca_d%s_vs_z", di);
+    h2_[h_name] = std::make_unique<TH2D>(h_name.c_str(), h_name.c_str(),
+      r_dca_binning.n_of_bins, r_dca_binning.x_min, r_dca_binning.x_max,
+      z_vtx_binning.n_of_bins, z_vtx_binning.x_min, z_vtx_binning.x_max);
+    h2_[h_name]->GetYaxis()->SetTitle(Form("Z [cm]"));
+    h2_[h_name]->GetXaxis()->SetTitle(Form("DCA_{%s} [cm]", di));
+  }
+  // ---- ------------------ ----
+
+  // ----     Residual with MC      ----
+  if (input_has_mc) {
+    LOG(info) << " - INFO - Enabling MC comparison";
+    for (const char* di : {"x", "y", "z"}){
+      h_name      = Form("res_%s_vs_x", di);
+      h2_[h_name] = std::make_unique<TH2D>(h_name.c_str(), h_name.c_str(),
+        r_dca_binning.n_of_bins, r_dca_binning.x_min, r_dca_binning.x_max,
+        x_vtx_binning.n_of_bins, x_vtx_binning.x_min, x_vtx_binning.x_max);
+      h2_[h_name]->GetYaxis()->SetTitle("X [cm]");
+      h2_[h_name]->GetXaxis()->SetTitle(Form("%s_{rec} - %s_{MC} [cm]", di, di));
+
+      h_name      = Form("res_%s_vs_y", di);
+      h2_[h_name] = std::make_unique<TH2D>(h_name.c_str(), h_name.c_str(),
+        r_dca_binning.n_of_bins, r_dca_binning.x_min, r_dca_binning.x_max,
+        y_vtx_binning.n_of_bins, y_vtx_binning.x_min, y_vtx_binning.x_max);
+      h2_[h_name]->GetYaxis()->SetTitle("Y [cm]");
+      h2_[h_name]->GetXaxis()->SetTitle(Form("%s_{rec} - %s_{MC} [cm]", di, di));
+
+      h_name      = Form("res_%s_vs_z", di);
+      h2_[h_name] = std::make_unique<TH2D>(h_name.c_str(), h_name.c_str(),
+        r_dca_binning.n_of_bins, r_dca_binning.x_min, r_dca_binning.x_max,
+        z_vtx_binning.n_of_bins, z_vtx_binning.x_min, z_vtx_binning.x_max);
+      h2_[h_name]->GetYaxis()->SetTitle(Form("Z [cm]"));
+      h2_[h_name]->GetXaxis()->SetTitle(Form("%s_{rec} - %s_{MC} [cm]", di, di));
+    }
+  }
+  // ---- ------------------------- ----
+
+  // Track multiplicity
+  h_name      = "ca_track_multiplicity_all";
+  h1_[h_name] = std::make_unique<TH1D>(h_name.c_str(), h_name.c_str(), 50, 0, 50);
+  h1_[h_name]->GetXaxis()->SetTitle("N_{CATrack}");
+  h1_[h_name]->GetYaxis()->SetTitle("Entries");
+
+  h_name      = "ca_track_multiplicity_sel";
+  h1_[h_name] = std::make_unique<TH1D>(h_name.c_str(), h_name.c_str(), 50, 0, 50);
+  h1_[h_name]->GetXaxis()->SetTitle("N_{CATrack}");
+  h1_[h_name]->GetYaxis()->SetTitle("Entries");
+}
+
+
+void CbmEventVertexDca::FinishTask() { SaveToFile(); }
+
+void CbmEventVertexDca::CheckVertex()
+{
+  h1_["ca_track_multiplicity_sel"]->Fill(glb_trks_.size());
+
+  vertex_finder_->SetTracks(glb_trks_);
+  const std::optional<CbmVertex> vertex = vertex_finder_->FindVertex();
+
+  if (vertex.has_value()){
+
+    TVector3 vtx(vertex->GetX(), vertex->GetY(), vertex->GetZ());
+
+    h2_["vertex_y_vs_x"]->Fill(vtx[0], vtx[1]);
+    h2_["vertex_x_vs_z"]->Fill(vtx[2], vtx[0]);
+    h2_["vertex_y_vs_z"]->Fill(vtx[2], vtx[1]);
+
+    for (const CbmGlobalTrack* trk : glb_trks_) {
+      float trk_tx       = trk->GetParamFirst()->GetTx();
+      float trk_ty       = trk->GetParamFirst()->GetTy();
+      float trk_x0       = trk->GetParamFirst()->GetX();
+      float trk_y0       = trk->GetParamFirst()->GetY();
+      float trk_z0       = trk->GetParamFirst()->GetZ();
+
+      TVector3 p(trk_x0, trk_y0, trk_z0);
+      TVector3 e(trk_tx, trk_ty, 1);
+      TVector3 trk_to_vtx    = ((vtx - p).Cross(e)) * (1. / e.Mag());
+
+      h2_["dca_dx_vs_x"]->Fill(trk_to_vtx.Px(), vtx.Px());
+      h2_["dca_dx_vs_y"]->Fill(trk_to_vtx.Px(), vtx.Py());
+      h2_["dca_dx_vs_z"]->Fill(trk_to_vtx.Px(), vtx.Pz());
+
+      h2_["dca_dy_vs_x"]->Fill(trk_to_vtx.Py(), vtx.Px());
+      h2_["dca_dy_vs_y"]->Fill(trk_to_vtx.Py(), vtx.Py());
+      h2_["dca_dy_vs_z"]->Fill(trk_to_vtx.Py(), vtx.Pz());
+
+      h2_["dca_dz_vs_x"]->Fill(trk_to_vtx.Pz(), vtx.Px());
+      h2_["dca_dz_vs_y"]->Fill(trk_to_vtx.Pz(), vtx.Py());
+      h2_["dca_dz_vs_z"]->Fill(trk_to_vtx.Pz(), vtx.Pz());
+    }
+
+    if (input_has_mc) {
+      TVector3 mc_vertex;
+      int n_of_mc_trks = mc_trk_array_->GetEntriesFast();
+      for (int mc_trk_idx = 0; mc_trk_idx < n_of_mc_trks; mc_trk_idx++) {
+        auto mc_trk = (CbmMCTrack*) mc_trk_array_->UncheckedAt(mc_trk_idx);
+        if (mc_trk->GetMotherId() == -1) {
+          mc_trk->GetStartVertex(mc_vertex);
+          break;
+        }
+      }
+
+      h2_["res_x_vs_x"]->Fill(vtx[0] - mc_vertex[0], vtx[0]);
+      h2_["res_x_vs_y"]->Fill(vtx[0] - mc_vertex[0], vtx[1]);
+      h2_["res_x_vs_z"]->Fill(vtx[0] - mc_vertex[0], vtx[2]);
+
+      h2_["res_y_vs_x"]->Fill(vtx[1] - mc_vertex[1], vtx[0]);
+      h2_["res_y_vs_y"]->Fill(vtx[1] - mc_vertex[1], vtx[1]);
+      h2_["res_y_vs_z"]->Fill(vtx[1] - mc_vertex[1], vtx[2]);
+
+      h2_["res_z_vs_x"]->Fill(vtx[2] - mc_vertex[2], vtx[0]);
+      h2_["res_z_vs_y"]->Fill(vtx[2] - mc_vertex[2], vtx[1]);
+      h2_["res_z_vs_z"]->Fill(vtx[2] - mc_vertex[2], vtx[2]);
+    }
+  }
+
+  // Clear track containers
+  glb_trks_.clear();
+}
+
+void CbmEventVertexDca::ProcessEvent(CbmEvent* evt)
+{
+  int nb_of_glob_trk = evt->GetNofData(ECbmDataType::kGlobalTrack);
+  h1_["ca_track_multiplicity_all"]->Fill(nb_of_glob_trk);
+
+  if (analysis_cut_ != nullptr && !analysis_cut_->CheckEvent(evt)) return;
+
+
+  for (int evt_glob_trk_idx = 0; evt_glob_trk_idx < nb_of_glob_trk; evt_glob_trk_idx++) {
+    int glob_trk_idx         = evt->GetIndex(ECbmDataType::kGlobalTrack, evt_glob_trk_idx);
+    ProcessGlobalTrack((CbmGlobalTrack*) glb_trk_array_->UncheckedAt(glob_trk_idx));
+  }
+
+  CheckVertex();
+}
+
+void CbmEventVertexDca::ProcessGlobalTrack(CbmGlobalTrack* trk)
+{
+  auto sts_trk_idx  = trk->GetStsTrackIndex();
+  auto rich_trk_idx = trk->GetRichRingIndex();
+  auto much_trk_idx = trk->GetMuchTrackIndex();
+  auto trd_trk_idx  = trk->GetTrdTrackIndex();
+  auto tof_trk_idx  = trk->GetTofTrackIndex();
+  float trk_p_val   = TMath::Prob(trk->GetChi2(), trk->GetNDF());
+
+  // Apply GlobalTracks cuts
+  int32_t mvd_trk_size = sts_trk_idx != -1 && sts_trk_array_ != nullptr
+                           ? ((CbmStsTrack*) sts_trk_array_->UncheckedAt(sts_trk_idx))->GetNofMvdHits()
+                           : 0;
+
+  int32_t sts_trk_size = sts_trk_idx != -1 && sts_trk_array_ != nullptr
+                           ? ((CbmStsTrack*) sts_trk_array_->UncheckedAt(sts_trk_idx))->GetNofStsHits()
+                           : 0;
+
+  int32_t rich_trk_size = rich_trk_idx != -1 && rch_trk_array_ != nullptr
+                            ? ((CbmTrack*) rch_trk_array_->UncheckedAt(rich_trk_idx))->GetNofHits()
+                            : 0;
+
+  int32_t much_trk_size = much_trk_idx != -1 && mch_trk_array_ != nullptr
+                            ? ((CbmTrack*) mch_trk_array_->UncheckedAt(much_trk_idx))->GetNofHits()
+                            : 0;
+
+  int32_t trd_trk_size = trd_trk_idx != -1 && trd_trk_array_ != nullptr
+                           ? ((CbmTrack*) trd_trk_array_->UncheckedAt(trd_trk_idx))->GetNofHits()
+                           : 0;
+
+  int32_t tof_trk_size = tof_trk_idx != -1 && tof_trk_array_ != nullptr
+                           ? ((CbmTrack*) tof_trk_array_->UncheckedAt(tof_trk_idx))->GetNofHits()
+                           : 0;
+
+  if (analysis_cut_ != nullptr
+      && (!analysis_cut_->Check(CbmCutId::kGlobalTrackMvdSize, mvd_trk_size)
+          || !analysis_cut_->Check(CbmCutId::kGlobalTrackStsSize, sts_trk_size)
+          || !analysis_cut_->Check(CbmCutId::kGlobalTrackRichSize, rich_trk_size)
+          || !analysis_cut_->Check(CbmCutId::kGlobalTrackMuchSize, much_trk_size)
+          || !analysis_cut_->Check(CbmCutId::kGlobalTrackTrdSize, trd_trk_size)
+          || !analysis_cut_->Check(CbmCutId::kGlobalTrackTofSize, tof_trk_size)
+          || !analysis_cut_->Check(CbmCutId::kGlobalTrackChi2, trk->GetChi2())
+          || !analysis_cut_->Check(CbmCutId::kGlobalTrackPval, trk_p_val))) {
+    return;
+  }
+
+  glb_trks_.push_back(trk);
+}
+
+void CbmEventVertexDca::Exec(Option_t*)
+{
+  LOG(info) << "Running CbmEventVertexDca;\t" << "Entry: " << entry_;
+
+  // Check if CbmEvent
+  if (cbm_evt_array_ != nullptr) {
+    uint32_t nb_events = cbm_evt_array_->GetEntriesFast();
+    LOG(info) << Form(" ... number of CbmEvent: %u\n", nb_events);
+    for (uint32_t evt_idx = 0; evt_idx < nb_events; evt_idx++) {
+      ProcessEvent((CbmEvent*) cbm_evt_array_->UncheckedAt(evt_idx));
+    }
+
+  } else {
+
+    LOG(debug) << " ... running time-like*** Using all tracks in TS - risk of high combinatorial";
+
+    uint32_t nb_of_glob_trk = glb_trk_array_->GetEntriesFast();
+    LOG(info) << Form("Number of GlobalTracks: %u\n", nb_of_glob_trk);
+    for (uint32_t glob_trk_idx = 0; glob_trk_idx < nb_of_glob_trk; glob_trk_idx++) {
+      CbmGlobalTrack* glob_trk = (CbmGlobalTrack*) glb_trk_array_->UncheckedAt(glob_trk_idx);
+      ProcessGlobalTrack(glob_trk);
+    }
+
+    CheckVertex();
+  }
+  entry_++;
+}
+
+InitStatus CbmEventVertexDca::Init()
+{
+  LOG(debug) << "Init CbmEventVertexDca ...";
+
+  FairRootManager* ioman = FairRootManager::Instance();
+  if (ioman != nullptr) {
+    cbm_evt_array_ = (TClonesArray*) ioman->GetObject("CbmEvent");
+
+    glb_trk_array_ = (TClonesArray*) ioman->GetObject("GlobalTrack");
+
+    sts_trk_array_ = (TClonesArray*) ioman->GetObject("StsTrack");
+    rch_trk_array_ = (TClonesArray*) ioman->GetObject("RichTrack");
+    mch_trk_array_ = (TClonesArray*) ioman->GetObject("MuchTrack");
+    trd_trk_array_ = (TClonesArray*) ioman->GetObject("TrdTrack");
+    tof_trk_array_ = (TClonesArray*) ioman->GetObject("TofTrack");
+
+    sts_hit_array_ = (TClonesArray*) ioman->GetObject("StsHit");
+
+    sts_clu_array_ = (TClonesArray*) ioman->GetObject("StsCluster");
+
+    mc_trk_array_ = (TClonesArray*) ioman->GetObject("MCTrack");
+    input_has_mc = mc_trk_array_ != nullptr;
+  }
+
+  LoadSetup();
+
+  BookHistograms();
+
+  glb_trks_.reserve(100);
+
+  return kSUCCESS;
+}
+
+void CbmEventVertexDca::SetVertexFinder(std::shared_ptr<CbmDcaVertexFinder> vtx_finder){
+  vertex_finder_ = vtx_finder;
+}
\ No newline at end of file
diff --git a/analysis/detectors/sts/CbmEventVertexDca.h b/analysis/detectors/sts/CbmEventVertexDca.h
new file mode 100644
index 0000000000..dd369bb711
--- /dev/null
+++ b/analysis/detectors/sts/CbmEventVertexDca.h
@@ -0,0 +1,88 @@
+/** \file CbmEventVertexDca.h
+ * \brief Definition of the CbmEventVertexDca class.
+ *
+ * Copyright (C) 2022 Facility for Antiproton and Ion Research in Europe, Darmstadt
+ * SPDX-License-Identifier: GPL-3.0-only
+ * Authors: Dario Ramirez [committer]
+ */
+
+#ifndef CBMEVENTVERTEXDCA_H
+#define CBMEVENTVERTEXDCA_H
+
+#include "CbmMCTrack.h"
+#include "CbmEvent.h"
+#include "CbmGlobalTrack.h"
+#include "CbmStsAnaBase.h"
+#include "CbmStsCluster.h"
+#include "CbmStsHit.h"
+#include "CbmStsTrack.h"
+#include "CbmStsUtils.h"
+#include "CbmTrack.h"
+
+#include <FairTask.h>
+
+#include <TClonesArray.h>
+#include <TVector3.h>
+
+#include <cstring>
+#include <map>
+#include <unordered_map>
+#include <unordered_set>
+
+#include "CbmDcaVertexFinder.h"
+
+/** \class CbmEventVertexDca
+ * \brief Task for Event based vertex reconstruction.
+ *
+ * The current approach is to average the PCA of multiple pair of tracks.
+ * Therfore the vertex found, is a primary vertex approximation.
+ */
+class CbmEventVertexDca : public FairTask, public CbmStsAnaBase {
+ public:
+  /** \brief Default constructor */
+  CbmEventVertexDca();
+
+  /** \brief Destructor */
+  virtual ~CbmEventVertexDca();
+
+  InitStatus Init();
+  void Exec(Option_t*);
+  void FinishTask();
+
+  void SetVertexFinder(std::shared_ptr<CbmDcaVertexFinder>);
+
+ private:
+  std::shared_ptr<CbmDcaVertexFinder> vertex_finder_;
+
+  bool input_has_mc{false};
+
+  std::vector<CbmGlobalTrack*> glb_trks_;
+
+  TClonesArray* mc_trk_array_{nullptr};
+  TClonesArray* cbm_evt_array_{nullptr};
+  TClonesArray* glb_trk_array_{nullptr};
+  TClonesArray* sts_trk_array_{nullptr};
+  TClonesArray* rch_trk_array_{nullptr};
+  TClonesArray* mch_trk_array_{nullptr};
+  TClonesArray* trd_trk_array_{nullptr};
+  TClonesArray* tof_trk_array_{nullptr};
+  TClonesArray* sts_hit_array_{nullptr};
+  TClonesArray* sts_clu_array_{nullptr};
+
+  void BookHistograms();
+
+  void CheckVertex();
+
+  /** \brief Process an Cbm events
+   * It filters event based on the provided CbmCutMap
+  */
+  void ProcessEvent(CbmEvent*);
+
+  /** \brief Process an Global tracks
+   * It filters the tracks based on the provided CbmCutMap
+  */
+  void ProcessGlobalTrack(CbmGlobalTrack*);
+
+  ClassDef(CbmEventVertexDca, 1);
+};
+#endif
diff --git a/analysis/detectors/sts/CbmStsAnaLinkDef.h b/analysis/detectors/sts/CbmStsAnaLinkDef.h
index e08f26d068..8f7a841e29 100644
--- a/analysis/detectors/sts/CbmStsAnaLinkDef.h
+++ b/analysis/detectors/sts/CbmStsAnaLinkDef.h
@@ -23,6 +23,7 @@
 #pragma link C++ class CbmDcaVertexFinder + ;
 #pragma link C++ class CbmStsEfficiency + ;
 #pragma link C++ class CbmStsResolution + ;
+#pragma link C++ class CbmEventVertexDca + ;
 
 
 #endif /* __CINT__ */
diff --git a/macro/sts/cbm_vertex.C b/macro/sts/cbm_vertex.C
new file mode 100755
index 0000000000..e0e7a54afb
--- /dev/null
+++ b/macro/sts/cbm_vertex.C
@@ -0,0 +1,102 @@
+
+void cbm_vertex(
+    int n_of_ts = -1,
+    double dca_cut = 0.5, // cm
+    std::string geo_setup_tag = "mcbm_beam_2024_05_08_nickel",
+    std::string raw_file = "",
+    std::string rec_file = "",
+    std::string geo_file = "",
+    std::string out_file = "cbm_vertex_dca.root",
+    bool bAli = true
+){
+    // -----   Timer   --------------------------------------------------------
+    TStopwatch timer;
+    timer.Start();
+
+    // --- Logger settings ----------------------------------------------------
+    TString logLevel     = "DEBUG";
+    TString logVerbosity = "veryhigh";
+            logLevel     = "INFO";
+            logVerbosity = "low";
+
+    FairLogger::GetLogger()->SetLogScreenLevel(logLevel.Data());
+    FairLogger::GetLogger()->SetLogVerbosityLevel(logVerbosity.Data());
+    // ------------------------------------------------------------------------
+
+
+    // -----   Environment   --------------------------------------------------
+    std::string srcDir = gSystem->Getenv("VMCWORKDIR");  // top source directory
+    // ------------------------------------------------------------------------
+
+    std::unique_ptr<CbmStsAnalysis> run = std::make_unique<CbmStsAnalysis>();
+
+    FairFileSource* inputSource = new FairFileSource(rec_file.c_str());
+    inputSource->AddFriend(raw_file.c_str());
+
+    FairRootFileSink* outputSink = new FairRootFileSink(out_file.c_str());
+
+
+    if (bAli) {
+        TString alignmentMatrixFileName = srcDir + "/parameters/mcbm/AlignmentMatrices_" + geo_setup_tag + ".root";
+        if (alignmentMatrixFileName.Length() != 0) {
+            std::map<std::string, TGeoHMatrix>* matrices{nullptr};
+            TFile* misalignmentMatrixRootfile = new TFile(alignmentMatrixFileName, "READ");
+            if (misalignmentMatrixRootfile->IsOpen()) {
+                gDirectory->GetObject("MisalignMatrices", matrices);
+                misalignmentMatrixRootfile->Close();
+            }
+            else {
+                LOG(error) << "Could not open file " << alignmentMatrixFileName << "\n Exiting";
+                exit(1);
+            }
+
+            if (matrices) {
+                run->AddAlignmentMatrices(*matrices);
+            }
+            else {
+                LOG(error) << "Alignment required but no matrices found."
+                << "\n Exiting";
+                exit(1);
+            }
+        }
+    }
+
+    run->SetGeomFile(geo_file.c_str());
+    run->SetSource(inputSource);
+    run->SetSink(outputSink);
+
+
+    // ------------------------------------------------------------------------
+    // Configure Analysis filters
+    // ------------------------------------------------------------------------
+    CbmCutMap ana_filter;
+    ana_filter.AddCbmCut(CbmCutId::kGlobalTrackStsSize)->SetMin(2);
+    ana_filter.AddCbmCut(CbmCutId::kGlobalTrackTrdSize)->SetMin(1);
+    ana_filter.AddCbmCut(CbmCutId::kGlobalTrackTofSize)->SetMin(1);
+    // ana_filter.AddCbmCut(CbmCutId::kGlobalTrackPval)->SetMax(0.005);
+
+    // ------------------------------------------------------------------------
+    // Configure Vertex Finder
+    // ------------------------------------------------------------------------
+    std::shared_ptr<CbmDcaVertexFinder> vertex_finder = std::make_shared<CbmDcaVertexFinder>(dca_cut);
+
+    // ------------------------------------------------------------------------
+    // Configure Task
+    // ------------------------------------------------------------------------
+    CbmEventVertexDca* cbm_vtx_cda = new CbmEventVertexDca();
+    cbm_vtx_cda->SetVertexFinder(vertex_finder);
+    cbm_vtx_cda->SetCutMap(&ana_filter);
+    run->AddTask(cbm_vtx_cda);
+
+    run->Init();
+    run->Run(0,n_of_ts);
+
+    // ------------------------------------------------------------------------
+    timer.Stop();
+    Double_t rtime = timer.RealTime();
+    Double_t ctime = timer.CpuTime();
+    cout << endl << endl;
+    cout << "Macro finished successfully." << endl;
+    cout << "Real time " << rtime << " s, CPU time " << ctime << " s" << endl;
+    cout << endl;
+}
-- 
GitLab


From 2a6c98f15efb6b05a3ec785bf6dc58cee4379eb5 Mon Sep 17 00:00:00 2001
From: Dario Ramirez <d.ramirez@gsi.de>
Date: Tue, 15 Apr 2025 14:52:55 +0200
Subject: [PATCH 13/18] Apply clang-format

---
 analysis/detectors/sts/CMakeLists.txt         |   3 +
 analysis/detectors/sts/CbmCut.h               |   6 +-
 analysis/detectors/sts/CbmCutId.cxx           | 105 +-------
 analysis/detectors/sts/CbmCutId.h             | 111 +++++++-
 analysis/detectors/sts/CbmCutMap.cxx          |   6 +-
 analysis/detectors/sts/CbmCutMap.h            |  22 +-
 analysis/detectors/sts/CbmDcaVertexFinder.cxx | 149 ++++++-----
 analysis/detectors/sts/CbmDcaVertexFinder.h   |  82 +++---
 analysis/detectors/sts/CbmEventVertexDca.cxx  | 155 ++++++-----
 analysis/detectors/sts/CbmEventVertexDca.h    |  22 +-
 analysis/detectors/sts/CbmSpillCheck.cxx      |  20 +-
 analysis/detectors/sts/CbmSpillCheck.h        |  13 +-
 analysis/detectors/sts/CbmStsAnaBase.cxx      |  23 +-
 analysis/detectors/sts/CbmStsAnaBase.h        |  57 ++--
 analysis/detectors/sts/CbmStsAnalysis.cxx     |   6 +-
 analysis/detectors/sts/CbmStsAnalysis.h       |   6 +-
 analysis/detectors/sts/CbmStsChannelQA.cxx    |  65 +++--
 analysis/detectors/sts/CbmStsChannelQA.h      |  19 +-
 analysis/detectors/sts/CbmStsCorrelation.cxx  |   5 +-
 analysis/detectors/sts/CbmStsCorrelation.h    |  17 +-
 analysis/detectors/sts/CbmStsEfficiency.cxx   | 203 +++++++--------
 analysis/detectors/sts/CbmStsEfficiency.h     |  20 +-
 analysis/detectors/sts/CbmStsHitAna.cxx       |  46 ++--
 analysis/detectors/sts/CbmStsHitAna.h         |  19 +-
 analysis/detectors/sts/CbmStsRecoBeamSpot.cxx |  11 +-
 analysis/detectors/sts/CbmStsRecoBeamSpot.h   |  29 +--
 analysis/detectors/sts/CbmStsResolution.cxx   | 143 +++++-----
 analysis/detectors/sts/CbmStsResolution.h     |  32 +--
 analysis/detectors/sts/CbmStsTimeCal.cxx      |  54 ++--
 analysis/detectors/sts/CbmStsTimeCal.h        |  21 +-
 analysis/detectors/sts/CbmStsUtils.cxx        |  17 +-
 analysis/detectors/sts/CbmStsUtils.h          |  19 +-
 core/detectors/sts/CbmStsParSetModule.cxx     |  17 +-
 core/detectors/sts/CbmStsParSetModule.h       |   6 +-
 macro/sts/cbm_vertex.C                        | 203 +++++++--------
 macro/sts/sts_beam_spot.C                     | 246 +++++++++---------
 macro/sts/sts_correlation.C                   | 181 +++++++------
 macro/sts/sts_efficiency.C                    | 215 ++++++++-------
 macro/sts/sts_hit_ana.C                       | 195 +++++++-------
 macro/sts/sts_resolution.C                    | 201 +++++++-------
 macro/sts/sts_time.C                          | 112 ++++----
 41 files changed, 1366 insertions(+), 1516 deletions(-)

diff --git a/analysis/detectors/sts/CMakeLists.txt b/analysis/detectors/sts/CMakeLists.txt
index 7dd38aee66..11179a1211 100644
--- a/analysis/detectors/sts/CMakeLists.txt
+++ b/analysis/detectors/sts/CMakeLists.txt
@@ -39,4 +39,7 @@ set(PRIVATE_DEPENDENCIES
   ROOT::MathCore
   )
 
+install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/CbmCut.h
+  DESTINATION include)
+
 generate_cbm_library()
diff --git a/analysis/detectors/sts/CbmCut.h b/analysis/detectors/sts/CbmCut.h
index 87140fa5e8..d432882b6c 100644
--- a/analysis/detectors/sts/CbmCut.h
+++ b/analysis/detectors/sts/CbmCut.h
@@ -1,5 +1,4 @@
-
-/* Copyright (C) 2022 Facility for Antiproton and Ion Research in Europe, Darmstadt
+/* Copyright (C) 2023 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
    SPDX-License-Identifier: GPL-3.0-only
    Authors: Dario Ramirez [committer] */
 
@@ -10,7 +9,6 @@
 
 #include <type_traits>
 
-
 template<typename T>
 class CbmCut {
  public:
@@ -44,7 +42,7 @@ class CbmCut {
    * #### TRUE ####--------------------------------#### TRUE ####
    *              @MAX                         @MIN
    */
-  bool Check(T a)
+  bool Check(T a) const
   {
     bool check_min_status = min_state_ ? a >= min_ : true;
     bool check_max_status = max_state_ ? a <= max_ : true;
diff --git a/analysis/detectors/sts/CbmCutId.cxx b/analysis/detectors/sts/CbmCutId.cxx
index 1f85eb8199..e39fb3eacb 100644
--- a/analysis/detectors/sts/CbmCutId.cxx
+++ b/analysis/detectors/sts/CbmCutId.cxx
@@ -1,110 +1,9 @@
-/* Copyright (C) 2022 Facility for Antiproton and Ion Research in Europe, Darmstadt
+/* Copyright (C) 2023 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
    SPDX-License-Identifier: GPL-3.0-only
    Authors: Dario Ramirez [committer] */
 
 #include "CbmCutId.h"
 
-static std::unordered_map<CbmCutId, std::string> cut_id_to_str_map = {
-  {CbmCutId::kBmonDigiChannel, "kBmonDigiChannel"},
-  {CbmCutId::kBmonDigiSide, "kBmonDigiSide"},
-  {CbmCutId::kMvdDigiChannel, "kMvdDigiChannel"},
-  {CbmCutId::kMvdDigiCharge, "kMvdDigiCharge"},
-  {CbmCutId::kMvdDigiTime, "kMvdDigiTime"},
-  {CbmCutId::kStsDigiChannel, "kStsDigiChannel"},
-  {CbmCutId::kStsDigiCharge, "kStsDigiCharge"},
-  {CbmCutId::kStsDigiTime, "kStsDigiTime"},
-  {CbmCutId::kRichDigiChannel, "kRichDigiChannel"},
-  {CbmCutId::kRichDigiCharge, "kRichDigiCharge"},
-  {CbmCutId::kRichDigiTime, "kRichDigiTime"},
-  {CbmCutId::kMuchigiChannel, "kMuchigiChannel"},
-  {CbmCutId::kMuchigiCharge, "kMuchigiCharge"},
-  {CbmCutId::kMuchigiTime, "kMuchigiTime"},
-  {CbmCutId::kTrdDigiChannel, "kTrdDigiChannel"},
-  {CbmCutId::kTrdDigiCharge, "kTrdDigiCharge"},
-  {CbmCutId::kTrdDigiTime, "kTrdDigiTime"},
-  {CbmCutId::kTofDigiChannel, "kTofDigiChannel"},
-  {CbmCutId::kTofDigiCharge, "kTofDigiCharge"},
-  {CbmCutId::kTofDigiTime, "kTofDigiTime"},
-  {CbmCutId::kStsClusterAddress, "kStsClusterAddress"},
-  {CbmCutId::kStsClusterTime, "kStsClusterTime"},
-  {CbmCutId::kStsClusterCharge, "kStsClusterCharge"},
-  {CbmCutId::kStsClusterSize, "kStsClusterSize"},
-  {CbmCutId::kStsClusterPosition, "kStsClusterPosition"},
-  {CbmCutId::kMvdHitAddress, "kMvdHitAddress"},
-  {CbmCutId::kMvdHitTime, "kMvdHitTime"},
-  {CbmCutId::kMvdHitCharge, "kMvdHitCharge"},
-  {CbmCutId::kMvdHitX, "kMvdHitX"},
-  {CbmCutId::kMvdHitY, "kMvdHitY"},
-  {CbmCutId::kMvdHitZ, "kMvdHitZ"},
-  {CbmCutId::kStsHitAddress, "kStsHitAddress"},
-  {CbmCutId::kStsHitTime, "kStsHitTime"},
-  {CbmCutId::kStsHitCharge, "kStsHitCharge"},
-  {CbmCutId::kStsHitQasym, "kStsHitQasym"},
-  {CbmCutId::kStsHitX, "kStsHitX"},
-  {CbmCutId::kStsHitY, "kStsHitY"},
-  {CbmCutId::kStsHitZ, "kStsHitZ"},
-  {CbmCutId::kRichHitAddress, "kRichHitAddress"},
-  {CbmCutId::kRichHitTime, "kRichHitTime"},
-  {CbmCutId::kRichHitCharge, "kRichHitCharge"},
-  {CbmCutId::kRichHitX, "kRichHitX"},
-  {CbmCutId::kRichHitY, "kRichHitY"},
-  {CbmCutId::kRichHitZ, "kRichHitZ"},
-  {CbmCutId::kMuchHitAddress, "kMuchHitAddress"},
-  {CbmCutId::kMuchHitTime, "kMuchHitTime"},
-  {CbmCutId::kMuchHitCharge, "kMuchHitCharge"},
-  {CbmCutId::kMuchHitX, "kMuchHitX"},
-  {CbmCutId::kMuchHitY, "kMuchHitY"},
-  {CbmCutId::kMuchHitZ, "kMuchHitZ"},
-  {CbmCutId::kTrdHitAddress, "kTrdHitAddress"},
-  {CbmCutId::kTrdHitTime, "kTrdHitTime"},
-  {CbmCutId::kTrdHitCharge, "kTrdHitCharge"},
-  {CbmCutId::kTrdHitX, "kTrdHitX"},
-  {CbmCutId::kTrdHitY, "kTrdHitY"},
-  {CbmCutId::kTrdHitZ, "kTrdHitZ"},
-  {CbmCutId::kTofHitAddress, "kTofHitAddress"},
-  {CbmCutId::kTofHitTime, "kTofHitTime"},
-  {CbmCutId::kTofHitCharge, "kTofHitCharge"},
-  {CbmCutId::kTofHitX, "kTofHitX"},
-  {CbmCutId::kTofHitY, "kTofHitY"},
-  {CbmCutId::kTofHitZ, "kTofHitZ"},
-  {CbmCutId::kEventNofMvdHit, "kEventNofMvdHit"},
-  {CbmCutId::kEventNofStsHit, "kEventNofStsHit"},
-  {CbmCutId::kEventNofRichHit, "kEventNofRichHit"},
-  {CbmCutId::kEventNofRichRing, "kEventNofRichRing"},
-  {CbmCutId::kEventNofMuchPixelHit, "kEventNofMuchPixelHit"},
-  {CbmCutId::kEventNofMuchStrawHit, "kEventNofMuchStrawHit"},
-  {CbmCutId::kEventNofTrdHit, "kEventNofTrdHit"},
-  {CbmCutId::kEventNofTofHit, "kEventNofTofHit"},
-  {CbmCutId::kEventNofGlobalTrack, "kEventNofGlobalTrack"},
-  {CbmCutId::kMvdTrackChi2, "kMvdTrackChi2"},
-  {CbmCutId::kMvdTrackSize, "kMvdTrackSize"},
-  {CbmCutId::kStsTrackChi2, "kStsTrackChi2"},
-  {CbmCutId::kStsTrackSize, "kStsTrackSize"},
-  {CbmCutId::kRichTrackChi2, "kRichTrackChi2"},
-  {CbmCutId::kRichTrackSize, "kRichTrackSize"},
-  {CbmCutId::kMuchTrackChi2, "kMuchTrackChi2"},
-  {CbmCutId::kMuchTrackSize, "kMuchTrackSize"},
-  {CbmCutId::kTrdTrackChi2, "kTrdTrackChi2"},
-  {CbmCutId::kTrdTrackSize, "kTrdTrackSize"},
-  {CbmCutId::kTofTrackChi2, "kTofTrackChi2"},
-  {CbmCutId::kTofTrackSize, "kTofTrackSize"},
-  {CbmCutId::kGlobalTrackChi2, "kGlobalTrackChi2"},
-  {CbmCutId::kGlobalTrackPval, "kGlobalTrackPval"},
-  {CbmCutId::kGlobalTrackSize, "kGlobalTrackSize"},
-  {CbmCutId::kGlobalTrackLength, "kGlobalTrackLength"},
-  {CbmCutId::kGlobalTrackMvdChi2, "kGlobalTrackMvdChi2"},
-  {CbmCutId::kGlobalTrackMvdSize, "kGlobalTrackMvdSize"},
-  {CbmCutId::kGlobalTrackStsChi2, "kGlobalTrackStsChi2"},
-  {CbmCutId::kGlobalTrackStsSize, "kGlobalTrackStsSize"},
-  {CbmCutId::kGlobalTrackRichChi2, "kGlobalTrackRichChi2"},
-  {CbmCutId::kGlobalTrackRichSize, "kGlobalTrackRichSize"},
-  {CbmCutId::kGlobalTrackMuchChi2, "kGlobalTrackMuchChi2"},
-  {CbmCutId::kGlobalTrackMuchSize, "kGlobalTrackMuchSize"},
-  {CbmCutId::kGlobalTrackTrdChi2, "kGlobalTrackTrdChi2"},
-  {CbmCutId::kGlobalTrackTrdSize, "kGlobalTrackTrdSize"},
-  {CbmCutId::kGlobalTrackTofChi2, "kGlobalTrackTofChi2"},
-  {CbmCutId::kGlobalTrackTofSize, "kGlobalTrackTofSize"}};
-
 std::string ToString(CbmCutId id)
 {
   auto result = cut_id_to_str_map.find(id);
@@ -118,4 +17,4 @@ std::ostream& operator<<(std::ostream& strm, const CbmCutId& cut_id)
 {
   strm << ToString(cut_id);
   return strm;
-}
\ No newline at end of file
+}
diff --git a/analysis/detectors/sts/CbmCutId.h b/analysis/detectors/sts/CbmCutId.h
index ece390f7bb..747b982f8a 100644
--- a/analysis/detectors/sts/CbmCutId.h
+++ b/analysis/detectors/sts/CbmCutId.h
@@ -1,10 +1,6 @@
-/** \file CbmCutId.h
- * \brief Definition of the CbmCutId enum class and related functions.
- *
- * Copyright (C) 2022 Facility for Antiproton and Ion Research in Europe, Darmstadt
- * SPDX-License-Identifier: GPL-3.0-only
- * Authors: Dario Ramirez [committer]
- */
+/* Copyright (C) 2023 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
+   SPDX-License-Identifier: GPL-3.0-only
+   Authors: Dario Ramirez [committer] */
 
 #ifndef CBMCUTID_H
 #define CBMCUTID_H
@@ -151,6 +147,107 @@ enum class CbmCutId : ushort
   kGlobalTrackTofSize
 };
 
+static const std::unordered_map<CbmCutId, std::string> cut_id_to_str_map = {
+  {CbmCutId::kBmonDigiChannel, "kBmonDigiChannel"},
+  {CbmCutId::kBmonDigiSide, "kBmonDigiSide"},
+  {CbmCutId::kMvdDigiChannel, "kMvdDigiChannel"},
+  {CbmCutId::kMvdDigiCharge, "kMvdDigiCharge"},
+  {CbmCutId::kMvdDigiTime, "kMvdDigiTime"},
+  {CbmCutId::kStsDigiChannel, "kStsDigiChannel"},
+  {CbmCutId::kStsDigiCharge, "kStsDigiCharge"},
+  {CbmCutId::kStsDigiTime, "kStsDigiTime"},
+  {CbmCutId::kRichDigiChannel, "kRichDigiChannel"},
+  {CbmCutId::kRichDigiCharge, "kRichDigiCharge"},
+  {CbmCutId::kRichDigiTime, "kRichDigiTime"},
+  {CbmCutId::kMuchigiChannel, "kMuchigiChannel"},
+  {CbmCutId::kMuchigiCharge, "kMuchigiCharge"},
+  {CbmCutId::kMuchigiTime, "kMuchigiTime"},
+  {CbmCutId::kTrdDigiChannel, "kTrdDigiChannel"},
+  {CbmCutId::kTrdDigiCharge, "kTrdDigiCharge"},
+  {CbmCutId::kTrdDigiTime, "kTrdDigiTime"},
+  {CbmCutId::kTofDigiChannel, "kTofDigiChannel"},
+  {CbmCutId::kTofDigiCharge, "kTofDigiCharge"},
+  {CbmCutId::kTofDigiTime, "kTofDigiTime"},
+  {CbmCutId::kStsClusterAddress, "kStsClusterAddress"},
+  {CbmCutId::kStsClusterTime, "kStsClusterTime"},
+  {CbmCutId::kStsClusterCharge, "kStsClusterCharge"},
+  {CbmCutId::kStsClusterSize, "kStsClusterSize"},
+  {CbmCutId::kStsClusterPosition, "kStsClusterPosition"},
+  {CbmCutId::kMvdHitAddress, "kMvdHitAddress"},
+  {CbmCutId::kMvdHitTime, "kMvdHitTime"},
+  {CbmCutId::kMvdHitCharge, "kMvdHitCharge"},
+  {CbmCutId::kMvdHitX, "kMvdHitX"},
+  {CbmCutId::kMvdHitY, "kMvdHitY"},
+  {CbmCutId::kMvdHitZ, "kMvdHitZ"},
+  {CbmCutId::kStsHitAddress, "kStsHitAddress"},
+  {CbmCutId::kStsHitTime, "kStsHitTime"},
+  {CbmCutId::kStsHitCharge, "kStsHitCharge"},
+  {CbmCutId::kStsHitQasym, "kStsHitQasym"},
+  {CbmCutId::kStsHitX, "kStsHitX"},
+  {CbmCutId::kStsHitY, "kStsHitY"},
+  {CbmCutId::kStsHitZ, "kStsHitZ"},
+  {CbmCutId::kRichHitAddress, "kRichHitAddress"},
+  {CbmCutId::kRichHitTime, "kRichHitTime"},
+  {CbmCutId::kRichHitCharge, "kRichHitCharge"},
+  {CbmCutId::kRichHitX, "kRichHitX"},
+  {CbmCutId::kRichHitY, "kRichHitY"},
+  {CbmCutId::kRichHitZ, "kRichHitZ"},
+  {CbmCutId::kMuchHitAddress, "kMuchHitAddress"},
+  {CbmCutId::kMuchHitTime, "kMuchHitTime"},
+  {CbmCutId::kMuchHitCharge, "kMuchHitCharge"},
+  {CbmCutId::kMuchHitX, "kMuchHitX"},
+  {CbmCutId::kMuchHitY, "kMuchHitY"},
+  {CbmCutId::kMuchHitZ, "kMuchHitZ"},
+  {CbmCutId::kTrdHitAddress, "kTrdHitAddress"},
+  {CbmCutId::kTrdHitTime, "kTrdHitTime"},
+  {CbmCutId::kTrdHitCharge, "kTrdHitCharge"},
+  {CbmCutId::kTrdHitX, "kTrdHitX"},
+  {CbmCutId::kTrdHitY, "kTrdHitY"},
+  {CbmCutId::kTrdHitZ, "kTrdHitZ"},
+  {CbmCutId::kTofHitAddress, "kTofHitAddress"},
+  {CbmCutId::kTofHitTime, "kTofHitTime"},
+  {CbmCutId::kTofHitCharge, "kTofHitCharge"},
+  {CbmCutId::kTofHitX, "kTofHitX"},
+  {CbmCutId::kTofHitY, "kTofHitY"},
+  {CbmCutId::kTofHitZ, "kTofHitZ"},
+  {CbmCutId::kEventNofMvdHit, "kEventNofMvdHit"},
+  {CbmCutId::kEventNofStsHit, "kEventNofStsHit"},
+  {CbmCutId::kEventNofRichHit, "kEventNofRichHit"},
+  {CbmCutId::kEventNofRichRing, "kEventNofRichRing"},
+  {CbmCutId::kEventNofMuchPixelHit, "kEventNofMuchPixelHit"},
+  {CbmCutId::kEventNofMuchStrawHit, "kEventNofMuchStrawHit"},
+  {CbmCutId::kEventNofTrdHit, "kEventNofTrdHit"},
+  {CbmCutId::kEventNofTofHit, "kEventNofTofHit"},
+  {CbmCutId::kEventNofGlobalTrack, "kEventNofGlobalTrack"},
+  {CbmCutId::kMvdTrackChi2, "kMvdTrackChi2"},
+  {CbmCutId::kMvdTrackSize, "kMvdTrackSize"},
+  {CbmCutId::kStsTrackChi2, "kStsTrackChi2"},
+  {CbmCutId::kStsTrackSize, "kStsTrackSize"},
+  {CbmCutId::kRichTrackChi2, "kRichTrackChi2"},
+  {CbmCutId::kRichTrackSize, "kRichTrackSize"},
+  {CbmCutId::kMuchTrackChi2, "kMuchTrackChi2"},
+  {CbmCutId::kMuchTrackSize, "kMuchTrackSize"},
+  {CbmCutId::kTrdTrackChi2, "kTrdTrackChi2"},
+  {CbmCutId::kTrdTrackSize, "kTrdTrackSize"},
+  {CbmCutId::kTofTrackChi2, "kTofTrackChi2"},
+  {CbmCutId::kTofTrackSize, "kTofTrackSize"},
+  {CbmCutId::kGlobalTrackChi2, "kGlobalTrackChi2"},
+  {CbmCutId::kGlobalTrackPval, "kGlobalTrackPval"},
+  {CbmCutId::kGlobalTrackSize, "kGlobalTrackSize"},
+  {CbmCutId::kGlobalTrackLength, "kGlobalTrackLength"},
+  {CbmCutId::kGlobalTrackMvdChi2, "kGlobalTrackMvdChi2"},
+  {CbmCutId::kGlobalTrackMvdSize, "kGlobalTrackMvdSize"},
+  {CbmCutId::kGlobalTrackStsChi2, "kGlobalTrackStsChi2"},
+  {CbmCutId::kGlobalTrackStsSize, "kGlobalTrackStsSize"},
+  {CbmCutId::kGlobalTrackRichChi2, "kGlobalTrackRichChi2"},
+  {CbmCutId::kGlobalTrackRichSize, "kGlobalTrackRichSize"},
+  {CbmCutId::kGlobalTrackMuchChi2, "kGlobalTrackMuchChi2"},
+  {CbmCutId::kGlobalTrackMuchSize, "kGlobalTrackMuchSize"},
+  {CbmCutId::kGlobalTrackTrdChi2, "kGlobalTrackTrdChi2"},
+  {CbmCutId::kGlobalTrackTrdSize, "kGlobalTrackTrdSize"},
+  {CbmCutId::kGlobalTrackTofChi2, "kGlobalTrackTofChi2"},
+  {CbmCutId::kGlobalTrackTofSize, "kGlobalTrackTofSize"}};
+
 /** \brief Convert CbmCutId to a string representation.
  *
  * \param cutId The CbmCutId to convert.
diff --git a/analysis/detectors/sts/CbmCutMap.cxx b/analysis/detectors/sts/CbmCutMap.cxx
index 4527424618..950df44a87 100644
--- a/analysis/detectors/sts/CbmCutMap.cxx
+++ b/analysis/detectors/sts/CbmCutMap.cxx
@@ -1,13 +1,9 @@
-
-/* Copyright (C) 2022 Facility for Antiproton and Ion Research in Europe, Darmstadt
+/* Copyright (C) 2023 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
    SPDX-License-Identifier: GPL-3.0-only
    Authors: Dario Ramirez [committer] */
 
 #include "CbmCutMap.h"
 
-CbmCutMap::CbmCutMap() {}
-CbmCutMap::~CbmCutMap() {}
-
 CbmCut<float>* CbmCutMap::AddCbmCut(CbmCutId id) { return &cbm_cuts_[id]; }
 
 bool CbmCutMap::Check(CbmCutId id, double value)
diff --git a/analysis/detectors/sts/CbmCutMap.h b/analysis/detectors/sts/CbmCutMap.h
index b7b31d38d9..6031f6b8dc 100644
--- a/analysis/detectors/sts/CbmCutMap.h
+++ b/analysis/detectors/sts/CbmCutMap.h
@@ -1,11 +1,6 @@
-/** @file CbmCutMap.h
- *  @brief CbmCutMap class header file.
- *
- *  @copyright (C) 2022 Facility for Antiproton and Ion Research in Europe, Darmstadt
- *  SPDX-License-Identifier: GPL-3.0-only
- *  Authors: Dario Ramirez [committer]
- */
-
+/* Copyright (C) 2023 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
+   SPDX-License-Identifier: GPL-3.0-only
+   Authors: Dario Ramirez [committer] */
 
 #ifndef CBMCUTMAP_H
 #define CBMCUTMAP_H
@@ -23,15 +18,8 @@
  */
 class CbmCutMap {
  public:
-  /**
-   * @brief Constructor for CbmCutMap.
-   */
-  CbmCutMap();
-
-  /**
-   * @brief Destructor for CbmCutMap.
-   */
-  virtual ~CbmCutMap();
+  CbmCutMap()  = default;
+  ~CbmCutMap() = default;
 
   /**
    * @brief Get the map of cuts.
diff --git a/analysis/detectors/sts/CbmDcaVertexFinder.cxx b/analysis/detectors/sts/CbmDcaVertexFinder.cxx
index 9226ca0f75..9e9f28b7c8 100644
--- a/analysis/detectors/sts/CbmDcaVertexFinder.cxx
+++ b/analysis/detectors/sts/CbmDcaVertexFinder.cxx
@@ -1,118 +1,127 @@
-#include <Logger.h>
+/* Copyright (C) 2023 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
+   SPDX-License-Identifier: GPL-3.0-only
+   Authors: Dario Ramirez [committer] */
 
 #include "CbmDcaVertexFinder.h"
 
-#include "CbmVertex.h"
 #include "CbmGlobalTrack.h"
+#include "CbmVertex.h"
+
+#include <Logger.h>
 
-/** \brief Default constructor
- * \param tracks
-*/
 CbmDcaVertexFinder::CbmDcaVertexFinder()
-    : max_dca_(0.1), tracks_(std::vector<CbmGlobalTrack*>()), n_of_pairs_(0), qa_(std::nullopt)
+  : max_dca_(0.1)
+  , tracks_(std::vector<CbmGlobalTrack*>())
+  , n_of_pairs_(0)
+  , qa_(std::nullopt)
 {
-    LOG(debug) << "Creating CbmDcaVertexFinder ...";
-    cov_matrix_.ResizeTo(3,3);
+  LOG(debug) << "Creating CbmDcaVertexFinder ...";
+  cov_matrix_.ResizeTo(3, 3);
 }
 
 CbmDcaVertexFinder::CbmDcaVertexFinder(double max_dca)
-    : max_dca_(max_dca), tracks_(std::vector<CbmGlobalTrack*>()), n_of_pairs_(0), qa_(std::nullopt)
+  : max_dca_(max_dca)
+  , tracks_(std::vector<CbmGlobalTrack*>())
+  , n_of_pairs_(0)
+  , qa_(std::nullopt)
 {
-    LOG(debug) << "Creating CbmDcaVertexFinder ...";
-    cov_matrix_.ResizeTo(3,3);
+  LOG(debug) << "Creating CbmDcaVertexFinder ...";
+  cov_matrix_.ResizeTo(3, 3);
 }
 
 /** \brief Default constructor
  * \param tracks
 */
 CbmDcaVertexFinder::CbmDcaVertexFinder(const std::vector<CbmGlobalTrack*> tracks)
-    : max_dca_(0.1), tracks_(tracks), n_of_pairs_(0), qa_(std::nullopt)
+  : max_dca_(0.1)
+  , tracks_(tracks)
+  , n_of_pairs_(0)
+  , qa_(std::nullopt)
 {
-    LOG(debug) << "Creating CbmDcaVertexFinder ...";
-    cov_matrix_.ResizeTo(3,3);
+  LOG(debug) << "Creating CbmDcaVertexFinder ...";
+  cov_matrix_.ResizeTo(3, 3);
 }
 
 /** \brief Default constructor
  * \param tracks
 */
 CbmDcaVertexFinder::CbmDcaVertexFinder(const std::vector<CbmGlobalTrack*> tracks, const double max_dca)
-    : max_dca_(max_dca), tracks_(tracks), n_of_pairs_(0), qa_(std::nullopt)
+  : max_dca_(max_dca)
+  , tracks_(tracks)
+  , n_of_pairs_(0)
+  , qa_(std::nullopt)
 {
-    LOG(debug) << "Creating CbmDcaVertexFinder ...";
-    cov_matrix_.ResizeTo(3,3);
+  LOG(debug) << "Creating CbmDcaVertexFinder ...";
+  cov_matrix_.ResizeTo(3, 3);
 }
 
-CbmDcaVertexFinder::~CbmDcaVertexFinder() {}
-
-void CbmDcaVertexFinder::SetTracks(const std::vector<CbmGlobalTrack*> tracks) {
-    tracks_.clear();
-    tracks_ = tracks;
+void CbmDcaVertexFinder::SetTracks(const std::vector<CbmGlobalTrack*> tracks)
+{
+  tracks_.clear();
+  tracks_ = tracks;
 }
 
 /** \brief find vertex using input tracks
  */
-std::optional<CbmVertex> CbmDcaVertexFinder::FindVertex() {
-    // Reset the number of track pair used
-    n_of_pairs_ = 0;
-    int n_of_trk = tracks_.size();
-    LOG(debug) << "- PCA - Find event vertex using CbmGlobalTracks: " << n_of_trk;
-    TVector3 vtx;
-    for (int trk_i_idx = 0; trk_i_idx < n_of_trk - 1; trk_i_idx++) {
-        for (int trk_j_idx = trk_i_idx + 1; trk_j_idx < n_of_trk; trk_j_idx++) {
-            auto pca = FindPca(tracks_[trk_i_idx], tracks_[trk_j_idx]);
-            if (pca.has_value() && pca->d_trk < max_dca_) {
-                TVector3 pca_i_j = pca->point;
-                vtx += pca_i_j;
-                n_of_pairs_++;
-
-                if (qa_.has_value()){
-                    qa_->pca_y_vs_x->Fill(pca_i_j[0], pca_i_j[1]);
-                    qa_->pca_x_vs_z->Fill(pca_i_j[2], pca_i_j[0]);
-                    qa_->pca_y_vs_z->Fill(pca_i_j[2], pca_i_j[1]);
-                }
-            }
+std::optional<CbmVertex> CbmDcaVertexFinder::FindVertex()
+{
+  // Reset the number of track pair used
+  n_of_pairs_  = 0;
+  int n_of_trk = tracks_.size();
+  LOG(debug) << "- PCA - Find event vertex using CbmGlobalTracks: " << n_of_trk;
+  TVector3 vtx;
+  for (int trk_i_idx = 0; trk_i_idx < n_of_trk - 1; trk_i_idx++) {
+    for (int trk_j_idx = trk_i_idx + 1; trk_j_idx < n_of_trk; trk_j_idx++) {
+      auto pca = FindPca(tracks_[trk_i_idx], tracks_[trk_j_idx]);
+      if (pca.has_value() && pca->d_trk < max_dca_) {
+        TVector3 pca_i_j = pca->point;
+        vtx += pca_i_j;
+        n_of_pairs_++;
+
+        if (qa_.has_value()) {
+          qa_->pca_y_vs_x->Fill(pca_i_j[0], pca_i_j[1]);
+          qa_->pca_x_vs_z->Fill(pca_i_j[2], pca_i_j[0]);
+          qa_->pca_y_vs_z->Fill(pca_i_j[2], pca_i_j[1]);
         }
+      }
     }
-    if (!n_of_pairs_)
-        return std::nullopt;
+  }
+  if (!n_of_pairs_) return std::nullopt;
 
-    vtx *= 1. / n_of_pairs_;
+  vtx *= 1. / n_of_pairs_;
 
-    // WARNING LINE
-    return CbmVertex("EventVertex", "EventVertex", vtx[0], vtx[1], vtx[2], 0, 0, n_of_pairs_, cov_matrix_);
+  // WARNING LINE
+  return CbmVertex("EventVertex", "EventVertex", vtx[0], vtx[1], vtx[2], 0, 0, n_of_pairs_, cov_matrix_);
 }
 
 std::optional<CbmDcaVertexFinder::PCA> CbmDcaVertexFinder::FindPca(CbmGlobalTrack* trk_i, CbmGlobalTrack* trk_j)
 {
-    TVector3 r1(trk_i->GetParamFirst()->GetX(), trk_i->GetParamFirst()->GetY(),
-                trk_i->GetParamFirst()->GetZ());
-    TVector3 e1(trk_i->GetParamFirst()->GetTx(), trk_i->GetParamFirst()->GetTy(), 1);
+  TVector3 r1(trk_i->GetParamFirst()->GetX(), trk_i->GetParamFirst()->GetY(), trk_i->GetParamFirst()->GetZ());
+  TVector3 e1(trk_i->GetParamFirst()->GetTx(), trk_i->GetParamFirst()->GetTy(), 1);
 
-    TVector3 r2(trk_j->GetParamFirst()->GetX(), trk_j->GetParamFirst()->GetY(),
-                trk_j->GetParamFirst()->GetZ());
-    TVector3 e2(trk_j->GetParamFirst()->GetTx(), trk_j->GetParamFirst()->GetTy(), 1);
+  TVector3 r2(trk_j->GetParamFirst()->GetX(), trk_j->GetParamFirst()->GetY(), trk_j->GetParamFirst()->GetZ());
+  TVector3 e2(trk_j->GetParamFirst()->GetTx(), trk_j->GetParamFirst()->GetTy(), 1);
 
-    TVector3 n = e1.Cross(e2);  // Directional vector for segment of the pca
+  TVector3 n = e1.Cross(e2);  // Directional vector for segment of the pca
 
-    float nn = n.Dot(n);
-    if (nn != 0) {  // Non-Parallel tracks
+  float nn = n.Dot(n);
+  if (nn != 0) {  // Non-Parallel tracks
 
-        TVector3 e1n = e1.Cross(n);
-        TVector3 e2n = e1.Cross(n);
-        TVector3 r21 = r2 - r1;
+    TVector3 e1n = e1.Cross(n);
+    TVector3 e2n = e1.Cross(n);
+    TVector3 r21 = r2 - r1;
 
-        float t1 = e2n.Dot(r21) / nn;
-        float t2 = e1n.Dot(r21) / nn;
+    float t1 = e2n.Dot(r21) / nn;
+    float t2 = e1n.Dot(r21) / nn;
 
-        TVector3 p1  = r1 + t1 * e1;  // Closest point on track 1
-        TVector3 p2  = r2 + t2 * e2;  // Closest point on track 2
-        TVector3 p21 = p2 - p1;
+    TVector3 p1  = r1 + t1 * e1;  // Closest point on track 1
+    TVector3 p2  = r2 + t2 * e2;  // Closest point on track 2
+    TVector3 p21 = p2 - p1;
 
-        TVector3 point  = 0.5 * (p1 + p2);
-        double d_trk  = 0.5 * p21.Mag();
+    TVector3 point = 0.5 * (p1 + p2);
+    double d_trk   = 0.5 * p21.Mag();
 
-        return std::make_optional<PCA>({point, d_trk});
-    }
-    return std::nullopt;
+    return std::make_optional<PCA>({point, d_trk});
+  }
+  return std::nullopt;
 }
-
diff --git a/analysis/detectors/sts/CbmDcaVertexFinder.h b/analysis/detectors/sts/CbmDcaVertexFinder.h
index 6f17aac2f1..c4f7b7783a 100644
--- a/analysis/detectors/sts/CbmDcaVertexFinder.h
+++ b/analysis/detectors/sts/CbmDcaVertexFinder.h
@@ -1,10 +1,15 @@
+/* Copyright (C) 2023 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
+   SPDX-License-Identifier: GPL-3.0-only
+   Authors: Dario Ramirez [committer] */
+
 #ifndef CBMDCAVERTEXFINDER_H
 #define CBMDCAVERTEXFINDER_H
 
-#include <optional>
-#include "TVector3.h"
 #include "TH2.h"
 #include "TMatrixFSym.h"
+#include "TVector3.h"
+
+#include <optional>
 class CbmVertex;
 class CbmGlobalTrack;
 
@@ -14,62 +19,57 @@ class CbmGlobalTrack;
  * The algorithm consist in averaging the PCA of all valid pair of tracks.
  * A valid pair is defined but a cut in the maximum value for DCA
  */
-class CbmDcaVertexFinder{
-public:
-    struct Qa{
-        std::shared_ptr<TH2> pca_y_vs_x;
-        std::shared_ptr<TH2> pca_x_vs_z;
-        std::shared_ptr<TH2> pca_y_vs_z;
-    };
+class CbmDcaVertexFinder {
+ public:
+  struct Qa {
+    std::shared_ptr<TH2> pca_y_vs_x;
+    std::shared_ptr<TH2> pca_x_vs_z;
+    std::shared_ptr<TH2> pca_y_vs_z;
+  };
 
-    /** Holds PCA analysis for a pair of straight tracks */
-    struct PCA {
-        TVector3 point;
-        double d_trk;
-    };
+  /** Holds PCA analysis for a pair of straight tracks */
+  struct PCA {
+    TVector3 point;
+    double d_trk;
+  };
 
-    /** \brief Default constructor
-    */
-    CbmDcaVertexFinder();
+  CbmDcaVertexFinder();
 
-    /** \brief Constructor setting maximum DCA for track pair */
-    CbmDcaVertexFinder(double max_dca);
+  /** \brief Constructor setting maximum DCA for track pair */
+  CbmDcaVertexFinder(double max_dca);
 
-    /** \brief Constructor using input set of track */
-    CbmDcaVertexFinder(const std::vector<CbmGlobalTrack*> tracks);
+  /** \brief Constructor using input set of track */
+  CbmDcaVertexFinder(const std::vector<CbmGlobalTrack*> tracks);
 
-    /** \brief Constructor using input set of track, and maximum DCA for track pair */
-    CbmDcaVertexFinder(const std::vector<CbmGlobalTrack*> tracks, const double max_dca);
+  /** \brief Constructor using input set of track, and maximum DCA for track pair */
+  CbmDcaVertexFinder(const std::vector<CbmGlobalTrack*> tracks, const double max_dca);
 
-    /** \brief Set input track */
-    void SetTracks(const std::vector<CbmGlobalTrack*> tracks);
+  /** \brief Set input track */
+  void SetTracks(const std::vector<CbmGlobalTrack*> tracks);
 
-    ~CbmDcaVertexFinder();
+  ~CbmDcaVertexFinder() = default;
 
-    /** \brief Calculate the Point of Closest Approach of two straight tracks
+  /** \brief Calculate the Point of Closest Approach of two straight tracks
      * if tracks are parallel it return a nullopt
      * \param trk_i, trk_j pointer to CbmGlobal tracks
      */
-    std::optional<CbmDcaVertexFinder::PCA> FindPca(CbmGlobalTrack* trk_i, CbmGlobalTrack* trk_j);
+  std::optional<CbmDcaVertexFinder::PCA> FindPca(CbmGlobalTrack* trk_i, CbmGlobalTrack* trk_j);
 
-    /** \brief Run algorithm to find vertex
+  /** \brief Run algorithm to find vertex
      * \return std::optional<CbmVertex>:
      *  - std::nullopt if algorithm fails or no vertex was found under present configuration
      */
-    std::optional<CbmVertex> FindVertex();
-
-    void EnableQa(Qa qa) {
-        qa_ = std::make_optional<Qa>(qa);
-    }
+  std::optional<CbmVertex> FindVertex();
 
-private:
-    const double max_dca_;
-    std::vector<CbmGlobalTrack*> tracks_;
-    double n_of_pairs_;
-    std::optional<Qa> qa_;
+  void EnableQa(Qa qa) { qa_ = std::make_optional<Qa>(qa); }
 
-    TMatrixFSym cov_matrix_;
+ private:
+  const double max_dca_;
+  std::vector<CbmGlobalTrack*> tracks_;
+  double n_of_pairs_;
+  std::optional<Qa> qa_;
 
+  TMatrixFSym cov_matrix_;
 };
 
-#endif
\ No newline at end of file
+#endif
diff --git a/analysis/detectors/sts/CbmEventVertexDca.cxx b/analysis/detectors/sts/CbmEventVertexDca.cxx
index d93613d10a..100d852982 100644
--- a/analysis/detectors/sts/CbmEventVertexDca.cxx
+++ b/analysis/detectors/sts/CbmEventVertexDca.cxx
@@ -1,18 +1,11 @@
-/* Copyright (C) 2022 Facility for Antiproton and Ion Research in Europe, Darmstadt
+/* Copyright (C) 2023 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
    SPDX-License-Identifier: GPL-3.0-only
    Authors: Dario Ramirez [committer] */
 
-
 #include "CbmEventVertexDca.h"
 
 #include "CbmStsAddress.h"
 
-#include <gsl/gsl_blas.h>
-#include <gsl/gsl_linalg.h>
-
-CbmEventVertexDca::CbmEventVertexDca(){}
-
-CbmEventVertexDca::~CbmEventVertexDca() {}
 
 void CbmEventVertexDca::BookHistograms()
 {
@@ -30,60 +23,63 @@ void CbmEventVertexDca::BookHistograms()
   double vertex_z_min = -65 + 0.5 * vertex_dz;
   double vertex_z_max = +65 + 0.5 * vertex_dz;
 
-  auto x_vtx_binning = cbm_sts_utils::HBinning{uint32_t((vertex_x_max - vertex_x_min) / vertex_dx), vertex_x_min, vertex_x_max};
-  auto y_vtx_binning = cbm_sts_utils::HBinning{uint32_t((vertex_y_max - vertex_y_min) / vertex_dy), vertex_y_min, vertex_y_max};
-  auto z_vtx_binning = cbm_sts_utils::HBinning{uint32_t((vertex_z_max - vertex_z_min) / vertex_dz), vertex_z_min, vertex_z_max};
+  auto x_vtx_binning =
+    cbm_sts_utils::HBinning{uint32_t((vertex_x_max - vertex_x_min) / vertex_dx), vertex_x_min, vertex_x_max};
+  auto y_vtx_binning =
+    cbm_sts_utils::HBinning{uint32_t((vertex_y_max - vertex_y_min) / vertex_dy), vertex_y_min, vertex_y_max};
+  auto z_vtx_binning =
+    cbm_sts_utils::HBinning{uint32_t((vertex_z_max - vertex_z_min) / vertex_dz), vertex_z_min, vertex_z_max};
 
   // DCA
-  double dca_dx = .001; // 10 um
-  double dca_min = -2.5 - 0.5 * dca_dx;
-  double dca_max = +2.5 + 0.5 * dca_dx;
+  double dca_dx      = .001;  // 10 um
+  double dca_min     = -2.5 - 0.5 * dca_dx;
+  double dca_max     = +2.5 + 0.5 * dca_dx;
   auto r_dca_binning = cbm_sts_utils::HBinning{uint32_t((dca_max - dca_min) / dca_dx), dca_min, dca_max};
   // ---- --------------------- ----
 
   // ---- 3D Vertex 2D projections ----
-  h_name      = "vertex_y_vs_x";
-  h2_[h_name] = std::make_unique<TH2D>(h_name.c_str(), h_name.c_str(),
-    x_vtx_binning.n_of_bins, x_vtx_binning.x_min, x_vtx_binning.x_max,
-    y_vtx_binning.n_of_bins, y_vtx_binning.x_min, y_vtx_binning.x_max);
+  h_name = "vertex_y_vs_x";
+  h2_[h_name] =
+    std::make_unique<TH2D>(h_name.c_str(), h_name.c_str(), x_vtx_binning.n_of_bins, x_vtx_binning.x_min,
+                           x_vtx_binning.x_max, y_vtx_binning.n_of_bins, y_vtx_binning.x_min, y_vtx_binning.x_max);
   h2_[h_name]->GetXaxis()->SetTitle("Vertex_{X} [cm]");
   h2_[h_name]->GetYaxis()->SetTitle("Vertex_{Y} [cm]");
 
-  h_name      = "vertex_x_vs_z";
-  h2_[h_name] = std::make_unique<TH2D>(h_name.c_str(), h_name.c_str(),
-    z_vtx_binning.n_of_bins, z_vtx_binning.x_min, z_vtx_binning.x_max,
-    x_vtx_binning.n_of_bins, x_vtx_binning.x_min, x_vtx_binning.x_max);
+  h_name = "vertex_x_vs_z";
+  h2_[h_name] =
+    std::make_unique<TH2D>(h_name.c_str(), h_name.c_str(), z_vtx_binning.n_of_bins, z_vtx_binning.x_min,
+                           z_vtx_binning.x_max, x_vtx_binning.n_of_bins, x_vtx_binning.x_min, x_vtx_binning.x_max);
   h2_[h_name]->GetXaxis()->SetTitle("Vertex_{Z} [cm]");
   h2_[h_name]->GetYaxis()->SetTitle("Vertex_{X} [cm]");
 
-  h_name      = "vertex_y_vs_z";
-  h2_[h_name] = std::make_unique<TH2D>(h_name.c_str(), h_name.c_str(),
-    z_vtx_binning.n_of_bins, z_vtx_binning.x_min, z_vtx_binning.x_max,
-    y_vtx_binning.n_of_bins, y_vtx_binning.x_min, y_vtx_binning.x_max);
+  h_name = "vertex_y_vs_z";
+  h2_[h_name] =
+    std::make_unique<TH2D>(h_name.c_str(), h_name.c_str(), z_vtx_binning.n_of_bins, z_vtx_binning.x_min,
+                           z_vtx_binning.x_max, y_vtx_binning.n_of_bins, y_vtx_binning.x_min, y_vtx_binning.x_max);
   h2_[h_name]->GetXaxis()->SetTitle("Vertex_{Z} [cm]");
   h2_[h_name]->GetYaxis()->SetTitle("Vertex_{Y} [cm]");
   // ---- ------------------------ ----
 
   // ---- PCA 2D projections ----
-  if (vertex_finder_){
-    h_name      = "pca_y_vs_x";
-    h2_s[h_name] = std::make_shared<TH2D>(h_name.c_str(), h_name.c_str(),
-      x_vtx_binning.n_of_bins, x_vtx_binning.x_min, x_vtx_binning.x_max,
-      y_vtx_binning.n_of_bins, y_vtx_binning.x_min, y_vtx_binning.x_max);
+  if (vertex_finder_) {
+    h_name = "pca_y_vs_x";
+    h2_s[h_name] =
+      std::make_shared<TH2D>(h_name.c_str(), h_name.c_str(), x_vtx_binning.n_of_bins, x_vtx_binning.x_min,
+                             x_vtx_binning.x_max, y_vtx_binning.n_of_bins, y_vtx_binning.x_min, y_vtx_binning.x_max);
     h2_s[h_name]->GetXaxis()->SetTitle("Vertex_{X} [cm]");
     h2_s[h_name]->GetYaxis()->SetTitle("Vertex_{Y} [cm]");
 
-    h_name      = "pca_x_vs_z";
-    h2_s[h_name] = std::make_shared<TH2D>(h_name.c_str(), h_name.c_str(),
-      z_vtx_binning.n_of_bins, z_vtx_binning.x_min, z_vtx_binning.x_max,
-      x_vtx_binning.n_of_bins, x_vtx_binning.x_min, x_vtx_binning.x_max);
+    h_name = "pca_x_vs_z";
+    h2_s[h_name] =
+      std::make_shared<TH2D>(h_name.c_str(), h_name.c_str(), z_vtx_binning.n_of_bins, z_vtx_binning.x_min,
+                             z_vtx_binning.x_max, x_vtx_binning.n_of_bins, x_vtx_binning.x_min, x_vtx_binning.x_max);
     h2_s[h_name]->GetXaxis()->SetTitle("Vertex_{Z} [cm]");
     h2_s[h_name]->GetYaxis()->SetTitle("Vertex_{X} [cm]");
 
-    h_name      = "pca_y_vs_z";
-    h2_s[h_name] = std::make_shared<TH2D>(h_name.c_str(), h_name.c_str(),
-      z_vtx_binning.n_of_bins, z_vtx_binning.x_min, z_vtx_binning.x_max,
-      y_vtx_binning.n_of_bins, y_vtx_binning.x_min, y_vtx_binning.x_max);
+    h_name = "pca_y_vs_z";
+    h2_s[h_name] =
+      std::make_shared<TH2D>(h_name.c_str(), h_name.c_str(), z_vtx_binning.n_of_bins, z_vtx_binning.x_min,
+                             z_vtx_binning.x_max, y_vtx_binning.n_of_bins, y_vtx_binning.x_min, y_vtx_binning.x_max);
     h2_s[h_name]->GetXaxis()->SetTitle("Vertex_{Z} [cm]");
     h2_s[h_name]->GetYaxis()->SetTitle("Vertex_{Y} [cm]");
 
@@ -93,25 +89,25 @@ void CbmEventVertexDca::BookHistograms()
   // ---- ------------------------ ----
 
   // ----        DCA         ----
-  for (const char* di : {"x", "y", "z"}){
-    h_name      = Form("dca_d%s_vs_x", di);
-    h2_[h_name] = std::make_unique<TH2D>(h_name.c_str(), h_name.c_str(),
-      r_dca_binning.n_of_bins, r_dca_binning.x_min, r_dca_binning.x_max,
-      x_vtx_binning.n_of_bins, x_vtx_binning.x_min, x_vtx_binning.x_max);
+  for (const char* di : {"x", "y", "z"}) {
+    h_name = Form("dca_d%s_vs_x", di);
+    h2_[h_name] =
+      std::make_unique<TH2D>(h_name.c_str(), h_name.c_str(), r_dca_binning.n_of_bins, r_dca_binning.x_min,
+                             r_dca_binning.x_max, x_vtx_binning.n_of_bins, x_vtx_binning.x_min, x_vtx_binning.x_max);
     h2_[h_name]->GetYaxis()->SetTitle("X [cm]");
     h2_[h_name]->GetXaxis()->SetTitle(Form("DCA_{%s} [cm]", di));
 
-    h_name      = Form("dca_d%s_vs_y", di);
-    h2_[h_name] = std::make_unique<TH2D>(h_name.c_str(), h_name.c_str(),
-      r_dca_binning.n_of_bins, r_dca_binning.x_min, r_dca_binning.x_max,
-      y_vtx_binning.n_of_bins, y_vtx_binning.x_min, y_vtx_binning.x_max);
+    h_name = Form("dca_d%s_vs_y", di);
+    h2_[h_name] =
+      std::make_unique<TH2D>(h_name.c_str(), h_name.c_str(), r_dca_binning.n_of_bins, r_dca_binning.x_min,
+                             r_dca_binning.x_max, y_vtx_binning.n_of_bins, y_vtx_binning.x_min, y_vtx_binning.x_max);
     h2_[h_name]->GetYaxis()->SetTitle("Y [cm]");
     h2_[h_name]->GetXaxis()->SetTitle(Form("DCA_{%s} [cm]", di));
 
-    h_name      = Form("dca_d%s_vs_z", di);
-    h2_[h_name] = std::make_unique<TH2D>(h_name.c_str(), h_name.c_str(),
-      r_dca_binning.n_of_bins, r_dca_binning.x_min, r_dca_binning.x_max,
-      z_vtx_binning.n_of_bins, z_vtx_binning.x_min, z_vtx_binning.x_max);
+    h_name = Form("dca_d%s_vs_z", di);
+    h2_[h_name] =
+      std::make_unique<TH2D>(h_name.c_str(), h_name.c_str(), r_dca_binning.n_of_bins, r_dca_binning.x_min,
+                             r_dca_binning.x_max, z_vtx_binning.n_of_bins, z_vtx_binning.x_min, z_vtx_binning.x_max);
     h2_[h_name]->GetYaxis()->SetTitle(Form("Z [cm]"));
     h2_[h_name]->GetXaxis()->SetTitle(Form("DCA_{%s} [cm]", di));
   }
@@ -120,25 +116,25 @@ void CbmEventVertexDca::BookHistograms()
   // ----     Residual with MC      ----
   if (input_has_mc) {
     LOG(info) << " - INFO - Enabling MC comparison";
-    for (const char* di : {"x", "y", "z"}){
-      h_name      = Form("res_%s_vs_x", di);
-      h2_[h_name] = std::make_unique<TH2D>(h_name.c_str(), h_name.c_str(),
-        r_dca_binning.n_of_bins, r_dca_binning.x_min, r_dca_binning.x_max,
-        x_vtx_binning.n_of_bins, x_vtx_binning.x_min, x_vtx_binning.x_max);
+    for (const char* di : {"x", "y", "z"}) {
+      h_name = Form("res_%s_vs_x", di);
+      h2_[h_name] =
+        std::make_unique<TH2D>(h_name.c_str(), h_name.c_str(), r_dca_binning.n_of_bins, r_dca_binning.x_min,
+                               r_dca_binning.x_max, x_vtx_binning.n_of_bins, x_vtx_binning.x_min, x_vtx_binning.x_max);
       h2_[h_name]->GetYaxis()->SetTitle("X [cm]");
       h2_[h_name]->GetXaxis()->SetTitle(Form("%s_{rec} - %s_{MC} [cm]", di, di));
 
-      h_name      = Form("res_%s_vs_y", di);
-      h2_[h_name] = std::make_unique<TH2D>(h_name.c_str(), h_name.c_str(),
-        r_dca_binning.n_of_bins, r_dca_binning.x_min, r_dca_binning.x_max,
-        y_vtx_binning.n_of_bins, y_vtx_binning.x_min, y_vtx_binning.x_max);
+      h_name = Form("res_%s_vs_y", di);
+      h2_[h_name] =
+        std::make_unique<TH2D>(h_name.c_str(), h_name.c_str(), r_dca_binning.n_of_bins, r_dca_binning.x_min,
+                               r_dca_binning.x_max, y_vtx_binning.n_of_bins, y_vtx_binning.x_min, y_vtx_binning.x_max);
       h2_[h_name]->GetYaxis()->SetTitle("Y [cm]");
       h2_[h_name]->GetXaxis()->SetTitle(Form("%s_{rec} - %s_{MC} [cm]", di, di));
 
-      h_name      = Form("res_%s_vs_z", di);
-      h2_[h_name] = std::make_unique<TH2D>(h_name.c_str(), h_name.c_str(),
-        r_dca_binning.n_of_bins, r_dca_binning.x_min, r_dca_binning.x_max,
-        z_vtx_binning.n_of_bins, z_vtx_binning.x_min, z_vtx_binning.x_max);
+      h_name = Form("res_%s_vs_z", di);
+      h2_[h_name] =
+        std::make_unique<TH2D>(h_name.c_str(), h_name.c_str(), r_dca_binning.n_of_bins, r_dca_binning.x_min,
+                               r_dca_binning.x_max, z_vtx_binning.n_of_bins, z_vtx_binning.x_min, z_vtx_binning.x_max);
       h2_[h_name]->GetYaxis()->SetTitle(Form("Z [cm]"));
       h2_[h_name]->GetXaxis()->SetTitle(Form("%s_{rec} - %s_{MC} [cm]", di, di));
     }
@@ -167,7 +163,7 @@ void CbmEventVertexDca::CheckVertex()
   vertex_finder_->SetTracks(glb_trks_);
   const std::optional<CbmVertex> vertex = vertex_finder_->FindVertex();
 
-  if (vertex.has_value()){
+  if (vertex.has_value()) {
 
     TVector3 vtx(vertex->GetX(), vertex->GetY(), vertex->GetZ());
 
@@ -176,15 +172,15 @@ void CbmEventVertexDca::CheckVertex()
     h2_["vertex_y_vs_z"]->Fill(vtx[2], vtx[1]);
 
     for (const CbmGlobalTrack* trk : glb_trks_) {
-      float trk_tx       = trk->GetParamFirst()->GetTx();
-      float trk_ty       = trk->GetParamFirst()->GetTy();
-      float trk_x0       = trk->GetParamFirst()->GetX();
-      float trk_y0       = trk->GetParamFirst()->GetY();
-      float trk_z0       = trk->GetParamFirst()->GetZ();
+      float trk_tx = trk->GetParamFirst()->GetTx();
+      float trk_ty = trk->GetParamFirst()->GetTy();
+      float trk_x0 = trk->GetParamFirst()->GetX();
+      float trk_y0 = trk->GetParamFirst()->GetY();
+      float trk_z0 = trk->GetParamFirst()->GetZ();
 
       TVector3 p(trk_x0, trk_y0, trk_z0);
       TVector3 e(trk_tx, trk_ty, 1);
-      TVector3 trk_to_vtx    = ((vtx - p).Cross(e)) * (1. / e.Mag());
+      TVector3 trk_to_vtx = ((vtx - p).Cross(e)) * (1. / e.Mag());
 
       h2_["dca_dx_vs_x"]->Fill(trk_to_vtx.Px(), vtx.Px());
       h2_["dca_dx_vs_y"]->Fill(trk_to_vtx.Px(), vtx.Py());
@@ -237,7 +233,7 @@ void CbmEventVertexDca::ProcessEvent(CbmEvent* evt)
 
 
   for (int evt_glob_trk_idx = 0; evt_glob_trk_idx < nb_of_glob_trk; evt_glob_trk_idx++) {
-    int glob_trk_idx         = evt->GetIndex(ECbmDataType::kGlobalTrack, evt_glob_trk_idx);
+    int glob_trk_idx = evt->GetIndex(ECbmDataType::kGlobalTrack, evt_glob_trk_idx);
     ProcessGlobalTrack((CbmGlobalTrack*) glb_trk_array_->UncheckedAt(glob_trk_idx));
   }
 
@@ -295,7 +291,8 @@ void CbmEventVertexDca::ProcessGlobalTrack(CbmGlobalTrack* trk)
 
 void CbmEventVertexDca::Exec(Option_t*)
 {
-  LOG(info) << "Running CbmEventVertexDca;\t" << "Entry: " << entry_;
+  LOG(info) << "Running CbmEventVertexDca;\t"
+            << "Entry: " << entry_;
 
   // Check if CbmEvent
   if (cbm_evt_array_ != nullptr) {
@@ -304,8 +301,8 @@ void CbmEventVertexDca::Exec(Option_t*)
     for (uint32_t evt_idx = 0; evt_idx < nb_events; evt_idx++) {
       ProcessEvent((CbmEvent*) cbm_evt_array_->UncheckedAt(evt_idx));
     }
-
-  } else {
+  }
+  else {
 
     LOG(debug) << " ... running time-like*** Using all tracks in TS - risk of high combinatorial";
 
@@ -342,7 +339,7 @@ InitStatus CbmEventVertexDca::Init()
     sts_clu_array_ = (TClonesArray*) ioman->GetObject("StsCluster");
 
     mc_trk_array_ = (TClonesArray*) ioman->GetObject("MCTrack");
-    input_has_mc = mc_trk_array_ != nullptr;
+    input_has_mc  = mc_trk_array_ != nullptr;
   }
 
   LoadSetup();
@@ -354,6 +351,4 @@ InitStatus CbmEventVertexDca::Init()
   return kSUCCESS;
 }
 
-void CbmEventVertexDca::SetVertexFinder(std::shared_ptr<CbmDcaVertexFinder> vtx_finder){
-  vertex_finder_ = vtx_finder;
-}
\ No newline at end of file
+void CbmEventVertexDca::SetVertexFinder(std::shared_ptr<CbmDcaVertexFinder> vtx_finder) { vertex_finder_ = vtx_finder; }
diff --git a/analysis/detectors/sts/CbmEventVertexDca.h b/analysis/detectors/sts/CbmEventVertexDca.h
index dd369bb711..90e20c9dde 100644
--- a/analysis/detectors/sts/CbmEventVertexDca.h
+++ b/analysis/detectors/sts/CbmEventVertexDca.h
@@ -1,17 +1,14 @@
-/** \file CbmEventVertexDca.h
- * \brief Definition of the CbmEventVertexDca class.
- *
- * Copyright (C) 2022 Facility for Antiproton and Ion Research in Europe, Darmstadt
- * SPDX-License-Identifier: GPL-3.0-only
- * Authors: Dario Ramirez [committer]
- */
+/* Copyright (C) 2023 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
+   SPDX-License-Identifier: GPL-3.0-only
+   Authors: Dario Ramirez [committer] */
 
 #ifndef CBMEVENTVERTEXDCA_H
 #define CBMEVENTVERTEXDCA_H
 
-#include "CbmMCTrack.h"
+#include "CbmDcaVertexFinder.h"
 #include "CbmEvent.h"
 #include "CbmGlobalTrack.h"
+#include "CbmMCTrack.h"
 #include "CbmStsAnaBase.h"
 #include "CbmStsCluster.h"
 #include "CbmStsHit.h"
@@ -29,8 +26,6 @@
 #include <unordered_map>
 #include <unordered_set>
 
-#include "CbmDcaVertexFinder.h"
-
 /** \class CbmEventVertexDca
  * \brief Task for Event based vertex reconstruction.
  *
@@ -39,11 +34,8 @@
  */
 class CbmEventVertexDca : public FairTask, public CbmStsAnaBase {
  public:
-  /** \brief Default constructor */
-  CbmEventVertexDca();
-
-  /** \brief Destructor */
-  virtual ~CbmEventVertexDca();
+  CbmEventVertexDca()  = default;
+  ~CbmEventVertexDca() = default;
 
   InitStatus Init();
   void Exec(Option_t*);
diff --git a/analysis/detectors/sts/CbmSpillCheck.cxx b/analysis/detectors/sts/CbmSpillCheck.cxx
index 5a53382984..d6e5aa18a8 100644
--- a/analysis/detectors/sts/CbmSpillCheck.cxx
+++ b/analysis/detectors/sts/CbmSpillCheck.cxx
@@ -1,6 +1,7 @@
-/* Copyright (C) 2022 Facility for Antiproton and Ion Research in Europe, Darmstadt
-	SPDX-License-Identifier: GPL-3.0-only
-	Authors: Dario Ramirez [committer] */
+/* Copyright (C) 2023 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
+   SPDX-License-Identifier: GPL-3.0-only
+   Authors: Dario Ramirez [committer] */
+
 #include "CbmSpillCheck.h"
 
 #include <TFitResult.h>
@@ -9,16 +10,15 @@
 #include <iostream>
 #include <typeinfo>
 
-CbmSpillCheck::CbmSpillCheck() : ref_system{ECbmModuleId::kBmon},
-                                 rate_min_percnt{0.2},
-                                 rate_max_percnt{0.5}
+CbmSpillCheck::CbmSpillCheck() : ref_system{ECbmModuleId::kBmon}, rate_min_percnt{0.2}, rate_max_percnt{0.5}
 {
   LOG(debug) << "Creating an instance of CbmSpillCheck ...";
 }
 
-CbmSpillCheck::CbmSpillCheck(ECbmModuleId ref, double lvl_min, double lvl_max) : ref_system{ref},
-                                                                                 rate_min_percnt{lvl_min},
-                                                                                 rate_max_percnt{lvl_max}
+CbmSpillCheck::CbmSpillCheck(ECbmModuleId ref, double lvl_min, double lvl_max)
+  : ref_system{ref}
+  , rate_min_percnt{lvl_min}
+  , rate_max_percnt{lvl_max}
 {
   LOG(debug) << "Creating an instance of CbmSpillCheck ...";
 }
@@ -50,8 +50,6 @@ InitStatus CbmSpillCheck::Init()
   return kERROR;
 }
 
-CbmSpillCheck::~CbmSpillCheck() {}
-
 void CbmSpillCheck::Exec(Option_t*)
 {
   LOG(info) << "Running CbmSpillCheck ...";
diff --git a/analysis/detectors/sts/CbmSpillCheck.h b/analysis/detectors/sts/CbmSpillCheck.h
index fd3d151d5d..5b8b8c0070 100644
--- a/analysis/detectors/sts/CbmSpillCheck.h
+++ b/analysis/detectors/sts/CbmSpillCheck.h
@@ -1,10 +1,6 @@
-/** \file CbmSpillCheck.h
- * \brief Definition of the CbmSpillCheck class for spill status checking.
- *
- * Copyright (C) 2022 Facility for Antiproton and Ion Research in Europe, Darmstadt
- * SPDX-License-Identifier: GPL-3.0-only
- * Authors: Dario Ramirez [committer]
- */
+/* Copyright (C) 2023 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
+   SPDX-License-Identifier: GPL-3.0-only
+   Authors: Dario Ramirez [committer] */
 
 #ifndef CBMSPILLCHECK_H
 #define CBMSPILLCHECK_H
@@ -36,8 +32,7 @@ class CbmSpillCheck : public FairTask, public CbmStsAnaBase {
    */
   CbmSpillCheck(ECbmModuleId ref = ECbmModuleId::kBmon, double spill_off_prcnt = 0.2, double spill_on_prcnt = 0.5);
 
-  /** \brief Destructor */
-  virtual ~CbmSpillCheck();
+  ~CbmSpillCheck() = default;
 
   InitStatus Init();
 
diff --git a/analysis/detectors/sts/CbmStsAnaBase.cxx b/analysis/detectors/sts/CbmStsAnaBase.cxx
index d758be372f..bc4d04f575 100644
--- a/analysis/detectors/sts/CbmStsAnaBase.cxx
+++ b/analysis/detectors/sts/CbmStsAnaBase.cxx
@@ -1,14 +1,12 @@
-/* Copyright (C) 2022 Facility for Antiproton and Ion Research in Europe, Darmstadt
+/* Copyright (C) 2023 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
    SPDX-License-Identifier: GPL-3.0-only
    Authors: Dario Ramirez [committer] */
 
-// #define NDEBUG
-#include "FairRootManager.h"
-
 #include "CbmStsAnaBase.h"
 
 #include "CbmStsModule.h"
 #include "CbmStsStation.h"
+#include "FairRootManager.h"
 
 #include <TGeoBBox.h>          // for Geometry loading from file
 #include <TGeoManager.h>       // for Geometry loading from file
@@ -20,9 +18,6 @@
 #include <cassert>
 
 
-CbmStsAnaBase::CbmStsAnaBase() {}
-CbmStsAnaBase::~CbmStsAnaBase() {}
-
 void CbmStsAnaBase::SetCutMap(CbmCutMap* cuts_map)
 {
   assert(cuts_map != nullptr);
@@ -78,27 +73,29 @@ void CbmStsAnaBase::LoadSetup()
 
     if (address > 8) {
       switch (2 * (int) sensor_shape->GetDY()) {
-        case  2: first_z_strip_[address] = 2048 -  32; break;
-        case  4: first_z_strip_[address] = 2048 -  88; break;
-        case  6: first_z_strip_[address] = 2048 - 134; break;
+        case 2: first_z_strip_[address] = 2048 - 32; break;
+        case 4: first_z_strip_[address] = 2048 - 88; break;
+        case 6: first_z_strip_[address] = 2048 - 134; break;
         case 12: first_z_strip_[address] = 2048 - 274; break;
         default:
           LOG(warning) << Form("Unknown sensor shape 0x%x: [%0.3f , %0.3f , %0.3f]", address, sensor_shape->GetDX(),
-                             sensor_shape->GetDY(), sensor_shape->GetDZ());
+                               sensor_shape->GetDY(), sensor_shape->GetDZ());
           break;
       }
     }
   }
 
+  LOG(debug) << "Loaded setup information:\n";
   for (auto& [address, geo] : sts_geo_info_) {
-    LOG(info) << Form("Loaded setup information:\n0x%x: [%+0.3f, %+0.3f] ^ [%+0.3f, %+0.3f] ^ [%+0.3f, %+0.3f]", address, geo[0], geo[1], geo[2], geo[3], geo[4], geo[5]);
+    LOG(debug) << Form("0x%x: [%+0.3f, %+0.3f] ^ [%+0.3f, %+0.3f] ^ [%+0.3f, %+0.3f]", address, geo[0], geo[1], geo[2],
+                       geo[3], geo[4], geo[5]);
   }
 }
 
 void CbmStsAnaBase::SaveToFile()
 {
   FairRootManager* ioman = FairRootManager::Instance();
-  auto sink = ioman->GetSink();
+  auto sink              = ioman->GetSink();
 
   if (!sink) {
     LOG(fatal) << "Check the configuration: sink is invalid!";
diff --git a/analysis/detectors/sts/CbmStsAnaBase.h b/analysis/detectors/sts/CbmStsAnaBase.h
index f162330860..06eb70ae56 100644
--- a/analysis/detectors/sts/CbmStsAnaBase.h
+++ b/analysis/detectors/sts/CbmStsAnaBase.h
@@ -1,27 +1,18 @@
-/** @file CbmStsAnaBase.h
- *  @brief CbmStsAnaBase class header file.
- *
- *  @copyright (C) 2022 Facility for Antiproton and Ion Research in Europe, Darmstadt
- *  SPDX-License-Identifier: GPL-3.0-only
- *  Authors: Dario Ramirez [committer]
- */
+/* Copyright (C) 2023 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
+   SPDX-License-Identifier: GPL-3.0-only
+   Authors: Dario Ramirez [committer] */
 
 #ifndef CBMSTSANABASE_H
 #define CBMSTSANABASE_H
 
-#include <optional>
-#include <cstring>
-#include <map>
-#include <unordered_set>
-
 #include "CbmCutMap.h"
 #include "CbmDefs.h"
 #include "CbmStsSetup.h"
 #include "CbmStsUtils.h"
 
+#include <FairRootManager.h>
 #include <Logger.h>
 
-#include <FairRootManager.h>
 #include <TCanvas.h>
 #include <TClonesArray.h>
 #include <TFile.h>
@@ -30,10 +21,19 @@
 #include <TH2D.h>
 #include <TSystem.h>
 
+#include <cstring>
+#include <map>
+#include <optional>
+#include <unordered_set>
 
 
-
-enum InputType {kMCEventMode, kMCTimeMode, kEventMode, kTimeMode};
+enum InputType
+{
+  kMCEventMode,
+  kMCTimeMode,
+  kEventMode,
+  kTimeMode
+};
 
 /**
  * @class CbmStsAnaBase
@@ -44,11 +44,8 @@ enum InputType {kMCEventMode, kMCTimeMode, kEventMode, kTimeMode};
  */
 class CbmStsAnaBase {
  public:
-  /** Constructor */
-  CbmStsAnaBase();
-
-  /** Destructor */
-  virtual ~CbmStsAnaBase();
+  CbmStsAnaBase()  = default;
+  ~CbmStsAnaBase() = default;
 
   /**
    * @brief Set the cut map for analysis.
@@ -60,9 +57,7 @@ class CbmStsAnaBase {
    * @brief User defined sensor translations.
    * @param user_mat Input translations.
    */
-  void UserAlignment(const std::map<int32_t, std::vector<double>>& user_mat) {
-    user_align_ = user_mat;
-  }
+  void UserAlignment(const std::map<int32_t, std::vector<double>>& user_mat) { user_align_ = user_mat; }
 
   /**
    * @brief Virtual function to draw analysis results.
@@ -73,16 +68,16 @@ class CbmStsAnaBase {
   uint entry_{0};
   std::unique_ptr<TFile> report_file_;
   std::unordered_set<int32_t> address_book_;
-  std::map<std::string, std::unique_ptr<TGraphErrors>> g1_; // Map of TGraphErrors objects.
-  std::map<std::string, std::unique_ptr<TH1D>> h1_;         // Map of TH1D objects.
-  std::map<std::string, std::unique_ptr<TH2D>> h2_;         // Map of TH2D objects.
-  std::map<std::string, std::shared_ptr<TH2D>> h2_s;        // Map of TH2D objects.
-  std::map<std::string, std::unique_ptr<TCanvas>> canvas_;  // Map of TH2D objects.
+  std::map<std::string, std::unique_ptr<TGraphErrors>> g1_;  // Map of TGraphErrors objects.
+  std::map<std::string, std::unique_ptr<TH1D>> h1_;          // Map of TH1D objects.
+  std::map<std::string, std::unique_ptr<TH2D>> h2_;          // Map of TH2D objects.
+  std::map<std::string, std::shared_ptr<TH2D>> h2_s;         // Map of TH2D objects.
+  std::map<std::string, std::unique_ptr<TCanvas>> canvas_;   // Map of TH2D objects.
 
-  int nb_sts_station_{8};                                         // Number of STS stations.
-  std::unordered_map<int32_t, std::vector<double>> sts_geo_info_; // Map of STS geometry information.
+  int nb_sts_station_{8};                                          // Number of STS stations.
+  std::unordered_map<int32_t, std::vector<double>> sts_geo_info_;  // Map of STS geometry information.
 
-  std::map<int32_t, std::vector<double>> user_align_; // Stores the user-defined alignment information.
+  std::map<int32_t, std::vector<double>> user_align_;  // Stores the user-defined alignment information.
 
   std::unordered_map<int32_t, int> first_z_strip_;
 
diff --git a/analysis/detectors/sts/CbmStsAnalysis.cxx b/analysis/detectors/sts/CbmStsAnalysis.cxx
index c14df72551..88bc8d233f 100644
--- a/analysis/detectors/sts/CbmStsAnalysis.cxx
+++ b/analysis/detectors/sts/CbmStsAnalysis.cxx
@@ -1,4 +1,4 @@
-/* Copyright (C) 2022 Facility for Antiproton and Ion Research in Europe, Darmstadt
+/* Copyright (C) 2023 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
    SPDX-License-Identifier: GPL-3.0-only
    Authors: Dario Ramirez [committer] */
 
@@ -9,8 +9,4 @@
 #include <cassert>
 #include <iomanip>
 
-
-CbmStsAnalysis::CbmStsAnalysis() { LOG(debug) << "Creating an instance of CbmStsAnalysis ..."; }
-CbmStsAnalysis::~CbmStsAnalysis() {}
-
 void CbmStsAnalysis::SetAnalysisCuts(CbmCutMap* cuts_map) { ana_cuts_map_ = cuts_map; }
diff --git a/analysis/detectors/sts/CbmStsAnalysis.h b/analysis/detectors/sts/CbmStsAnalysis.h
index 9dca153c17..68e8509bcc 100644
--- a/analysis/detectors/sts/CbmStsAnalysis.h
+++ b/analysis/detectors/sts/CbmStsAnalysis.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 2022 Facility for Antiproton and Ion Research in Europe, Darmstadt
+/* Copyright (C) 2023 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
    SPDX-License-Identifier: GPL-3.0-only
    Authors: Dario Ramirez [committer] */
 
@@ -25,8 +25,8 @@
 
 class CbmStsAnalysis : public FairRunAna {
  public:
-  CbmStsAnalysis();
-  virtual ~CbmStsAnalysis();
+  CbmStsAnalysis()  = default;
+  ~CbmStsAnalysis() = default;
 
   void SetAnalysisCuts(CbmCutMap*);
 
diff --git a/analysis/detectors/sts/CbmStsChannelQA.cxx b/analysis/detectors/sts/CbmStsChannelQA.cxx
index 2faaa2971c..9e26dc4e55 100644
--- a/analysis/detectors/sts/CbmStsChannelQA.cxx
+++ b/analysis/detectors/sts/CbmStsChannelQA.cxx
@@ -1,6 +1,6 @@
-/* Copyright (C) 2022 Facility for Antiproton and Ion Research in Europe, Darmstadt
-	SPDX-License-Identifier: GPL-3.0-only
-	Authors: Dario Ramirez [committer] */
+/* Copyright (C) 2023 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
+   SPDX-License-Identifier: GPL-3.0-only
+   Authors: Dario Ramirez [committer] */
 
 #include "CbmStsChannelQA.h"
 
@@ -17,12 +17,7 @@
 #include <iostream>
 #include <typeinfo>
 
-CbmStsChannelQA::CbmStsChannelQA() { LOG(debug) << "Creating an instance of CbmStsChannelQA ..."; }
-
-CbmStsChannelQA::CbmStsChannelQA(int dead_threshold) : active_min_entries_(dead_threshold)
-{
-  LOG(debug) << "Creating an instance of CbmStsChannelQA ...";
-}
+CbmStsChannelQA::CbmStsChannelQA(int dead_threshold) : active_min_entries_(dead_threshold) {}
 CbmStsChannelQA::CbmStsChannelQA(int dead_threshold, double noise_threshold,
                                  std::optional<std::pair<size_t, size_t>> spill_on_off_threshold)
   : active_min_entries_(dead_threshold)
@@ -34,11 +29,8 @@ CbmStsChannelQA::CbmStsChannelQA(int dead_threshold, double noise_threshold,
     assert(spill_on_off_threshold_->first <= spill_on_off_threshold_->second);
     spill_sections_ = {":ramp", ":spill_on", ":spill_off"};
   }
-  LOG(debug) << "Creating an instance of CbmStsChannelQA ...";
 }
 
-CbmStsChannelQA::~CbmStsChannelQA() {}
-
 InitStatus CbmStsChannelQA::Init()
 {
   FairRootManager* ioman = FairRootManager::Instance();
@@ -48,14 +40,17 @@ InitStatus CbmStsChannelQA::Init()
 
     if (!digi_manager->IsPresent(ECbmModuleId::kSts)) LOG(fatal) << GetName() << ": No StsDigi branch in input!";
 
+    LOG(info) << "CbmStsChannelQA configuration:";
     LOG(info) << "Report lvl:                     " << report_level_;
     LOG(info) << "Active channel minimum entries: " << active_min_entries_;
     LOG(info) << "Noisy channel S/B thresholds:    " << sb_ratio_threshold_;
-    LOG_IF(info, !spill_on_off_threshold_.has_value()) << "No Spill section defined. Using all time slices";
-    LOG_IF(info, spill_on_off_threshold_.has_value())
-      << Form("Spill OFF: RefDet_DigiRate < %lu", spill_on_off_threshold_->first);
-    LOG_IF(info, spill_on_off_threshold_.has_value())
-      << Form("Spill  ON: RefDet_DigiRate > %lu", spill_on_off_threshold_->second);
+    if (spill_on_off_threshold_.has_value()) {
+      LOG(info) << Form("Spill OFF: RefDet_DigiRate < %lu", spill_on_off_threshold_->first);
+      LOG(info) << Form("Spill  ON: RefDet_DigiRate > %lu", spill_on_off_threshold_->second);
+    }
+    else {
+      LOG(info) << "No Spill section defined. Using all time slices";
+    }
 
     return kSUCCESS;
   }
@@ -67,7 +62,7 @@ void CbmStsChannelQA::BookHistograms(int32_t address)
 {
   LOG(debug) << Form("Booking histograms for module_addr: 0x%x", address);
 
-  double dt_max = 120; // HARDCODE
+  double dt_max  = 120;  // HARDCODE
   auto t_binning = cbm_sts_utils::HBinning{uint32_t(dt_max / 3.125), 0, dt_max};
 
   std::string h_name;
@@ -79,18 +74,16 @@ void CbmStsChannelQA::BookHistograms(int32_t address)
     h2_[h_name]->GetYaxis()->SetTitle("Charge_{StsDigi} [ADC]");
 
     LOG(debug) << h_name;
-    h_name = Form("0x%x_dt_vs_charge%s", address, modifier);
-    h2_[h_name] = std::make_unique<TH2D>(h_name.c_str(), h_name.c_str(),
-      31, 1, 32,
-      t_binning.n_of_bins, t_binning.x_min, t_binning.x_max);
+    h_name      = Form("0x%x_dt_vs_charge%s", address, modifier);
+    h2_[h_name] = std::make_unique<TH2D>(h_name.c_str(), h_name.c_str(), 31, 1, 32, t_binning.n_of_bins,
+                                         t_binning.x_min, t_binning.x_max);
     h2_[h_name]->GetYaxis()->SetTitle("Charge_{StsDigi} [ADC]");
     h2_[h_name]->GetYaxis()->SetTitle("Time difference [ns]");
 
     LOG(debug) << h_name;
-    h_name = Form("0x%x_dt_vs_channel%s", address, modifier);
-    h2_[h_name] = std::make_unique<TH2D>(h_name.c_str(), h_name.c_str(),
-      2048, 0, 2048,
-      t_binning.n_of_bins, t_binning.x_min, t_binning.x_max);
+    h_name      = Form("0x%x_dt_vs_channel%s", address, modifier);
+    h2_[h_name] = std::make_unique<TH2D>(h_name.c_str(), h_name.c_str(), 2048, 0, 2048, t_binning.n_of_bins,
+                                         t_binning.x_min, t_binning.x_max);
     h2_[h_name]->GetXaxis()->SetTitle("Channel_{StsDigi}");
     h2_[h_name]->GetYaxis()->SetTitle("Time difference [ns]");
   }
@@ -98,9 +91,10 @@ void CbmStsChannelQA::BookHistograms(int32_t address)
   address_book_.insert(address);
 }
 
-void CbmStsChannelQA::ResetLastTime(){
-  for (auto &[address, time] : last_digi_time_){
-    for (int chn = 0 ; chn < 2048 ; chn++){
+void CbmStsChannelQA::ResetLastTime()
+{
+  for (auto& [address, time] : last_digi_time_) {
+    for (int chn = 0; chn < 2048; chn++) {
       time[chn] = -1;
     }
   }
@@ -157,16 +151,18 @@ void CbmStsChannelQA::Exec(Option_t*)
     if (!address_book_.count(sts_digi_addr)) {
       BookHistograms(sts_digi_addr);
 
-      for (int chn = 0 ; chn < 2048 ; chn++){
+      for (int chn = 0; chn < 2048; chn++) {
         last_digi_time_[sts_digi_addr][chn] = -1;
       }
     }
 
     h2_[Form("0x%x_charge_vs_channel%s", sts_digi_addr, str_spill.c_str())]->Fill(sts_digi_chan, sts_digi_char);
 
-    if (last_digi_time_[sts_digi_addr][sts_digi_chan] > 0){
-      h2_[Form("0x%x_dt_vs_charge%s",  sts_digi_addr, str_spill.c_str())]->Fill(sts_digi_char, sts_digi_time - last_digi_time_[sts_digi_addr][sts_digi_chan]);
-      h2_[Form("0x%x_dt_vs_channel%s", sts_digi_addr, str_spill.c_str())]->Fill(sts_digi_chan, sts_digi_time - last_digi_time_[sts_digi_addr][sts_digi_chan]);
+    if (last_digi_time_[sts_digi_addr][sts_digi_chan] > 0) {
+      h2_[Form("0x%x_dt_vs_charge%s", sts_digi_addr, str_spill.c_str())]->Fill(
+        sts_digi_char, sts_digi_time - last_digi_time_[sts_digi_addr][sts_digi_chan]);
+      h2_[Form("0x%x_dt_vs_channel%s", sts_digi_addr, str_spill.c_str())]->Fill(
+        sts_digi_chan, sts_digi_time - last_digi_time_[sts_digi_addr][sts_digi_chan]);
     }
 
     last_digi_time_[sts_digi_addr][sts_digi_chan] = sts_digi_time;
@@ -275,9 +271,6 @@ void CbmStsChannelQA::GenerateReport()
   }
 }
 
-
-void CbmStsChannelQA::SetReportLevel(int lvl) { report_level_ = lvl; }
-
 void CbmStsChannelQA::Finish()
 {
   CheckDeadChannels();
diff --git a/analysis/detectors/sts/CbmStsChannelQA.h b/analysis/detectors/sts/CbmStsChannelQA.h
index 138fae0e2a..cd2c9342f1 100644
--- a/analysis/detectors/sts/CbmStsChannelQA.h
+++ b/analysis/detectors/sts/CbmStsChannelQA.h
@@ -1,12 +1,7 @@
-/* Copyright (C) 2022 Facility for Antiproton and Ion Research in Europe, Darmstadt
+/* Copyright (C) 2023 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
    SPDX-License-Identifier: GPL-3.0-only
    Authors: Dario Ramirez [committer] */
 
-/**
- * @file CbmStsChannelQA.h
- * @brief Declaration of CbmStsChannelQA class.
- */
-
 
 /**
  * @class CbmStsChannelQA
@@ -71,10 +66,7 @@
  */
 class CbmStsChannelQA : public FairTask, public CbmStsAnaBase {
  public:
-  /**
-   * @brief Default constructor.
-   */
-  CbmStsChannelQA();
+  CbmStsChannelQA() = default;
 
   /**
    * @brief Constructor with threshold for inactive channels.
@@ -92,16 +84,13 @@ class CbmStsChannelQA : public FairTask, public CbmStsAnaBase {
    */
   CbmStsChannelQA(int dead_threshold, double noise_threshold, const std::optional<std::pair<size_t, size_t>>);
 
-  /**
-   * @brief Destructor.
-   */
-  virtual ~CbmStsChannelQA();
+  ~CbmStsChannelQA() = default;
 
   InitStatus Init();
   void Exec(Option_t*);
   void Finish();
 
-  void SetReportLevel(int lvl = 0);
+  void SetReportLevel(int lvl) { report_level_ = lvl; }
 
  private:
   int report_level_{0};
diff --git a/analysis/detectors/sts/CbmStsCorrelation.cxx b/analysis/detectors/sts/CbmStsCorrelation.cxx
index 4eeb643137..e856a1daad 100644
--- a/analysis/detectors/sts/CbmStsCorrelation.cxx
+++ b/analysis/detectors/sts/CbmStsCorrelation.cxx
@@ -1,4 +1,4 @@
-/* Copyright (C) 2022 Facility for Antiproton and Ion Research in Europe, Darmstadt
+/* Copyright (C) 2023 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
    SPDX-License-Identifier: GPL-3.0-only
    Authors: Dario Ramirez [committer] */
 
@@ -9,9 +9,6 @@
 #include "TPaveStats.h"
 #include "TStyle.h"
 
-CbmStsCorrelation::CbmStsCorrelation() { LOG(debug) << "Creating an instance of CbmStsCorrelation ..."; }
-CbmStsCorrelation::~CbmStsCorrelation() {}
-
 void CbmStsCorrelation::BookHistograms()
 {
 
diff --git a/analysis/detectors/sts/CbmStsCorrelation.h b/analysis/detectors/sts/CbmStsCorrelation.h
index 19093511a8..ca55a95c7b 100644
--- a/analysis/detectors/sts/CbmStsCorrelation.h
+++ b/analysis/detectors/sts/CbmStsCorrelation.h
@@ -1,10 +1,6 @@
-/** \file CbmStsCorrelation.h
- * \brief Definition of the CbmStsCorrelation class.
- *
- * Copyright (C) 2022 Facility for Antiproton and Ion Research in Europe, Darmstadt
- * SPDX-License-Identifier: GPL-3.0-only
- * Authors: Dario Ramirez [committer]
- */
+/* Copyright (C) 2023 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
+   SPDX-License-Identifier: GPL-3.0-only
+   Authors: Dario Ramirez [committer] */
 
 #ifndef CBMSTSCORRELATION_H
 #define CBMSTSCORRELATION_H
@@ -33,11 +29,8 @@
  */
 class CbmStsCorrelation : public FairTask, public CbmStsAnaBase {
  public:
-  /** \brief Constructor */
-  CbmStsCorrelation();
-
-  /** \brief Destructor */
-  virtual ~CbmStsCorrelation();
+  CbmStsCorrelation()  = default;
+  ~CbmStsCorrelation() = default;
 
   InitStatus Init();
   void Exec(Option_t*);
diff --git a/analysis/detectors/sts/CbmStsEfficiency.cxx b/analysis/detectors/sts/CbmStsEfficiency.cxx
index 63b3edfc83..313aaa244b 100644
--- a/analysis/detectors/sts/CbmStsEfficiency.cxx
+++ b/analysis/detectors/sts/CbmStsEfficiency.cxx
@@ -1,29 +1,25 @@
-/* Copyright (C) 2022 Facility for Antiproton and Ion Research in Europe, Darmstadt
+/* Copyright (C) 2023 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
    SPDX-License-Identifier: GPL-3.0-only
    Authors: Dario Ramirez [committer] */
 
 #include "CbmStsEfficiency.h"
 
 #include "CbmStsAddress.h"
-
 #include "CbmStsUtils.h"
 
-CbmStsEfficiency::CbmStsEfficiency() { LOG(debug) << "Creating an instance of CbmStsEfficiency ..."; }
-
-CbmStsEfficiency::CbmStsEfficiency(uint32_t layer_idx)
-  : test_layer_(layer_idx)
+CbmStsEfficiency::CbmStsEfficiency(uint32_t layer_idx) : test_layer_(layer_idx)
 {
   LOG(debug) << "Creating an instance of CbmStsEfficiency ...";
 }
-CbmStsEfficiency::CbmStsEfficiency(uint32_t test_layer, double max_dis_trg_vtx, double max_dca_trk_vtx, double default_residual)
-  : test_layer_(test_layer),
-    max_dis_trg_vtx_(max_dis_trg_vtx),
-    max_dca_trk_vtx_(max_dca_trk_vtx),
-    default_residual_(default_residual)
+CbmStsEfficiency::CbmStsEfficiency(uint32_t test_layer, double max_dis_trg_vtx, double max_dca_trk_vtx,
+                                   double default_residual)
+  : test_layer_(test_layer)
+  , max_dis_trg_vtx_(max_dis_trg_vtx)
+  , max_dca_trk_vtx_(max_dca_trk_vtx)
+  , default_residual_(default_residual)
 {
   LOG(debug) << "Creating an instance of CbmStsEfficiency ...";
 }
-CbmStsEfficiency::~CbmStsEfficiency() {}
 
 void CbmStsEfficiency::BookHistograms()
 {
@@ -39,20 +35,23 @@ void CbmStsEfficiency::BookHistograms()
   double vertex_dy    = 0.1;
   double vertex_dz    = 0.1;
 
-  auto x_vtx_binning = cbm_sts_utils::HBinning{uint32_t((vertex_x_max - vertex_x_min) / vertex_dx), vertex_x_min, vertex_x_max};
-  auto y_vtx_binning = cbm_sts_utils::HBinning{uint32_t((vertex_y_max - vertex_y_min) / vertex_dy), vertex_y_min, vertex_y_max};
-  auto z_vtx_binning = cbm_sts_utils::HBinning{uint32_t((vertex_z_max - vertex_z_min) / vertex_dz), vertex_z_min, vertex_z_max};
+  auto x_vtx_binning =
+    cbm_sts_utils::HBinning{uint32_t((vertex_x_max - vertex_x_min) / vertex_dx), vertex_x_min, vertex_x_max};
+  auto y_vtx_binning =
+    cbm_sts_utils::HBinning{uint32_t((vertex_y_max - vertex_y_min) / vertex_dy), vertex_y_min, vertex_y_max};
+  auto z_vtx_binning =
+    cbm_sts_utils::HBinning{uint32_t((vertex_z_max - vertex_z_min) / vertex_dz), vertex_z_min, vertex_z_max};
 
   // DCA
-  double dca_dx = .001; // 10 um
-  double dca_min = -2.5 - 0.5 * dca_dx;
-  double dca_max = +2.5 + 0.5 * dca_dx;
+  double dca_dx      = .001;  // 10 um
+  double dca_min     = -2.5 - 0.5 * dca_dx;
+  double dca_max     = +2.5 + 0.5 * dca_dx;
   auto r_dca_binning = cbm_sts_utils::HBinning{uint32_t((dca_max - dca_min) / dca_dx), dca_min, dca_max};
 
   // Residuals track - hit
-  double res_dx    = +0.001; // 10 um
-  double res_min = -2.50 - 0.5*res_dx;
-  double res_max = +2.50 + 0.5*res_dx;
+  double res_dx      = +0.001;  // 10 um
+  double res_min     = -2.50 - 0.5 * res_dx;
+  double res_max     = +2.50 + 0.5 * res_dx;
   auto r_sen_binning = cbm_sts_utils::HBinning{uint32_t((res_max - res_min) / res_dx), res_min, res_max};
   // ---- --------------------- ----
 
@@ -75,103 +74,103 @@ void CbmStsEfficiency::BookHistograms()
 
     // ---- efficiency ----
     h_name = Form("%s_found", h_name_base.c_str());
-    h2_[h_name] = std::make_unique<TH2D>(h_name.c_str(), h_name.c_str(),
-      x_sen_binning.n_of_bins, x_sen_binning.x_min, x_sen_binning.x_max,
-      y_sen_binning.n_of_bins, y_sen_binning.x_min, y_sen_binning.x_max);
+    h2_[h_name] =
+      std::make_unique<TH2D>(h_name.c_str(), h_name.c_str(), x_sen_binning.n_of_bins, x_sen_binning.x_min,
+                             x_sen_binning.x_max, y_sen_binning.n_of_bins, y_sen_binning.x_min, y_sen_binning.x_max);
     h2_[h_name]->GetXaxis()->SetTitle("StsHit^{rec}_{X} [cm]");
     h2_[h_name]->GetYaxis()->SetTitle("StsHit^{rec}_{Y} [cm]");
 
     h_name = Form("%s_track", h_name_base.c_str());
-    h2_[h_name] = std::make_unique<TH2D>(h_name.c_str(), h_name.c_str(),
-      x_sen_binning.n_of_bins, x_sen_binning.x_min, x_sen_binning.x_max,
-      y_sen_binning.n_of_bins, y_sen_binning.x_min, y_sen_binning.x_max);
+    h2_[h_name] =
+      std::make_unique<TH2D>(h_name.c_str(), h_name.c_str(), x_sen_binning.n_of_bins, x_sen_binning.x_min,
+                             x_sen_binning.x_max, y_sen_binning.n_of_bins, y_sen_binning.x_min, y_sen_binning.x_max);
     h2_[h_name]->GetXaxis()->SetTitle("StsHit^{ext}_{X} [cm]");
     h2_[h_name]->GetYaxis()->SetTitle("StsHit^{ext}_{Y} [cm]");
 
     h_name = Form("%s_hit_map", h_name_base.c_str());
-    h2_[h_name] = std::make_unique<TH2D>(h_name.c_str(), h_name.c_str(),
-      x_sen_binning.n_of_bins, x_sen_binning.x_min, x_sen_binning.x_max,
-      y_sen_binning.n_of_bins, y_sen_binning.x_min, y_sen_binning.x_max);
+    h2_[h_name] =
+      std::make_unique<TH2D>(h_name.c_str(), h_name.c_str(), x_sen_binning.n_of_bins, x_sen_binning.x_min,
+                             x_sen_binning.x_max, y_sen_binning.n_of_bins, y_sen_binning.x_min, y_sen_binning.x_max);
     h2_[h_name]->GetXaxis()->SetTitle("StsHit_{X} [cm]");
     h2_[h_name]->GetYaxis()->SetTitle("StsHit_{Y} [cm]");
     // ---- ---------- ----
 
     // ---- residuals ----
-    for (const char* di : {"x", "y"}){
-      h_name      = Form("%s_d%s_vs_x", h_name_base.c_str(), di);
-      h2_[h_name] = std::make_unique<TH2D>(h_name.c_str(), h_name.c_str(),
-        r_sen_binning.n_of_bins, r_sen_binning.x_min, r_sen_binning.x_max,
-        x_sen_binning.n_of_bins, x_sen_binning.x_min, x_sen_binning.x_max);
+    for (const char* di : {"x", "y"}) {
+      h_name = Form("%s_d%s_vs_x", h_name_base.c_str(), di);
+      h2_[h_name] =
+        std::make_unique<TH2D>(h_name.c_str(), h_name.c_str(), r_sen_binning.n_of_bins, r_sen_binning.x_min,
+                               r_sen_binning.x_max, x_sen_binning.n_of_bins, x_sen_binning.x_min, x_sen_binning.x_max);
       h2_[h_name]->GetYaxis()->SetTitle("X [cm]");
       h2_[h_name]->GetXaxis()->SetTitle(Form("\\rho_{%s} [cm]", di));
 
-      h_name      = Form("%s_d%s_vs_y", h_name_base.c_str(), di);
-      h2_[h_name] = std::make_unique<TH2D>(h_name.c_str(), h_name.c_str(),
-        r_sen_binning.n_of_bins, r_sen_binning.x_min, r_sen_binning.x_max,
-        y_sen_binning.n_of_bins, y_sen_binning.x_min, y_sen_binning.x_max);
+      h_name = Form("%s_d%s_vs_y", h_name_base.c_str(), di);
+      h2_[h_name] =
+        std::make_unique<TH2D>(h_name.c_str(), h_name.c_str(), r_sen_binning.n_of_bins, r_sen_binning.x_min,
+                               r_sen_binning.x_max, y_sen_binning.n_of_bins, y_sen_binning.x_min, y_sen_binning.x_max);
       h2_[h_name]->GetYaxis()->SetTitle("Y [cm]");
       h2_[h_name]->GetXaxis()->SetTitle(Form("\\rho_{%s} [cm]", di));
     }
     // ---- --------- ----
-  } // end geo loop
+  }  // end geo loop
 
   // ----     3D vertex      ----
-  h_name      = "vertex_y_vs_x";
-  h2_[h_name] = std::make_unique<TH2D>(h_name.c_str(), h_name.c_str(),
-    x_vtx_binning.n_of_bins, x_vtx_binning.x_min, x_vtx_binning.x_max,
-    y_vtx_binning.n_of_bins, y_vtx_binning.x_min, y_vtx_binning.x_max);
+  h_name = "vertex_y_vs_x";
+  h2_[h_name] =
+    std::make_unique<TH2D>(h_name.c_str(), h_name.c_str(), x_vtx_binning.n_of_bins, x_vtx_binning.x_min,
+                           x_vtx_binning.x_max, y_vtx_binning.n_of_bins, y_vtx_binning.x_min, y_vtx_binning.x_max);
   h2_[h_name]->GetXaxis()->SetTitle("Vertex_{X} [cm]");
   h2_[h_name]->GetYaxis()->SetTitle("Vertex_{Y} [cm]");
 
-  h_name      = "vertex_x_vs_z";
-  h2_[h_name] = std::make_unique<TH2D>(h_name.c_str(), h_name.c_str(),
-    z_vtx_binning.n_of_bins, z_vtx_binning.x_min, z_vtx_binning.x_max,
-    x_vtx_binning.n_of_bins, x_vtx_binning.x_min, x_vtx_binning.x_max);
+  h_name = "vertex_x_vs_z";
+  h2_[h_name] =
+    std::make_unique<TH2D>(h_name.c_str(), h_name.c_str(), z_vtx_binning.n_of_bins, z_vtx_binning.x_min,
+                           z_vtx_binning.x_max, x_vtx_binning.n_of_bins, x_vtx_binning.x_min, x_vtx_binning.x_max);
   h2_[h_name]->GetXaxis()->SetTitle("Vertex_{Z} [cm]");
   h2_[h_name]->GetYaxis()->SetTitle("Vertex_{X} [cm]");
 
-  h_name      = "vertex_y_vs_z";
-  h2_[h_name] = std::make_unique<TH2D>(h_name.c_str(), h_name.c_str(),
-    z_vtx_binning.n_of_bins, z_vtx_binning.x_min, z_vtx_binning.x_max,
-    y_vtx_binning.n_of_bins, y_vtx_binning.x_min, y_vtx_binning.x_max);
+  h_name = "vertex_y_vs_z";
+  h2_[h_name] =
+    std::make_unique<TH2D>(h_name.c_str(), h_name.c_str(), z_vtx_binning.n_of_bins, z_vtx_binning.x_min,
+                           z_vtx_binning.x_max, y_vtx_binning.n_of_bins, y_vtx_binning.x_min, y_vtx_binning.x_max);
   h2_[h_name]->GetXaxis()->SetTitle("Vertex_{Z} [cm]");
   h2_[h_name]->GetYaxis()->SetTitle("Vertex_{Y} [cm]");
   // ---- ------------------ ----
 
   // ----        DCA         ----
-  for (const char* di : {"x", "y", "z"}){
-    h_name      = Form("dca_d%s_vs_x", di);
-    h2_[h_name] = std::make_unique<TH2D>(h_name.c_str(), h_name.c_str(),
-      r_dca_binning.n_of_bins, r_dca_binning.x_min, r_dca_binning.x_max,
-      x_vtx_binning.n_of_bins, x_vtx_binning.x_min, x_vtx_binning.x_max);
+  for (const char* di : {"x", "y", "z"}) {
+    h_name = Form("dca_d%s_vs_x", di);
+    h2_[h_name] =
+      std::make_unique<TH2D>(h_name.c_str(), h_name.c_str(), r_dca_binning.n_of_bins, r_dca_binning.x_min,
+                             r_dca_binning.x_max, x_vtx_binning.n_of_bins, x_vtx_binning.x_min, x_vtx_binning.x_max);
     h2_[h_name]->GetYaxis()->SetTitle("X [cm]");
     h2_[h_name]->GetXaxis()->SetTitle(Form("DCA_{%s} [cm]", di));
 
-    h_name      = Form("dca_d%s_vs_y", di);
-    h2_[h_name] = std::make_unique<TH2D>(h_name.c_str(), h_name.c_str(),
-      r_dca_binning.n_of_bins, r_dca_binning.x_min, r_dca_binning.x_max,
-      y_vtx_binning.n_of_bins, y_vtx_binning.x_min, y_vtx_binning.x_max);
+    h_name = Form("dca_d%s_vs_y", di);
+    h2_[h_name] =
+      std::make_unique<TH2D>(h_name.c_str(), h_name.c_str(), r_dca_binning.n_of_bins, r_dca_binning.x_min,
+                             r_dca_binning.x_max, y_vtx_binning.n_of_bins, y_vtx_binning.x_min, y_vtx_binning.x_max);
     h2_[h_name]->GetYaxis()->SetTitle("Y [cm]");
     h2_[h_name]->GetXaxis()->SetTitle(Form("DCA_{%s} [cm]", di));
 
-    h_name      = Form("dca_d%s_vs_z", di);
-    h2_[h_name] = std::make_unique<TH2D>(h_name.c_str(), h_name.c_str(),
-      r_dca_binning.n_of_bins, r_dca_binning.x_min, r_dca_binning.x_max,
-      z_vtx_binning.n_of_bins, z_vtx_binning.x_min, z_vtx_binning.x_max);
+    h_name = Form("dca_d%s_vs_z", di);
+    h2_[h_name] =
+      std::make_unique<TH2D>(h_name.c_str(), h_name.c_str(), r_dca_binning.n_of_bins, r_dca_binning.x_min,
+                             r_dca_binning.x_max, z_vtx_binning.n_of_bins, z_vtx_binning.x_min, z_vtx_binning.x_max);
     h2_[h_name]->GetYaxis()->SetTitle(Form("Z [cm]"));
     h2_[h_name]->GetXaxis()->SetTitle(Form("DCA_{%s} [cm]", di));
   }
   // ---- ------------------ ----
 
   // ---- Track multiplicity ----
-  for (const char* mod : {":all", ":sel"}){
+  for (const char* mod : {":all", ":sel"}) {
     h_name      = Form("ca_track_multiplicity%s", mod);
-    h1_[h_name] = std::make_unique<TH1D>(h_name.c_str(), h_name.c_str(), 50, 0, 50); // HARDCODE
+    h1_[h_name] = std::make_unique<TH1D>(h_name.c_str(), h_name.c_str(), 50, 0, 50);  // HARDCODE
     h1_[h_name]->GetXaxis()->SetTitle("N_{CATrack}");
     h1_[h_name]->GetYaxis()->SetTitle("Entries");
 
     h_name      = Form("ca_track_chi2%s", mod);
-    h1_[h_name] = std::make_unique<TH1D>(h_name.c_str(), h_name.c_str(), 10000, 0, 10); // HARDCODE
+    h1_[h_name] = std::make_unique<TH1D>(h_name.c_str(), h_name.c_str(), 10000, 0, 10);  // HARDCODE
     h1_[h_name]->GetXaxis()->SetTitle("Chi2");
     h1_[h_name]->GetYaxis()->SetTitle("Entries");
   }
@@ -180,7 +179,8 @@ void CbmStsEfficiency::BookHistograms()
 
 void CbmStsEfficiency::CheckEfficiency()
 {
-  LOG(debug) << "Checking efficiency of STS station " << test_layer_ << " using " << glb_trks_.size() << " CbmGlobalTracks";
+  LOG(debug) << "Checking efficiency of STS station " << test_layer_ << " using " << glb_trks_.size()
+             << " CbmGlobalTracks";
   vertex_finder_->SetTracks(glb_trks_);
   const std::optional<CbmVertex> vertex = vertex_finder_->FindVertex();
 
@@ -195,16 +195,16 @@ void CbmStsEfficiency::CheckEfficiency()
   TVector3 vtx(vertex->GetX(), vertex->GetY(), vertex->GetZ());
   std::map<int32_t, std::vector<bool>> hit_used;
   for (auto trk : glb_trks_) {
-    double trk_tx       = trk->GetParamFirst()->GetTx();
-    double trk_ty       = trk->GetParamFirst()->GetTy();
-    double trk_x0       = trk->GetParamFirst()->GetX();
-    double trk_y0       = trk->GetParamFirst()->GetY();
-    double trk_z0       = trk->GetParamFirst()->GetZ();
+    double trk_tx = trk->GetParamFirst()->GetTx();
+    double trk_ty = trk->GetParamFirst()->GetTy();
+    double trk_x0 = trk->GetParamFirst()->GetX();
+    double trk_y0 = trk->GetParamFirst()->GetY();
+    double trk_z0 = trk->GetParamFirst()->GetZ();
 
     // Check if tack comes from vertex
     TVector3 p(trk_x0, trk_y0, trk_z0);
     TVector3 e(trk_tx, trk_ty, 1);
-    TVector3 trk_to_vtx    = ((vtx - p).Cross(e)) * (1. / e.Mag());
+    TVector3 trk_to_vtx = ((vtx - p).Cross(e)) * (1. / e.Mag());
 
     h2_["dca_dx_vs_x"]->Fill(trk_to_vtx.Px(), vtx.Px());
     h2_["dca_dx_vs_y"]->Fill(trk_to_vtx.Px(), vtx.Py());
@@ -220,8 +220,8 @@ void CbmStsEfficiency::CheckEfficiency()
 
     if (trk_to_vtx.Mag() > max_dca_trk_vtx_) continue;
 
-    for(int32_t & sensor : sensors_under_test_) {
-      auto hits = sts_hits_[sensor];
+    for (int32_t& sensor : sensors_under_test_) {
+      auto hits        = sts_hits_[sensor];
       size_t n_of_hits = hits.size();
 
       // Extrapolate to the current sensor z-plane
@@ -231,7 +231,7 @@ void CbmStsEfficiency::CheckEfficiency()
 
       // Check if the sensor contain the space point
       if (predicted_x < sts_geo_info_[sensor][0] || predicted_x > sts_geo_info_[sensor][1]
-        || predicted_y < sts_geo_info_[sensor][2] || predicted_y > sts_geo_info_[sensor][3]) {
+          || predicted_y < sts_geo_info_[sensor][2] || predicted_y > sts_geo_info_[sensor][3]) {
         continue;
       }
 
@@ -239,26 +239,26 @@ void CbmStsEfficiency::CheckEfficiency()
       h2_[Form("Sts%d_track", unit)]->Fill(predicted_x, predicted_y);
       h2_[Form("Sts0x%x_track", sensor)]->Fill(predicted_x, predicted_y);
 
-      if (n_of_hits){
+      if (n_of_hits) {
         /* Block to search in available hits */
-        double closest_id = 0;
-        double dx = hits[0]->GetX() - predicted_x - residuals_[sensor].mean.Px();
-        double dy = hits[0]->GetY() - predicted_y - residuals_[sensor].mean.Py();
-        double closest_rho = dx*dx + dy*dy;
+        double closest_id  = 0;
+        double dx          = hits[0]->GetX() - predicted_x - residuals_[sensor].mean.Px();
+        double dy          = hits[0]->GetY() - predicted_y - residuals_[sensor].mean.Py();
+        double closest_rho = dx * dx + dy * dy;
 
-        for (size_t idx = 1 ; idx < n_of_hits ; idx++) {
-          dx  = hits[idx]->GetX() - predicted_x - residuals_[sensor].mean.Px();
-          dy  = hits[idx]->GetY() - predicted_y - residuals_[sensor].mean.Py();
-          double rho = dx*dx + dy*dy;
+        for (size_t idx = 1; idx < n_of_hits; idx++) {
+          dx         = hits[idx]->GetX() - predicted_x - residuals_[sensor].mean.Px();
+          dy         = hits[idx]->GetY() - predicted_y - residuals_[sensor].mean.Py();
+          double rho = dx * dx + dy * dy;
 
           if (rho < closest_rho) {
-            closest_id = idx;
+            closest_id  = idx;
             closest_rho = rho;
           }
         }
 
-        dx  = hits[closest_id]->GetX() - predicted_x - residuals_[sensor].mean.Px();
-        dy  = hits[closest_id]->GetY() - predicted_y - residuals_[sensor].mean.Py();
+        dx = hits[closest_id]->GetX() - predicted_x - residuals_[sensor].mean.Px();
+        dy = hits[closest_id]->GetY() - predicted_y - residuals_[sensor].mean.Py();
 
         h2_[Form("Sts%d_dx_vs_x", unit)]->Fill(dx, hits[closest_id]->GetX());
         h2_[Form("Sts%d_dy_vs_x", unit)]->Fill(dy, hits[closest_id]->GetX());
@@ -270,7 +270,8 @@ void CbmStsEfficiency::CheckEfficiency()
         h2_[Form("Sts0x%x_dx_vs_y", sensor)]->Fill(dx, hits[closest_id]->GetY());
         h2_[Form("Sts0x%x_dy_vs_y", sensor)]->Fill(dy, hits[closest_id]->GetY());
 
-        double sensor_resolution = residuals_[sensor].sigma.Mag() != 0 ? residuals_[sensor].sigma.Mag() : default_residual_;
+        double sensor_resolution =
+          residuals_[sensor].sigma.Mag() != 0 ? residuals_[sensor].sigma.Mag() : default_residual_;
         if (closest_rho <= 3.0 * sensor_resolution) {
           h2_[Form("Sts%d_found", unit)]->Fill(predicted_x, predicted_y);
           h2_[Form("Sts0x%x_found", sensor)]->Fill(predicted_x, predicted_y);
@@ -280,8 +281,8 @@ void CbmStsEfficiency::CheckEfficiency()
 
       /* Block to search in avaliable hit */
 
-    } // end sensor under test lopp
-  }// end track loop
+    }  // end sensor under test lopp
+  }    // end track loop
 }
 
 TH2D* FindInactiveArea(TH2D* h, int dead_size_x = 10, int dead_size_y = 10)
@@ -427,7 +428,7 @@ void CbmStsEfficiency::ProcessGlobalTrack(CbmGlobalTrack* trk)
   auto much_trk_idx = trk->GetMuchTrackIndex();
   auto trd_trk_idx  = trk->GetTrdTrackIndex();
   auto tof_trk_idx  = trk->GetTofTrackIndex();
-  double trk_p_val   = TMath::Prob(trk->GetChi2(), trk->GetNDF());
+  double trk_p_val  = TMath::Prob(trk->GetChi2(), trk->GetNDF());
   h1_["ca_track_chi2:all"]->Fill(trk->GetChi2());
 
   // Apply GlobalTracks cuts
@@ -484,7 +485,6 @@ void CbmStsEfficiency::ProcessHit(CbmStsHit* hit)
   sts_hits_[address].push_back(hit);
   h2_[Form("Sts%u_hit_map", unit)]->Fill(hit->GetX(), hit->GetY());
   h2_[Form("Sts0x%x_hit_map", address)]->Fill(hit->GetX(), hit->GetY());
-
 }
 
 void CbmStsEfficiency::Exec(Option_t*)
@@ -550,12 +550,9 @@ InitStatus CbmStsEfficiency::Init()
   BookHistograms();
 
   std::stringstream ss;
-  for (auto s : sensors_under_test_){
-    ss << Form("\t\t0x%x - U%d L%d M%d\n",
-      s,
-      CbmStsAddress::GetElementId(s, kStsUnit),
-      CbmStsAddress::GetElementId(s, kStsLadder),
-      CbmStsAddress::GetElementId(s, kStsModule));
+  for (auto s : sensors_under_test_) {
+    ss << Form("\t\t0x%x - U%d L%d M%d\n", s, CbmStsAddress::GetElementId(s, kStsUnit),
+               CbmStsAddress::GetElementId(s, kStsLadder), CbmStsAddress::GetElementId(s, kStsModule));
   }
 
   LOG(info) << "Max vtx target dz: " << max_dis_trg_vtx_;
@@ -583,6 +580,4 @@ void CbmStsEfficiency::SetResidual(std::string file_name)
 }
 
 
-void CbmStsEfficiency::SetVertexFinder(CbmDcaVertexFinder* vtx_finder){
-  vertex_finder_ = vtx_finder;
-}
\ No newline at end of file
+void CbmStsEfficiency::SetVertexFinder(CbmDcaVertexFinder* vtx_finder) { vertex_finder_ = vtx_finder; }
diff --git a/analysis/detectors/sts/CbmStsEfficiency.h b/analysis/detectors/sts/CbmStsEfficiency.h
index 4597439272..b775e0d6a3 100644
--- a/analysis/detectors/sts/CbmStsEfficiency.h
+++ b/analysis/detectors/sts/CbmStsEfficiency.h
@@ -1,14 +1,11 @@
-/** \file CbmStsEfficiency.h
- * \brief Definition of the CbmStsEfficiency class.
- *
- * Copyright (C) 2022 Facility for Antiproton and Ion Research in Europe, Darmstadt
- * SPDX-License-Identifier: GPL-3.0-only
- * Authors: Dario Ramirez [committer]
- */
+/* Copyright (C) 2023 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
+   SPDX-License-Identifier: GPL-3.0-only
+   Authors: Dario Ramirez [committer] */
 
 #ifndef CBMSTSEFFICIENCY_H
 #define CBMSTSEFFICIENCY_H
 
+#include "CbmDcaVertexFinder.h"
 #include "CbmEvent.h"
 #include "CbmGlobalTrack.h"
 #include "CbmStsAnaBase.h"
@@ -28,8 +25,6 @@
 #include <unordered_map>
 #include <unordered_set>
 
-#include "CbmDcaVertexFinder.h"
-
 struct Residual {
   TVector3 mean;
   TVector3 sigma;
@@ -50,8 +45,8 @@ struct Residual {
  */
 class CbmStsEfficiency : public FairTask, public CbmStsAnaBase {
  public:
-  /** \brief Default constructor */
-  CbmStsEfficiency();
+  CbmStsEfficiency()  = default;
+  ~CbmStsEfficiency() = default;
 
   /** \brief Parameterized constructor */
   CbmStsEfficiency(uint32_t);
@@ -59,9 +54,6 @@ class CbmStsEfficiency : public FairTask, public CbmStsAnaBase {
   /** \brief Parameterized constructor */
   CbmStsEfficiency(uint32_t, double, double, double);
 
-  /** \brief Destructor */
-  virtual ~CbmStsEfficiency();
-
   InitStatus Init();
   void Exec(Option_t*);
   void FinishTask();
diff --git a/analysis/detectors/sts/CbmStsHitAna.cxx b/analysis/detectors/sts/CbmStsHitAna.cxx
index 2c92c198ac..9af4971f22 100644
--- a/analysis/detectors/sts/CbmStsHitAna.cxx
+++ b/analysis/detectors/sts/CbmStsHitAna.cxx
@@ -1,6 +1,7 @@
-/* Copyright (C) 2022 Facility for Antiproton and Ion Research in Europe, Darmstadt
+/* Copyright (C) 2023 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
    SPDX-License-Identifier: GPL-3.0-only
    Authors: Dario Ramirez [committer] */
+
 #include "CbmStsHitAna.h"
 
 #include <CbmStsTrack.h>
@@ -9,14 +10,9 @@
 #include <iostream>
 #include <typeinfo>
 
-CbmStsHitAna::CbmStsHitAna() : hit_modifier_({":all"}) { LOG(debug) << "Creating an instance of CbmStsHitAna ..."; }
-
-CbmStsHitAna::CbmStsHitAna(std::string cal_par_file) : hit_modifier_({":all"}), calibration_file_(cal_par_file)
-{
-  LOG(debug) << "Creating an instance of CbmStsHitAna ...";
-}
+CbmStsHitAna::CbmStsHitAna() : hit_modifier_({":all"}) {}
 
-CbmStsHitAna::~CbmStsHitAna() {}
+CbmStsHitAna::CbmStsHitAna(std::string cal_par_file) : hit_modifier_({":all"}), calibration_file_(cal_par_file) {}
 
 InitStatus CbmStsHitAna::Init()
 {
@@ -62,8 +58,8 @@ void CbmStsHitAna::BookHistograms(int32_t address)
   double y_min = sts_geo_info_.count(address) ? sts_geo_info_[address][2] : -15;
   double y_max = sts_geo_info_.count(address) ? sts_geo_info_[address][3] : +15;
 
-  double t_min = - 150 - 0.5*cbm_sts_utils::kStsClock;
-  double t_max = + 150 + 0.5*cbm_sts_utils::kStsClock;
+  double t_min = -150 - 0.5 * cbm_sts_utils::kStsClock;
+  double t_max = +150 + 0.5 * cbm_sts_utils::kStsClock;
 
   auto x_binning = cbm_sts_utils::HBinning{uint32_t((x_max - x_min) / cbm_sts_utils::kStsDx), x_min, x_max};
   auto y_binning = cbm_sts_utils::HBinning{uint32_t((y_max - y_min) / cbm_sts_utils::kStsDy), y_min, y_max};
@@ -91,13 +87,12 @@ void CbmStsHitAna::BookHistograms(int32_t address)
                                          max_clu_size_, 1, max_clu_size_ + 1);
 
     h_name      = Form("0x%x_y_vs_x%s", address, mod);
-    h2_[h_name] = std::make_unique<TH2D>(h_name.c_str(), h_name.c_str(),
-      x_binning.n_of_bins, x_binning.x_min, x_binning.x_max,
-      y_binning.n_of_bins, y_binning.x_min, y_binning.x_max);
+    h2_[h_name] = std::make_unique<TH2D>(h_name.c_str(), h_name.c_str(), x_binning.n_of_bins, x_binning.x_min,
+                                         x_binning.x_max, y_binning.n_of_bins, y_binning.x_min, y_binning.x_max);
 
-    h_name      = Form("0x%x_cluster_dt%s", address, mod);
-    h1_[h_name] = std::make_unique<TH1D>(h_name.c_str(), h_name.c_str(),
-      t_binning.n_of_bins, t_binning.x_min, t_binning.x_max);
+    h_name = Form("0x%x_cluster_dt%s", address, mod);
+    h1_[h_name] =
+      std::make_unique<TH1D>(h_name.c_str(), h_name.c_str(), t_binning.n_of_bins, t_binning.x_min, t_binning.x_max);
   }
 }
 
@@ -148,7 +143,8 @@ void CbmStsHitAna::ProcessHit(CbmStsHit* hit, bool belong_to_trk)
   h2_[Form("0x%x_Qn_vs_size%s", address, mod)]->Fill(q_n, size_n);
   h2_[Form("0x%x_psize_vs_nsize%s", address, mod)]->Fill(size_p, size_n);
   h2_[Form("0x%x_y_vs_x%s", address, mod)]->Fill(hit->GetX(), hit->GetY());
-  h1_[Form("0x%x_cluster_dt%s", address, mod)]->Fill(cbm_sts_utils::GetHitTimeF(hit, sts_clu_array_) - cbm_sts_utils::GetHitTimeB(hit, sts_clu_array_));
+  h1_[Form("0x%x_cluster_dt%s", address, mod)]->Fill(cbm_sts_utils::GetHitTimeF(hit, sts_clu_array_)
+                                                     - cbm_sts_utils::GetHitTimeB(hit, sts_clu_array_));
 }
 
 void CbmStsHitAna::ProcessGlobalTrack(CbmGlobalTrack* trk)
@@ -213,20 +209,18 @@ void CbmStsHitAna::ProcessGlobalTrack(CbmGlobalTrack* trk)
 void CbmStsHitAna::Exec(Option_t*)
 {
   if (cbm_evt_array_ != nullptr) {
-    uint32_t nb_events = cbm_evt_array_->GetEntriesFast();
-    double avg_nb_sts_hits = 0;
+    uint32_t nb_events        = cbm_evt_array_->GetEntriesFast();
+    double avg_nb_sts_hits    = 0;
     double avg_nb_of_glob_trk = 0;
     for (uint32_t evt_idx = 0; evt_idx < nb_events; evt_idx++) {
       ProcessEvent((CbmEvent*) cbm_evt_array_->UncheckedAt(evt_idx));
-      avg_nb_sts_hits    += ((CbmEvent*) cbm_evt_array_->UncheckedAt(evt_idx))->GetNofData(ECbmDataType::kStsHit);
+      avg_nb_sts_hits += ((CbmEvent*) cbm_evt_array_->UncheckedAt(evt_idx))->GetNofData(ECbmDataType::kStsHit);
       avg_nb_of_glob_trk += ((CbmEvent*) cbm_evt_array_->UncheckedAt(evt_idx))->GetNofData(ECbmDataType::kGlobalTrack);
     }
-    LOG_IF(info, nb_events) << "Running CbmStsHitAna - Event-like - Entry: " << entry_
-      << "\tEvents: " << nb_events
-      << "\tAvg StsHit/Events: "  << avg_nb_sts_hits / nb_events
-      << "\tAvg GlobalTrk/Events: " << avg_nb_of_glob_trk / nb_events;
-    LOG_IF(info, !nb_events) << "Running CbmStsHitAna - Event-like - Entry: " << entry_
-      << "\tEvents: " << nb_events;
+    LOG_IF(info, nb_events) << "Running CbmStsHitAna - Event-like - Entry: " << entry_ << "\tEvents: " << nb_events
+                            << "\tAvg StsHit/Events: " << avg_nb_sts_hits / nb_events
+                            << "\tAvg GlobalTrk/Events: " << avg_nb_of_glob_trk / nb_events;
+    LOG_IF(info, !nb_events) << "Running CbmStsHitAna - Event-like - Entry: " << entry_ << "\tEvents: " << nb_events;
   }
   else {
     uint32_t n_of_hits = sts_hit_array_->GetEntriesFast();
diff --git a/analysis/detectors/sts/CbmStsHitAna.h b/analysis/detectors/sts/CbmStsHitAna.h
index a391086ce0..95c556bd82 100644
--- a/analysis/detectors/sts/CbmStsHitAna.h
+++ b/analysis/detectors/sts/CbmStsHitAna.h
@@ -1,10 +1,6 @@
-/** \file CbmStsHitAna.h
- * \brief Definition of the CbmStsHitAna class.
- *
- * Copyright (C) 2022 Facility for Antiproton and Ion Research in Europe, Darmstadt
- * SPDX-License-Identifier: GPL-3.0-only
- * Authors: Dario Ramirez [committer]
- */
+/* Copyright (C) 2023 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
+   SPDX-License-Identifier: GPL-3.0-only
+   Authors: Dario Ramirez [committer] */
 
 #ifndef CBMSTSHITANA_H
 #define CBMSTSHITANA_H
@@ -48,23 +44,20 @@
  *
  * - **Hit Type Separation**:
  *   All analyses are performed separately for:
- *   - **All hits** (`all`) — includes all reconstructed hits.
- *   - **Track hits** (`trk`) — includes only hits associated with reconstructed tracks.
+ *   - **All hits** (all) - includes all reconstructed hits.
+ *   - **Track hits** (trk) - includes only hits associated with reconstructed tracks.
   */
 
 class CbmStsHitAna : public FairTask, public CbmStsAnaBase {
  public:
-  /** \brief Constructor */
   CbmStsHitAna();
+  ~CbmStsHitAna() = default;
 
   /** \brief Constructor
    * \param cal_par_file charge calibration file
   */
   CbmStsHitAna(std::string cal_par_file);
 
-  /** \brief Destructor */
-  virtual ~CbmStsHitAna();
-
   InitStatus Init();
   void Exec(Option_t*);
   void Finish();
diff --git a/analysis/detectors/sts/CbmStsRecoBeamSpot.cxx b/analysis/detectors/sts/CbmStsRecoBeamSpot.cxx
index 394bfe63f8..a62f68f720 100644
--- a/analysis/detectors/sts/CbmStsRecoBeamSpot.cxx
+++ b/analysis/detectors/sts/CbmStsRecoBeamSpot.cxx
@@ -1,15 +1,11 @@
-/* Copyright (C) 2022 Facility for Antiproton and Ion Research in Europe, Darmstadt
-	 SPDX-License-Identifier: GPL-3.0-only
-	 Authors: Dario Ramirez [committer] */
+/* Copyright (C) 2023 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
+   SPDX-License-Identifier: GPL-3.0-only
+   Authors: Dario Ramirez [committer] */
 
 #include "CbmStsRecoBeamSpot.h"
 
 #include "CbmStsAddress.h"
 
-CbmStsRecoBeamSpot::CbmStsRecoBeamSpot() { LOG(debug) << "Creating an instance of CbmStsRecoBeamSpot ..."; }
-
-CbmStsRecoBeamSpot::~CbmStsRecoBeamSpot() {}
-
 void CbmStsRecoBeamSpot::AddTarget(CbmTarget* trg) { AddTarget("", trg); }
 void CbmStsRecoBeamSpot::AddTarget(std::string trg_name, CbmTarget* trg)
 {
@@ -144,7 +140,6 @@ void CbmStsRecoBeamSpot::ProcessEvent(CbmEvent* evt)
       int sts_hit_idx = evt->GetIndex(ECbmDataType::kStsHit, hit_evt_idx);
       CbmStsHit* hit  = (CbmStsHit*) sts_hit_array_->UncheckedAt(sts_hit_idx);
       ProcessHit(hit);
-
     }
 }
 
diff --git a/analysis/detectors/sts/CbmStsRecoBeamSpot.h b/analysis/detectors/sts/CbmStsRecoBeamSpot.h
index 5b11986ba9..a5a524f2a5 100644
--- a/analysis/detectors/sts/CbmStsRecoBeamSpot.h
+++ b/analysis/detectors/sts/CbmStsRecoBeamSpot.h
@@ -1,10 +1,6 @@
-/** \file CbmStsRecoBeamSpot.h
- * \brief Definition of the CbmStsRecoBeamSpot class.
- *
- * Copyright (C) 2022 Facility for Antiproton and Ion Research in Europe, Darmstadt
- * SPDX-License-Identifier: GPL-3.0-only
- * Authors: Dario Ramirez [committer]
- */
+/* Copyright (C) 2023 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
+   SPDX-License-Identifier: GPL-3.0-only
+   Authors: Dario Ramirez [committer] */
 
 #ifndef CBMSTSRECOBEAMSPOT_H
 #define CBMSTSRECOBEAMSPOT_H
@@ -39,11 +35,8 @@
  */
 class CbmStsRecoBeamSpot : public FairTask, public CbmStsAnaBase {
  public:
-  /** \brief Constructor */
-  CbmStsRecoBeamSpot();
-
-  /** \brief Destructor */
-  virtual ~CbmStsRecoBeamSpot();
+  CbmStsRecoBeamSpot()  = default;
+  ~CbmStsRecoBeamSpot() = default;
 
   /**
    * @brief Add a CbmTarget object to the list of targets.
@@ -71,12 +64,12 @@ class CbmStsRecoBeamSpot : public FairTask, public CbmStsAnaBase {
   /* Beam Spot sampling range
    * It is dynamically caculate when multiple targets planes are provided
    */
-  double bs_range_x_min_{-10}; // cm
-  double bs_range_x_max_{+10}; // cm
-  double bs_range_y_min_{-10}; // cm
-  double bs_range_y_max_{+10}; // cm
-  double bs_range_z_min_{-10}; // cm
-  double bs_range_z_max_{+10}; // cm
+  double bs_range_x_min_{-10};  // cm
+  double bs_range_x_max_{+10};  // cm
+  double bs_range_y_min_{-10};  // cm
+  double bs_range_y_max_{+10};  // cm
+  double bs_range_z_min_{-10};  // cm
+  double bs_range_z_max_{+10};  // cm
 
   /* Bin width for Beam Spot 2D histograms */
   double bs_resolution_x_{0.01};
diff --git a/analysis/detectors/sts/CbmStsResolution.cxx b/analysis/detectors/sts/CbmStsResolution.cxx
index aa0f3c7c06..6a4a5e5ba7 100644
--- a/analysis/detectors/sts/CbmStsResolution.cxx
+++ b/analysis/detectors/sts/CbmStsResolution.cxx
@@ -1,4 +1,4 @@
-/* Copyright (C) 2022 Facility for Antiproton and Ion Research in Europe, Darmstadt
+/* Copyright (C) 2023 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
    SPDX-License-Identifier: GPL-3.0-only
    Authors: Dario Ramirez [committer] */
 
@@ -6,17 +6,14 @@
 
 #include "CbmPixelHit.h"
 #include "CbmStsAddress.h"
+#include "CbmStsTrack.h"
 #include "TPaveStats.h"
 #include "TStyle.h"
 
-#include "CbmStsTrack.h"
-
-CbmStsResolution::CbmStsResolution() : d_max_trk_trg_(-1)
-{ LOG(debug) << "Creating an instance of CbmStsResolution ..."; }
-
 CbmStsResolution::CbmStsResolution(double d_max) : d_max_trk_trg_(d_max)
-{ LOG(debug) << "Creating an instance of CbmStsResolution ..."; }
-CbmStsResolution::~CbmStsResolution() {}
+{
+  LOG(debug) << "Creating an instance of CbmStsResolution ...";
+}
 
 void CbmStsResolution::BookHistograms()
 {
@@ -34,49 +31,44 @@ void CbmStsResolution::BookHistograms()
     unsigned int nb_bins_y = (y_max - y_min) / cbm_sts_utils::kStsDy;
 
 
-    double dr = 5e-4;
-    double r_min = -2.7 - 0.5 * dr;
-    double r_max = +2.7 + 0.5 * dr;
+    double dr              = 5e-4;
+    double r_min           = -2.7 - 0.5 * dr;
+    double r_max           = +2.7 + 0.5 * dr;
     unsigned int nb_bins_r = (r_max - r_min) / dr;
 
-    for (auto mod : {":all", ":trk"}){
+    for (auto mod : {":all", ":trk"}) {
       std::string h_name;
-      h_name = Form("%s_dx_vs_x%s", h_name_base.c_str(), mod);
-      h2_[h_name] =
-      std::make_unique<TH2D>(h_name.c_str(), "", nb_bins_r, r_min, r_max, nb_bins_x, x_min, x_max);
+      h_name      = Form("%s_dx_vs_x%s", h_name_base.c_str(), mod);
+      h2_[h_name] = std::make_unique<TH2D>(h_name.c_str(), "", nb_bins_r, r_min, r_max, nb_bins_x, x_min, x_max);
       h2_[h_name]->GetXaxis()->SetTitle(Form("X_{trk} - X_{hit} [cm]"));
       h2_[h_name]->GetYaxis()->SetTitle("X_{hit} [cm]");
       h2_[h_name]->GetXaxis()->CenterTitle(true);
       h2_[h_name]->GetYaxis()->CenterTitle(true);
 
-      h_name = Form("%s_dx_vs_y%s", h_name_base.c_str(), mod);
-      h2_[h_name] =
-      std::make_unique<TH2D>(h_name.c_str(), "", nb_bins_r, r_min, r_max, nb_bins_y, y_min, y_max);
+      h_name      = Form("%s_dx_vs_y%s", h_name_base.c_str(), mod);
+      h2_[h_name] = std::make_unique<TH2D>(h_name.c_str(), "", nb_bins_r, r_min, r_max, nb_bins_y, y_min, y_max);
       h2_[h_name]->GetXaxis()->SetTitle(Form("X_{trk} - X_{hit} [cm]"));
       h2_[h_name]->GetYaxis()->SetTitle("Y_{hit} [cm]");
       h2_[h_name]->GetXaxis()->CenterTitle(true);
       h2_[h_name]->GetYaxis()->CenterTitle(true);
 
-      h_name = Form("%s_dy_vs_x%s", h_name_base.c_str(), mod);
-      h2_[h_name] =
-      std::make_unique<TH2D>(h_name.c_str(), "", nb_bins_r, r_min, r_max, nb_bins_x, x_min, x_max);
+      h_name      = Form("%s_dy_vs_x%s", h_name_base.c_str(), mod);
+      h2_[h_name] = std::make_unique<TH2D>(h_name.c_str(), "", nb_bins_r, r_min, r_max, nb_bins_x, x_min, x_max);
       h2_[h_name]->GetXaxis()->SetTitle(Form("Y_{trk} - Y_{hit} [cm]"));
       h2_[h_name]->GetYaxis()->SetTitle("X_{hit} [cm]");
       h2_[h_name]->GetXaxis()->CenterTitle(true);
       h2_[h_name]->GetYaxis()->CenterTitle(true);
 
-      h_name = Form("%s_dy_vs_y%s", h_name_base.c_str(), mod);
-      h2_[h_name] =
-      std::make_unique<TH2D>(h_name.c_str(), "", nb_bins_r, r_min, r_max, nb_bins_y, y_min, y_max);
+      h_name      = Form("%s_dy_vs_y%s", h_name_base.c_str(), mod);
+      h2_[h_name] = std::make_unique<TH2D>(h_name.c_str(), "", nb_bins_r, r_min, r_max, nb_bins_y, y_min, y_max);
       h2_[h_name]->GetXaxis()->SetTitle(Form("Y_{trk} - Y_{hit} [cm]"));
       h2_[h_name]->GetYaxis()->SetTitle("Y_{hit} [cm]");
       h2_[h_name]->GetXaxis()->CenterTitle(true);
       h2_[h_name]->GetYaxis()->CenterTitle(true);
-
     }
-    if (element < 8){
+    if (element < 8) {
       std::string h_name = Form("Sts%d_ref_hits", element);
-      h2_[h_name] = std::make_unique<TH2D>(h_name.c_str(), "", nb_bins_x, x_min, x_max, nb_bins_y, y_min, y_max);
+      h2_[h_name]        = std::make_unique<TH2D>(h_name.c_str(), "", nb_bins_x, x_min, x_max, nb_bins_y, y_min, y_max);
       h2_[h_name]->GetXaxis()->SetTitle(Form("X_{TrkHit} [cm]"));
       h2_[h_name]->GetYaxis()->SetTitle("Y_{TrkHit} [cm]");
       h2_[h_name]->GetXaxis()->CenterTitle(true);
@@ -105,11 +97,12 @@ void CbmStsResolution::ProcessEvent(CbmEvent* evt)
   BuildResidual();
 }
 
-void CbmStsResolution::BuildResidual() {
+void CbmStsResolution::BuildResidual()
+{
   int n_of_units = sts_hits_.size();
 
   for (auto trk : glb_trks_) {
-    auto sts_trk_idx  = trk->GetStsTrackIndex();
+    auto sts_trk_idx = trk->GetStsTrackIndex();
     if (sts_trk_idx == -1) continue;
 
     CbmStsTrack* sts_track = (CbmStsTrack*) sts_trk_array_->UncheckedAt(sts_trk_idx);
@@ -119,15 +112,22 @@ void CbmStsResolution::BuildResidual() {
     CbmStsHit* hit_j = (CbmStsHit*) sts_hit_array_->UncheckedAt(sts_track->GetStsHitIndex(1));
 
     // Charge cut to Sts track hits
-    if (trk_hit_q_min_ > 0 && (cbm_sts_utils::GetHitCharge(hit_i, sts_clu_array_) < trk_hit_q_min_ || cbm_sts_utils::GetHitCharge(hit_j, sts_clu_array_) < trk_hit_q_min_)) continue;
+    if (trk_hit_q_min_ > 0
+        && (cbm_sts_utils::GetHitCharge(hit_i, sts_clu_array_) < trk_hit_q_min_
+            || cbm_sts_utils::GetHitCharge(hit_j, sts_clu_array_) < trk_hit_q_min_))
+      continue;
 
     int unit_i = CbmStsAddress::GetElementId(hit_i->GetAddress(), kStsUnit);
     int unit_j = CbmStsAddress::GetElementId(hit_j->GetAddress(), kStsUnit);
 
     // Checkk track crossed eneabled sensors
-    if (active_ref_sensors_.size()){
-      if (std::find(active_ref_sensors_.begin(), active_ref_sensors_.end(), hit_i->GetAddress()) == active_ref_sensors_.end()) continue;
-      if (std::find(active_ref_sensors_.begin(), active_ref_sensors_.end(), hit_j->GetAddress()) == active_ref_sensors_.end()) continue;
+    if (active_ref_sensors_.size()) {
+      if (std::find(active_ref_sensors_.begin(), active_ref_sensors_.end(), hit_i->GetAddress())
+          == active_ref_sensors_.end())
+        continue;
+      if (std::find(active_ref_sensors_.begin(), active_ref_sensors_.end(), hit_j->GetAddress())
+          == active_ref_sensors_.end())
+        continue;
     }
 
     double x_i = hit_i->GetX();
@@ -141,13 +141,14 @@ void CbmStsResolution::BuildResidual() {
     h2_[Form("Sts%d_ref_hits", unit_i)]->Fill(x_i, y_i);
     h2_[Form("Sts%d_ref_hits", unit_j)]->Fill(x_j, y_j);
 
-    double x_0,y_0,t_x,t_y;
+    double x_0, y_0, t_x, t_y;
     if (tracking_use_two_sts_) {
       t_x = (x_i - x_j) / (z_i - z_j);
       t_y = (y_i - y_j) / (z_i - z_j);
       x_0 = x_i - t_x * z_i;
       y_0 = y_i - t_y * z_i;
-    }else{
+    }
+    else {
       t_x = trk->GetParamFirst()->GetTx();
       t_y = trk->GetParamFirst()->GetTy();
       x_0 = x_i - t_x * z_i;
@@ -158,11 +159,11 @@ void CbmStsResolution::BuildResidual() {
 
     if (d_max_trk_trg_ > 0 && d_max_trk_trg_ < d_trk_trg) continue;
 
-    for (int uut = 0; uut < n_of_units ; uut++){
+    for (int uut = 0; uut < n_of_units; uut++) {
       if (uut == unit_i || uut == unit_j) continue;
 
       CbmStsHit* closest_hit = nullptr;
-      double min_dist = 1e+6;
+      double min_dist        = 1e+6;
       for (auto hit_dut : sts_hits_[uut]) {
         double x_dut = hit_dut->GetX();
         double y_dut = hit_dut->GetY();
@@ -185,10 +186,10 @@ void CbmStsResolution::BuildResidual() {
         h2_[Form("Sts%d_dy_vs_y:all", uut)]->Fill(dy, y_dut);
 
         if (min_dist > dx * dx + dy * dy) {
-          min_dist = dx * dx + dy * dy;
+          min_dist    = dx * dx + dy * dy;
           closest_hit = hit_dut;
         }
-      } // hit_dut loop
+      }  // hit_dut loop
 
       if (closest_hit) {
         double x_dut = closest_hit->GetX();
@@ -211,8 +212,8 @@ void CbmStsResolution::BuildResidual() {
         h2_[Form("Sts%d_dy_vs_x:trk", uut)]->Fill(dy, x_dut);
         h2_[Form("Sts%d_dy_vs_y:trk", uut)]->Fill(dy, y_dut);
       }
-    } // uut loop
-  } // track loop
+    }  // uut loop
+  }    // track loop
 
   sts_hits_.clear();
   glb_trks_.clear();
@@ -230,9 +231,7 @@ void CbmStsResolution::ProcessHit(CbmStsHit* hit)
   sts_hits_[unit].push_back(hit);
 }
 
-void CbmStsResolution::EnableRefSensor(int32_t address) {
-  active_ref_sensors_.push_back(address);
-}
+void CbmStsResolution::EnableRefSensor(int32_t address) { active_ref_sensors_.push_back(address); }
 
 void CbmStsResolution::ProcessGlobalTrack(CbmGlobalTrack* trk)
 {
@@ -288,7 +287,7 @@ void CbmStsResolution::ProcessGlobalTrack(CbmGlobalTrack* trk)
 void CbmStsResolution::Exec(Option_t*)
 {
   switch (input_type) {
-    case kEventMode : {
+    case kEventMode: {
       if (cbm_evt_array_ == nullptr) {
         LOG(error) << "Invalid branch for event-mode: Branch CbmEvent -> nullptr";
         break;
@@ -303,25 +302,25 @@ void CbmStsResolution::Exec(Option_t*)
       }
       break;
     }
-    case kMCTimeMode : {
+    case kMCTimeMode: {
       break;
     }
-    case kMCEventMode :
-    case kTimeMode :
-    default : {
-        uint32_t n_of_hits = sts_hit_array_->GetEntriesFast();
-        uint32_t n_of_glb_trk = glb_trk_array_->GetEntriesFast();
-        LOG(info) << "Processing entry " << entry_ << "\tStsHit: " << n_of_hits << "\tGlobalTrack: " << n_of_glb_trk;
-
-        for (uint32_t hit_idx = 0; hit_idx < n_of_hits; hit_idx++) {
-          ProcessHit((CbmStsHit*) sts_hit_array_->UncheckedAt(hit_idx));
-        }
+    case kMCEventMode:
+    case kTimeMode:
+    default: {
+      uint32_t n_of_hits    = sts_hit_array_->GetEntriesFast();
+      uint32_t n_of_glb_trk = glb_trk_array_->GetEntriesFast();
+      LOG(info) << "Processing entry " << entry_ << "\tStsHit: " << n_of_hits << "\tGlobalTrack: " << n_of_glb_trk;
+
+      for (uint32_t hit_idx = 0; hit_idx < n_of_hits; hit_idx++) {
+        ProcessHit((CbmStsHit*) sts_hit_array_->UncheckedAt(hit_idx));
+      }
 
-        for (uint32_t glb_trk_idx = 0; glb_trk_idx < n_of_glb_trk; glb_trk_idx++) {
-          ProcessGlobalTrack((CbmGlobalTrack*) glb_trk_array_->UncheckedAt(glb_trk_idx));
-        }
+      for (uint32_t glb_trk_idx = 0; glb_trk_idx < n_of_glb_trk; glb_trk_idx++) {
+        ProcessGlobalTrack((CbmGlobalTrack*) glb_trk_array_->UncheckedAt(glb_trk_idx));
+      }
 
-        BuildResidual();
+      BuildResidual();
       break;
     }
   }
@@ -335,18 +334,17 @@ InitStatus CbmStsResolution::Init()
   FairRootManager* ioman = FairRootManager::Instance();
   if (ioman != nullptr) {
 
-  cbm_evt_array_ = (TClonesArray*) ioman->GetObject("CbmEvent");
-
-  glb_trk_array_ = (TClonesArray*) ioman->GetObject("GlobalTrack");
-  sts_trk_array_ = (TClonesArray*) ioman->GetObject("StsTrack");
-  rch_trk_array_ = (TClonesArray*) ioman->GetObject("RichTrack");
-  mch_trk_array_ = (TClonesArray*) ioman->GetObject("MuchTrack");
-  trd_trk_array_ = (TClonesArray*) ioman->GetObject("TrdTrack");
-  tof_trk_array_ = (TClonesArray*) ioman->GetObject("TofTrack");
+    cbm_evt_array_ = (TClonesArray*) ioman->GetObject("CbmEvent");
 
-  sts_hit_array_ = (TClonesArray*) ioman->GetObject("StsHit");
-  sts_clu_array_ = (TClonesArray*) ioman->GetObject("StsCluster");
+    glb_trk_array_ = (TClonesArray*) ioman->GetObject("GlobalTrack");
+    sts_trk_array_ = (TClonesArray*) ioman->GetObject("StsTrack");
+    rch_trk_array_ = (TClonesArray*) ioman->GetObject("RichTrack");
+    mch_trk_array_ = (TClonesArray*) ioman->GetObject("MuchTrack");
+    trd_trk_array_ = (TClonesArray*) ioman->GetObject("TrdTrack");
+    tof_trk_array_ = (TClonesArray*) ioman->GetObject("TofTrack");
 
+    sts_hit_array_ = (TClonesArray*) ioman->GetObject("StsHit");
+    sts_clu_array_ = (TClonesArray*) ioman->GetObject("StsCluster");
   }
 
   LoadSetup();
@@ -356,7 +354,4 @@ InitStatus CbmStsResolution::Init()
   return kSUCCESS;
 }
 
-void CbmStsResolution::Finish()
-{
-  SaveToFile();
-}
+void CbmStsResolution::Finish() { SaveToFile(); }
diff --git a/analysis/detectors/sts/CbmStsResolution.h b/analysis/detectors/sts/CbmStsResolution.h
index 9b4aac5e18..049787d7c2 100644
--- a/analysis/detectors/sts/CbmStsResolution.h
+++ b/analysis/detectors/sts/CbmStsResolution.h
@@ -1,18 +1,14 @@
-/** \file CbmStsResolution.h
- * \brief Definition of the CbmStsResolution class.
- *
- * Copyright (C) 2022 Facility for Antiproton and Ion Research in Europe, Darmstadt
- * SPDX-License-Identifier: GPL-3.0-only
- * Authors: Dario Ramirez [committer]
- */
+/* Copyright (C) 2023 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
+   SPDX-License-Identifier: GPL-3.0-only
+   Authors: Dario Ramirez [committer] */
 
 #ifndef CBMSTSRESOLUTION_H
 #define CBMSTSRESOLUTION_H
 
 #include "CbmEvent.h"
+#include "CbmGlobalTrack.h"
 #include "CbmStsAnaBase.h"
 #include "CbmStsCluster.h"
-#include "CbmGlobalTrack.h"
 #include "CbmStsHit.h"
 #include "CbmStsUtils.h"
 
@@ -72,32 +68,24 @@
  */
 class CbmStsResolution : public FairTask, public CbmStsAnaBase {
  public:
-  /** \brief Constructor */
-  CbmStsResolution();
+  CbmStsResolution()  = default;
+  ~CbmStsResolution() = default;
+  ;
 
   /** \brief Constructor */
   CbmStsResolution(double);
 
-  /** \brief Destructor */
-  virtual ~CbmStsResolution();
-
   InitStatus Init();
   void Exec(Option_t*);
   void Finish();
 
-  void SetInputType(InputType type) {
-    input_type = type;
-  };
+  void SetInputType(InputType type) { input_type = type; };
 
   void EnableRefSensor(int32_t);
 
-  void SetMinTrkHitQ(double q) {
-    trk_hit_q_min_ = q;
-  }
+  void SetMinTrkHitQ(double q) { trk_hit_q_min_ = q; }
 
-  void TrackUseTwoSts() {
-    tracking_use_two_sts_ = true;
-  }
+  void TrackUseTwoSts() { tracking_use_two_sts_ = true; }
 
  private:
   double d_max_trk_trg_{-1};
diff --git a/analysis/detectors/sts/CbmStsTimeCal.cxx b/analysis/detectors/sts/CbmStsTimeCal.cxx
index d2cae864f6..5807b156e9 100644
--- a/analysis/detectors/sts/CbmStsTimeCal.cxx
+++ b/analysis/detectors/sts/CbmStsTimeCal.cxx
@@ -1,6 +1,7 @@
-/* Copyright (C) 2022 Facility for Antiproton and Ion Research in Europe, Darmstadt
-	SPDX-License-Identifier: GPL-3.0-only
-	Authors: Dario Ramirez [committer] */
+/* Copyright (C) 2023 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
+   SPDX-License-Identifier: GPL-3.0-only
+   Authors: Dario Ramirez [committer] */
+
 #include "CbmStsTimeCal.h"
 
 #include "CbmBmonDigi.h"
@@ -16,8 +17,8 @@
 #include <TDirectory.h>
 #include <TF1.h>
 #include <TFitResult.h>
-#include <TPaveText.h>
 #include <TLine.h>
+#include <TPaveText.h>
 #include <TStyle.h>
 
 #include <cassert>
@@ -31,12 +32,11 @@
 #include <yaml-cpp/emittermanip.h>
 #include <yaml-cpp/node/node.h>
 
-CbmStsTimeCal::CbmStsTimeCal() { LOG(debug) << "Creating an instance of CbmStsTimeCal ..."; }
 CbmStsTimeCal::CbmStsTimeCal(ECbmModuleId ref_sys, double t_min, double t_max)
+  : time_window_min_(t_min)
+  , time_window_max_(t_max)
+  , time_ref_system_(ref_sys)
 {
-  time_window_min_ = t_min;
-  time_window_max_ = t_max;
-  time_ref_system_ = ref_sys;
 }
 
 CbmStsTimeCal::CbmStsTimeCal(int run_id, ECbmModuleId ref_sys, double t_min, double t_max)
@@ -69,9 +69,9 @@ InitStatus CbmStsTimeCal::Init()
         LOG(warning) << "Could not create output directory\n Setting output path at current location:\n";
       }
     }
-    offset_file_       = std::make_unique<TFile>(Form("%s/cbm_sts_time_cal_offset.root", o_path_.c_str()), "RECREATE");
-    report_file_       = std::make_unique<TFile>(Form("%s/cbm_sts_time_cal_report.root", o_path_.c_str()), "RECREATE");
-    fit_file_          = std::make_unique<TFile>(Form("%s/cbm_sts_time_cal_fits.root",   o_path_.c_str()), "RECREATE");
+    offset_file_ = std::make_unique<TFile>(Form("%s/cbm_sts_time_cal_offset.root", o_path_.c_str()), "RECREATE");
+    report_file_ = std::make_unique<TFile>(Form("%s/cbm_sts_time_cal_report.root", o_path_.c_str()), "RECREATE");
+    fit_file_    = std::make_unique<TFile>(Form("%s/cbm_sts_time_cal_fits.root", o_path_.c_str()), "RECREATE");
 
     return kSUCCESS;
   }
@@ -82,10 +82,10 @@ void CbmStsTimeCal::InitTimeWalkMap(int32_t address)
 {
   for (unsigned int asic_idx = 0; asic_idx < 16; asic_idx++) {
     tw_map[address][asic_idx] = std::vector<double>(32, 0);
-    auto loaded_par = time_walk_map.Get(address, asic_idx);
-    if (loaded_par.size() == 31){
-      for (int adc = 1 ; adc <= 31; adc++) {
-        tw_map[address][asic_idx][adc] = loaded_par[adc-1];
+    auto loaded_par           = time_walk_map.Get(address, asic_idx);
+    if (loaded_par.size() == 31) {
+      for (int adc = 1; adc <= 31; adc++) {
+        tw_map[address][asic_idx][adc] = loaded_par[adc - 1];
       }
     }
   }
@@ -103,15 +103,12 @@ void CbmStsTimeCal::LoadWalkFromFile()
 
   if (TString(par_file_.c_str()).EndsWith(".yaml") || TString(par_file_.c_str()).EndsWith(".yml")) {
     LOG(info) << Form("Loading time calibration from parameter file: %s", par_file_.c_str());
-    time_walk_map = cbm::algo::yaml::ReadFromFile<cbm::algo::sts::WalkMap>(par_file_);
+    time_walk_map       = cbm::algo::yaml::ReadFromFile<cbm::algo::sts::WalkMap>(par_file_);
     global_time_offset_ = time_walk_map.GetSystemTimeOffset();
     LOG(info) << "Current system offset: " << global_time_offset_ << " ns";
   }
 }
 
-CbmStsTimeCal::~CbmStsTimeCal() {}
-
-
 void CbmStsTimeCal::BookHistograms(int32_t address)
 {
   LOG(debug) << Form("Booking histograms for module: 0x%x", address);
@@ -475,12 +472,12 @@ double CbmStsTimeCal::FindGlobalOffset()
 {
   double setup_offset  = 0;
   double min_sum_sigma = 999;
-  for (int32_t module : address_book_) { // module loop
+  for (int32_t module : address_book_) {  // module loop
     double module_avg_sigma  = 0;
     double module_avg_offset = 0;
     int n_of_values          = 0;
 
-    for (unsigned int asic_idx = 0; asic_idx < 16; asic_idx++) { // asic loop
+    for (unsigned int asic_idx = 0; asic_idx < 16; asic_idx++) {  // asic loop
       std::string h_name = Form("0x%x_%02d", module, asic_idx);
       auto g             = g1_[h_name].get();
 
@@ -497,7 +494,7 @@ double CbmStsTimeCal::FindGlobalOffset()
           n_of_values++;
         }
       }
-    } // end asic loop
+    }  // end asic loop
 
     module_avg_sigma  = n_of_values ? module_avg_sigma / n_of_values : -1;
     module_avg_offset = n_of_values ? module_avg_offset / n_of_values : -1;
@@ -506,19 +503,20 @@ double CbmStsTimeCal::FindGlobalOffset()
       min_sum_sigma = module_avg_sigma;
       setup_offset  = module_avg_offset;
     }
-  } // end module loop
+  }  // end module loop
 
   return setup_offset;
 }
 
-void CbmStsTimeCal::WriteYAML(){
+void CbmStsTimeCal::WriteYAML()
+{
   std::string o_yaml_file = o_path_ + "/StsTimeCalibration.yaml";
   LOG(info) << "Writing parameter file to:" << o_yaml_file;
 
   YAML::Emitter walk_map;
   walk_map << YAML::BeginMap;
   walk_map << YAML::Key << "timeOffset";
-  walk_map << YAML::Value << (int)global_time_offset_;
+  walk_map << YAML::Value << (int) global_time_offset_;
   walk_map << YAML::Key << "WalkMap";
   walk_map << YAML::Value << YAML::BeginMap;
   for (const auto& [module, asics] : tw_map) {
@@ -528,7 +526,7 @@ void CbmStsTimeCal::WriteYAML(){
       // Begin a flow sequence
       walk_map << YAML::Flow << YAML::BeginSeq;
       for (const auto& value : pars) {
-          walk_map << fmt::format("{:+.3f}", value);  // Add '+' for positive numbers
+        walk_map << fmt::format("{:+.3f}", value);  // Add '+' for positive numbers
       }
       // End the flow sequence
       walk_map << YAML::EndSeq;
@@ -552,8 +550,8 @@ void CbmStsTimeCal::Finish()
   // resize ADC offset vector to 31 channels from 0 [0-30`]
   for (auto& [module, asics] : tw_map) {        // Loop over modules
     for (auto& [asic_idx, asic_par] : asics) {  // Loop over ASICs
-      for (int adc = 1; adc <= 31; adc++) {  // loop over ADC channels 31 channels [1 - 31]
-        asic_par[adc-1] = asic_par[adc];
+      for (int adc = 1; adc <= 31; adc++) {     // loop over ADC channels 31 channels [1 - 31]
+        asic_par[adc - 1] = asic_par[adc];
       }
       asic_par.pop_back();
     }
diff --git a/analysis/detectors/sts/CbmStsTimeCal.h b/analysis/detectors/sts/CbmStsTimeCal.h
index e2040cba62..c602ac70f3 100644
--- a/analysis/detectors/sts/CbmStsTimeCal.h
+++ b/analysis/detectors/sts/CbmStsTimeCal.h
@@ -1,10 +1,6 @@
-/** \file CbmStsTimeCal.h
- * \brief Definition of the CbmStsTimeCal class.
- *
- * Copyright (C) 2022 Facility for Antiproton and Ion Research in Europe, Darmstadt
- * SPDX-License-Identifier: GPL-3.0-only
- * Authors: Dario Ramirez [committer]
- */
+/* Copyright (C) 2023 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
+   SPDX-License-Identifier: GPL-3.0-only
+   Authors: Dario Ramirez [committer] */
 
 #ifndef CBMSTSTIMECAL_H
 #define CBMSTSTIMECAL_H
@@ -13,9 +9,8 @@
 #include "CbmDigiManager.h"
 #include "CbmStsAnaBase.h"
 #include "CbmStsUtils.h"
-
+#include "sts/WalkMap.h"
 #include "yaml/Yaml.h"
-#include "detectors/sts/WalkMap.h"
 
 #include <FairTask.h>
 
@@ -79,8 +74,8 @@
  */
 class CbmStsTimeCal : public FairTask, public CbmStsAnaBase {
  public:
-  /** \brief Constructor */
-  CbmStsTimeCal();
+  CbmStsTimeCal()  = default;
+  ~CbmStsTimeCal() = default;
 
   /** \brief Parameterized constructor
    * @param system reference detector for time
@@ -96,9 +91,6 @@ class CbmStsTimeCal : public FairTask, public CbmStsAnaBase {
    */
   CbmStsTimeCal(int run_id, ECbmModuleId system, double lower_lim, double upper_lim);
 
-  /** \brief Destructor */
-  virtual ~CbmStsTimeCal();
-
   /**
    * @brief Set parameter file used during unpacking
    * @param file_name full/relative path to the parameters file
@@ -174,6 +166,5 @@ class CbmStsTimeCal : public FairTask, public CbmStsAnaBase {
   void DrawResults();
 
   ClassDef(CbmStsTimeCal, 1);
-
 };
 #endif
diff --git a/analysis/detectors/sts/CbmStsUtils.cxx b/analysis/detectors/sts/CbmStsUtils.cxx
index 836c285645..a51244af3e 100644
--- a/analysis/detectors/sts/CbmStsUtils.cxx
+++ b/analysis/detectors/sts/CbmStsUtils.cxx
@@ -1,4 +1,4 @@
-/* Copyright (C) 2022 Facility for Antiproton and Ion Research in Europe, Darmstadt
+/* Copyright (C) 2023 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
    SPDX-License-Identifier: GPL-3.0-only
    Authors: Dario Ramirez [committer] */
 
@@ -118,21 +118,22 @@ cbm_sts_utils::ChargeBinning(const CbmStsParModule& par_module, const uint32_t m
 }
 
 
-
-std::set<int> cbm_sts_utils::GetUnits(const std::vector<int32_t> addresses) {
+std::set<int> cbm_sts_utils::GetUnits(const std::vector<int32_t> addresses)
+{
   std::set<int> units;
-  for (int32_t address : addresses){
+  for (int32_t address : addresses) {
     units.insert(CbmStsAddress::GetElementId(address, kStsUnit));
   }
   return units;
 }
 
-std::vector<int32_t> cbm_sts_utils::GetUnitModules(const std::vector<int32_t> addresses, const uint32_t unit) {
+std::vector<int32_t> cbm_sts_utils::GetUnitModules(const std::vector<int32_t> addresses, const uint32_t unit)
+{
   std::vector<int32_t> unit_modules;
-  for (int32_t address : addresses){
-    if (CbmStsAddress::GetElementId(address, kStsUnit) == unit){
+  for (int32_t address : addresses) {
+    if (CbmStsAddress::GetElementId(address, kStsUnit) == unit) {
       unit_modules.push_back(address);
     }
   }
   return unit_modules;
-}
\ No newline at end of file
+}
diff --git a/analysis/detectors/sts/CbmStsUtils.h b/analysis/detectors/sts/CbmStsUtils.h
index 0369023ff2..0df5c03f6a 100644
--- a/analysis/detectors/sts/CbmStsUtils.h
+++ b/analysis/detectors/sts/CbmStsUtils.h
@@ -1,10 +1,7 @@
-/** \file CbmStsUtils.h
- * \brief Definition of utility functions for STS detector.
- *
- * Copyright (C) 2022 Facility for Antiproton and Ion Research in Europe, Darmstadt
- * SPDX-License-Identifier: GPL-3.0-only
- * Authors: Dario Ramirez [committer]
- */
+/* Copyright (C) 2023 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
+   SPDX-License-Identifier: GPL-3.0-only
+   Authors: Dario Ramirez [committer] */
+
 #ifndef CBMSTSUTILS_H
 #define CBMSTSUTILS_H
 
@@ -21,10 +18,10 @@ class CbmStsParModule;
 namespace cbm_sts_utils
 {
   static const double kStsClock = 3.125;
-  static const double kStsDx   = 6. / 1024;
-  static const double kStsDy   = kStsDx / std::tan(7.5 * TMath::Pi() / 180);
-  static const double kStsErrX = kStsDx / sqrt(12);
-  static const double kStsErrY = kStsDy / sqrt(12);
+  static const double kStsDx    = 6. / 1024;
+  static const double kStsDy    = kStsDx / std::tan(7.5 * TMath::Pi() / 180);
+  static const double kStsErrX  = kStsDx / sqrt(12);
+  static const double kStsErrY  = kStsDy / sqrt(12);
 
   /** \brief Get the cluster size of a hit from the front side
    *  \param hit Pointer to the STS hit
diff --git a/core/detectors/sts/CbmStsParSetModule.cxx b/core/detectors/sts/CbmStsParSetModule.cxx
index 8a4f4363bf..62b888a00d 100644
--- a/core/detectors/sts/CbmStsParSetModule.cxx
+++ b/core/detectors/sts/CbmStsParSetModule.cxx
@@ -13,9 +13,9 @@
 #include <Logger.h>  // for LOG, Logger
 
 #include <cassert>  // for assert
+#include <fstream>  // for reading parameters from ASCII file
 #include <sstream>  // for operator<<, basic_ostream, stringstream
 #include <string>   // for char_traits
-#include <fstream>  // for reading parameters from ASCII file
 
 
 ClassImp(CbmStsParSetModule)
@@ -99,8 +99,14 @@ Bool_t CbmStsParSetModule::LoadParASCII(std::string file_name)
     str_stream >> std::hex >> address >> std::dec >> side >> asic_idx >> nb_channels >> nb_adc >> dyn_range >> threshold
       >> time_res >> dead_time >> noise >> znr;
 
+    if (address == -1) {
+      LOG(info) << "[STS Charge Calibration] Using same configuration for all modules";
+      SetGlobalPar(*default_module);
+      break;
+    }
+
     // Initialize map entry with default configuration
-    if (!fParams.count(address)){
+    if (!fParams.count(address)) {
       fParams[address] = *default_module;
     }
 
@@ -116,7 +122,7 @@ Bool_t CbmStsParSetModule::LoadParASCII(std::string file_name)
       else {
         // Configure ASIC all for given side
         LOG(info) << Form("[STS Charge Calibration] Using same configuration for all ASICs in module 0x%x, side %u",
-                           address, side);
+                          address, side);
         for (int idx = 0; idx < 8; idx++) {
           fParams[address].SetAsic(idx + 8 * side, *custom_asic);
         }
@@ -133,11 +139,6 @@ Bool_t CbmStsParSetModule::LoadParASCII(std::string file_name)
     }
   }
 
-  if (fParams.size() == 1 && fParams.begin()->first == -1) {
-    LOG(info) << "[STS Charge Calibration] Using same configuration for all modules";
-    SetGlobalPar(fParams.begin()->second);
-    fParams.clear();
-  }
 
   return kTRUE;
 }
diff --git a/core/detectors/sts/CbmStsParSetModule.h b/core/detectors/sts/CbmStsParSetModule.h
index d4c6026be6..6302ee1d96 100644
--- a/core/detectors/sts/CbmStsParSetModule.h
+++ b/core/detectors/sts/CbmStsParSetModule.h
@@ -62,12 +62,12 @@ public:
      **
      ** An ASCII I/O is not implemented. The method throws an error.
      **/
-    virtual Bool_t getParams(FairParamList* parList);
+  virtual Bool_t getParams(FairParamList* parList);
 
-   /** @brief Reading parameters from ASCII.
+  /** @brief Reading parameters from ASCII.
     * * @param file_name  path to the parameters file
        **/
-   Bool_t LoadParASCII(std::string file_name);
+  Bool_t LoadParASCII(std::string file_name);
 
 
   /** @brief Get condition parameters of a sensor
diff --git a/macro/sts/cbm_vertex.C b/macro/sts/cbm_vertex.C
index e0e7a54afb..12b6baada4 100755
--- a/macro/sts/cbm_vertex.C
+++ b/macro/sts/cbm_vertex.C
@@ -1,102 +1,101 @@
-
-void cbm_vertex(
-    int n_of_ts = -1,
-    double dca_cut = 0.5, // cm
-    std::string geo_setup_tag = "mcbm_beam_2024_05_08_nickel",
-    std::string raw_file = "",
-    std::string rec_file = "",
-    std::string geo_file = "",
-    std::string out_file = "cbm_vertex_dca.root",
-    bool bAli = true
-){
-    // -----   Timer   --------------------------------------------------------
-    TStopwatch timer;
-    timer.Start();
-
-    // --- Logger settings ----------------------------------------------------
-    TString logLevel     = "DEBUG";
-    TString logVerbosity = "veryhigh";
-            logLevel     = "INFO";
-            logVerbosity = "low";
-
-    FairLogger::GetLogger()->SetLogScreenLevel(logLevel.Data());
-    FairLogger::GetLogger()->SetLogVerbosityLevel(logVerbosity.Data());
-    // ------------------------------------------------------------------------
-
-
-    // -----   Environment   --------------------------------------------------
-    std::string srcDir = gSystem->Getenv("VMCWORKDIR");  // top source directory
-    // ------------------------------------------------------------------------
-
-    std::unique_ptr<CbmStsAnalysis> run = std::make_unique<CbmStsAnalysis>();
-
-    FairFileSource* inputSource = new FairFileSource(rec_file.c_str());
-    inputSource->AddFriend(raw_file.c_str());
-
-    FairRootFileSink* outputSink = new FairRootFileSink(out_file.c_str());
-
-
-    if (bAli) {
-        TString alignmentMatrixFileName = srcDir + "/parameters/mcbm/AlignmentMatrices_" + geo_setup_tag + ".root";
-        if (alignmentMatrixFileName.Length() != 0) {
-            std::map<std::string, TGeoHMatrix>* matrices{nullptr};
-            TFile* misalignmentMatrixRootfile = new TFile(alignmentMatrixFileName, "READ");
-            if (misalignmentMatrixRootfile->IsOpen()) {
-                gDirectory->GetObject("MisalignMatrices", matrices);
-                misalignmentMatrixRootfile->Close();
-            }
-            else {
-                LOG(error) << "Could not open file " << alignmentMatrixFileName << "\n Exiting";
-                exit(1);
-            }
-
-            if (matrices) {
-                run->AddAlignmentMatrices(*matrices);
-            }
-            else {
-                LOG(error) << "Alignment required but no matrices found."
-                << "\n Exiting";
-                exit(1);
-            }
-        }
-    }
-
-    run->SetGeomFile(geo_file.c_str());
-    run->SetSource(inputSource);
-    run->SetSink(outputSink);
-
-
-    // ------------------------------------------------------------------------
-    // Configure Analysis filters
-    // ------------------------------------------------------------------------
-    CbmCutMap ana_filter;
-    ana_filter.AddCbmCut(CbmCutId::kGlobalTrackStsSize)->SetMin(2);
-    ana_filter.AddCbmCut(CbmCutId::kGlobalTrackTrdSize)->SetMin(1);
-    ana_filter.AddCbmCut(CbmCutId::kGlobalTrackTofSize)->SetMin(1);
-    // ana_filter.AddCbmCut(CbmCutId::kGlobalTrackPval)->SetMax(0.005);
-
-    // ------------------------------------------------------------------------
-    // Configure Vertex Finder
-    // ------------------------------------------------------------------------
-    std::shared_ptr<CbmDcaVertexFinder> vertex_finder = std::make_shared<CbmDcaVertexFinder>(dca_cut);
-
-    // ------------------------------------------------------------------------
-    // Configure Task
-    // ------------------------------------------------------------------------
-    CbmEventVertexDca* cbm_vtx_cda = new CbmEventVertexDca();
-    cbm_vtx_cda->SetVertexFinder(vertex_finder);
-    cbm_vtx_cda->SetCutMap(&ana_filter);
-    run->AddTask(cbm_vtx_cda);
-
-    run->Init();
-    run->Run(0,n_of_ts);
-
-    // ------------------------------------------------------------------------
-    timer.Stop();
-    Double_t rtime = timer.RealTime();
-    Double_t ctime = timer.CpuTime();
-    cout << endl << endl;
-    cout << "Macro finished successfully." << endl;
-    cout << "Real time " << rtime << " s, CPU time " << ctime << " s" << endl;
-    cout << endl;
-}
+/* Copyright (C) 2023 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
+   SPDX-License-Identifier: GPL-3.0-only
+   Authors: Dario Ramirez [committer] */
+
+void cbm_vertex(int n_of_ts               = -1,
+                double dca_cut            = 0.5,  // cm
+                std::string geo_setup_tag = "mcbm_beam_2024_05_08_nickel", std::string raw_file = "",
+                std::string rec_file = "", std::string geo_file = "", std::string out_file = "cbm_vertex_dca.root",
+                bool bAli = true)
+{
+  // -----   Timer   --------------------------------------------------------
+  TStopwatch timer;
+  timer.Start();
+
+  // --- Logger settings ----------------------------------------------------
+  TString logLevel     = "DEBUG";
+  TString logVerbosity = "veryhigh";
+  logLevel             = "INFO";
+  logVerbosity         = "low";
+
+  FairLogger::GetLogger()->SetLogScreenLevel(logLevel.Data());
+  FairLogger::GetLogger()->SetLogVerbosityLevel(logVerbosity.Data());
+  // ------------------------------------------------------------------------
+
+
+  // -----   Environment   --------------------------------------------------
+  std::string srcDir = gSystem->Getenv("VMCWORKDIR");  // top source directory
+  // ------------------------------------------------------------------------
+
+  std::unique_ptr<CbmStsAnalysis> run = std::make_unique<CbmStsAnalysis>();
+
+  FairFileSource* inputSource = new FairFileSource(rec_file.c_str());
+  inputSource->AddFriend(raw_file.c_str());
+
+  FairRootFileSink* outputSink = new FairRootFileSink(out_file.c_str());
+
+
+  if (bAli) {
+    TString alignmentMatrixFileName = srcDir + "/parameters/mcbm/AlignmentMatrices_" + geo_setup_tag + ".root";
+    if (alignmentMatrixFileName.Length() != 0) {
+      std::map<std::string, TGeoHMatrix>* matrices{nullptr};
+      TFile* misalignmentMatrixRootfile = new TFile(alignmentMatrixFileName, "READ");
+      if (misalignmentMatrixRootfile->IsOpen()) {
+        gDirectory->GetObject("MisalignMatrices", matrices);
+        misalignmentMatrixRootfile->Close();
+      }
+      else {
+        LOG(error) << "Could not open file " << alignmentMatrixFileName << "\n Exiting";
+        exit(1);
+      }
+
+      if (matrices) {
+        run->AddAlignmentMatrices(*matrices);
+      }
+      else {
+        LOG(error) << "Alignment required but no matrices found."
+                   << "\n Exiting";
+        exit(1);
+      }
+    }
+  }
+
+  run->SetGeomFile(geo_file.c_str());
+  run->SetSource(inputSource);
+  run->SetSink(outputSink);
+
+
+  // ------------------------------------------------------------------------
+  // Configure Analysis filters
+  // ------------------------------------------------------------------------
+  CbmCutMap ana_filter;
+  ana_filter.AddCbmCut(CbmCutId::kGlobalTrackStsSize)->SetMin(2);
+  ana_filter.AddCbmCut(CbmCutId::kGlobalTrackTrdSize)->SetMin(1);
+  ana_filter.AddCbmCut(CbmCutId::kGlobalTrackTofSize)->SetMin(1);
+  // ana_filter.AddCbmCut(CbmCutId::kGlobalTrackPval)->SetMax(0.005);
+
+  // ------------------------------------------------------------------------
+  // Configure Vertex Finder
+  // ------------------------------------------------------------------------
+  std::shared_ptr<CbmDcaVertexFinder> vertex_finder = std::make_shared<CbmDcaVertexFinder>(dca_cut);
+
+  // ------------------------------------------------------------------------
+  // Configure Task
+  // ------------------------------------------------------------------------
+  CbmEventVertexDca* cbm_vtx_cda = new CbmEventVertexDca();
+  cbm_vtx_cda->SetVertexFinder(vertex_finder);
+  cbm_vtx_cda->SetCutMap(&ana_filter);
+  run->AddTask(cbm_vtx_cda);
+
+  run->Init();
+  run->Run(0, n_of_ts);
+
+  // ------------------------------------------------------------------------
+  timer.Stop();
+  Double_t rtime = timer.RealTime();
+  Double_t ctime = timer.CpuTime();
+  cout << endl << endl;
+  cout << "Macro finished successfully." << endl;
+  cout << "Real time " << rtime << " s, CPU time " << ctime << " s" << endl;
+  cout << endl;
+}
diff --git a/macro/sts/sts_beam_spot.C b/macro/sts/sts_beam_spot.C
index 676aa83499..c927fcadd7 100644
--- a/macro/sts/sts_beam_spot.C
+++ b/macro/sts/sts_beam_spot.C
@@ -1,125 +1,123 @@
-
-void sts_beam_spot(
-    int n_of_ts = -1,
-    std::string geo_setup_tag = "mcbm_beam_2024_05_08_nickel",
-    std::string raw_file = "",
-    std::string rec_file = "",
-    std::string geo_file = "",
-    std::string out_file = "sts_beam_spot.root",
-    bool bAli = true
-){
-    // -----   Timer   --------------------------------------------------------
-    TStopwatch timer;
-    timer.Start();
-
-    // --- Logger settings ----------------------------------------------------
-    TString logLevel     = "DEBUG";
-    TString logVerbosity = "veryhigh";
-            logLevel     = "INFO";
-            logVerbosity = "low";
-
-    FairLogger::GetLogger()->SetLogScreenLevel(logLevel.Data());
-    FairLogger::GetLogger()->SetLogVerbosityLevel(logVerbosity.Data());
-    // ------------------------------------------------------------------------
-
-
-    // -----   Environment   --------------------------------------------------
-    std::string srcDir = gSystem->Getenv("VMCWORKDIR");  // top source directory
-    // ------------------------------------------------------------------------
-
-    std::unique_ptr<CbmStsAnalysis> run = std::make_unique<CbmStsAnalysis>();
-
-    FairFileSource* inputSource = new FairFileSource(rec_file.c_str());
-    inputSource->AddFriend(raw_file.c_str());
-
-    FairRootFileSink* outputSink = new FairRootFileSink(out_file.c_str());
-
-
-    if (bAli) {
-        TString alignmentMatrixFileName = srcDir + "/parameters/mcbm/AlignmentMatrices_" + geo_setup_tag + ".root";
-        if (alignmentMatrixFileName.Length() != 0) {
-            std::map<std::string, TGeoHMatrix>* matrices{nullptr};
-            TFile* misalignmentMatrixRootfile = new TFile(alignmentMatrixFileName, "READ");
-            if (misalignmentMatrixRootfile->IsOpen()) {
-                gDirectory->GetObject("MisalignMatrices", matrices);
-                misalignmentMatrixRootfile->Close();
-            }
-            else {
-                LOG(error) << "Could not open file " << alignmentMatrixFileName << "\n Exiting";
-                exit(1);
-            }
-
-            if (matrices) {
-                run->AddAlignmentMatrices(*matrices);
-            }
-            else {
-                LOG(error) << "Alignment required but no matrices found."
-                << "\n Exiting";
-                exit(1);
-            }
-        }
+/* Copyright (C) 2023 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
+   SPDX-License-Identifier: GPL-3.0-only
+   Authors: Dario Ramirez [committer] */
+
+void sts_beam_spot(int n_of_ts = -1, std::string geo_setup_tag = "mcbm_beam_2024_05_08_nickel",
+                   std::string raw_file = "", std::string rec_file = "", std::string geo_file = "",
+                   std::string out_file = "sts_beam_spot.root", bool bAli = true)
+{
+  // -----   Timer   --------------------------------------------------------
+  TStopwatch timer;
+  timer.Start();
+
+  // --- Logger settings ----------------------------------------------------
+  TString logLevel     = "DEBUG";
+  TString logVerbosity = "veryhigh";
+  logLevel             = "INFO";
+  logVerbosity         = "low";
+
+  FairLogger::GetLogger()->SetLogScreenLevel(logLevel.Data());
+  FairLogger::GetLogger()->SetLogVerbosityLevel(logVerbosity.Data());
+  // ------------------------------------------------------------------------
+
+
+  // -----   Environment   --------------------------------------------------
+  std::string srcDir = gSystem->Getenv("VMCWORKDIR");  // top source directory
+  // ------------------------------------------------------------------------
+
+  std::unique_ptr<CbmStsAnalysis> run = std::make_unique<CbmStsAnalysis>();
+
+  FairFileSource* inputSource = new FairFileSource(rec_file.c_str());
+  inputSource->AddFriend(raw_file.c_str());
+
+  FairRootFileSink* outputSink = new FairRootFileSink(out_file.c_str());
+
+
+  if (bAli) {
+    TString alignmentMatrixFileName = srcDir + "/parameters/mcbm/AlignmentMatrices_" + geo_setup_tag + ".root";
+    if (alignmentMatrixFileName.Length() != 0) {
+      std::map<std::string, TGeoHMatrix>* matrices{nullptr};
+      TFile* misalignmentMatrixRootfile = new TFile(alignmentMatrixFileName, "READ");
+      if (misalignmentMatrixRootfile->IsOpen()) {
+        gDirectory->GetObject("MisalignMatrices", matrices);
+        misalignmentMatrixRootfile->Close();
+      }
+      else {
+        LOG(error) << "Could not open file " << alignmentMatrixFileName << "\n Exiting";
+        exit(1);
+      }
+
+      if (matrices) {
+        run->AddAlignmentMatrices(*matrices);
+      }
+      else {
+        LOG(error) << "Alignment required but no matrices found."
+                   << "\n Exiting";
+        exit(1);
+      }
     }
-
-    run->SetGeomFile(geo_file.c_str());
-    run->SetSource(inputSource);
-    run->SetSink(outputSink);
-
-
-    // ------------------------------------------------------------------------
-    // Configure Analysis filters
-    // ------------------------------------------------------------------------
-    CbmCutMap ana_filter;
-    ana_filter.AddCbmCut(CbmCutId::kStsHitCharge)->SetMin(10000);
-    ana_filter.AddCbmCut(CbmCutId::kEventNofStsHit)->SetMin(2);
-
-    // ------------------------------------------------------------------------
-    // Configure mCBM target planes
-    // ------------------------------------------------------------------------
-    double l_k0 = 38.45;
-    double l_k1 = l_k0 + 0.86 + 11.8 + 1.3 + 0.7;
-    double l_b1 = l_k0 + 4.99 + 1.2 + 0.75;
-
-    double beam_rot_y = (25.)*TMath::DegToRad();
-    CbmTarget Ni;
-    Ni.SetPosition(0, 0, 0);
-    Ni.SetRotation(beam_rot_y);
-
-    CbmTarget T0;
-    T0.SetPosition(-20*sin(beam_rot_y), 0, -20*cos(beam_rot_y));
-    T0.SetRotation(beam_rot_y);
-
-    CbmTarget K0;
-    K0.SetPosition(-l_k0*sin(beam_rot_y), 0, -l_k0*cos(beam_rot_y));
-    K0.SetRotation(beam_rot_y);
-
-    CbmTarget B1;
-    B1.SetPosition(-l_b1*sin(beam_rot_y), 0, -l_b1*cos(beam_rot_y));
-    B1.SetRotation(beam_rot_y);
-
-    CbmTarget K1;
-    K1.SetPosition(-l_k1*sin(beam_rot_y), 0, -l_k1*cos(beam_rot_y));
-    K1.SetRotation(beam_rot_y);
-    // ------------------------------------------------------------------------
-
-    CbmStsRecoBeamSpot* sts_bs = new CbmStsRecoBeamSpot();
-    sts_bs->SetCutMap(&ana_filter);
-    sts_bs->AddTarget("Ni",&Ni);
-    sts_bs->AddTarget("T0",&T0);
-    sts_bs->AddTarget("K0",&K0);
-    sts_bs->AddTarget("B1",&B1);
-    sts_bs->AddTarget("K1",&K1);
-
-    run->AddTask(sts_bs);
-
-    run->Init();
-    run->Run(0,n_of_ts);
-
-    // ------------------------------------------------------------------------
-    timer.Stop();
-    Double_t rtime = timer.RealTime();
-    Double_t ctime = timer.CpuTime();
-    cout << endl << endl;
-    cout << "Macro finished successfully." << endl;
-    cout << "Real time " << rtime << " s, CPU time " << ctime << " s" << endl;
-    cout << endl;
-}
\ No newline at end of file
+  }
+
+  run->SetGeomFile(geo_file.c_str());
+  run->SetSource(inputSource);
+  run->SetSink(outputSink);
+
+
+  // ------------------------------------------------------------------------
+  // Configure Analysis filters
+  // ------------------------------------------------------------------------
+  CbmCutMap ana_filter;
+  ana_filter.AddCbmCut(CbmCutId::kStsHitCharge)->SetMin(10000);
+  ana_filter.AddCbmCut(CbmCutId::kEventNofStsHit)->SetMin(2);
+
+  // ------------------------------------------------------------------------
+  // Configure mCBM target planes
+  // ------------------------------------------------------------------------
+  double l_k0 = 38.45;
+  double l_k1 = l_k0 + 0.86 + 11.8 + 1.3 + 0.7;
+  double l_b1 = l_k0 + 4.99 + 1.2 + 0.75;
+
+  double beam_rot_y = (25.) * TMath::DegToRad();
+  CbmTarget Ni;
+  Ni.SetPosition(0, 0, 0);
+  Ni.SetRotation(beam_rot_y);
+
+  CbmTarget T0;
+  T0.SetPosition(-20 * sin(beam_rot_y), 0, -20 * cos(beam_rot_y));
+  T0.SetRotation(beam_rot_y);
+
+  CbmTarget K0;
+  K0.SetPosition(-l_k0 * sin(beam_rot_y), 0, -l_k0 * cos(beam_rot_y));
+  K0.SetRotation(beam_rot_y);
+
+  CbmTarget B1;
+  B1.SetPosition(-l_b1 * sin(beam_rot_y), 0, -l_b1 * cos(beam_rot_y));
+  B1.SetRotation(beam_rot_y);
+
+  CbmTarget K1;
+  K1.SetPosition(-l_k1 * sin(beam_rot_y), 0, -l_k1 * cos(beam_rot_y));
+  K1.SetRotation(beam_rot_y);
+  // ------------------------------------------------------------------------
+
+  CbmStsRecoBeamSpot* sts_bs = new CbmStsRecoBeamSpot();
+  sts_bs->SetCutMap(&ana_filter);
+  sts_bs->AddTarget("Ni", &Ni);
+  sts_bs->AddTarget("T0", &T0);
+  sts_bs->AddTarget("K0", &K0);
+  sts_bs->AddTarget("B1", &B1);
+  sts_bs->AddTarget("K1", &K1);
+
+  run->AddTask(sts_bs);
+
+  run->Init();
+  run->Run(0, n_of_ts);
+
+  // ------------------------------------------------------------------------
+  timer.Stop();
+  Double_t rtime = timer.RealTime();
+  Double_t ctime = timer.CpuTime();
+  cout << endl << endl;
+  cout << "Macro finished successfully." << endl;
+  cout << "Real time " << rtime << " s, CPU time " << ctime << " s" << endl;
+  cout << endl;
+}
diff --git a/macro/sts/sts_correlation.C b/macro/sts/sts_correlation.C
index 866351b603..ac5b37e11b 100644
--- a/macro/sts/sts_correlation.C
+++ b/macro/sts/sts_correlation.C
@@ -1,92 +1,91 @@
-void sts_correlation(
-    int n_of_ts = -1,
-    std::string geo_setup_tag = "mcbm_beam_2024_05_08_nickel",
-    std::string raw_file = "",
-    std::string rec_file = "",
-    std::string geo_file = "",
-    std::string out_file = "cbm_sts_correlation.root",
-    bool bAli = true
-){
-    // -----   Timer   --------------------------------------------------------
-    TStopwatch timer;
-    timer.Start();
-
-    // --- Logger settings ----------------------------------------------------
-    TString logLevel     = "DEBUG";
-    TString logVerbosity = "veryhigh";
-            logLevel     = "INFO";
-            logVerbosity = "low";
-
-    FairLogger::GetLogger()->SetLogScreenLevel(logLevel.Data());
-    FairLogger::GetLogger()->SetLogVerbosityLevel(logVerbosity.Data());
-    // ------------------------------------------------------------------------
-
-
-    // -----   Environment   --------------------------------------------------
-    std::string srcDir = gSystem->Getenv("VMCWORKDIR");  // top source directory
-    // ------------------------------------------------------------------------
-
-    std::unique_ptr<CbmStsAnalysis> run = std::make_unique<CbmStsAnalysis>();
-
-    FairFileSource* inputSource = new FairFileSource(rec_file.c_str());
-    inputSource->AddFriend(raw_file.c_str());
-
-    FairRootFileSink* outputSink = new FairRootFileSink(out_file.c_str());
-
-
-    if (bAli) {
-        TString alignmentMatrixFileName = srcDir + "/parameters/mcbm/AlignmentMatrices_" + geo_setup_tag + ".root";
-        if (alignmentMatrixFileName.Length() != 0) {
-            std::map<std::string, TGeoHMatrix>* matrices{nullptr};
-            TFile* misalignmentMatrixRootfile = new TFile(alignmentMatrixFileName, "READ");
-            if (misalignmentMatrixRootfile->IsOpen()) {
-                gDirectory->GetObject("MisalignMatrices", matrices);
-                misalignmentMatrixRootfile->Close();
-            }
-            else {
-                LOG(error) << "Could not open file " << alignmentMatrixFileName << "\n Exiting";
-                exit(1);
-            }
-
-            if (matrices) {
-                run->AddAlignmentMatrices(*matrices);
-            }
-            else {
-                LOG(error) << "Alignment required but no matrices found."
-                << "\n Exiting";
-                exit(1);
-            }
-        }
+/* Copyright (C) 2023 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
+   SPDX-License-Identifier: GPL-3.0-only
+   Authors: Dario Ramirez [committer] */
+
+void sts_correlation(int n_of_ts = -1, std::string geo_setup_tag = "mcbm_beam_2024_05_08_nickel",
+                     std::string raw_file = "", std::string rec_file = "", std::string geo_file = "",
+                     std::string out_file = "cbm_sts_correlation.root", bool bAli = true)
+{
+  // -----   Timer   --------------------------------------------------------
+  TStopwatch timer;
+  timer.Start();
+
+  // --- Logger settings ----------------------------------------------------
+  TString logLevel     = "DEBUG";
+  TString logVerbosity = "veryhigh";
+  logLevel             = "INFO";
+  logVerbosity         = "low";
+
+  FairLogger::GetLogger()->SetLogScreenLevel(logLevel.Data());
+  FairLogger::GetLogger()->SetLogVerbosityLevel(logVerbosity.Data());
+  // ------------------------------------------------------------------------
+
+
+  // -----   Environment   --------------------------------------------------
+  std::string srcDir = gSystem->Getenv("VMCWORKDIR");  // top source directory
+  // ------------------------------------------------------------------------
+
+  std::unique_ptr<CbmStsAnalysis> run = std::make_unique<CbmStsAnalysis>();
+
+  FairFileSource* inputSource = new FairFileSource(rec_file.c_str());
+  inputSource->AddFriend(raw_file.c_str());
+
+  FairRootFileSink* outputSink = new FairRootFileSink(out_file.c_str());
+
+
+  if (bAli) {
+    TString alignmentMatrixFileName = srcDir + "/parameters/mcbm/AlignmentMatrices_" + geo_setup_tag + ".root";
+    if (alignmentMatrixFileName.Length() != 0) {
+      std::map<std::string, TGeoHMatrix>* matrices{nullptr};
+      TFile* misalignmentMatrixRootfile = new TFile(alignmentMatrixFileName, "READ");
+      if (misalignmentMatrixRootfile->IsOpen()) {
+        gDirectory->GetObject("MisalignMatrices", matrices);
+        misalignmentMatrixRootfile->Close();
+      }
+      else {
+        LOG(error) << "Could not open file " << alignmentMatrixFileName << "\n Exiting";
+        exit(1);
+      }
+
+      if (matrices) {
+        run->AddAlignmentMatrices(*matrices);
+      }
+      else {
+        LOG(error) << "Alignment required but no matrices found."
+                   << "\n Exiting";
+        exit(1);
+      }
     }
-
-    run->SetGeomFile(geo_file.c_str());
-    run->SetSource(inputSource);
-    run->SetSink(outputSink);
-
-
-    // ------------------------------------------------------------------------
-    // Configure Analysis filters
-    // ------------------------------------------------------------------------
-    CbmCutMap ana_filter;
-    ana_filter.AddCbmCut(CbmCutId::kStsHitCharge)->SetMin(10000);
-    ana_filter.AddCbmCut(CbmCutId::kEventNofStsHit)->SetMin(2);
-
-    // ------------------------------------------------------------------------
-    // Configure Correlation
-    // ------------------------------------------------------------------------
-    CbmStsCorrelation* sts_corr = new CbmStsCorrelation();
-    sts_corr->SetCutMap(&ana_filter);
-    run->AddTask(sts_corr);
-
-    run->Init();
-    run->Run(0,n_of_ts);
-
-    // ------------------------------------------------------------------------
-    timer.Stop();
-    Double_t rtime = timer.RealTime();
-    Double_t ctime = timer.CpuTime();
-    cout << endl << endl;
-    cout << "Macro finished successfully." << endl;
-    cout << "Real time " << rtime << " s, CPU time " << ctime << " s" << endl;
-    cout << endl;
-}
\ No newline at end of file
+  }
+
+  run->SetGeomFile(geo_file.c_str());
+  run->SetSource(inputSource);
+  run->SetSink(outputSink);
+
+
+  // ------------------------------------------------------------------------
+  // Configure Analysis filters
+  // ------------------------------------------------------------------------
+  CbmCutMap ana_filter;
+  ana_filter.AddCbmCut(CbmCutId::kStsHitCharge)->SetMin(10000);
+  ana_filter.AddCbmCut(CbmCutId::kEventNofStsHit)->SetMin(2);
+
+  // ------------------------------------------------------------------------
+  // Configure Correlation
+  // ------------------------------------------------------------------------
+  CbmStsCorrelation* sts_corr = new CbmStsCorrelation();
+  sts_corr->SetCutMap(&ana_filter);
+  run->AddTask(sts_corr);
+
+  run->Init();
+  run->Run(0, n_of_ts);
+
+  // ------------------------------------------------------------------------
+  timer.Stop();
+  Double_t rtime = timer.RealTime();
+  Double_t ctime = timer.CpuTime();
+  cout << endl << endl;
+  cout << "Macro finished successfully." << endl;
+  cout << "Real time " << rtime << " s, CPU time " << ctime << " s" << endl;
+  cout << endl;
+}
diff --git a/macro/sts/sts_efficiency.C b/macro/sts/sts_efficiency.C
index 74f1eb84f4..091c43dbc4 100755
--- a/macro/sts/sts_efficiency.C
+++ b/macro/sts/sts_efficiency.C
@@ -1,108 +1,107 @@
-void sts_efficiency(
-    int n_of_ts = -1,
-    std::string geo_setup_tag = "mcbm_beam_2024_05_08_nickel",
-    std::string raw_file = "",
-    std::string rec_file = "",
-    std::string geo_file = "",
-    std::string out_file = "cbm_sts_efficiency.root",
-    bool bAli = true
-){
-    // -----   Timer   --------------------------------------------------------
-    TStopwatch timer;
-    timer.Start();
-
-    // --- Logger settings ----------------------------------------------------
-    TString logLevel     = "DEBUG";
-    TString logVerbosity = "veryhigh";
-            logLevel     = "INFO";
-            logVerbosity = "low";
-
-    FairLogger::GetLogger()->SetLogScreenLevel(logLevel.Data());
-    FairLogger::GetLogger()->SetLogVerbosityLevel(logVerbosity.Data());
-    // ------------------------------------------------------------------------
-
-
-    // -----   Environment   --------------------------------------------------
-    std::string srcDir = gSystem->Getenv("VMCWORKDIR");  // top source directory
-    // ------------------------------------------------------------------------
-
-    std::unique_ptr<CbmStsAnalysis> run = std::make_unique<CbmStsAnalysis>();
-
-    FairFileSource* inputSource = new FairFileSource(rec_file.c_str());
-    inputSource->AddFriend(raw_file.c_str());
-
-    FairRootFileSink* outputSink = new FairRootFileSink(out_file.c_str());
-
-
-    if (bAli) {
-        TString alignmentMatrixFileName = srcDir + "/parameters/mcbm/AlignmentMatrices_" + geo_setup_tag + ".root";
-        if (alignmentMatrixFileName.Length() != 0) {
-            std::map<std::string, TGeoHMatrix>* matrices{nullptr};
-            TFile* misalignmentMatrixRootfile = new TFile(alignmentMatrixFileName, "READ");
-            if (misalignmentMatrixRootfile->IsOpen()) {
-                gDirectory->GetObject("MisalignMatrices", matrices);
-                misalignmentMatrixRootfile->Close();
-            }
-            else {
-                LOG(error) << "Could not open file " << alignmentMatrixFileName << "\n Exiting";
-                exit(1);
-            }
-
-            if (matrices) {
-                run->AddAlignmentMatrices(*matrices);
-            }
-            else {
-                LOG(error) << "Alignment required but no matrices found."
-                << "\n Exiting";
-                exit(1);
-            }
-        }
-    }
-
-    run->SetGeomFile(geo_file.c_str());
-    run->SetSource(inputSource);
-    run->SetSink(outputSink);
-
-
-    // ------------------------------------------------------------------------
-    // Configure Analysis filters
-    // ------------------------------------------------------------------------
-    CbmCutMap ana_filter;
-    ana_filter.AddCbmCut(CbmCutId::kStsHitCharge)->SetMin(10000);
-    ana_filter.AddCbmCut(CbmCutId::kEventNofStsHit)->SetMin(2);
-    ana_filter.AddCbmCut(CbmCutId::kGlobalTrackStsSize)->SetMin(2);
-    ana_filter.AddCbmCut(CbmCutId::kGlobalTrackTrdSize)->SetMin(1);
-    ana_filter.AddCbmCut(CbmCutId::kGlobalTrackTofSize)->SetMin(1);
-    // ana_filter.AddCbmCut(CbmCutId::kGlobalTrackPval)->SetMax(0.005);
-
-    // ------------------------------------------------------------------------
-    // Configure Vertex Finder
-    // ------------------------------------------------------------------------
-    std::shared_ptr<CbmDcaVertexFinder> vertex_finder = std::make_shared<CbmDcaVertexFinder>(0.2);
-
-    // ------------------------------------------------------------------------
-    // Configure Efficiency
-    // ------------------------------------------------------------------------
-    CbmStsEfficiency* sts_eff1 = new CbmStsEfficiency(  1,      // test_layer_(layer_idx)
-                                                        0.25,   // max_dis_trg_vtx_(cut_trg_vtx)
-                                                        0.25,   // max_dca_trk_vtx_(cut_trk_vtx)
-                                                        0.005    // default_residual(def_res)
-    );
-
-    sts_eff1->SetCutMap(&ana_filter);
-    sts_eff1->SetVertexFinder(vertex_finder.get());
-    // sts_eff1->SetResidual("Ref_Sts10_residuals.info");
-    run->AddTask(sts_eff1);
-
-    run->Init();
-    run->Run(0,n_of_ts);
-
-    // ------------------------------------------------------------------------
-    timer.Stop();
-    Double_t rtime = timer.RealTime();
-    Double_t ctime = timer.CpuTime();
-    cout << endl << endl;
-    cout << "Macro finished successfully." << endl;
-    cout << "Real time " << rtime << " s, CPU time " << ctime << " s" << endl;
-    cout << endl;
-}
\ No newline at end of file
+/* Copyright (C) 2023 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
+   SPDX-License-Identifier: GPL-3.0-only
+   Authors: Dario Ramirez [committer] */
+
+void sts_efficiency(int n_of_ts = -1, std::string geo_setup_tag = "mcbm_beam_2024_05_08_nickel",
+                    std::string raw_file = "", std::string rec_file = "", std::string geo_file = "",
+                    std::string out_file = "cbm_sts_efficiency.root", bool bAli = true)
+{
+  // -----   Timer   --------------------------------------------------------
+  TStopwatch timer;
+  timer.Start();
+
+  // --- Logger settings ----------------------------------------------------
+  TString logLevel     = "DEBUG";
+  TString logVerbosity = "veryhigh";
+  logLevel             = "INFO";
+  logVerbosity         = "low";
+
+  FairLogger::GetLogger()->SetLogScreenLevel(logLevel.Data());
+  FairLogger::GetLogger()->SetLogVerbosityLevel(logVerbosity.Data());
+  // ------------------------------------------------------------------------
+
+
+  // -----   Environment   --------------------------------------------------
+  std::string srcDir = gSystem->Getenv("VMCWORKDIR");  // top source directory
+  // ------------------------------------------------------------------------
+
+  std::unique_ptr<CbmStsAnalysis> run = std::make_unique<CbmStsAnalysis>();
+
+  FairFileSource* inputSource = new FairFileSource(rec_file.c_str());
+  inputSource->AddFriend(raw_file.c_str());
+
+  FairRootFileSink* outputSink = new FairRootFileSink(out_file.c_str());
+
+
+  if (bAli) {
+    TString alignmentMatrixFileName = srcDir + "/parameters/mcbm/AlignmentMatrices_" + geo_setup_tag + ".root";
+    if (alignmentMatrixFileName.Length() != 0) {
+      std::map<std::string, TGeoHMatrix>* matrices{nullptr};
+      TFile* misalignmentMatrixRootfile = new TFile(alignmentMatrixFileName, "READ");
+      if (misalignmentMatrixRootfile->IsOpen()) {
+        gDirectory->GetObject("MisalignMatrices", matrices);
+        misalignmentMatrixRootfile->Close();
+      }
+      else {
+        LOG(error) << "Could not open file " << alignmentMatrixFileName << "\n Exiting";
+        exit(1);
+      }
+
+      if (matrices) {
+        run->AddAlignmentMatrices(*matrices);
+      }
+      else {
+        LOG(error) << "Alignment required but no matrices found."
+                   << "\n Exiting";
+        exit(1);
+      }
+    }
+  }
+
+  run->SetGeomFile(geo_file.c_str());
+  run->SetSource(inputSource);
+  run->SetSink(outputSink);
+
+
+  // ------------------------------------------------------------------------
+  // Configure Analysis filters
+  // ------------------------------------------------------------------------
+  CbmCutMap ana_filter;
+  ana_filter.AddCbmCut(CbmCutId::kStsHitCharge)->SetMin(10000);
+  ana_filter.AddCbmCut(CbmCutId::kEventNofStsHit)->SetMin(2);
+  ana_filter.AddCbmCut(CbmCutId::kGlobalTrackStsSize)->SetMin(2);
+  ana_filter.AddCbmCut(CbmCutId::kGlobalTrackTrdSize)->SetMin(1);
+  ana_filter.AddCbmCut(CbmCutId::kGlobalTrackTofSize)->SetMin(1);
+  // ana_filter.AddCbmCut(CbmCutId::kGlobalTrackPval)->SetMax(0.005);
+
+  // ------------------------------------------------------------------------
+  // Configure Vertex Finder
+  // ------------------------------------------------------------------------
+  std::shared_ptr<CbmDcaVertexFinder> vertex_finder = std::make_shared<CbmDcaVertexFinder>(0.2);
+
+  // ------------------------------------------------------------------------
+  // Configure Efficiency
+  // ------------------------------------------------------------------------
+  CbmStsEfficiency* sts_eff1 = new CbmStsEfficiency(1,     // test_layer_(layer_idx)
+                                                    0.25,  // max_dis_trg_vtx_(cut_trg_vtx)
+                                                    0.25,  // max_dca_trk_vtx_(cut_trk_vtx)
+                                                    0.005  // default_residual(def_res)
+  );
+
+  sts_eff1->SetCutMap(&ana_filter);
+  sts_eff1->SetVertexFinder(vertex_finder.get());
+  // sts_eff1->SetResidual("Ref_Sts10_residuals.info");
+  run->AddTask(sts_eff1);
+
+  run->Init();
+  run->Run(0, n_of_ts);
+
+  // ------------------------------------------------------------------------
+  timer.Stop();
+  Double_t rtime = timer.RealTime();
+  Double_t ctime = timer.CpuTime();
+  cout << endl << endl;
+  cout << "Macro finished successfully." << endl;
+  cout << "Real time " << rtime << " s, CPU time " << ctime << " s" << endl;
+  cout << endl;
+}
diff --git a/macro/sts/sts_hit_ana.C b/macro/sts/sts_hit_ana.C
index 4f764f1e91..327d69b2ba 100644
--- a/macro/sts/sts_hit_ana.C
+++ b/macro/sts/sts_hit_ana.C
@@ -1,100 +1,97 @@
-
-void sts_hit_ana(
-    int n_of_ts = -1,
-    std::string geo_setup_tag = "mcbm_beam_2024_05_08_nickel",
-    std::string raw_file = "",
-    std::string rec_file = "",
-    std::string geo_file = "",
-    std::string out_file = "cbm_sts_hit_ana.root",
-    bool bAli = true
-){
-    // -----   Timer   --------------------------------------------------------
-    TStopwatch timer;
-    timer.Start();
-
-    // --- Logger settings ----------------------------------------------------
-    TString logLevel     = "DEBUG";
-    TString logVerbosity = "veryhigh";
-            logLevel     = "INFO";
-            logVerbosity = "low";
-
-    FairLogger::GetLogger()->SetLogScreenLevel(logLevel.Data());
-    FairLogger::GetLogger()->SetLogVerbosityLevel(logVerbosity.Data());
-    // ------------------------------------------------------------------------
-
-
-    // -----   Environment   --------------------------------------------------
-    std::string srcDir = gSystem->Getenv("VMCWORKDIR");  // top source directory
-    // ------------------------------------------------------------------------
-
-    std::unique_ptr<CbmStsAnalysis> run = std::make_unique<CbmStsAnalysis>();
-
-    FairFileSource* inputSource = new FairFileSource(rec_file.c_str());
-    inputSource->AddFriend(raw_file.c_str());
-
-    FairRootFileSink* outputSink = new FairRootFileSink(out_file.c_str());
-
-
-    if (bAli) {
-        TString alignmentMatrixFileName = srcDir + "/parameters/mcbm/AlignmentMatrices_" + geo_setup_tag + ".root";
-        if (alignmentMatrixFileName.Length() != 0) {
-            std::map<std::string, TGeoHMatrix>* matrices{nullptr};
-            TFile* misalignmentMatrixRootfile = new TFile(alignmentMatrixFileName, "READ");
-            if (misalignmentMatrixRootfile->IsOpen()) {
-                gDirectory->GetObject("MisalignMatrices", matrices);
-                misalignmentMatrixRootfile->Close();
-            }
-            else {
-                LOG(error) << "Could not open file " << alignmentMatrixFileName << "\n Exiting";
-                exit(1);
-            }
-
-            if (matrices) {
-                run->AddAlignmentMatrices(*matrices);
-            }
-            else {
-                LOG(error) << "Alignment required but no matrices found."
-                << "\n Exiting";
-                exit(1);
-            }
-        }
+/* Copyright (C) 2023 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
+   SPDX-License-Identifier: GPL-3.0-only
+   Authors: Dario Ramirez [committer] */
+
+void sts_hit_ana(int n_of_ts = -1, std::string geo_setup_tag = "mcbm_beam_2024_05_08_nickel", std::string raw_file = "",
+                 std::string rec_file = "", std::string geo_file = "", std::string out_file = "cbm_sts_hit_ana.root",
+                 bool bAli = true)
+{
+  // -----   Timer   --------------------------------------------------------
+  TStopwatch timer;
+  timer.Start();
+
+  // --- Logger settings ----------------------------------------------------
+  TString logLevel     = "DEBUG";
+  TString logVerbosity = "veryhigh";
+  logLevel             = "INFO";
+  logVerbosity         = "low";
+
+  FairLogger::GetLogger()->SetLogScreenLevel(logLevel.Data());
+  FairLogger::GetLogger()->SetLogVerbosityLevel(logVerbosity.Data());
+  // ------------------------------------------------------------------------
+
+
+  // -----   Environment   --------------------------------------------------
+  std::string srcDir = gSystem->Getenv("VMCWORKDIR");  // top source directory
+  // ------------------------------------------------------------------------
+
+  std::unique_ptr<CbmStsAnalysis> run = std::make_unique<CbmStsAnalysis>();
+
+  FairFileSource* inputSource = new FairFileSource(rec_file.c_str());
+  inputSource->AddFriend(raw_file.c_str());
+
+  FairRootFileSink* outputSink = new FairRootFileSink(out_file.c_str());
+
+
+  if (bAli) {
+    TString alignmentMatrixFileName = srcDir + "/parameters/mcbm/AlignmentMatrices_" + geo_setup_tag + ".root";
+    if (alignmentMatrixFileName.Length() != 0) {
+      std::map<std::string, TGeoHMatrix>* matrices{nullptr};
+      TFile* misalignmentMatrixRootfile = new TFile(alignmentMatrixFileName, "READ");
+      if (misalignmentMatrixRootfile->IsOpen()) {
+        gDirectory->GetObject("MisalignMatrices", matrices);
+        misalignmentMatrixRootfile->Close();
+      }
+      else {
+        LOG(error) << "Could not open file " << alignmentMatrixFileName << "\n Exiting";
+        exit(1);
+      }
+
+      if (matrices) {
+        run->AddAlignmentMatrices(*matrices);
+      }
+      else {
+        LOG(error) << "Alignment required but no matrices found."
+                   << "\n Exiting";
+        exit(1);
+      }
     }
-
-    run->SetGeomFile(geo_file.c_str());
-    run->SetSource(inputSource);
-    run->SetSink(outputSink);
-
-
-    // ------------------------------------------------------------------------
-    // Configure Analysis filters
-    // ------------------------------------------------------------------------
-    CbmCutMap ana_filter;
-    // Filter for all STS hits
-    ana_filter.AddCbmCut(CbmCutId::kStsHitQasym)->SetRange(-0.8, +0.8);
-    ana_filter.AddCbmCut(CbmCutId::kStsHitCharge)->SetMin(10000);
-
-    // Filter for track to extract STS hits tracks
-    ana_filter.AddCbmCut(CbmCutId::kGlobalTrackStsSize)->SetMin(2);
-    ana_filter.AddCbmCut(CbmCutId::kGlobalTrackTrdSize)->SetMin(1);
-    ana_filter.AddCbmCut(CbmCutId::kGlobalTrackTofSize)->SetMin(1);
-
-    // ------------------------------------------------------------------------
-    // Configure Charge Analysis
-    // ------------------------------------------------------------------------
-    CbmStsHitAna* sts_hit = new CbmStsHitAna(Form("%s/parameters/sts/sts_charge_cal_v24a.par", srcDir.c_str()));
-
-    sts_hit->SetCutMap(&ana_filter);
-    run->AddTask(sts_hit);
-
-    run->Init();
-    run->Run(0, n_of_ts);
-
-    // ------------------------------------------------------------------------
-    timer.Stop();
-    Double_t rtime = timer.RealTime();
-    Double_t ctime = timer.CpuTime();
-    cout << endl << endl;
-    cout << "Macro finished successfully." << endl;
-    cout << "Real time " << rtime << " s, CPU time " << ctime << " s" << endl;
-    cout << endl;
-}
\ No newline at end of file
+  }
+
+  run->SetGeomFile(geo_file.c_str());
+  run->SetSource(inputSource);
+  run->SetSink(outputSink);
+
+
+  // ------------------------------------------------------------------------
+  // Configure Analysis filters
+  // ------------------------------------------------------------------------
+  CbmCutMap ana_filter;
+  // Filter for all STS hits
+  ana_filter.AddCbmCut(CbmCutId::kStsHitQasym)->SetRange(-0.8, +0.8);
+  ana_filter.AddCbmCut(CbmCutId::kStsHitCharge)->SetMin(10000);
+
+  // Filter for track to extract STS hits tracks
+  ana_filter.AddCbmCut(CbmCutId::kGlobalTrackStsSize)->SetMin(2);
+  ana_filter.AddCbmCut(CbmCutId::kGlobalTrackTrdSize)->SetMin(1);
+  ana_filter.AddCbmCut(CbmCutId::kGlobalTrackTofSize)->SetMin(1);
+
+  // ------------------------------------------------------------------------
+  // Configure Charge Analysis
+  // ------------------------------------------------------------------------
+  CbmStsHitAna* sts_hit = new CbmStsHitAna(Form("%s/parameters/sts/sts_charge_cal_v24a.par", srcDir.c_str()));
+  sts_hit->SetCutMap(&ana_filter);
+  run->AddTask(sts_hit);
+
+  run->Init();
+  run->Run(0, n_of_ts);
+
+  // ------------------------------------------------------------------------
+  timer.Stop();
+  Double_t rtime = timer.RealTime();
+  Double_t ctime = timer.CpuTime();
+  cout << endl << endl;
+  cout << "Macro finished successfully." << endl;
+  cout << "Real time " << rtime << " s, CPU time " << ctime << " s" << endl;
+  cout << endl;
+}
diff --git a/macro/sts/sts_resolution.C b/macro/sts/sts_resolution.C
index 5941f39bc1..75404c6926 100755
--- a/macro/sts/sts_resolution.C
+++ b/macro/sts/sts_resolution.C
@@ -1,103 +1,98 @@
-void sts_resolution(
-    int n_of_ts = -1,
-    std::string geo_setup_tag = "mcbm_beam_2024_05_08_nickel",
-    std::string raw_file = "",
-    std::string rec_file = "",
-    std::string geo_file = "",
-    std::string out_file = "cbm_sts_correlation.root",
-    bool bAli = true
-){
-    // -----   Timer   --------------------------------------------------------
-    TStopwatch timer;
-    timer.Start();
-
-    // --- Logger settings ----------------------------------------------------
-    TString logLevel     = "DEBUG";
-    TString logVerbosity = "veryhigh";
-            logLevel     = "INFO";
-            logVerbosity = "low";
-
-    FairLogger::GetLogger()->SetLogScreenLevel(logLevel.Data());
-    FairLogger::GetLogger()->SetLogVerbosityLevel(logVerbosity.Data());
-    // ------------------------------------------------------------------------
-
-
-    // -----   Environment   --------------------------------------------------
-    std::string srcDir = gSystem->Getenv("VMCWORKDIR");  // top source directory
-    // ------------------------------------------------------------------------
-
-    std::unique_ptr<CbmStsAnalysis> run = std::make_unique<CbmStsAnalysis>();
-
-    FairFileSource* inputSource = new FairFileSource(rec_file.c_str());
-    inputSource->AddFriend(raw_file.c_str());
-
-    FairRootFileSink* outputSink = new FairRootFileSink(out_file.c_str());
-
-
-    if (bAli) {
-        TString alignmentMatrixFileName = srcDir + "/parameters/mcbm/AlignmentMatrices_" + geo_setup_tag + ".root";
-        if (alignmentMatrixFileName.Length() != 0) {
-            std::map<std::string, TGeoHMatrix>* matrices{nullptr};
-            TFile* misalignmentMatrixRootfile = new TFile(alignmentMatrixFileName, "READ");
-            if (misalignmentMatrixRootfile->IsOpen()) {
-                gDirectory->GetObject("MisalignMatrices", matrices);
-                misalignmentMatrixRootfile->Close();
-            }
-            else {
-                LOG(error) << "Could not open file " << alignmentMatrixFileName << "\n Exiting";
-                exit(1);
-            }
-
-            if (matrices) {
-                run->AddAlignmentMatrices(*matrices);
-            }
-            else {
-                LOG(error) << "Alignment required but no matrices found."
-                << "\n Exiting";
-                exit(1);
-            }
-        }
-    }
-
-    run->SetGeomFile(geo_file.c_str());
-    run->SetSource(inputSource);
-    run->SetSink(outputSink);
-
-
-    // ------------------------------------------------------------------------
-    // Configure filters
-    // ------------------------------------------------------------------------
-    CbmCutMap ana_filter;
-    ana_filter.AddCbmCut(CbmCutId::kEventNofGlobalTrack)->SetMin(1);
-    ana_filter.AddCbmCut(CbmCutId::kGlobalTrackStsSize)->SetMin(2);
-    ana_filter.AddCbmCut(CbmCutId::kGlobalTrackTrdSize)->SetMin(1);
-    ana_filter.AddCbmCut(CbmCutId::kGlobalTrackTofSize)->SetMin(1);
-    ana_filter.AddCbmCut(CbmCutId::kGlobalTrackPval)->SetMax(0.5);
-
-    // ------------------------------------------------------------------------
-    // Configure analysis
-    // ------------------------------------------------------------------------
-    CbmStsResolution* sts_resolution = new CbmStsResolution(0.5);
-    sts_resolution->SetCutMap(&ana_filter);
-
-    sts_resolution->EnableRefSensor(0x10000002); // U0 L0 U0
-    // sts_resolution->EnableRefSensor(0x10008422); // U1 L1 U0
-    sts_resolution->EnableRefSensor(0x10018422); // U1 L1 U1
-
-    sts_resolution->SetMinTrkHitQ(10000);
-
-    run->AddTask(sts_resolution);
-
-    run->Init();
-    run->Run(0,n_of_ts);
-
-    ana_filter.Print();
-    // ------------------------------------------------------------------------
-    timer.Stop();
-    Double_t rtime = timer.RealTime();
-    Double_t ctime = timer.CpuTime();
-    cout << endl << endl;
-    cout << "Macro finished successfully." << endl;
-    cout << "Real time " << rtime << " s, CPU time " << ctime << " s" << endl;
-    cout << endl;
-}
\ No newline at end of file
+/* Copyright (C) 2023 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
+   SPDX-License-Identifier: GPL-3.0-only
+   Authors: Dario Ramirez [committer] */
+
+void sts_resolution(int n_of_ts = -1, std::string geo_setup_tag = "mcbm_beam_2024_05_08_nickel",
+                    std::string raw_file = "", std::string rec_file = "", std::string geo_file = "",
+                    std::string out_file = "cbm_sts_correlation.root", bool bAli = true)
+{
+  // -----   Timer   --------------------------------------------------------
+  TStopwatch timer;
+  timer.Start();
+
+  // --- Logger settings ----------------------------------------------------
+  TString logLevel     = "DEBUG";
+  TString logVerbosity = "veryhigh";
+  logLevel             = "INFO";
+  logVerbosity         = "low";
+
+  FairLogger::GetLogger()->SetLogScreenLevel(logLevel.Data());
+  FairLogger::GetLogger()->SetLogVerbosityLevel(logVerbosity.Data());
+  // ------------------------------------------------------------------------
+
+
+  // -----   Environment   --------------------------------------------------
+  std::string srcDir = gSystem->Getenv("VMCWORKDIR");  // top source directory
+  // ------------------------------------------------------------------------
+
+  std::unique_ptr<CbmStsAnalysis> run = std::make_unique<CbmStsAnalysis>();
+
+  FairFileSource* inputSource = new FairFileSource(rec_file.c_str());
+  inputSource->AddFriend(raw_file.c_str());
+
+  FairRootFileSink* outputSink = new FairRootFileSink(out_file.c_str());
+
+
+  if (bAli) {
+    TString alignmentMatrixFileName = srcDir + "/parameters/mcbm/AlignmentMatrices_" + geo_setup_tag + ".root";
+    if (alignmentMatrixFileName.Length() != 0) {
+      std::map<std::string, TGeoHMatrix>* matrices{nullptr};
+      TFile* misalignmentMatrixRootfile = new TFile(alignmentMatrixFileName, "READ");
+      if (misalignmentMatrixRootfile->IsOpen()) {
+        gDirectory->GetObject("MisalignMatrices", matrices);
+        misalignmentMatrixRootfile->Close();
+      }
+      else {
+        LOG(error) << "Could not open file " << alignmentMatrixFileName << "\n Exiting";
+        exit(1);
+      }
+
+      if (matrices) {
+        run->AddAlignmentMatrices(*matrices);
+      }
+      else {
+        LOG(error) << "Alignment required but no matrices found."
+                   << "\n Exiting";
+        exit(1);
+      }
+    }
+  }
+
+  run->SetGeomFile(geo_file.c_str());
+  run->SetSource(inputSource);
+  run->SetSink(outputSink);
+
+
+  // ------------------------------------------------------------------------
+  // Configure filters
+  // ------------------------------------------------------------------------
+  CbmCutMap ana_filter;
+  ana_filter.AddCbmCut(CbmCutId::kEventNofGlobalTrack)->SetMin(1);
+  ana_filter.AddCbmCut(CbmCutId::kGlobalTrackStsSize)->SetMin(2);
+  ana_filter.AddCbmCut(CbmCutId::kGlobalTrackTrdSize)->SetMin(1);
+  ana_filter.AddCbmCut(CbmCutId::kGlobalTrackTofSize)->SetMin(1);
+  ana_filter.AddCbmCut(CbmCutId::kGlobalTrackPval)->SetMax(0.5);
+
+  // ------------------------------------------------------------------------
+  // Configure analysis
+  // ------------------------------------------------------------------------
+  CbmStsResolution* sts_resolution = new CbmStsResolution(0.5);
+  sts_resolution->SetCutMap(&ana_filter);
+  sts_resolution->EnableRefSensor(0x10000002);  // U0 L0 U0
+  sts_resolution->EnableRefSensor(0x10018422);  // U1 L1 U1
+  sts_resolution->SetMinTrkHitQ(10000);
+  run->AddTask(sts_resolution);
+
+  run->Init();
+  run->Run(0, n_of_ts);
+
+  ana_filter.Print();
+  // ------------------------------------------------------------------------
+  timer.Stop();
+  Double_t rtime = timer.RealTime();
+  Double_t ctime = timer.CpuTime();
+  cout << endl << endl;
+  cout << "Macro finished successfully." << endl;
+  cout << "Real time " << rtime << " s, CPU time " << ctime << " s" << endl;
+  cout << endl;
+}
diff --git a/macro/sts/sts_time.C b/macro/sts/sts_time.C
index 455df4139d..64a4013a31 100644
--- a/macro/sts/sts_time.C
+++ b/macro/sts/sts_time.C
@@ -1,56 +1,56 @@
-
-void sts_time(
-    int run_id = 2984,
-    int n_of_ts = 2,
-    std::string raw_file = "",
-    std::string out_file = "cbm_sts_time_cal.root"
-){
-    // -----   Timer   --------------------------------------------------------
-    TStopwatch timer;
-    timer.Start();
-
-    // --- Logger settings ----------------------------------------------------
-    TString logLevel     = "DEBUG";
-    TString logVerbosity = "veryhigh";
-            logLevel     = "INFO";
-            logVerbosity = "low";
-
-    FairLogger::GetLogger()->SetLogScreenLevel(logLevel.Data());
-    FairLogger::GetLogger()->SetLogVerbosityLevel(logVerbosity.Data());
-    // ------------------------------------------------------------------------
-
-
-    // -----   Environment   --------------------------------------------------
-    std::string srcDir = gSystem->Getenv("VMCWORKDIR");  // top source directory
-    // ------------------------------------------------------------------------
-
-    std::unique_ptr<CbmStsAnalysis> run = std::make_unique<CbmStsAnalysis>();
-    FairFileSource* inputSource = new FairFileSource(raw_file.c_str());
-    FairRootFileSink* outputSink = new FairRootFileSink(out_file.c_str());
-
-    run->SetSource(inputSource);
-    run->SetSink(outputSink);
-
-    // ------------------------------------------------------------------------
-    // Configure Analysis filters
-    // ------------------------------------------------------------------------
-    CbmCutMap ana_filter;
-    ana_filter.AddCbmCut(CbmCutId::kBmonDigiSide)->SetRange(1, 1);
-
-    CbmStsTimeCal* sts_time = new CbmStsTimeCal(run_id, ECbmModuleId::kBmon, -100, 100);
-    sts_time->SetCutMap(&ana_filter);
-    sts_time->SetWalkFile(Form("%s/parameters/online/StsWalkMap_mcbm2024.yaml", srcDir.c_str()));
-    run->AddTask(sts_time);
-
-    run->Init();
-    run->Run(0,n_of_ts);
-
-    // ------------------------------------------------------------------------
-    timer.Stop();
-    Double_t rtime = timer.RealTime();
-    Double_t ctime = timer.CpuTime();
-    cout << endl << endl;
-    cout << "Macro finished successfully." << endl;
-    cout << "Real time " << rtime << " s, CPU time " << ctime << " s" << endl;
-    cout << endl;
-}
\ No newline at end of file
+/* Copyright (C) 2023 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
+   SPDX-License-Identifier: GPL-3.0-only
+   Authors: Dario Ramirez [committer] */
+
+void sts_time(int run_id = 2984, int n_of_ts = 2, std::string raw_file = "",
+              std::string out_file = "cbm_sts_time_cal.root")
+{
+  // -----   Timer   --------------------------------------------------------
+  TStopwatch timer;
+  timer.Start();
+
+  // --- Logger settings ----------------------------------------------------
+  TString logLevel     = "DEBUG";
+  TString logVerbosity = "veryhigh";
+  logLevel             = "INFO";
+  logVerbosity         = "low";
+
+  FairLogger::GetLogger()->SetLogScreenLevel(logLevel.Data());
+  FairLogger::GetLogger()->SetLogVerbosityLevel(logVerbosity.Data());
+  // ------------------------------------------------------------------------
+
+
+  // -----   Environment   --------------------------------------------------
+  std::string srcDir = gSystem->Getenv("VMCWORKDIR");  // top source directory
+  // ------------------------------------------------------------------------
+
+  std::unique_ptr<CbmStsAnalysis> run = std::make_unique<CbmStsAnalysis>();
+  FairFileSource* inputSource         = new FairFileSource(raw_file.c_str());
+  FairRootFileSink* outputSink        = new FairRootFileSink(out_file.c_str());
+
+  run->SetSource(inputSource);
+  run->SetSink(outputSink);
+
+  // ------------------------------------------------------------------------
+  // Configure Analysis filters
+  // ------------------------------------------------------------------------
+  CbmCutMap ana_filter;
+  ana_filter.AddCbmCut(CbmCutId::kBmonDigiSide)->SetRange(1, 1);
+
+  CbmStsTimeCal* sts_time = new CbmStsTimeCal(run_id, ECbmModuleId::kBmon, -100, 100);
+  sts_time->SetCutMap(&ana_filter);
+  sts_time->SetWalkFile(Form("%s/parameters/online/StsWalkMap_mcbm2024.yaml", srcDir.c_str()));
+  run->AddTask(sts_time);
+
+  run->Init();
+  run->Run(0, n_of_ts);
+
+  // ------------------------------------------------------------------------
+  timer.Stop();
+  Double_t rtime = timer.RealTime();
+  Double_t ctime = timer.CpuTime();
+  cout << endl << endl;
+  cout << "Macro finished successfully." << endl;
+  cout << "Real time " << rtime << " s, CPU time " << ctime << " s" << endl;
+  cout << endl;
+}
-- 
GitLab


From 7ae330f64eb29c529fffb263e7f2affec6723283 Mon Sep 17 00:00:00 2001
From: Dario Ramirez <d.ramirez@gsi.de>
Date: Wed, 23 Apr 2025 11:13:47 +0200
Subject: [PATCH 14/18] Add CbmCut test

---
 analysis/detectors/sts/CMakeLists.txt         |  4 ++
 analysis/detectors/sts/CbmCut.h               | 23 ++++++-
 analysis/detectors/sts/CbmCutMap.cxx          |  3 +-
 analysis/detectors/sts/CbmStsUtils.cxx        |  4 ++
 analysis/detectors/sts/tests/CMakeLists.txt   | 27 +++++++++
 analysis/detectors/sts/tests/_GTestCbmCut.cxx | 60 +++++++++++++++++++
 6 files changed, 117 insertions(+), 4 deletions(-)
 create mode 100644 analysis/detectors/sts/tests/CMakeLists.txt
 create mode 100644 analysis/detectors/sts/tests/_GTestCbmCut.cxx

diff --git a/analysis/detectors/sts/CMakeLists.txt b/analysis/detectors/sts/CMakeLists.txt
index 11179a1211..ecb7c91bb2 100644
--- a/analysis/detectors/sts/CMakeLists.txt
+++ b/analysis/detectors/sts/CMakeLists.txt
@@ -43,3 +43,7 @@ install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/CbmCut.h
   DESTINATION include)
 
 generate_cbm_library()
+
+If(GTEST_FOUND)
+  add_subdirectory(tests)
+EndIf()
diff --git a/analysis/detectors/sts/CbmCut.h b/analysis/detectors/sts/CbmCut.h
index d432882b6c..0cf82b4724 100644
--- a/analysis/detectors/sts/CbmCut.h
+++ b/analysis/detectors/sts/CbmCut.h
@@ -16,7 +16,7 @@ class CbmCut {
    * @brief Default constructor
    * Any check done to a non-configured object CbmCut will pass
     */
-  CbmCut() {}
+  CbmCut() = default;
 
   /**
    * @brief Add a CbmTarget object to the list of targets with a key as trg_name.
@@ -74,10 +74,27 @@ class CbmCut {
     return out;
   }
 
+  T GetMin() const
+  {
+    return min_;
+  }
+  T GetMax() const
+  {
+    return max_;
+  }
+  bool GetMinState() const
+  {
+    return min_state_;
+  }
+  bool GetMaxState() const
+  {
+    return max_state_;
+  }
+
 
  private:
-  bool min_state_ = false;
-  bool max_state_ = false;
+  bool min_state_{false};
+  bool max_state_{false};
   T min_;
   T max_;
 };
diff --git a/analysis/detectors/sts/CbmCutMap.cxx b/analysis/detectors/sts/CbmCutMap.cxx
index 950df44a87..1eadf95aba 100644
--- a/analysis/detectors/sts/CbmCutMap.cxx
+++ b/analysis/detectors/sts/CbmCutMap.cxx
@@ -9,7 +9,7 @@ CbmCut<float>* CbmCutMap::AddCbmCut(CbmCutId id) { return &cbm_cuts_[id]; }
 bool CbmCutMap::Check(CbmCutId id, double value)
 {
   if (!cbm_cuts_.count(id)) {
-    failed_pass_counter_[id] = 0;  //HARDCODE: Why to create this cut??????
+    failed_pass_counter_[id] = 0;
     return true;
   }
   bool check_result        = cbm_cuts_[id].Check(value);
@@ -20,6 +20,7 @@ bool CbmCutMap::Check(CbmCutId id, double value)
 bool CbmCutMap::CheckStsHit(CbmStsHit* hit, TClonesArray* clu_array = nullptr)
 {
   if (hit == nullptr) return false;
+
   if (clu_array != nullptr) {
     if (!Check(CbmCutId::kStsHitCharge, cbm_sts_utils::GetHitCharge(hit, clu_array))) {
       return false;
diff --git a/analysis/detectors/sts/CbmStsUtils.cxx b/analysis/detectors/sts/CbmStsUtils.cxx
index a51244af3e..c3b0c0c1bb 100644
--- a/analysis/detectors/sts/CbmStsUtils.cxx
+++ b/analysis/detectors/sts/CbmStsUtils.cxx
@@ -8,6 +8,8 @@
 #include "CbmStsCluster.h"
 #include "CbmStsParSetModule.h"
 
+#include <cassert>
+
 int32_t cbm_sts_utils::GetHitCluSizeF(CbmStsHit* hit, TClonesArray* sts_clu_array)
 {
   if (hit == nullptr || sts_clu_array == nullptr) {
@@ -82,6 +84,8 @@ double cbm_sts_utils::GetHitChargeAsy(CbmStsHit* hit, TClonesArray* sts_clu_arra
 std::pair<cbm_sts_utils::HBinning, cbm_sts_utils::HBinning>
 cbm_sts_utils::ChargeBinning(const CbmStsParModule& par_module, const uint32_t max_clu_size)
 {
+  assert(("Maximum cluster size must be greater than 0", max_clu_size > 0));
+
   auto par_asic = par_module.GetAsicParams();
 
   double n_side_q_thr = par_asic[0].GetThreshold();
diff --git a/analysis/detectors/sts/tests/CMakeLists.txt b/analysis/detectors/sts/tests/CMakeLists.txt
new file mode 100644
index 0000000000..49e69527ae
--- /dev/null
+++ b/analysis/detectors/sts/tests/CMakeLists.txt
@@ -0,0 +1,27 @@
+# CMakeList file for library libStsAna dedicated tests
+# Last update: Dario Ramirez, 23.04.2025
+
+Function(AddBasicTest name)
+  set(PVT_DEPS
+    Gtest
+    GtestMain
+    CbmData
+    CbmStsBase
+    CbmStsAna
+  )
+
+  add_executable(${name} ${name}.cxx)
+  target_include_directories(${name} PRIVATE ${INCLUDE_DIRECTORIES})
+  target_link_libraries(${name} PRIVATE ${PVT_DEPS})
+  Add_Test(
+    NAME ${name}
+    COMMAND ${name}
+    WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
+  )
+EndFunction()
+
+set(INCLUDE_DIRECTORIES
+  ${CMAKE_SOURCE_DIR}/analysis/detectors/sts
+  )
+
+AddBasicTest(_GTestCbmCut)
diff --git a/analysis/detectors/sts/tests/_GTestCbmCut.cxx b/analysis/detectors/sts/tests/_GTestCbmCut.cxx
new file mode 100644
index 0000000000..a217e75b8f
--- /dev/null
+++ b/analysis/detectors/sts/tests/_GTestCbmCut.cxx
@@ -0,0 +1,60 @@
+/* Copyright (C) 2016-2020 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
+   SPDX-License-Identifier: GPL-3.0-only
+   Authors: Dario Ramirez [committer] */
+
+#include "CbmCut.h"
+#include "gtest/gtest.h"
+
+TEST(_GTestCbmCut, DefConstructor)
+{
+    CbmCut<float> cut;
+    EXPECT_EQ(false, cut.GetMinState());
+    EXPECT_EQ(false, cut.GetMaxState());
+}
+
+TEST(_GTestCbmCut, ParConstructor)
+{
+    float min = -100;
+    float max = +100;
+    CbmCut<float> cut(min, max);
+    EXPECT_EQ(true, cut.GetMinState());
+    EXPECT_EQ(true, cut.GetMaxState());
+    EXPECT_EQ(min, cut.GetMin());
+    EXPECT_EQ(max, cut.GetMax());
+}
+
+TEST(_GTestCbmCut, CheckOnDefConstructor)
+{
+    CbmCut<float> cut;
+    for (float i = -1e+6; i < 1e+6; i++) {
+        EXPECT_EQ(true, cut.Check(i));
+    }
+}
+
+TEST(_GTestCbmCut, CheckCase1)
+{
+    float min = -100;
+    float max = +100;
+    CbmCut<float> cut(min, max);
+    for (float i = -1e+6; i < 1e+6; i++) {
+        if (i < min || i > max) {
+            EXPECT_EQ(false, cut.Check(i));
+        } else {
+            EXPECT_EQ(true, cut.Check(i));
+        }
+    }
+}
+
+TEST(_GTestCbmCut, CheckCase2)
+{
+    float min = +100;
+    float max = -100;
+    CbmCut<float> cut(min, max);
+    for (float i = -1e+6; i < 1e+6; i++) {
+        if (i <= max || i >= min) {
+            EXPECT_EQ(true, cut.Check(i));
+        } else {
+            EXPECT_EQ(false, cut.Check(i));
+        }
+    }
+}
-- 
GitLab


From 5941fc158706be22d3491a523c711e98c8e69971 Mon Sep 17 00:00:00 2001
From: Dario Ramirez <d.ramirez@gsi.de>
Date: Wed, 23 Apr 2025 11:27:37 +0200
Subject: [PATCH 15/18] Add documentation to StsUtils address-related methods

---
 analysis/detectors/sts/CbmStsUtils.h | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/analysis/detectors/sts/CbmStsUtils.h b/analysis/detectors/sts/CbmStsUtils.h
index 0df5c03f6a..f6c4c98e16 100644
--- a/analysis/detectors/sts/CbmStsUtils.h
+++ b/analysis/detectors/sts/CbmStsUtils.h
@@ -102,8 +102,17 @@ namespace cbm_sts_utils
    */
   std::pair<HBinning, HBinning> ChargeBinning(const CbmStsParModule& par_module, const uint32_t max_clu_size = 1);
 
+  /** \brief Return the STS units from a list of addresses
+   *  \param addresses Vector containing the addresses of the modules
+   *  \return set of units
+   */
   std::set<int> GetUnits(const std::vector<int32_t> addresses);
 
+  /** \brief From a list of module address, return those that belong to a selected unit
+   *  \param addresses Vector containing the addresses of the modules
+   *  \param unit Selected unit
+   *  \return subset of modules that belong to the selected unit
+   */
   std::vector<int32_t> GetUnitModules(const std::vector<int32_t> addresses, const uint32_t unit);
 };  // namespace cbm_sts_utils
 #endif
-- 
GitLab


From 7947f14818ad199a2e8ae358f9f3fc8ca6b302f1 Mon Sep 17 00:00:00 2001
From: Dario Ramirez <d.ramirez@gsi.de>
Date: Wed, 23 Apr 2025 11:30:36 +0200
Subject: [PATCH 16/18] Apply clang-format

---
 analysis/detectors/sts/CbmCut.h               | 20 ++----
 analysis/detectors/sts/tests/_GTestCbmCut.cxx | 66 ++++++++++---------
 2 files changed, 38 insertions(+), 48 deletions(-)

diff --git a/analysis/detectors/sts/CbmCut.h b/analysis/detectors/sts/CbmCut.h
index 0cf82b4724..b594411070 100644
--- a/analysis/detectors/sts/CbmCut.h
+++ b/analysis/detectors/sts/CbmCut.h
@@ -74,22 +74,10 @@ class CbmCut {
     return out;
   }
 
-  T GetMin() const
-  {
-    return min_;
-  }
-  T GetMax() const
-  {
-    return max_;
-  }
-  bool GetMinState() const
-  {
-    return min_state_;
-  }
-  bool GetMaxState() const
-  {
-    return max_state_;
-  }
+  T GetMin() const { return min_; }
+  T GetMax() const { return max_; }
+  bool GetMinState() const { return min_state_; }
+  bool GetMaxState() const { return max_state_; }
 
 
  private:
diff --git a/analysis/detectors/sts/tests/_GTestCbmCut.cxx b/analysis/detectors/sts/tests/_GTestCbmCut.cxx
index a217e75b8f..1db1ccf035 100644
--- a/analysis/detectors/sts/tests/_GTestCbmCut.cxx
+++ b/analysis/detectors/sts/tests/_GTestCbmCut.cxx
@@ -7,54 +7,56 @@
 
 TEST(_GTestCbmCut, DefConstructor)
 {
-    CbmCut<float> cut;
-    EXPECT_EQ(false, cut.GetMinState());
-    EXPECT_EQ(false, cut.GetMaxState());
+  CbmCut<float> cut;
+  EXPECT_EQ(false, cut.GetMinState());
+  EXPECT_EQ(false, cut.GetMaxState());
 }
 
 TEST(_GTestCbmCut, ParConstructor)
 {
-    float min = -100;
-    float max = +100;
-    CbmCut<float> cut(min, max);
-    EXPECT_EQ(true, cut.GetMinState());
-    EXPECT_EQ(true, cut.GetMaxState());
-    EXPECT_EQ(min, cut.GetMin());
-    EXPECT_EQ(max, cut.GetMax());
+  float min = -100;
+  float max = +100;
+  CbmCut<float> cut(min, max);
+  EXPECT_EQ(true, cut.GetMinState());
+  EXPECT_EQ(true, cut.GetMaxState());
+  EXPECT_EQ(min, cut.GetMin());
+  EXPECT_EQ(max, cut.GetMax());
 }
 
 TEST(_GTestCbmCut, CheckOnDefConstructor)
 {
-    CbmCut<float> cut;
-    for (float i = -1e+6; i < 1e+6; i++) {
-        EXPECT_EQ(true, cut.Check(i));
-    }
+  CbmCut<float> cut;
+  for (float i = -1e+6; i < 1e+6; i++) {
+    EXPECT_EQ(true, cut.Check(i));
+  }
 }
 
 TEST(_GTestCbmCut, CheckCase1)
 {
-    float min = -100;
-    float max = +100;
-    CbmCut<float> cut(min, max);
-    for (float i = -1e+6; i < 1e+6; i++) {
-        if (i < min || i > max) {
-            EXPECT_EQ(false, cut.Check(i));
-        } else {
-            EXPECT_EQ(true, cut.Check(i));
-        }
+  float min = -100;
+  float max = +100;
+  CbmCut<float> cut(min, max);
+  for (float i = -1e+6; i < 1e+6; i++) {
+    if (i < min || i > max) {
+      EXPECT_EQ(false, cut.Check(i));
+    }
+    else {
+      EXPECT_EQ(true, cut.Check(i));
     }
+  }
 }
 
 TEST(_GTestCbmCut, CheckCase2)
 {
-    float min = +100;
-    float max = -100;
-    CbmCut<float> cut(min, max);
-    for (float i = -1e+6; i < 1e+6; i++) {
-        if (i <= max || i >= min) {
-            EXPECT_EQ(true, cut.Check(i));
-        } else {
-            EXPECT_EQ(false, cut.Check(i));
-        }
+  float min = +100;
+  float max = -100;
+  CbmCut<float> cut(min, max);
+  for (float i = -1e+6; i < 1e+6; i++) {
+    if (i <= max || i >= min) {
+      EXPECT_EQ(true, cut.Check(i));
+    }
+    else {
+      EXPECT_EQ(false, cut.Check(i));
     }
+  }
 }
-- 
GitLab


From 73e3997949fde10a526cd72f4808e7b52b9ef6be Mon Sep 17 00:00:00 2001
From: Dario Ramirez <d.ramirez@gsi.de>
Date: Wed, 23 Apr 2025 13:15:22 +0200
Subject: [PATCH 17/18] Variables names rework to follow ROOT convention

---
 analysis/detectors/sts/CbmCut.h               |  22 +-
 analysis/detectors/sts/CbmCutMap.cxx          |  10 +-
 analysis/detectors/sts/CbmCutMap.h            |  10 +-
 analysis/detectors/sts/CbmDcaVertexFinder.cxx |  68 ++--
 analysis/detectors/sts/CbmDcaVertexFinder.h   |  12 +-
 analysis/detectors/sts/CbmEventVertexDca.cxx  | 230 ++++++-------
 analysis/detectors/sts/CbmEventVertexDca.h    |  26 +-
 analysis/detectors/sts/CbmSpillCheck.cxx      |  54 +--
 analysis/detectors/sts/CbmSpillCheck.h        |  18 +-
 analysis/detectors/sts/CbmStsAnaBase.cxx      |  46 +--
 analysis/detectors/sts/CbmStsAnaBase.h        |  26 +-
 analysis/detectors/sts/CbmStsAnalysis.cxx     |   2 +-
 analysis/detectors/sts/CbmStsAnalysis.h       |   2 +-
 analysis/detectors/sts/CbmStsChannelQA.cxx    | 156 ++++-----
 analysis/detectors/sts/CbmStsChannelQA.h      |  28 +-
 analysis/detectors/sts/CbmStsCorrelation.cxx  |  78 ++---
 analysis/detectors/sts/CbmStsCorrelation.h    |   8 +-
 analysis/detectors/sts/CbmStsEfficiency.cxx   | 318 +++++++++---------
 analysis/detectors/sts/CbmStsEfficiency.h     |  46 +--
 analysis/detectors/sts/CbmStsHitAna.cxx       | 169 +++++-----
 analysis/detectors/sts/CbmStsHitAna.h         |  28 +-
 analysis/detectors/sts/CbmStsRecoBeamSpot.cxx | 104 +++---
 analysis/detectors/sts/CbmStsRecoBeamSpot.h   |  32 +-
 analysis/detectors/sts/CbmStsResolution.cxx   | 216 ++++++------
 analysis/detectors/sts/CbmStsResolution.h     |  34 +-
 analysis/detectors/sts/CbmStsTimeCal.cxx      | 168 ++++-----
 analysis/detectors/sts/CbmStsTimeCal.h        |  26 +-
 27 files changed, 966 insertions(+), 971 deletions(-)

diff --git a/analysis/detectors/sts/CbmCut.h b/analysis/detectors/sts/CbmCut.h
index b594411070..79ff461421 100644
--- a/analysis/detectors/sts/CbmCut.h
+++ b/analysis/detectors/sts/CbmCut.h
@@ -44,21 +44,21 @@ class CbmCut {
    */
   bool Check(T a) const
   {
-    bool check_min_status = min_state_ ? a >= min_ : true;
-    bool check_max_status = max_state_ ? a <= max_ : true;
-    if (min_state_ && max_state_ && (max_ < min_)) return check_min_status || check_max_status;
+    bool check_min_status = fMinState ? a >= min_ : true;
+    bool check_max_status = fMaxState ? a <= max_ : true;
+    if (fMinState && fMaxState && (max_ < min_)) return check_min_status || check_max_status;
     return check_min_status && check_max_status;
   }
 
   void SetMin(T val)
   {
     min_       = val;
-    min_state_ = true;
+    fMinState = true;
   }
   void SetMax(T val)
   {
     max_       = val;
-    max_state_ = true;
+    fMaxState = true;
   }
   void SetRange(T min_val, T max_val)
   {
@@ -68,21 +68,21 @@ class CbmCut {
 
   friend std::ostream& operator<<(std::ostream& out, const CbmCut<T>& obj)
   {
-    std::string min_msg = obj.min_state_ ? std::to_string(obj.min_) : "none";
-    std::string max_msg = obj.max_state_ ? std::to_string(obj.max_) : "none";
+    std::string min_msg = obj.fMinState ? std::to_string(obj.min_) : "none";
+    std::string max_msg = obj.fMaxState ? std::to_string(obj.max_) : "none";
     out << "[Min: " << min_msg << " , Max: " << max_msg << "]";
     return out;
   }
 
   T GetMin() const { return min_; }
   T GetMax() const { return max_; }
-  bool GetMinState() const { return min_state_; }
-  bool GetMaxState() const { return max_state_; }
+  bool GetMinState() const { return fMinState; }
+  bool GetMaxState() const { return fMaxState; }
 
 
  private:
-  bool min_state_{false};
-  bool max_state_{false};
+  bool fMinState{false};
+  bool fMaxState{false};
   T min_;
   T max_;
 };
diff --git a/analysis/detectors/sts/CbmCutMap.cxx b/analysis/detectors/sts/CbmCutMap.cxx
index 1eadf95aba..9e60f33bdf 100644
--- a/analysis/detectors/sts/CbmCutMap.cxx
+++ b/analysis/detectors/sts/CbmCutMap.cxx
@@ -4,16 +4,16 @@
 
 #include "CbmCutMap.h"
 
-CbmCut<float>* CbmCutMap::AddCbmCut(CbmCutId id) { return &cbm_cuts_[id]; }
+CbmCut<float>* CbmCutMap::AddCbmCut(CbmCutId id) { return &fCbmCuts[id]; }
 
 bool CbmCutMap::Check(CbmCutId id, double value)
 {
-  if (!cbm_cuts_.count(id)) {
-    failed_pass_counter_[id] = 0;
+  if (!fCbmCuts.count(id)) {
+    fFailedCounter[id] = 0;
     return true;
   }
-  bool check_result        = cbm_cuts_[id].Check(value);
-  failed_pass_counter_[id] = check_result ? failed_pass_counter_[id] + 1 : failed_pass_counter_[id];
+  bool check_result        = fCbmCuts[id].Check(value);
+  fFailedCounter[id] = check_result ? fFailedCounter[id] + 1 : fFailedCounter[id];
   return check_result;
 }
 
diff --git a/analysis/detectors/sts/CbmCutMap.h b/analysis/detectors/sts/CbmCutMap.h
index 6031f6b8dc..513e9b9e98 100644
--- a/analysis/detectors/sts/CbmCutMap.h
+++ b/analysis/detectors/sts/CbmCutMap.h
@@ -25,7 +25,7 @@ class CbmCutMap {
    * @brief Get the map of cuts.
    * @return The map of cuts.
    */
-  std::unordered_map<CbmCutId, CbmCut<float>> GetMap() const { return cbm_cuts_; }
+  std::unordered_map<CbmCutId, CbmCut<float>> GetMap() const { return fCbmCuts; }
 
   /**
    * @brief Add a new cut to the map.
@@ -76,14 +76,14 @@ class CbmCutMap {
    */
   void Print()
   {
-    for (auto& [id, cut] : cbm_cuts_) {
-      std::cout << int(id) << ": " << cut << "\tFailed: " << failed_pass_counter_[id] << std::endl;
+    for (auto& [id, cut] : fCbmCuts) {
+      std::cout << int(id) << ": " << cut << "\tFailed: " << fFailedCounter[id] << std::endl;
     }
   }
 
  private:
-  std::unordered_map<CbmCutId, CbmCut<float>> cbm_cuts_;
-  std::unordered_map<CbmCutId, unsigned long int> failed_pass_counter_;
+  std::unordered_map<CbmCutId, CbmCut<float>> fCbmCuts;
+  std::unordered_map<CbmCutId, unsigned long int> fFailedCounter;
 };
 
 #endif
diff --git a/analysis/detectors/sts/CbmDcaVertexFinder.cxx b/analysis/detectors/sts/CbmDcaVertexFinder.cxx
index 9e9f28b7c8..695f8ea3c1 100644
--- a/analysis/detectors/sts/CbmDcaVertexFinder.cxx
+++ b/analysis/detectors/sts/CbmDcaVertexFinder.cxx
@@ -10,55 +10,55 @@
 #include <Logger.h>
 
 CbmDcaVertexFinder::CbmDcaVertexFinder()
-  : max_dca_(0.1)
-  , tracks_(std::vector<CbmGlobalTrack*>())
-  , n_of_pairs_(0)
-  , qa_(std::nullopt)
+  : fMaxDca(0.1)
+  , fInputTracks(std::vector<CbmGlobalTrack*>())
+  , fNbPairs(0)
+  , fQA(std::nullopt)
 {
   LOG(debug) << "Creating CbmDcaVertexFinder ...";
-  cov_matrix_.ResizeTo(3, 3);
+  fCovMatrix.ResizeTo(3, 3);
 }
 
 CbmDcaVertexFinder::CbmDcaVertexFinder(double max_dca)
-  : max_dca_(max_dca)
-  , tracks_(std::vector<CbmGlobalTrack*>())
-  , n_of_pairs_(0)
-  , qa_(std::nullopt)
+  : fMaxDca(max_dca)
+  , fInputTracks(std::vector<CbmGlobalTrack*>())
+  , fNbPairs(0)
+  , fQA(std::nullopt)
 {
   LOG(debug) << "Creating CbmDcaVertexFinder ...";
-  cov_matrix_.ResizeTo(3, 3);
+  fCovMatrix.ResizeTo(3, 3);
 }
 
 /** \brief Default constructor
  * \param tracks
 */
 CbmDcaVertexFinder::CbmDcaVertexFinder(const std::vector<CbmGlobalTrack*> tracks)
-  : max_dca_(0.1)
-  , tracks_(tracks)
-  , n_of_pairs_(0)
-  , qa_(std::nullopt)
+  : fMaxDca(0.1)
+  , fInputTracks(tracks)
+  , fNbPairs(0)
+  , fQA(std::nullopt)
 {
   LOG(debug) << "Creating CbmDcaVertexFinder ...";
-  cov_matrix_.ResizeTo(3, 3);
+  fCovMatrix.ResizeTo(3, 3);
 }
 
 /** \brief Default constructor
  * \param tracks
 */
 CbmDcaVertexFinder::CbmDcaVertexFinder(const std::vector<CbmGlobalTrack*> tracks, const double max_dca)
-  : max_dca_(max_dca)
-  , tracks_(tracks)
-  , n_of_pairs_(0)
-  , qa_(std::nullopt)
+  : fMaxDca(max_dca)
+  , fInputTracks(tracks)
+  , fNbPairs(0)
+  , fQA(std::nullopt)
 {
   LOG(debug) << "Creating CbmDcaVertexFinder ...";
-  cov_matrix_.ResizeTo(3, 3);
+  fCovMatrix.ResizeTo(3, 3);
 }
 
 void CbmDcaVertexFinder::SetTracks(const std::vector<CbmGlobalTrack*> tracks)
 {
-  tracks_.clear();
-  tracks_ = tracks;
+  fInputTracks.clear();
+  fInputTracks = tracks;
 }
 
 /** \brief find vertex using input tracks
@@ -66,32 +66,32 @@ void CbmDcaVertexFinder::SetTracks(const std::vector<CbmGlobalTrack*> tracks)
 std::optional<CbmVertex> CbmDcaVertexFinder::FindVertex()
 {
   // Reset the number of track pair used
-  n_of_pairs_  = 0;
-  int n_of_trk = tracks_.size();
+  fNbPairs  = 0;
+  int n_of_trk = fInputTracks.size();
   LOG(debug) << "- PCA - Find event vertex using CbmGlobalTracks: " << n_of_trk;
   TVector3 vtx;
   for (int trk_i_idx = 0; trk_i_idx < n_of_trk - 1; trk_i_idx++) {
     for (int trk_j_idx = trk_i_idx + 1; trk_j_idx < n_of_trk; trk_j_idx++) {
-      auto pca = FindPca(tracks_[trk_i_idx], tracks_[trk_j_idx]);
-      if (pca.has_value() && pca->d_trk < max_dca_) {
+      auto pca = FindPca(fInputTracks[trk_i_idx], fInputTracks[trk_j_idx]);
+      if (pca.has_value() && pca->d_trk < fMaxDca) {
         TVector3 pca_i_j = pca->point;
         vtx += pca_i_j;
-        n_of_pairs_++;
+        fNbPairs++;
 
-        if (qa_.has_value()) {
-          qa_->pca_y_vs_x->Fill(pca_i_j[0], pca_i_j[1]);
-          qa_->pca_x_vs_z->Fill(pca_i_j[2], pca_i_j[0]);
-          qa_->pca_y_vs_z->Fill(pca_i_j[2], pca_i_j[1]);
+        if (fQA.has_value()) {
+          fQA->pca_y_vs_x->Fill(pca_i_j[0], pca_i_j[1]);
+          fQA->pca_x_vs_z->Fill(pca_i_j[2], pca_i_j[0]);
+          fQA->pca_y_vs_z->Fill(pca_i_j[2], pca_i_j[1]);
         }
       }
     }
   }
-  if (!n_of_pairs_) return std::nullopt;
+  if (!fNbPairs) return std::nullopt;
 
-  vtx *= 1. / n_of_pairs_;
+  vtx *= 1. / fNbPairs;
 
   // WARNING LINE
-  return CbmVertex("EventVertex", "EventVertex", vtx[0], vtx[1], vtx[2], 0, 0, n_of_pairs_, cov_matrix_);
+  return CbmVertex("EventVertex", "EventVertex", vtx[0], vtx[1], vtx[2], 0, 0, fNbPairs, fCovMatrix);
 }
 
 std::optional<CbmDcaVertexFinder::PCA> CbmDcaVertexFinder::FindPca(CbmGlobalTrack* trk_i, CbmGlobalTrack* trk_j)
diff --git a/analysis/detectors/sts/CbmDcaVertexFinder.h b/analysis/detectors/sts/CbmDcaVertexFinder.h
index c4f7b7783a..f3830f17e3 100644
--- a/analysis/detectors/sts/CbmDcaVertexFinder.h
+++ b/analysis/detectors/sts/CbmDcaVertexFinder.h
@@ -61,15 +61,15 @@ class CbmDcaVertexFinder {
      */
   std::optional<CbmVertex> FindVertex();
 
-  void EnableQa(Qa qa) { qa_ = std::make_optional<Qa>(qa); }
+  void EnableQa(Qa qa) { fQA = std::make_optional<Qa>(qa); }
 
  private:
-  const double max_dca_;
-  std::vector<CbmGlobalTrack*> tracks_;
-  double n_of_pairs_;
-  std::optional<Qa> qa_;
+  const double fMaxDca;
+  std::vector<CbmGlobalTrack*> fInputTracks;
+  double fNbPairs;
+  std::optional<Qa> fQA;
 
-  TMatrixFSym cov_matrix_;
+  TMatrixFSym fCovMatrix;
 };
 
 #endif
diff --git a/analysis/detectors/sts/CbmEventVertexDca.cxx b/analysis/detectors/sts/CbmEventVertexDca.cxx
index 100d852982..df72d346c2 100644
--- a/analysis/detectors/sts/CbmEventVertexDca.cxx
+++ b/analysis/detectors/sts/CbmEventVertexDca.cxx
@@ -39,77 +39,77 @@ void CbmEventVertexDca::BookHistograms()
 
   // ---- 3D Vertex 2D projections ----
   h_name = "vertex_y_vs_x";
-  h2_[h_name] =
+  fH2D[h_name] =
     std::make_unique<TH2D>(h_name.c_str(), h_name.c_str(), x_vtx_binning.n_of_bins, x_vtx_binning.x_min,
                            x_vtx_binning.x_max, y_vtx_binning.n_of_bins, y_vtx_binning.x_min, y_vtx_binning.x_max);
-  h2_[h_name]->GetXaxis()->SetTitle("Vertex_{X} [cm]");
-  h2_[h_name]->GetYaxis()->SetTitle("Vertex_{Y} [cm]");
+  fH2D[h_name]->GetXaxis()->SetTitle("Vertex_{X} [cm]");
+  fH2D[h_name]->GetYaxis()->SetTitle("Vertex_{Y} [cm]");
 
   h_name = "vertex_x_vs_z";
-  h2_[h_name] =
+  fH2D[h_name] =
     std::make_unique<TH2D>(h_name.c_str(), h_name.c_str(), z_vtx_binning.n_of_bins, z_vtx_binning.x_min,
                            z_vtx_binning.x_max, x_vtx_binning.n_of_bins, x_vtx_binning.x_min, x_vtx_binning.x_max);
-  h2_[h_name]->GetXaxis()->SetTitle("Vertex_{Z} [cm]");
-  h2_[h_name]->GetYaxis()->SetTitle("Vertex_{X} [cm]");
+  fH2D[h_name]->GetXaxis()->SetTitle("Vertex_{Z} [cm]");
+  fH2D[h_name]->GetYaxis()->SetTitle("Vertex_{X} [cm]");
 
   h_name = "vertex_y_vs_z";
-  h2_[h_name] =
+  fH2D[h_name] =
     std::make_unique<TH2D>(h_name.c_str(), h_name.c_str(), z_vtx_binning.n_of_bins, z_vtx_binning.x_min,
                            z_vtx_binning.x_max, y_vtx_binning.n_of_bins, y_vtx_binning.x_min, y_vtx_binning.x_max);
-  h2_[h_name]->GetXaxis()->SetTitle("Vertex_{Z} [cm]");
-  h2_[h_name]->GetYaxis()->SetTitle("Vertex_{Y} [cm]");
+  fH2D[h_name]->GetXaxis()->SetTitle("Vertex_{Z} [cm]");
+  fH2D[h_name]->GetYaxis()->SetTitle("Vertex_{Y} [cm]");
   // ---- ------------------------ ----
 
   // ---- PCA 2D projections ----
-  if (vertex_finder_) {
+  if (fVertexFinder) {
     h_name = "pca_y_vs_x";
-    h2_s[h_name] =
+    fH2DShared[h_name] =
       std::make_shared<TH2D>(h_name.c_str(), h_name.c_str(), x_vtx_binning.n_of_bins, x_vtx_binning.x_min,
                              x_vtx_binning.x_max, y_vtx_binning.n_of_bins, y_vtx_binning.x_min, y_vtx_binning.x_max);
-    h2_s[h_name]->GetXaxis()->SetTitle("Vertex_{X} [cm]");
-    h2_s[h_name]->GetYaxis()->SetTitle("Vertex_{Y} [cm]");
+    fH2DShared[h_name]->GetXaxis()->SetTitle("Vertex_{X} [cm]");
+    fH2DShared[h_name]->GetYaxis()->SetTitle("Vertex_{Y} [cm]");
 
     h_name = "pca_x_vs_z";
-    h2_s[h_name] =
+    fH2DShared[h_name] =
       std::make_shared<TH2D>(h_name.c_str(), h_name.c_str(), z_vtx_binning.n_of_bins, z_vtx_binning.x_min,
                              z_vtx_binning.x_max, x_vtx_binning.n_of_bins, x_vtx_binning.x_min, x_vtx_binning.x_max);
-    h2_s[h_name]->GetXaxis()->SetTitle("Vertex_{Z} [cm]");
-    h2_s[h_name]->GetYaxis()->SetTitle("Vertex_{X} [cm]");
+    fH2DShared[h_name]->GetXaxis()->SetTitle("Vertex_{Z} [cm]");
+    fH2DShared[h_name]->GetYaxis()->SetTitle("Vertex_{X} [cm]");
 
     h_name = "pca_y_vs_z";
-    h2_s[h_name] =
+    fH2DShared[h_name] =
       std::make_shared<TH2D>(h_name.c_str(), h_name.c_str(), z_vtx_binning.n_of_bins, z_vtx_binning.x_min,
                              z_vtx_binning.x_max, y_vtx_binning.n_of_bins, y_vtx_binning.x_min, y_vtx_binning.x_max);
-    h2_s[h_name]->GetXaxis()->SetTitle("Vertex_{Z} [cm]");
-    h2_s[h_name]->GetYaxis()->SetTitle("Vertex_{Y} [cm]");
+    fH2DShared[h_name]->GetXaxis()->SetTitle("Vertex_{Z} [cm]");
+    fH2DShared[h_name]->GetYaxis()->SetTitle("Vertex_{Y} [cm]");
 
     std::cout << " - DcaVertexFinder - Enabling QA" << std::endl;
-    vertex_finder_->EnableQa({h2_s["pca_y_vs_x"], h2_s["pca_x_vs_z"], h2_s["pca_y_vs_z"]});
+    fVertexFinder->EnableQa({fH2DShared["pca_y_vs_x"], fH2DShared["pca_x_vs_z"], fH2DShared["pca_y_vs_z"]});
   }
   // ---- ------------------------ ----
 
   // ----        DCA         ----
   for (const char* di : {"x", "y", "z"}) {
     h_name = Form("dca_d%s_vs_x", di);
-    h2_[h_name] =
+    fH2D[h_name] =
       std::make_unique<TH2D>(h_name.c_str(), h_name.c_str(), r_dca_binning.n_of_bins, r_dca_binning.x_min,
                              r_dca_binning.x_max, x_vtx_binning.n_of_bins, x_vtx_binning.x_min, x_vtx_binning.x_max);
-    h2_[h_name]->GetYaxis()->SetTitle("X [cm]");
-    h2_[h_name]->GetXaxis()->SetTitle(Form("DCA_{%s} [cm]", di));
+    fH2D[h_name]->GetYaxis()->SetTitle("X [cm]");
+    fH2D[h_name]->GetXaxis()->SetTitle(Form("DCA_{%s} [cm]", di));
 
     h_name = Form("dca_d%s_vs_y", di);
-    h2_[h_name] =
+    fH2D[h_name] =
       std::make_unique<TH2D>(h_name.c_str(), h_name.c_str(), r_dca_binning.n_of_bins, r_dca_binning.x_min,
                              r_dca_binning.x_max, y_vtx_binning.n_of_bins, y_vtx_binning.x_min, y_vtx_binning.x_max);
-    h2_[h_name]->GetYaxis()->SetTitle("Y [cm]");
-    h2_[h_name]->GetXaxis()->SetTitle(Form("DCA_{%s} [cm]", di));
+    fH2D[h_name]->GetYaxis()->SetTitle("Y [cm]");
+    fH2D[h_name]->GetXaxis()->SetTitle(Form("DCA_{%s} [cm]", di));
 
     h_name = Form("dca_d%s_vs_z", di);
-    h2_[h_name] =
+    fH2D[h_name] =
       std::make_unique<TH2D>(h_name.c_str(), h_name.c_str(), r_dca_binning.n_of_bins, r_dca_binning.x_min,
                              r_dca_binning.x_max, z_vtx_binning.n_of_bins, z_vtx_binning.x_min, z_vtx_binning.x_max);
-    h2_[h_name]->GetYaxis()->SetTitle(Form("Z [cm]"));
-    h2_[h_name]->GetXaxis()->SetTitle(Form("DCA_{%s} [cm]", di));
+    fH2D[h_name]->GetYaxis()->SetTitle(Form("Z [cm]"));
+    fH2D[h_name]->GetXaxis()->SetTitle(Form("DCA_{%s} [cm]", di));
   }
   // ---- ------------------ ----
 
@@ -118,39 +118,39 @@ void CbmEventVertexDca::BookHistograms()
     LOG(info) << " - INFO - Enabling MC comparison";
     for (const char* di : {"x", "y", "z"}) {
       h_name = Form("res_%s_vs_x", di);
-      h2_[h_name] =
+      fH2D[h_name] =
         std::make_unique<TH2D>(h_name.c_str(), h_name.c_str(), r_dca_binning.n_of_bins, r_dca_binning.x_min,
                                r_dca_binning.x_max, x_vtx_binning.n_of_bins, x_vtx_binning.x_min, x_vtx_binning.x_max);
-      h2_[h_name]->GetYaxis()->SetTitle("X [cm]");
-      h2_[h_name]->GetXaxis()->SetTitle(Form("%s_{rec} - %s_{MC} [cm]", di, di));
+      fH2D[h_name]->GetYaxis()->SetTitle("X [cm]");
+      fH2D[h_name]->GetXaxis()->SetTitle(Form("%s_{rec} - %s_{MC} [cm]", di, di));
 
       h_name = Form("res_%s_vs_y", di);
-      h2_[h_name] =
+      fH2D[h_name] =
         std::make_unique<TH2D>(h_name.c_str(), h_name.c_str(), r_dca_binning.n_of_bins, r_dca_binning.x_min,
                                r_dca_binning.x_max, y_vtx_binning.n_of_bins, y_vtx_binning.x_min, y_vtx_binning.x_max);
-      h2_[h_name]->GetYaxis()->SetTitle("Y [cm]");
-      h2_[h_name]->GetXaxis()->SetTitle(Form("%s_{rec} - %s_{MC} [cm]", di, di));
+      fH2D[h_name]->GetYaxis()->SetTitle("Y [cm]");
+      fH2D[h_name]->GetXaxis()->SetTitle(Form("%s_{rec} - %s_{MC} [cm]", di, di));
 
       h_name = Form("res_%s_vs_z", di);
-      h2_[h_name] =
+      fH2D[h_name] =
         std::make_unique<TH2D>(h_name.c_str(), h_name.c_str(), r_dca_binning.n_of_bins, r_dca_binning.x_min,
                                r_dca_binning.x_max, z_vtx_binning.n_of_bins, z_vtx_binning.x_min, z_vtx_binning.x_max);
-      h2_[h_name]->GetYaxis()->SetTitle(Form("Z [cm]"));
-      h2_[h_name]->GetXaxis()->SetTitle(Form("%s_{rec} - %s_{MC} [cm]", di, di));
+      fH2D[h_name]->GetYaxis()->SetTitle(Form("Z [cm]"));
+      fH2D[h_name]->GetXaxis()->SetTitle(Form("%s_{rec} - %s_{MC} [cm]", di, di));
     }
   }
   // ---- ------------------------- ----
 
   // Track multiplicity
   h_name      = "ca_track_multiplicity_all";
-  h1_[h_name] = std::make_unique<TH1D>(h_name.c_str(), h_name.c_str(), 50, 0, 50);
-  h1_[h_name]->GetXaxis()->SetTitle("N_{CATrack}");
-  h1_[h_name]->GetYaxis()->SetTitle("Entries");
+  fH1D[h_name] = std::make_unique<TH1D>(h_name.c_str(), h_name.c_str(), 50, 0, 50);
+  fH1D[h_name]->GetXaxis()->SetTitle("N_{CATrack}");
+  fH1D[h_name]->GetYaxis()->SetTitle("Entries");
 
   h_name      = "ca_track_multiplicity_sel";
-  h1_[h_name] = std::make_unique<TH1D>(h_name.c_str(), h_name.c_str(), 50, 0, 50);
-  h1_[h_name]->GetXaxis()->SetTitle("N_{CATrack}");
-  h1_[h_name]->GetYaxis()->SetTitle("Entries");
+  fH1D[h_name] = std::make_unique<TH1D>(h_name.c_str(), h_name.c_str(), 50, 0, 50);
+  fH1D[h_name]->GetXaxis()->SetTitle("N_{CATrack}");
+  fH1D[h_name]->GetYaxis()->SetTitle("Entries");
 }
 
 
@@ -158,20 +158,20 @@ void CbmEventVertexDca::FinishTask() { SaveToFile(); }
 
 void CbmEventVertexDca::CheckVertex()
 {
-  h1_["ca_track_multiplicity_sel"]->Fill(glb_trks_.size());
+  fH1D["ca_track_multiplicity_sel"]->Fill(fGlbTrks.size());
 
-  vertex_finder_->SetTracks(glb_trks_);
-  const std::optional<CbmVertex> vertex = vertex_finder_->FindVertex();
+  fVertexFinder->SetTracks(fGlbTrks);
+  const std::optional<CbmVertex> vertex = fVertexFinder->FindVertex();
 
   if (vertex.has_value()) {
 
     TVector3 vtx(vertex->GetX(), vertex->GetY(), vertex->GetZ());
 
-    h2_["vertex_y_vs_x"]->Fill(vtx[0], vtx[1]);
-    h2_["vertex_x_vs_z"]->Fill(vtx[2], vtx[0]);
-    h2_["vertex_y_vs_z"]->Fill(vtx[2], vtx[1]);
+    fH2D["vertex_y_vs_x"]->Fill(vtx[0], vtx[1]);
+    fH2D["vertex_x_vs_z"]->Fill(vtx[2], vtx[0]);
+    fH2D["vertex_y_vs_z"]->Fill(vtx[2], vtx[1]);
 
-    for (const CbmGlobalTrack* trk : glb_trks_) {
+    for (const CbmGlobalTrack* trk : fGlbTrks) {
       float trk_tx = trk->GetParamFirst()->GetTx();
       float trk_ty = trk->GetParamFirst()->GetTy();
       float trk_x0 = trk->GetParamFirst()->GetX();
@@ -182,59 +182,59 @@ void CbmEventVertexDca::CheckVertex()
       TVector3 e(trk_tx, trk_ty, 1);
       TVector3 trk_to_vtx = ((vtx - p).Cross(e)) * (1. / e.Mag());
 
-      h2_["dca_dx_vs_x"]->Fill(trk_to_vtx.Px(), vtx.Px());
-      h2_["dca_dx_vs_y"]->Fill(trk_to_vtx.Px(), vtx.Py());
-      h2_["dca_dx_vs_z"]->Fill(trk_to_vtx.Px(), vtx.Pz());
+      fH2D["dca_dx_vs_x"]->Fill(trk_to_vtx.Px(), vtx.Px());
+      fH2D["dca_dx_vs_y"]->Fill(trk_to_vtx.Px(), vtx.Py());
+      fH2D["dca_dx_vs_z"]->Fill(trk_to_vtx.Px(), vtx.Pz());
 
-      h2_["dca_dy_vs_x"]->Fill(trk_to_vtx.Py(), vtx.Px());
-      h2_["dca_dy_vs_y"]->Fill(trk_to_vtx.Py(), vtx.Py());
-      h2_["dca_dy_vs_z"]->Fill(trk_to_vtx.Py(), vtx.Pz());
+      fH2D["dca_dy_vs_x"]->Fill(trk_to_vtx.Py(), vtx.Px());
+      fH2D["dca_dy_vs_y"]->Fill(trk_to_vtx.Py(), vtx.Py());
+      fH2D["dca_dy_vs_z"]->Fill(trk_to_vtx.Py(), vtx.Pz());
 
-      h2_["dca_dz_vs_x"]->Fill(trk_to_vtx.Pz(), vtx.Px());
-      h2_["dca_dz_vs_y"]->Fill(trk_to_vtx.Pz(), vtx.Py());
-      h2_["dca_dz_vs_z"]->Fill(trk_to_vtx.Pz(), vtx.Pz());
+      fH2D["dca_dz_vs_x"]->Fill(trk_to_vtx.Pz(), vtx.Px());
+      fH2D["dca_dz_vs_y"]->Fill(trk_to_vtx.Pz(), vtx.Py());
+      fH2D["dca_dz_vs_z"]->Fill(trk_to_vtx.Pz(), vtx.Pz());
     }
 
     if (input_has_mc) {
       TVector3 mc_vertex;
-      int n_of_mc_trks = mc_trk_array_->GetEntriesFast();
+      int n_of_mc_trks = fMCTrkArray->GetEntriesFast();
       for (int mc_trk_idx = 0; mc_trk_idx < n_of_mc_trks; mc_trk_idx++) {
-        auto mc_trk = (CbmMCTrack*) mc_trk_array_->UncheckedAt(mc_trk_idx);
+        auto mc_trk = (CbmMCTrack*) fMCTrkArray->UncheckedAt(mc_trk_idx);
         if (mc_trk->GetMotherId() == -1) {
           mc_trk->GetStartVertex(mc_vertex);
           break;
         }
       }
 
-      h2_["res_x_vs_x"]->Fill(vtx[0] - mc_vertex[0], vtx[0]);
-      h2_["res_x_vs_y"]->Fill(vtx[0] - mc_vertex[0], vtx[1]);
-      h2_["res_x_vs_z"]->Fill(vtx[0] - mc_vertex[0], vtx[2]);
+      fH2D["res_x_vs_x"]->Fill(vtx[0] - mc_vertex[0], vtx[0]);
+      fH2D["res_x_vs_y"]->Fill(vtx[0] - mc_vertex[0], vtx[1]);
+      fH2D["res_x_vs_z"]->Fill(vtx[0] - mc_vertex[0], vtx[2]);
 
-      h2_["res_y_vs_x"]->Fill(vtx[1] - mc_vertex[1], vtx[0]);
-      h2_["res_y_vs_y"]->Fill(vtx[1] - mc_vertex[1], vtx[1]);
-      h2_["res_y_vs_z"]->Fill(vtx[1] - mc_vertex[1], vtx[2]);
+      fH2D["res_y_vs_x"]->Fill(vtx[1] - mc_vertex[1], vtx[0]);
+      fH2D["res_y_vs_y"]->Fill(vtx[1] - mc_vertex[1], vtx[1]);
+      fH2D["res_y_vs_z"]->Fill(vtx[1] - mc_vertex[1], vtx[2]);
 
-      h2_["res_z_vs_x"]->Fill(vtx[2] - mc_vertex[2], vtx[0]);
-      h2_["res_z_vs_y"]->Fill(vtx[2] - mc_vertex[2], vtx[1]);
-      h2_["res_z_vs_z"]->Fill(vtx[2] - mc_vertex[2], vtx[2]);
+      fH2D["res_z_vs_x"]->Fill(vtx[2] - mc_vertex[2], vtx[0]);
+      fH2D["res_z_vs_y"]->Fill(vtx[2] - mc_vertex[2], vtx[1]);
+      fH2D["res_z_vs_z"]->Fill(vtx[2] - mc_vertex[2], vtx[2]);
     }
   }
 
   // Clear track containers
-  glb_trks_.clear();
+  fGlbTrks.clear();
 }
 
 void CbmEventVertexDca::ProcessEvent(CbmEvent* evt)
 {
   int nb_of_glob_trk = evt->GetNofData(ECbmDataType::kGlobalTrack);
-  h1_["ca_track_multiplicity_all"]->Fill(nb_of_glob_trk);
+  fH1D["ca_track_multiplicity_all"]->Fill(nb_of_glob_trk);
 
-  if (analysis_cut_ != nullptr && !analysis_cut_->CheckEvent(evt)) return;
+  if (fAnalysisCuts != nullptr && !fAnalysisCuts->CheckEvent(evt)) return;
 
 
   for (int evt_glob_trk_idx = 0; evt_glob_trk_idx < nb_of_glob_trk; evt_glob_trk_idx++) {
     int glob_trk_idx = evt->GetIndex(ECbmDataType::kGlobalTrack, evt_glob_trk_idx);
-    ProcessGlobalTrack((CbmGlobalTrack*) glb_trk_array_->UncheckedAt(glob_trk_idx));
+    ProcessGlobalTrack((CbmGlobalTrack*) fGlbTrkArray->UncheckedAt(glob_trk_idx));
   }
 
   CheckVertex();
@@ -250,43 +250,43 @@ void CbmEventVertexDca::ProcessGlobalTrack(CbmGlobalTrack* trk)
   float trk_p_val   = TMath::Prob(trk->GetChi2(), trk->GetNDF());
 
   // Apply GlobalTracks cuts
-  int32_t mvd_trk_size = sts_trk_idx != -1 && sts_trk_array_ != nullptr
-                           ? ((CbmStsTrack*) sts_trk_array_->UncheckedAt(sts_trk_idx))->GetNofMvdHits()
+  int32_t mvd_trk_size = sts_trk_idx != -1 && fStsTrkArray != nullptr
+                           ? ((CbmStsTrack*) fStsTrkArray->UncheckedAt(sts_trk_idx))->GetNofMvdHits()
                            : 0;
 
-  int32_t sts_trk_size = sts_trk_idx != -1 && sts_trk_array_ != nullptr
-                           ? ((CbmStsTrack*) sts_trk_array_->UncheckedAt(sts_trk_idx))->GetNofStsHits()
+  int32_t sts_trk_size = sts_trk_idx != -1 && fStsTrkArray != nullptr
+                           ? ((CbmStsTrack*) fStsTrkArray->UncheckedAt(sts_trk_idx))->GetNofStsHits()
                            : 0;
 
-  int32_t rich_trk_size = rich_trk_idx != -1 && rch_trk_array_ != nullptr
-                            ? ((CbmTrack*) rch_trk_array_->UncheckedAt(rich_trk_idx))->GetNofHits()
+  int32_t rich_trk_size = rich_trk_idx != -1 && fRchTrkArray != nullptr
+                            ? ((CbmTrack*) fRchTrkArray->UncheckedAt(rich_trk_idx))->GetNofHits()
                             : 0;
 
-  int32_t much_trk_size = much_trk_idx != -1 && mch_trk_array_ != nullptr
-                            ? ((CbmTrack*) mch_trk_array_->UncheckedAt(much_trk_idx))->GetNofHits()
+  int32_t much_trk_size = much_trk_idx != -1 && fMchTrkArray != nullptr
+                            ? ((CbmTrack*) fMchTrkArray->UncheckedAt(much_trk_idx))->GetNofHits()
                             : 0;
 
-  int32_t trd_trk_size = trd_trk_idx != -1 && trd_trk_array_ != nullptr
-                           ? ((CbmTrack*) trd_trk_array_->UncheckedAt(trd_trk_idx))->GetNofHits()
+  int32_t trd_trk_size = trd_trk_idx != -1 && fTrdTrkArray != nullptr
+                           ? ((CbmTrack*) fTrdTrkArray->UncheckedAt(trd_trk_idx))->GetNofHits()
                            : 0;
 
-  int32_t tof_trk_size = tof_trk_idx != -1 && tof_trk_array_ != nullptr
-                           ? ((CbmTrack*) tof_trk_array_->UncheckedAt(tof_trk_idx))->GetNofHits()
+  int32_t tof_trk_size = tof_trk_idx != -1 && fTofTrkArray != nullptr
+                           ? ((CbmTrack*) fTofTrkArray->UncheckedAt(tof_trk_idx))->GetNofHits()
                            : 0;
 
-  if (analysis_cut_ != nullptr
-      && (!analysis_cut_->Check(CbmCutId::kGlobalTrackMvdSize, mvd_trk_size)
-          || !analysis_cut_->Check(CbmCutId::kGlobalTrackStsSize, sts_trk_size)
-          || !analysis_cut_->Check(CbmCutId::kGlobalTrackRichSize, rich_trk_size)
-          || !analysis_cut_->Check(CbmCutId::kGlobalTrackMuchSize, much_trk_size)
-          || !analysis_cut_->Check(CbmCutId::kGlobalTrackTrdSize, trd_trk_size)
-          || !analysis_cut_->Check(CbmCutId::kGlobalTrackTofSize, tof_trk_size)
-          || !analysis_cut_->Check(CbmCutId::kGlobalTrackChi2, trk->GetChi2())
-          || !analysis_cut_->Check(CbmCutId::kGlobalTrackPval, trk_p_val))) {
+  if (fAnalysisCuts != nullptr
+      && (!fAnalysisCuts->Check(CbmCutId::kGlobalTrackMvdSize, mvd_trk_size)
+          || !fAnalysisCuts->Check(CbmCutId::kGlobalTrackStsSize, sts_trk_size)
+          || !fAnalysisCuts->Check(CbmCutId::kGlobalTrackRichSize, rich_trk_size)
+          || !fAnalysisCuts->Check(CbmCutId::kGlobalTrackMuchSize, much_trk_size)
+          || !fAnalysisCuts->Check(CbmCutId::kGlobalTrackTrdSize, trd_trk_size)
+          || !fAnalysisCuts->Check(CbmCutId::kGlobalTrackTofSize, tof_trk_size)
+          || !fAnalysisCuts->Check(CbmCutId::kGlobalTrackChi2, trk->GetChi2())
+          || !fAnalysisCuts->Check(CbmCutId::kGlobalTrackPval, trk_p_val))) {
     return;
   }
 
-  glb_trks_.push_back(trk);
+  fGlbTrks.push_back(trk);
 }
 
 void CbmEventVertexDca::Exec(Option_t*)
@@ -295,21 +295,21 @@ void CbmEventVertexDca::Exec(Option_t*)
             << "Entry: " << entry_;
 
   // Check if CbmEvent
-  if (cbm_evt_array_ != nullptr) {
-    uint32_t nb_events = cbm_evt_array_->GetEntriesFast();
+  if (fCbmEvtArray != nullptr) {
+    uint32_t nb_events = fCbmEvtArray->GetEntriesFast();
     LOG(info) << Form(" ... number of CbmEvent: %u\n", nb_events);
     for (uint32_t evt_idx = 0; evt_idx < nb_events; evt_idx++) {
-      ProcessEvent((CbmEvent*) cbm_evt_array_->UncheckedAt(evt_idx));
+      ProcessEvent((CbmEvent*) fCbmEvtArray->UncheckedAt(evt_idx));
     }
   }
   else {
 
     LOG(debug) << " ... running time-like*** Using all tracks in TS - risk of high combinatorial";
 
-    uint32_t nb_of_glob_trk = glb_trk_array_->GetEntriesFast();
+    uint32_t nb_of_glob_trk = fGlbTrkArray->GetEntriesFast();
     LOG(info) << Form("Number of GlobalTracks: %u\n", nb_of_glob_trk);
     for (uint32_t glob_trk_idx = 0; glob_trk_idx < nb_of_glob_trk; glob_trk_idx++) {
-      CbmGlobalTrack* glob_trk = (CbmGlobalTrack*) glb_trk_array_->UncheckedAt(glob_trk_idx);
+      CbmGlobalTrack* glob_trk = (CbmGlobalTrack*) fGlbTrkArray->UncheckedAt(glob_trk_idx);
       ProcessGlobalTrack(glob_trk);
     }
 
@@ -324,31 +324,31 @@ InitStatus CbmEventVertexDca::Init()
 
   FairRootManager* ioman = FairRootManager::Instance();
   if (ioman != nullptr) {
-    cbm_evt_array_ = (TClonesArray*) ioman->GetObject("CbmEvent");
+    fCbmEvtArray = (TClonesArray*) ioman->GetObject("CbmEvent");
 
-    glb_trk_array_ = (TClonesArray*) ioman->GetObject("GlobalTrack");
+    fGlbTrkArray = (TClonesArray*) ioman->GetObject("GlobalTrack");
 
-    sts_trk_array_ = (TClonesArray*) ioman->GetObject("StsTrack");
-    rch_trk_array_ = (TClonesArray*) ioman->GetObject("RichTrack");
-    mch_trk_array_ = (TClonesArray*) ioman->GetObject("MuchTrack");
-    trd_trk_array_ = (TClonesArray*) ioman->GetObject("TrdTrack");
-    tof_trk_array_ = (TClonesArray*) ioman->GetObject("TofTrack");
+    fStsTrkArray = (TClonesArray*) ioman->GetObject("StsTrack");
+    fRchTrkArray = (TClonesArray*) ioman->GetObject("RichTrack");
+    fMchTrkArray = (TClonesArray*) ioman->GetObject("MuchTrack");
+    fTrdTrkArray = (TClonesArray*) ioman->GetObject("TrdTrack");
+    fTofTrkArray = (TClonesArray*) ioman->GetObject("TofTrack");
 
-    sts_hit_array_ = (TClonesArray*) ioman->GetObject("StsHit");
+    fStsHitArray = (TClonesArray*) ioman->GetObject("StsHit");
 
-    sts_clu_array_ = (TClonesArray*) ioman->GetObject("StsCluster");
+    fStsCluArray = (TClonesArray*) ioman->GetObject("StsCluster");
 
-    mc_trk_array_ = (TClonesArray*) ioman->GetObject("MCTrack");
-    input_has_mc  = mc_trk_array_ != nullptr;
+    fMCTrkArray = (TClonesArray*) ioman->GetObject("MCTrack");
+    input_has_mc  = fMCTrkArray != nullptr;
   }
 
   LoadSetup();
 
   BookHistograms();
 
-  glb_trks_.reserve(100);
+  fGlbTrks.reserve(100);
 
   return kSUCCESS;
 }
 
-void CbmEventVertexDca::SetVertexFinder(std::shared_ptr<CbmDcaVertexFinder> vtx_finder) { vertex_finder_ = vtx_finder; }
+void CbmEventVertexDca::SetVertexFinder(std::shared_ptr<CbmDcaVertexFinder> vtx_finder) { fVertexFinder = vtx_finder; }
diff --git a/analysis/detectors/sts/CbmEventVertexDca.h b/analysis/detectors/sts/CbmEventVertexDca.h
index 90e20c9dde..7ff35da8e9 100644
--- a/analysis/detectors/sts/CbmEventVertexDca.h
+++ b/analysis/detectors/sts/CbmEventVertexDca.h
@@ -44,22 +44,22 @@ class CbmEventVertexDca : public FairTask, public CbmStsAnaBase {
   void SetVertexFinder(std::shared_ptr<CbmDcaVertexFinder>);
 
  private:
-  std::shared_ptr<CbmDcaVertexFinder> vertex_finder_;
+  std::shared_ptr<CbmDcaVertexFinder> fVertexFinder;
 
   bool input_has_mc{false};
 
-  std::vector<CbmGlobalTrack*> glb_trks_;
-
-  TClonesArray* mc_trk_array_{nullptr};
-  TClonesArray* cbm_evt_array_{nullptr};
-  TClonesArray* glb_trk_array_{nullptr};
-  TClonesArray* sts_trk_array_{nullptr};
-  TClonesArray* rch_trk_array_{nullptr};
-  TClonesArray* mch_trk_array_{nullptr};
-  TClonesArray* trd_trk_array_{nullptr};
-  TClonesArray* tof_trk_array_{nullptr};
-  TClonesArray* sts_hit_array_{nullptr};
-  TClonesArray* sts_clu_array_{nullptr};
+  std::vector<CbmGlobalTrack*> fGlbTrks;
+
+  TClonesArray* fMCTrkArray{nullptr};
+  TClonesArray* fCbmEvtArray{nullptr};
+  TClonesArray* fGlbTrkArray{nullptr};
+  TClonesArray* fStsTrkArray{nullptr};
+  TClonesArray* fRchTrkArray{nullptr};
+  TClonesArray* fMchTrkArray{nullptr};
+  TClonesArray* fTrdTrkArray{nullptr};
+  TClonesArray* fTofTrkArray{nullptr};
+  TClonesArray* fStsHitArray{nullptr};
+  TClonesArray* fStsCluArray{nullptr};
 
   void BookHistograms();
 
diff --git a/analysis/detectors/sts/CbmSpillCheck.cxx b/analysis/detectors/sts/CbmSpillCheck.cxx
index d6e5aa18a8..e52c916dd7 100644
--- a/analysis/detectors/sts/CbmSpillCheck.cxx
+++ b/analysis/detectors/sts/CbmSpillCheck.cxx
@@ -10,15 +10,15 @@
 #include <iostream>
 #include <typeinfo>
 
-CbmSpillCheck::CbmSpillCheck() : ref_system{ECbmModuleId::kBmon}, rate_min_percnt{0.2}, rate_max_percnt{0.5}
+CbmSpillCheck::CbmSpillCheck() : fRefSystem{ECbmModuleId::kBmon}, fRateMinPercent{0.2}, fRateMaxPercent{0.5}
 {
   LOG(debug) << "Creating an instance of CbmSpillCheck ...";
 }
 
 CbmSpillCheck::CbmSpillCheck(ECbmModuleId ref, double lvl_min, double lvl_max)
-  : ref_system{ref}
-  , rate_min_percnt{lvl_min}
-  , rate_max_percnt{lvl_max}
+  : fRefSystem{ref}
+  , fRateMinPercent{lvl_min}
+  , fRateMaxPercent{lvl_max}
 {
   LOG(debug) << "Creating an instance of CbmSpillCheck ...";
 }
@@ -27,22 +27,22 @@ void CbmSpillCheck::BookHistograms(ECbmModuleId system)
 {
   std::string h_name = Form("%s Digi Rate", ToString(system).c_str());
   LOG(debug) << "Booking rate for : " << h_name;
-  g1_[h_name] = std::make_unique<TGraphErrors>();
+  fG1D[h_name] = std::make_unique<TGraphErrors>();
 }
 
 InitStatus CbmSpillCheck::Init()
 {
   FairRootManager* ioman = FairRootManager::Instance();
   if (ioman != nullptr) {
-    digi_manager = CbmDigiManager::Instance();
-    digi_manager->Init();
+    fDigiManager = CbmDigiManager::Instance();
+    fDigiManager->Init();
 
-    if (!digi_manager->IsPresent(ref_system)) {
-      LOG(fatal) << GetName() << ": No " << ToString(ref_system) << " branch in input!";
+    if (!fDigiManager->IsPresent(fRefSystem)) {
+      LOG(fatal) << GetName() << ": No " << ToString(fRefSystem) << " branch in input!";
     }
 
     for (ECbmModuleId system = ECbmModuleId::kRef; system != ECbmModuleId::kLastModule; ++system) {
-      if (digi_manager->IsPresent(system)) BookHistograms(system);
+      if (fDigiManager->IsPresent(system)) BookHistograms(system);
     }
 
     return kSUCCESS;
@@ -54,36 +54,36 @@ void CbmSpillCheck::Exec(Option_t*)
 {
   LOG(info) << "Running CbmSpillCheck ...";
 
-  size_t nb_ref_digis = digi_manager->GetNofDigis(ref_system);
-  rate_min_           = rate_min_ == -1 ? nb_ref_digis : std::min(nb_ref_digis, size_t(rate_min_));
-  rate_max_           = rate_max_ == -1 ? nb_ref_digis : std::max(nb_ref_digis, size_t(rate_max_));
-  ref_rate_.push_back(nb_ref_digis);
+  size_t nb_ref_digis = fDigiManager->GetNofDigis(fRefSystem);
+  fRateMin           = fRateMin == -1 ? nb_ref_digis : std::min(nb_ref_digis, size_t(fRateMin));
+  fRateMax           = fRateMax == -1 ? nb_ref_digis : std::max(nb_ref_digis, size_t(fRateMax));
+  fRefRate.push_back(nb_ref_digis);
 
   for (ECbmModuleId system = ECbmModuleId::kRef; system != ECbmModuleId::kLastModule; ++system) {
-    if (digi_manager->IsPresent(system)) {
-      size_t n_of_digis  = digi_manager->GetNofDigis(system);
+    if (fDigiManager->IsPresent(system)) {
+      size_t n_of_digis  = fDigiManager->GetNofDigis(system);
       std::string h_name = Form("%s Digi Rate", ToString(system).c_str());
-      g1_[h_name]->SetPoint(n_of_pts_, n_of_pts_, n_of_digis);
+      fG1D[h_name]->SetPoint(fNbPoints, fNbPoints, n_of_digis);
     }
   }
-  n_of_pts_++;
+  fNbPoints++;
 }
 
 void CbmSpillCheck::Finish()
 {
-  double spill_lvl_off = rate_min_ + rate_min_percnt * (rate_max_ - rate_min_);
-  double spill_lvl_on  = rate_min_ + rate_max_percnt * (rate_max_ - rate_min_);
-  spill_status_        = std::vector<int>(ref_rate_.size(), 0);
-  for (size_t ts_idx = 0; ts_idx < ref_rate_.size(); ts_idx++) {
-    spill_status_[ts_idx] = ref_rate_[ts_idx] <= spill_lvl_off ? -1 : (ref_rate_[ts_idx] <= spill_lvl_on ? 0 : 1);
-    std::cout << spill_status_[ts_idx] << std::endl;
+  double spill_lvl_off = fRateMin + fRateMinPercent * (fRateMax - fRateMin);
+  double spill_lvl_on  = fRateMin + fRateMaxPercent * (fRateMax - fRateMin);
+  fSpillStatus        = std::vector<int>(fRefRate.size(), 0);
+  for (size_t ts_idx = 0; ts_idx < fRefRate.size(); ts_idx++) {
+    fSpillStatus[ts_idx] = fRefRate[ts_idx] <= spill_lvl_off ? -1 : (fRefRate[ts_idx] <= spill_lvl_on ? 0 : 1);
+    std::cout << fSpillStatus[ts_idx] << std::endl;
   }
 
   std::cout << spill_lvl_off << std::endl;
   std::cout << spill_lvl_on << std::endl;
 
   SaveToFile();
-  g1_.clear();
-  h1_.clear();
-  h2_.clear();
+  fG1D.clear();
+  fH1D.clear();
+  fH2D.clear();
 }
diff --git a/analysis/detectors/sts/CbmSpillCheck.h b/analysis/detectors/sts/CbmSpillCheck.h
index 5b8b8c0070..3a93596bef 100644
--- a/analysis/detectors/sts/CbmSpillCheck.h
+++ b/analysis/detectors/sts/CbmSpillCheck.h
@@ -41,17 +41,17 @@ class CbmSpillCheck : public FairTask, public CbmStsAnaBase {
   void Finish();
 
  private:
-  ECbmModuleId ref_system;
-  double rate_min_percnt;
-  double rate_max_percnt;
-  int rate_max_{-1};
-  int rate_min_{-1};
-  int n_of_pts_{0};
-  std::vector<int> ref_rate_;
-  std::vector<int> spill_status_;
+  ECbmModuleId fRefSystem;
+  double fRateMinPercent;
+  double fRateMaxPercent;
+  int fRateMax{-1};
+  int fRateMin{-1};
+  int fNbPoints{0};
+  std::vector<int> fRefRate;
+  std::vector<int> fSpillStatus;
 
 
-  CbmDigiManager* digi_manager{nullptr};
+  CbmDigiManager* fDigiManager{nullptr};
 
   /** \brief Book histograms for a specific module */
   void BookHistograms(ECbmModuleId);
diff --git a/analysis/detectors/sts/CbmStsAnaBase.cxx b/analysis/detectors/sts/CbmStsAnaBase.cxx
index bc4d04f575..fac278da1e 100644
--- a/analysis/detectors/sts/CbmStsAnaBase.cxx
+++ b/analysis/detectors/sts/CbmStsAnaBase.cxx
@@ -21,7 +21,7 @@
 void CbmStsAnaBase::SetCutMap(CbmCutMap* cuts_map)
 {
   assert(cuts_map != nullptr);
-  analysis_cut_ = cuts_map;
+  fAnalysisCuts = cuts_map;
 }
 
 void CbmStsAnaBase::LoadSetup()
@@ -41,12 +41,12 @@ void CbmStsAnaBase::LoadSetup()
 
   for (unsigned short unit_idx = 0; unit_idx < nb_sts_station_; unit_idx++) {
     CbmStsStation* sts_unit    = sts_setup->GetStation(unit_idx);
-    sts_geo_info_[unit_idx]    = std::vector<double>(5, 0);
-    sts_geo_info_[unit_idx][0] = sts_unit->GetXmin();
-    sts_geo_info_[unit_idx][1] = sts_unit->GetXmax();
-    sts_geo_info_[unit_idx][2] = sts_unit->GetYmin();
-    sts_geo_info_[unit_idx][3] = sts_unit->GetYmax();
-    sts_geo_info_[unit_idx][4] = sts_unit->GetZ();
+    fStsGeoInfo[unit_idx]    = std::vector<double>(5, 0);
+    fStsGeoInfo[unit_idx][0] = sts_unit->GetXmin();
+    fStsGeoInfo[unit_idx][1] = sts_unit->GetXmax();
+    fStsGeoInfo[unit_idx][2] = sts_unit->GetYmin();
+    fStsGeoInfo[unit_idx][3] = sts_unit->GetYmax();
+    fStsGeoInfo[unit_idx][4] = sts_unit->GetZ();
   }
 
   for (unsigned short module_idx = 0; module_idx < sts_setup->GetNofModules(); module_idx++) {  // Loop over modules
@@ -63,20 +63,20 @@ void CbmStsAnaBase::LoadSetup()
 
     // const double* local = sensor_shape->GetOrigin();
     const double* trans       = sensor_matrix->GetTranslation();
-    sts_geo_info_[address]    = std::vector<double>(6, 0);
-    sts_geo_info_[address][0] = trans[0] - sensor_shape->GetDX();  // Xmin
-    sts_geo_info_[address][1] = trans[0] + sensor_shape->GetDX();  // Xmax
-    sts_geo_info_[address][2] = trans[1] - sensor_shape->GetDY();  // Ymin
-    sts_geo_info_[address][3] = trans[1] + sensor_shape->GetDY();  // Ymax
-    sts_geo_info_[address][4] = trans[2] - sensor_shape->GetDZ();  // Zmin
-    sts_geo_info_[address][5] = trans[2] + sensor_shape->GetDZ();  // Zmax
+    fStsGeoInfo[address]    = std::vector<double>(6, 0);
+    fStsGeoInfo[address][0] = trans[0] - sensor_shape->GetDX();  // Xmin
+    fStsGeoInfo[address][1] = trans[0] + sensor_shape->GetDX();  // Xmax
+    fStsGeoInfo[address][2] = trans[1] - sensor_shape->GetDY();  // Ymin
+    fStsGeoInfo[address][3] = trans[1] + sensor_shape->GetDY();  // Ymax
+    fStsGeoInfo[address][4] = trans[2] - sensor_shape->GetDZ();  // Zmin
+    fStsGeoInfo[address][5] = trans[2] + sensor_shape->GetDZ();  // Zmax
 
     if (address > 8) {
       switch (2 * (int) sensor_shape->GetDY()) {
-        case 2: first_z_strip_[address] = 2048 - 32; break;
-        case 4: first_z_strip_[address] = 2048 - 88; break;
-        case 6: first_z_strip_[address] = 2048 - 134; break;
-        case 12: first_z_strip_[address] = 2048 - 274; break;
+        case 2: fFirstZStrip[address] = 2048 - 32; break;
+        case 4: fFirstZStrip[address] = 2048 - 88; break;
+        case 6: fFirstZStrip[address] = 2048 - 134; break;
+        case 12: fFirstZStrip[address] = 2048 - 274; break;
         default:
           LOG(warning) << Form("Unknown sensor shape 0x%x: [%0.3f , %0.3f , %0.3f]", address, sensor_shape->GetDX(),
                                sensor_shape->GetDY(), sensor_shape->GetDZ());
@@ -86,7 +86,7 @@ void CbmStsAnaBase::LoadSetup()
   }
 
   LOG(debug) << "Loaded setup information:\n";
-  for (auto& [address, geo] : sts_geo_info_) {
+  for (auto& [address, geo] : fStsGeoInfo) {
     LOG(debug) << Form("0x%x: [%+0.3f, %+0.3f] ^ [%+0.3f, %+0.3f] ^ [%+0.3f, %+0.3f]", address, geo[0], geo[1], geo[2],
                        geo[3], geo[4], geo[5]);
   }
@@ -104,19 +104,19 @@ void CbmStsAnaBase::SaveToFile()
 
   LOG(info) << Form("Task histograms will be saved to %s ...", sink->GetFileName().Data());
 
-  for (auto& [name, gr] : g1_) {
+  for (auto& [name, gr] : fG1D) {
     if (gr == nullptr) continue;
     sink->WriteObject(gr.get(), name.c_str());
   }
-  for (auto& [name, h] : h1_) {
+  for (auto& [name, h] : fH1D) {
     if (h == nullptr) continue;
     sink->WriteObject(h.get(), name.c_str());
   }
-  for (auto& [name, h] : h2_) {
+  for (auto& [name, h] : fH2D) {
     if (h == nullptr) continue;
     sink->WriteObject(h.get(), name.c_str());
   }
-  for (auto& [name, h] : h2_s) {
+  for (auto& [name, h] : fH2DShared) {
     if (h == nullptr) continue;
     sink->WriteObject(h.get(), name.c_str());
   }
diff --git a/analysis/detectors/sts/CbmStsAnaBase.h b/analysis/detectors/sts/CbmStsAnaBase.h
index 06eb70ae56..152af21bb0 100644
--- a/analysis/detectors/sts/CbmStsAnaBase.h
+++ b/analysis/detectors/sts/CbmStsAnaBase.h
@@ -57,7 +57,7 @@ class CbmStsAnaBase {
    * @brief User defined sensor translations.
    * @param user_mat Input translations.
    */
-  void UserAlignment(const std::map<int32_t, std::vector<double>>& user_mat) { user_align_ = user_mat; }
+  void UserAlignment(const std::map<int32_t, std::vector<double>>& user_mat) { fUserAlignment = user_mat; }
 
   /**
    * @brief Virtual function to draw analysis results.
@@ -66,24 +66,24 @@ class CbmStsAnaBase {
 
  protected:
   uint entry_{0};
-  std::unique_ptr<TFile> report_file_;
-  std::unordered_set<int32_t> address_book_;
-  std::map<std::string, std::unique_ptr<TGraphErrors>> g1_;  // Map of TGraphErrors objects.
-  std::map<std::string, std::unique_ptr<TH1D>> h1_;          // Map of TH1D objects.
-  std::map<std::string, std::unique_ptr<TH2D>> h2_;          // Map of TH2D objects.
-  std::map<std::string, std::shared_ptr<TH2D>> h2_s;         // Map of TH2D objects.
-  std::map<std::string, std::unique_ptr<TCanvas>> canvas_;   // Map of TH2D objects.
+  std::unique_ptr<TFile> fReportFile;
+  std::unordered_set<int32_t> fAddressBook;
+  std::map<std::string, std::unique_ptr<TGraphErrors>> fG1D;  // Map of TGraphErrors objects.
+  std::map<std::string, std::unique_ptr<TH1D>> fH1D;          // Map of TH1D objects.
+  std::map<std::string, std::unique_ptr<TH2D>> fH2D;          // Map of TH2D objects.
+  std::map<std::string, std::shared_ptr<TH2D>> fH2DShared;         // Map of TH2D objects.
+  std::map<std::string, std::unique_ptr<TCanvas>> fCanvas;   // Map of TH2D objects.
 
   int nb_sts_station_{8};                                          // Number of STS stations.
-  std::unordered_map<int32_t, std::vector<double>> sts_geo_info_;  // Map of STS geometry information.
+  std::unordered_map<int32_t, std::vector<double>> fStsGeoInfo;  // Map of STS geometry information.
 
-  std::map<int32_t, std::vector<double>> user_align_;  // Stores the user-defined alignment information.
+  std::map<int32_t, std::vector<double>> fUserAlignment;  // Stores the user-defined alignment information.
 
-  std::unordered_map<int32_t, int> first_z_strip_;
+  std::unordered_map<int32_t, int> fFirstZStrip;
 
-  CbmCutMap* analysis_cut_{nullptr};
+  CbmCutMap* fAnalysisCuts{nullptr};
 
-  int run_id_{-1};
+  int fRunId{-1};
 
   /**
    * @brief Load the STS setup and fill the map with XYZ boundaries for each STS setup element.
diff --git a/analysis/detectors/sts/CbmStsAnalysis.cxx b/analysis/detectors/sts/CbmStsAnalysis.cxx
index 88bc8d233f..497afb8ee6 100644
--- a/analysis/detectors/sts/CbmStsAnalysis.cxx
+++ b/analysis/detectors/sts/CbmStsAnalysis.cxx
@@ -9,4 +9,4 @@
 #include <cassert>
 #include <iomanip>
 
-void CbmStsAnalysis::SetAnalysisCuts(CbmCutMap* cuts_map) { ana_cuts_map_ = cuts_map; }
+void CbmStsAnalysis::SetAnalysisCuts(CbmCutMap* cuts_map) { fAnaCutsMap = cuts_map; }
diff --git a/analysis/detectors/sts/CbmStsAnalysis.h b/analysis/detectors/sts/CbmStsAnalysis.h
index 68e8509bcc..f5d7b2e259 100644
--- a/analysis/detectors/sts/CbmStsAnalysis.h
+++ b/analysis/detectors/sts/CbmStsAnalysis.h
@@ -31,7 +31,7 @@ class CbmStsAnalysis : public FairRunAna {
   void SetAnalysisCuts(CbmCutMap*);
 
  private:
-  CbmCutMap* ana_cuts_map_{nullptr};
+  CbmCutMap* fAnaCutsMap{nullptr};
 
   ClassDef(CbmStsAnalysis, 1);
 };
diff --git a/analysis/detectors/sts/CbmStsChannelQA.cxx b/analysis/detectors/sts/CbmStsChannelQA.cxx
index 9e26dc4e55..dd60c57115 100644
--- a/analysis/detectors/sts/CbmStsChannelQA.cxx
+++ b/analysis/detectors/sts/CbmStsChannelQA.cxx
@@ -17,17 +17,17 @@
 #include <iostream>
 #include <typeinfo>
 
-CbmStsChannelQA::CbmStsChannelQA(int dead_threshold) : active_min_entries_(dead_threshold) {}
+CbmStsChannelQA::CbmStsChannelQA(int dead_threshold) : fActiveMinEntries(dead_threshold) {}
 CbmStsChannelQA::CbmStsChannelQA(int dead_threshold, double noise_threshold,
                                  std::optional<std::pair<size_t, size_t>> spill_on_off_threshold)
-  : active_min_entries_(dead_threshold)
-  , sb_ratio_threshold_(noise_threshold)
-  , spill_on_off_threshold_(spill_on_off_threshold)
+  : fActiveMinEntries(dead_threshold)
+  , fSBThreshold(noise_threshold)
+  , fSpillThresholds(spill_on_off_threshold)
 {
   assert(noise_threshold > 0);
-  if (spill_on_off_threshold_.has_value()) {
-    assert(spill_on_off_threshold_->first <= spill_on_off_threshold_->second);
-    spill_sections_ = {":ramp", ":spill_on", ":spill_off"};
+  if (fSpillThresholds.has_value()) {
+    assert(fSpillThresholds->first <= fSpillThresholds->second);
+    fSpillSections = {":ramp", ":spill_on", ":spill_off"};
   }
 }
 
@@ -35,18 +35,18 @@ InitStatus CbmStsChannelQA::Init()
 {
   FairRootManager* ioman = FairRootManager::Instance();
   if (ioman != nullptr) {
-    digi_manager = CbmDigiManager::Instance();
-    digi_manager->Init();
+    fDigiManager = CbmDigiManager::Instance();
+    fDigiManager->Init();
 
-    if (!digi_manager->IsPresent(ECbmModuleId::kSts)) LOG(fatal) << GetName() << ": No StsDigi branch in input!";
+    if (!fDigiManager->IsPresent(ECbmModuleId::kSts)) LOG(fatal) << GetName() << ": No StsDigi branch in input!";
 
     LOG(info) << "CbmStsChannelQA configuration:";
-    LOG(info) << "Report lvl:                     " << report_level_;
-    LOG(info) << "Active channel minimum entries: " << active_min_entries_;
-    LOG(info) << "Noisy channel S/B thresholds:    " << sb_ratio_threshold_;
-    if (spill_on_off_threshold_.has_value()) {
-      LOG(info) << Form("Spill OFF: RefDet_DigiRate < %lu", spill_on_off_threshold_->first);
-      LOG(info) << Form("Spill  ON: RefDet_DigiRate > %lu", spill_on_off_threshold_->second);
+    LOG(info) << "Report lvl:                     " << fReportLvl;
+    LOG(info) << "Active channel minimum entries: " << fActiveMinEntries;
+    LOG(info) << "Noisy channel S/B thresholds:    " << fSBThreshold;
+    if (fSpillThresholds.has_value()) {
+      LOG(info) << Form("Spill OFF: RefDet_DigiRate < %lu", fSpillThresholds->first);
+      LOG(info) << Form("Spill  ON: RefDet_DigiRate > %lu", fSpillThresholds->second);
     }
     else {
       LOG(info) << "No Spill section defined. Using all time slices";
@@ -66,34 +66,34 @@ void CbmStsChannelQA::BookHistograms(int32_t address)
   auto t_binning = cbm_sts_utils::HBinning{uint32_t(dt_max / 3.125), 0, dt_max};
 
   std::string h_name;
-  for (auto modifier : spill_sections_) {
+  for (auto modifier : fSpillSections) {
     h_name = Form("0x%x_charge_vs_channel%s", address, modifier);
     LOG(debug) << h_name;
-    h2_[h_name] = std::make_unique<TH2D>(h_name.c_str(), h_name.c_str(), 2048, 0, 2048, 31, 1, 32);
-    h2_[h_name]->GetXaxis()->SetTitle("Channel_{StsDigi}");
-    h2_[h_name]->GetYaxis()->SetTitle("Charge_{StsDigi} [ADC]");
+    fH2D[h_name] = std::make_unique<TH2D>(h_name.c_str(), h_name.c_str(), 2048, 0, 2048, 31, 1, 32);
+    fH2D[h_name]->GetXaxis()->SetTitle("Channel_{StsDigi}");
+    fH2D[h_name]->GetYaxis()->SetTitle("Charge_{StsDigi} [ADC]");
 
     LOG(debug) << h_name;
     h_name      = Form("0x%x_dt_vs_charge%s", address, modifier);
-    h2_[h_name] = std::make_unique<TH2D>(h_name.c_str(), h_name.c_str(), 31, 1, 32, t_binning.n_of_bins,
+    fH2D[h_name] = std::make_unique<TH2D>(h_name.c_str(), h_name.c_str(), 31, 1, 32, t_binning.n_of_bins,
                                          t_binning.x_min, t_binning.x_max);
-    h2_[h_name]->GetYaxis()->SetTitle("Charge_{StsDigi} [ADC]");
-    h2_[h_name]->GetYaxis()->SetTitle("Time difference [ns]");
+    fH2D[h_name]->GetYaxis()->SetTitle("Charge_{StsDigi} [ADC]");
+    fH2D[h_name]->GetYaxis()->SetTitle("Time difference [ns]");
 
     LOG(debug) << h_name;
     h_name      = Form("0x%x_dt_vs_channel%s", address, modifier);
-    h2_[h_name] = std::make_unique<TH2D>(h_name.c_str(), h_name.c_str(), 2048, 0, 2048, t_binning.n_of_bins,
+    fH2D[h_name] = std::make_unique<TH2D>(h_name.c_str(), h_name.c_str(), 2048, 0, 2048, t_binning.n_of_bins,
                                          t_binning.x_min, t_binning.x_max);
-    h2_[h_name]->GetXaxis()->SetTitle("Channel_{StsDigi}");
-    h2_[h_name]->GetYaxis()->SetTitle("Time difference [ns]");
+    fH2D[h_name]->GetXaxis()->SetTitle("Channel_{StsDigi}");
+    fH2D[h_name]->GetYaxis()->SetTitle("Time difference [ns]");
   }
 
-  address_book_.insert(address);
+  fAddressBook.insert(address);
 }
 
 void CbmStsChannelQA::ResetLastTime()
 {
-  for (auto& [address, time] : last_digi_time_) {
+  for (auto& [address, time] : fLastDigiTime) {
     for (int chn = 0; chn < 2048; chn++) {
       time[chn] = -1;
     }
@@ -105,33 +105,33 @@ void CbmStsChannelQA::Exec(Option_t*)
   LOG(info) << "Running CbmStsChannelQA ...";
 
   // Get Spill status
-  size_t nb_ref_digis = digi_manager->GetNofDigis(ECbmModuleId::kBmon);
+  size_t nb_ref_digis = fDigiManager->GetNofDigis(ECbmModuleId::kBmon);
 
   /**
    * -1 Off spill
    *  0 Spill ramp
    * +1 On spill
   **/
-  int spill_status_ = 0;
-  if (spill_on_off_threshold_.has_value()) {
-    spill_status_ =
-      nb_ref_digis <= spill_on_off_threshold_->first ? -1 : (nb_ref_digis <= spill_on_off_threshold_->second ? 0 : 1);
+  int fSpillStatus = 0;
+  if (fSpillThresholds.has_value()) {
+    fSpillStatus =
+      nb_ref_digis <= fSpillThresholds->first ? -1 : (nb_ref_digis <= fSpillThresholds->second ? 0 : 1);
   }
 
   std::string str_spill;
-  switch (spill_status_) {
+  switch (fSpillStatus) {
     case +1: {
-      nb_spill_on_++;
-      str_spill = spill_sections_[1];
+      fNbTsSpillOn++;
+      str_spill = fSpillSections[1];
       break;
     }
     case -1: {
-      nb_spill_off_++;
-      str_spill = spill_sections_[2];
+      fNbTsSpillOff++;
+      str_spill = fSpillSections[2];
       break;
     }
     default: {
-      str_spill = spill_sections_[0];
+      str_spill = fSpillSections[0];
       break;
     }
   }
@@ -139,8 +139,8 @@ void CbmStsChannelQA::Exec(Option_t*)
   LOG(info) << Form("TS %d\t-\t Spill section: %s", entry_, str_spill.c_str());
 
 
-  auto sts_digis_     = digi_manager->GetArray<CbmStsDigi>();
-  size_t nb_sts_digis = digi_manager->GetNofDigis(ECbmModuleId::kSts);
+  auto sts_digis_     = fDigiManager->GetArray<CbmStsDigi>();
+  size_t nb_sts_digis = fDigiManager->GetNofDigis(ECbmModuleId::kSts);
   for (size_t sts_digi_idx = 0; sts_digi_idx < nb_sts_digis; sts_digi_idx++) {  // sts digi loop
     const CbmStsDigi* sts_digi = &sts_digis_[sts_digi_idx];
     int32_t sts_digi_addr      = sts_digi->GetAddress();
@@ -148,24 +148,24 @@ void CbmStsChannelQA::Exec(Option_t*)
     int32_t sts_digi_char      = sts_digi->GetCharge();
     double sts_digi_time       = sts_digi->GetTime();
 
-    if (!address_book_.count(sts_digi_addr)) {
+    if (!fAddressBook.count(sts_digi_addr)) {
       BookHistograms(sts_digi_addr);
 
       for (int chn = 0; chn < 2048; chn++) {
-        last_digi_time_[sts_digi_addr][chn] = -1;
+        fLastDigiTime[sts_digi_addr][chn] = -1;
       }
     }
 
-    h2_[Form("0x%x_charge_vs_channel%s", sts_digi_addr, str_spill.c_str())]->Fill(sts_digi_chan, sts_digi_char);
+    fH2D[Form("0x%x_charge_vs_channel%s", sts_digi_addr, str_spill.c_str())]->Fill(sts_digi_chan, sts_digi_char);
 
-    if (last_digi_time_[sts_digi_addr][sts_digi_chan] > 0) {
-      h2_[Form("0x%x_dt_vs_charge%s", sts_digi_addr, str_spill.c_str())]->Fill(
-        sts_digi_char, sts_digi_time - last_digi_time_[sts_digi_addr][sts_digi_chan]);
-      h2_[Form("0x%x_dt_vs_channel%s", sts_digi_addr, str_spill.c_str())]->Fill(
-        sts_digi_chan, sts_digi_time - last_digi_time_[sts_digi_addr][sts_digi_chan]);
+    if (fLastDigiTime[sts_digi_addr][sts_digi_chan] > 0) {
+      fH2D[Form("0x%x_dt_vs_charge%s", sts_digi_addr, str_spill.c_str())]->Fill(
+        sts_digi_char, sts_digi_time - fLastDigiTime[sts_digi_addr][sts_digi_chan]);
+      fH2D[Form("0x%x_dt_vs_channel%s", sts_digi_addr, str_spill.c_str())]->Fill(
+        sts_digi_chan, sts_digi_time - fLastDigiTime[sts_digi_addr][sts_digi_chan]);
     }
 
-    last_digi_time_[sts_digi_addr][sts_digi_chan] = sts_digi_time;
+    fLastDigiTime[sts_digi_addr][sts_digi_chan] = sts_digi_time;
 
   }  // end sts digi loop
 
@@ -175,14 +175,14 @@ void CbmStsChannelQA::Exec(Option_t*)
 
 void CbmStsChannelQA::CheckDeadChannels()
 {
-  const char* mod = spill_on_off_threshold_.has_value() ? spill_sections_[1] : spill_sections_[0];
-  for (auto& module_addr : address_book_) {
-    auto h = (TH1D*) h2_[Form("0x%x_charge_vs_channel%s", module_addr, mod)]->ProjectionX();
+  const char* mod = fSpillThresholds.has_value() ? fSpillSections[1] : fSpillSections[0];
+  for (auto& module_addr : fAddressBook) {
+    auto h = (TH1D*) fH2D[Form("0x%x_charge_vs_channel%s", module_addr, mod)]->ProjectionX();
     for (int chn = 0; chn < 2048; chn++) {
       double entries = h->GetBinContent(chn + 1);
 
-      if (entries < active_min_entries_) {
-        dead_channel_list_[module_addr].push_back(chn);
+      if (entries < fActiveMinEntries) {
+        fDeadChannelList[module_addr].push_back(chn);
       }
     }
   }
@@ -190,12 +190,12 @@ void CbmStsChannelQA::CheckDeadChannels()
 
 void CbmStsChannelQA::CheckNoisyChannels()
 {
-  for (auto& module_addr : address_book_) {
-    TH1D* h_sgn = h2_[Form("0x%x_charge_vs_channel:spill_on", module_addr)]->ProjectionX();
-    TH1D* h_bkg = h2_[Form("0x%x_charge_vs_channel:spill_off", module_addr)]->ProjectionX();
+  for (auto& module_addr : fAddressBook) {
+    TH1D* h_sgn = fH2D[Form("0x%x_charge_vs_channel:spill_on", module_addr)]->ProjectionX();
+    TH1D* h_bkg = fH2D[Form("0x%x_charge_vs_channel:spill_off", module_addr)]->ProjectionX();
 
-    h_sgn->Scale(1. / nb_spill_on_);
-    h_bkg->Scale(1. / nb_spill_off_);
+    h_sgn->Scale(1. / fNbTsSpillOn);
+    h_bkg->Scale(1. / fNbTsSpillOff);
     h_sgn->Add(h_bkg, -1);
 
     for (int chn = 0; chn < 2048; chn++) {
@@ -206,9 +206,9 @@ void CbmStsChannelQA::CheckNoisyChannels()
 
       double sb_ratio = sgn / bkg;
 
-      if (sb_ratio < sb_ratio_threshold_) {
+      if (sb_ratio < fSBThreshold) {
         LOG(debug) << Form("Noisy channel 0x%x: %d, \tS/B: %0.4f", module_addr, chn, sb_ratio);
-        noisy_channel_list_[module_addr].push_back(chn);
+        fNoisyChannelList[module_addr].push_back(chn);
       }
     }
   }
@@ -220,15 +220,15 @@ void CbmStsChannelQA::GenerateReport()
   std::unique_ptr<TFile> o_root_file = std::make_unique<TFile>(f_name.c_str(), "RECREATE");
   int pad_size_x                     = 1000;
   int pad_size_y                     = 1000;
-  for (auto& module_addr : address_book_) {
+  for (auto& module_addr : fAddressBook) {
     std::string c_name         = Form("0x%x_channel", module_addr);
     std::unique_ptr<TCanvas> c = std::make_unique<TCanvas>(c_name.c_str(), c_name.c_str(), pad_size_x, pad_size_y);
-    TH1D* h_sgn                = h2_[Form("0x%x_charge_vs_channel:spill_on", module_addr)]->ProjectionX();
-    TH1D* h_bkg                = h2_[Form("0x%x_charge_vs_channel:spill_off", module_addr)]->ProjectionX();
+    TH1D* h_sgn                = fH2D[Form("0x%x_charge_vs_channel:spill_on", module_addr)]->ProjectionX();
+    TH1D* h_bkg                = fH2D[Form("0x%x_charge_vs_channel:spill_off", module_addr)]->ProjectionX();
 
     LOG(debug) << Form("Building report for 0x%x", module_addr);
-    h_sgn->Scale(1. / nb_spill_on_);
-    h_bkg->Scale(1. / nb_spill_off_);
+    h_sgn->Scale(1. / fNbTsSpillOn);
+    h_bkg->Scale(1. / fNbTsSpillOff);
 
     h_sgn->SetLineColor(kRed);
     h_bkg->SetLineColor(kBlack);
@@ -257,9 +257,9 @@ void CbmStsChannelQA::GenerateReport()
     h_bkg->Draw("histo same");
 
     // Draw a line for bad channels
-    if (report_level_ > 1) {
-      LOG(debug) << Form("Drawing %d noisy channel markers: %lu", module_addr, noisy_channel_list_[module_addr].size());
-      for (auto& chn : noisy_channel_list_[module_addr]) {
+    if (fReportLvl > 1) {
+      LOG(debug) << Form("Drawing %d noisy channel markers: %lu", module_addr, fNoisyChannelList[module_addr].size());
+      for (auto& chn : fNoisyChannelList[module_addr]) {
         TBox chn_box = TBox(chn + 0.2, 0.99 * max, chn + 0.8, 1.01 * max);
         chn_box.SetLineColor(kBlue);
         chn_box.SetFillColor(kBlue);
@@ -274,25 +274,25 @@ void CbmStsChannelQA::GenerateReport()
 void CbmStsChannelQA::Finish()
 {
   CheckDeadChannels();
-  if (spill_on_off_threshold_.has_value()) CheckNoisyChannels();
+  if (fSpillThresholds.has_value()) CheckNoisyChannels();
 
-  if (report_level_) GenerateReport();
+  if (fReportLvl) GenerateReport();
 
   SaveToFile();
 
-  h1_.clear();
-  h2_.clear();
+  fH1D.clear();
+  fH2D.clear();
 
   // Write normalization factor to file
   std::unique_ptr<TFile> out_file = std::make_unique<TFile>("cbm_sts_channel_qa.root", "UPDATE");
-  TParameter<int>("nb_spill_on_", nb_spill_on_).Write();
-  TParameter<int>("nb_spill_off_", nb_spill_off_).Write();
+  TParameter<int>("fNbTsSpillOn", fNbTsSpillOn).Write();
+  TParameter<int>("fNbTsSpillOff", fNbTsSpillOff).Write();
 
   std::ofstream dead_info("sts_dead_channels.info");
   std::ofstream dead_par("sts_dead_channels.par");
   dead_info << Form("# Module\t Number of dead channels\n");
   int n_of_dead_chn = 0;
-  for (auto& [module_addr, list] : dead_channel_list_) {
+  for (auto& [module_addr, list] : fDeadChannelList) {
     dead_info << Form("0x%x\t%lu\n", module_addr, list.size());
     for (int& dead_chn : list) {
       dead_par << module_addr << "\t" << dead_chn << std::endl;
@@ -305,7 +305,7 @@ void CbmStsChannelQA::Finish()
   std::ofstream noisy_par("sts_noisy_channels.par");
   noisy_info << Form("# Module\t Number of noisy channels\n");
   int n_of_noisy_chn = 0;
-  for (auto& [module_addr, list] : noisy_channel_list_) {
+  for (auto& [module_addr, list] : fNoisyChannelList) {
     noisy_info << Form("0x%x\t%lu\n", module_addr, list.size());
     for (int& noisy_chn : list) {
       noisy_par << module_addr << "\t" << noisy_chn << std::endl;
diff --git a/analysis/detectors/sts/CbmStsChannelQA.h b/analysis/detectors/sts/CbmStsChannelQA.h
index cd2c9342f1..d947d5fb56 100644
--- a/analysis/detectors/sts/CbmStsChannelQA.h
+++ b/analysis/detectors/sts/CbmStsChannelQA.h
@@ -90,26 +90,26 @@ class CbmStsChannelQA : public FairTask, public CbmStsAnaBase {
   void Exec(Option_t*);
   void Finish();
 
-  void SetReportLevel(int lvl) { report_level_ = lvl; }
+  void SetReportLevel(int lvl) { fReportLvl = lvl; }
 
  private:
-  int report_level_{0};
-  const int active_min_entries_{1};
-  const double sb_ratio_threshold_{0.5};
-  const std::optional<std::pair<size_t, size_t>> spill_on_off_threshold_{std::nullopt};
+  int fReportLvl{0};
+  const int fActiveMinEntries{1};
+  const double fSBThreshold{0.5};
+  const std::optional<std::pair<size_t, size_t>> fSpillThresholds{std::nullopt};
 
-  std::vector<const char*> spill_sections_ = {":all"};
+  std::vector<const char*> fSpillSections = {":all"};
 
-  int nb_spill_on_{0};
-  int nb_spill_off_{0};
+  int fNbTsSpillOn{0};
+  int fNbTsSpillOff{0};
 
-  std::map<int32_t, std::vector<int>> dead_channel_list_;
-  std::map<int32_t, std::vector<int>> noisy_channel_list_;
+  std::map<int32_t, std::vector<int>> fDeadChannelList;
+  std::map<int32_t, std::vector<int>> fNoisyChannelList;
 
-  std::map<int32_t, double[2048]> last_digi_time_;
+  std::map<int32_t, double[2048]> fLastDigiTime;
   void ResetLastTime();
 
-  CbmDigiManager* digi_manager{nullptr};
+  CbmDigiManager* fDigiManager{nullptr};
 
   /**
    * @brief Book histograms.
@@ -119,13 +119,13 @@ class CbmStsChannelQA : public FairTask, public CbmStsAnaBase {
 
   /**
    * @brief Check for dead channels.
-   * Fills dead_channel_list_ map
+   * Fills fDeadChannelList map
    */
   void CheckDeadChannels();
 
   /**
    * @brief Check for dead channels.
-   * Fills noisy_channel_list_ map
+   * Fills fNoisyChannelList map
    */
   void CheckNoisyChannels();
 
diff --git a/analysis/detectors/sts/CbmStsCorrelation.cxx b/analysis/detectors/sts/CbmStsCorrelation.cxx
index e856a1daad..9f0e34f325 100644
--- a/analysis/detectors/sts/CbmStsCorrelation.cxx
+++ b/analysis/detectors/sts/CbmStsCorrelation.cxx
@@ -12,8 +12,8 @@
 void CbmStsCorrelation::BookHistograms()
 {
 
-  for (auto& [element_i, geo_i] : sts_geo_info_) {
-    for (auto& [element_j, geo_j] : sts_geo_info_) {
+  for (auto& [element_i, geo_i] : fStsGeoInfo) {
+    for (auto& [element_j, geo_j] : fStsGeoInfo) {
 
       std::string h_name_base = "";
       std::string obj_x, obj_y;
@@ -58,20 +58,20 @@ void CbmStsCorrelation::BookHistograms()
 
       std::string h_name;
       h_name = Form("%s_XX", h_name_base.c_str());
-      h2_[h_name] =
+      fH2D[h_name] =
         std::make_unique<TH2D>(h_name.c_str(), "", nb_bins_x_i, x_min_i, x_max_i, nb_bins_x_j, x_min_j, x_max_j);
-      h2_[h_name]->GetXaxis()->SetTitle(Form("X_{%s} [cm]", obj_x.c_str()));
-      h2_[h_name]->GetYaxis()->SetTitle(Form("X_{%s} [cm]", obj_y.c_str()));
-      h2_[h_name]->GetXaxis()->CenterTitle(true);
-      h2_[h_name]->GetYaxis()->CenterTitle(true);
+      fH2D[h_name]->GetXaxis()->SetTitle(Form("X_{%s} [cm]", obj_x.c_str()));
+      fH2D[h_name]->GetYaxis()->SetTitle(Form("X_{%s} [cm]", obj_y.c_str()));
+      fH2D[h_name]->GetXaxis()->CenterTitle(true);
+      fH2D[h_name]->GetYaxis()->CenterTitle(true);
 
       h_name = Form("%s_YY", h_name_base.c_str());
-      h2_[h_name] =
+      fH2D[h_name] =
         std::make_unique<TH2D>(h_name.c_str(), "", nb_bins_y_i, y_min_i, y_max_i, nb_bins_y_j, y_min_j, y_max_j);
-      h2_[h_name]->GetXaxis()->SetTitle(Form("Y_{%s} [cm]", obj_x.c_str()));
-      h2_[h_name]->GetYaxis()->SetTitle(Form("Y_{%s} [cm]", obj_y.c_str()));
-      h2_[h_name]->GetXaxis()->CenterTitle(true);
-      h2_[h_name]->GetYaxis()->CenterTitle(true);
+      fH2D[h_name]->GetXaxis()->SetTitle(Form("Y_{%s} [cm]", obj_x.c_str()));
+      fH2D[h_name]->GetYaxis()->SetTitle(Form("Y_{%s} [cm]", obj_y.c_str()));
+      fH2D[h_name]->GetXaxis()->CenterTitle(true);
+      fH2D[h_name]->GetYaxis()->CenterTitle(true);
     }
   }
 }
@@ -79,29 +79,29 @@ void CbmStsCorrelation::BookHistograms()
 void CbmStsCorrelation::BuildCorrelation()
 {
   bool is_mc_data = false;
-  if (!sts_hits_.size()) return;
+  if (!fStsHits.size()) return;
   for (int sts_unit_i = 0; sts_unit_i < nb_sts_station_ - 1; sts_unit_i++) {
     for (int sts_unit_j = sts_unit_i + 1; sts_unit_j < nb_sts_station_; sts_unit_j++) {
       LOG(debug) << Form("Building correlations for STS%d:STS%d: %ld\t%ld", sts_unit_i, sts_unit_j,
-                         sts_hits_[sts_unit_i].size(), sts_hits_[sts_unit_j].size());
-      for (auto sts_hit_i : sts_hits_[sts_unit_i]) {
+                         fStsHits[sts_unit_i].size(), fStsHits[sts_unit_j].size());
+      for (auto sts_hit_i : fStsHits[sts_unit_i]) {
         int32_t sts_address_i = sts_hit_i->GetAddress();
         double sts_i_x        = sts_hit_i->GetX();
         double sts_i_y        = sts_hit_i->GetY();
 
         CbmStsHit* closest_hit = nullptr;
         double abs_time_diff   = 999;
-        for (auto sts_hit_j : sts_hits_[sts_unit_j]) {
+        for (auto sts_hit_j : fStsHits[sts_unit_j]) {
 
           if (is_mc_data) {
             int32_t sts_address_j = sts_hit_j->GetAddress();
             double sts_j_x        = sts_hit_j->GetX();
             double sts_j_y        = sts_hit_j->GetY();
 
-            h2_[Form("Sts%d:Sts%d_YY", sts_unit_i, sts_unit_j)]->Fill(sts_i_y, sts_j_y);
-            h2_[Form("Sts%d:Sts%d_XX", sts_unit_i, sts_unit_j)]->Fill(sts_i_x, sts_j_x);
-            h2_[Form("Sts0x%x:Sts0x%x_YY", sts_address_i, sts_address_j)]->Fill(sts_i_y, sts_j_y);
-            h2_[Form("Sts0x%x:Sts0x%x_XX", sts_address_i, sts_address_j)]->Fill(sts_i_x, sts_j_x);
+            fH2D[Form("Sts%d:Sts%d_YY", sts_unit_i, sts_unit_j)]->Fill(sts_i_y, sts_j_y);
+            fH2D[Form("Sts%d:Sts%d_XX", sts_unit_i, sts_unit_j)]->Fill(sts_i_x, sts_j_x);
+            fH2D[Form("Sts0x%x:Sts0x%x_YY", sts_address_i, sts_address_j)]->Fill(sts_i_y, sts_j_y);
+            fH2D[Form("Sts0x%x:Sts0x%x_XX", sts_address_i, sts_address_j)]->Fill(sts_i_x, sts_j_x);
           }
           else {
 
@@ -117,26 +117,26 @@ void CbmStsCorrelation::BuildCorrelation()
           double sts_j_x        = closest_hit->GetX();
           double sts_j_y        = closest_hit->GetY();
 
-          h2_[Form("Sts%d:Sts%d_YY", sts_unit_i, sts_unit_j)]->Fill(sts_i_y, sts_j_y);
-          h2_[Form("Sts%d:Sts%d_XX", sts_unit_i, sts_unit_j)]->Fill(sts_i_x, sts_j_x);
-          h2_[Form("Sts0x%x:Sts0x%x_YY", sts_address_i, sts_address_j)]->Fill(sts_i_y, sts_j_y);
-          h2_[Form("Sts0x%x:Sts0x%x_XX", sts_address_i, sts_address_j)]->Fill(sts_i_x, sts_j_x);
+          fH2D[Form("Sts%d:Sts%d_YY", sts_unit_i, sts_unit_j)]->Fill(sts_i_y, sts_j_y);
+          fH2D[Form("Sts%d:Sts%d_XX", sts_unit_i, sts_unit_j)]->Fill(sts_i_x, sts_j_x);
+          fH2D[Form("Sts0x%x:Sts0x%x_YY", sts_address_i, sts_address_j)]->Fill(sts_i_y, sts_j_y);
+          fH2D[Form("Sts0x%x:Sts0x%x_XX", sts_address_i, sts_address_j)]->Fill(sts_i_x, sts_j_x);
         }
       }
     }
   }
-  sts_hits_.clear();
+  fStsHits.clear();
 }
 
 void CbmStsCorrelation::ProcessEvent(CbmEvent* evt)
 {
-  if (analysis_cut_ != nullptr && !analysis_cut_->CheckEvent(evt)) return;
+  if (fAnalysisCuts != nullptr && !fAnalysisCuts->CheckEvent(evt)) return;
 
   int nb_sts_hits = evt->GetNofData(ECbmDataType::kStsHit);
   LOG(debug) << Form("Processing event with %d StsHit", nb_sts_hits);
   for (int hit_evt_idx = 0; hit_evt_idx < nb_sts_hits; hit_evt_idx++) {
     int sts_hit_idx = evt->GetIndex(ECbmDataType::kStsHit, hit_evt_idx);
-    CbmStsHit* hit  = (CbmStsHit*) sts_hit_array_->UncheckedAt(sts_hit_idx);
+    CbmStsHit* hit  = (CbmStsHit*) fStsHitArray->UncheckedAt(sts_hit_idx);
     ProcessHit(hit);
   }
 }
@@ -145,22 +145,22 @@ void CbmStsCorrelation::ProcessHit(CbmStsHit* hit)
 {
   if (hit == nullptr) return;
 
-  if (analysis_cut_ != nullptr && !analysis_cut_->CheckStsHit(hit, sts_clu_array_)) return;
+  if (fAnalysisCuts != nullptr && !fAnalysisCuts->CheckStsHit(hit, fStsCluArray)) return;
 
   int32_t address = hit->GetAddress();
   int32_t unit    = CbmStsAddress::GetElementId(address, kStsUnit);
 
-  sts_hits_[unit].push_back(hit);
+  fStsHits[unit].push_back(hit);
 }
 
 void CbmStsCorrelation::Exec(Option_t*)
 {
   // Check if CbmEvent
-  if (cbm_evt_array_ != nullptr) {
-    uint32_t nb_events = cbm_evt_array_->GetEntriesFast();
+  if (fCbmEvtArray != nullptr) {
+    uint32_t nb_events = fCbmEvtArray->GetEntriesFast();
     LOG(info) << Form("Running event-like Entry: %d\t%d CbmEvents", entry_, nb_events);
     for (uint32_t evt_idx = 0; evt_idx < nb_events; evt_idx++) {
-      CbmEvent* event = (CbmEvent*) cbm_evt_array_->UncheckedAt(evt_idx);
+      CbmEvent* event = (CbmEvent*) fCbmEvtArray->UncheckedAt(evt_idx);
       ProcessEvent(event);
       BuildCorrelation();
     }
@@ -168,9 +168,9 @@ void CbmStsCorrelation::Exec(Option_t*)
   else {
 
     LOG(debug) << "Running time-like ...";
-    uint32_t n_of_hits = sts_hit_array_->GetEntriesFast();
+    uint32_t n_of_hits = fStsHitArray->GetEntriesFast();
     for (uint32_t hit_idx = 0; hit_idx < n_of_hits; hit_idx++) {
-      CbmStsHit* sts_hit = (CbmStsHit*) sts_hit_array_->UncheckedAt(hit_idx);
+      CbmStsHit* sts_hit = (CbmStsHit*) fStsHitArray->UncheckedAt(hit_idx);
       ProcessHit(sts_hit);
     }
     BuildCorrelation();
@@ -184,9 +184,9 @@ InitStatus CbmStsCorrelation::Init()
 
   FairRootManager* ioman = FairRootManager::Instance();
   if (ioman != nullptr) {
-    cbm_evt_array_ = (TClonesArray*) ioman->GetObject("CbmEvent");
-    sts_hit_array_ = (TClonesArray*) ioman->GetObject("StsHit");
-    sts_clu_array_ = (TClonesArray*) ioman->GetObject("StsCluster");
+    fCbmEvtArray = (TClonesArray*) ioman->GetObject("CbmEvent");
+    fStsHitArray = (TClonesArray*) ioman->GetObject("StsHit");
+    fStsCluArray = (TClonesArray*) ioman->GetObject("StsCluster");
   }
 
   LoadSetup();
@@ -200,6 +200,6 @@ InitStatus CbmStsCorrelation::Init()
 void CbmStsCorrelation::Finish()
 {
   SaveToFile();
-  h1_.clear();
-  h2_.clear();
+  fH1D.clear();
+  fH2D.clear();
 }
diff --git a/analysis/detectors/sts/CbmStsCorrelation.h b/analysis/detectors/sts/CbmStsCorrelation.h
index ca55a95c7b..34cbf428cb 100644
--- a/analysis/detectors/sts/CbmStsCorrelation.h
+++ b/analysis/detectors/sts/CbmStsCorrelation.h
@@ -37,11 +37,11 @@ class CbmStsCorrelation : public FairTask, public CbmStsAnaBase {
   void Finish();
 
  private:
-  std::map<int32_t, std::vector<CbmStsHit*>> sts_hits_;
+  std::map<int32_t, std::vector<CbmStsHit*>> fStsHits;
 
-  TClonesArray* cbm_evt_array_;
-  TClonesArray* sts_hit_array_;
-  TClonesArray* sts_clu_array_;
+  TClonesArray* fCbmEvtArray;
+  TClonesArray* fStsHitArray;
+  TClonesArray* fStsCluArray;
 
   void BookHistograms();
 
diff --git a/analysis/detectors/sts/CbmStsEfficiency.cxx b/analysis/detectors/sts/CbmStsEfficiency.cxx
index 313aaa244b..30ddb383c4 100644
--- a/analysis/detectors/sts/CbmStsEfficiency.cxx
+++ b/analysis/detectors/sts/CbmStsEfficiency.cxx
@@ -7,16 +7,16 @@
 #include "CbmStsAddress.h"
 #include "CbmStsUtils.h"
 
-CbmStsEfficiency::CbmStsEfficiency(uint32_t layer_idx) : test_layer_(layer_idx)
+CbmStsEfficiency::CbmStsEfficiency(uint32_t layer_idx) : fTestLayer(layer_idx)
 {
   LOG(debug) << "Creating an instance of CbmStsEfficiency ...";
 }
 CbmStsEfficiency::CbmStsEfficiency(uint32_t test_layer, double max_dis_trg_vtx, double max_dca_trk_vtx,
                                    double default_residual)
-  : test_layer_(test_layer)
-  , max_dis_trg_vtx_(max_dis_trg_vtx)
-  , max_dca_trk_vtx_(max_dca_trk_vtx)
-  , default_residual_(default_residual)
+  : fTestLayer(test_layer)
+  , fMaxDisTrgVtx(max_dis_trg_vtx)
+  , fMaxDCATrkVtx(max_dca_trk_vtx)
+  , fDefaultResidual(default_residual)
 {
   LOG(debug) << "Creating an instance of CbmStsEfficiency ...";
 }
@@ -56,14 +56,14 @@ void CbmStsEfficiency::BookHistograms()
   // ---- --------------------- ----
 
   std::string h_name;
-  for (auto& [element, geo] : sts_geo_info_) {
+  for (auto& [element, geo] : fStsGeoInfo) {
     std::string h_name_base = "";
-    if (element == test_layer_) {
+    if (element == fTestLayer) {
       h_name_base = Form("Sts%d", element);
     }
     else if (element > 8) {
-      if (CbmStsAddress::GetElementId(element, kStsUnit) != test_layer_) continue;
-      sensors_under_test_.push_back(element);
+      if (CbmStsAddress::GetElementId(element, kStsUnit) != fTestLayer) continue;
+      fDUTList.push_back(element);
       h_name_base = Form("Sts0x%x", element);
     }
 
@@ -74,127 +74,127 @@ void CbmStsEfficiency::BookHistograms()
 
     // ---- efficiency ----
     h_name = Form("%s_found", h_name_base.c_str());
-    h2_[h_name] =
+    fH2D[h_name] =
       std::make_unique<TH2D>(h_name.c_str(), h_name.c_str(), x_sen_binning.n_of_bins, x_sen_binning.x_min,
                              x_sen_binning.x_max, y_sen_binning.n_of_bins, y_sen_binning.x_min, y_sen_binning.x_max);
-    h2_[h_name]->GetXaxis()->SetTitle("StsHit^{rec}_{X} [cm]");
-    h2_[h_name]->GetYaxis()->SetTitle("StsHit^{rec}_{Y} [cm]");
+    fH2D[h_name]->GetXaxis()->SetTitle("StsHit^{rec}_{X} [cm]");
+    fH2D[h_name]->GetYaxis()->SetTitle("StsHit^{rec}_{Y} [cm]");
 
     h_name = Form("%s_track", h_name_base.c_str());
-    h2_[h_name] =
+    fH2D[h_name] =
       std::make_unique<TH2D>(h_name.c_str(), h_name.c_str(), x_sen_binning.n_of_bins, x_sen_binning.x_min,
                              x_sen_binning.x_max, y_sen_binning.n_of_bins, y_sen_binning.x_min, y_sen_binning.x_max);
-    h2_[h_name]->GetXaxis()->SetTitle("StsHit^{ext}_{X} [cm]");
-    h2_[h_name]->GetYaxis()->SetTitle("StsHit^{ext}_{Y} [cm]");
+    fH2D[h_name]->GetXaxis()->SetTitle("StsHit^{ext}_{X} [cm]");
+    fH2D[h_name]->GetYaxis()->SetTitle("StsHit^{ext}_{Y} [cm]");
 
     h_name = Form("%s_hit_map", h_name_base.c_str());
-    h2_[h_name] =
+    fH2D[h_name] =
       std::make_unique<TH2D>(h_name.c_str(), h_name.c_str(), x_sen_binning.n_of_bins, x_sen_binning.x_min,
                              x_sen_binning.x_max, y_sen_binning.n_of_bins, y_sen_binning.x_min, y_sen_binning.x_max);
-    h2_[h_name]->GetXaxis()->SetTitle("StsHit_{X} [cm]");
-    h2_[h_name]->GetYaxis()->SetTitle("StsHit_{Y} [cm]");
+    fH2D[h_name]->GetXaxis()->SetTitle("StsHit_{X} [cm]");
+    fH2D[h_name]->GetYaxis()->SetTitle("StsHit_{Y} [cm]");
     // ---- ---------- ----
 
     // ---- residuals ----
     for (const char* di : {"x", "y"}) {
       h_name = Form("%s_d%s_vs_x", h_name_base.c_str(), di);
-      h2_[h_name] =
+      fH2D[h_name] =
         std::make_unique<TH2D>(h_name.c_str(), h_name.c_str(), r_sen_binning.n_of_bins, r_sen_binning.x_min,
                                r_sen_binning.x_max, x_sen_binning.n_of_bins, x_sen_binning.x_min, x_sen_binning.x_max);
-      h2_[h_name]->GetYaxis()->SetTitle("X [cm]");
-      h2_[h_name]->GetXaxis()->SetTitle(Form("\\rho_{%s} [cm]", di));
+      fH2D[h_name]->GetYaxis()->SetTitle("X [cm]");
+      fH2D[h_name]->GetXaxis()->SetTitle(Form("\\rho_{%s} [cm]", di));
 
       h_name = Form("%s_d%s_vs_y", h_name_base.c_str(), di);
-      h2_[h_name] =
+      fH2D[h_name] =
         std::make_unique<TH2D>(h_name.c_str(), h_name.c_str(), r_sen_binning.n_of_bins, r_sen_binning.x_min,
                                r_sen_binning.x_max, y_sen_binning.n_of_bins, y_sen_binning.x_min, y_sen_binning.x_max);
-      h2_[h_name]->GetYaxis()->SetTitle("Y [cm]");
-      h2_[h_name]->GetXaxis()->SetTitle(Form("\\rho_{%s} [cm]", di));
+      fH2D[h_name]->GetYaxis()->SetTitle("Y [cm]");
+      fH2D[h_name]->GetXaxis()->SetTitle(Form("\\rho_{%s} [cm]", di));
     }
     // ---- --------- ----
   }  // end geo loop
 
   // ----     3D vertex      ----
   h_name = "vertex_y_vs_x";
-  h2_[h_name] =
+  fH2D[h_name] =
     std::make_unique<TH2D>(h_name.c_str(), h_name.c_str(), x_vtx_binning.n_of_bins, x_vtx_binning.x_min,
                            x_vtx_binning.x_max, y_vtx_binning.n_of_bins, y_vtx_binning.x_min, y_vtx_binning.x_max);
-  h2_[h_name]->GetXaxis()->SetTitle("Vertex_{X} [cm]");
-  h2_[h_name]->GetYaxis()->SetTitle("Vertex_{Y} [cm]");
+  fH2D[h_name]->GetXaxis()->SetTitle("Vertex_{X} [cm]");
+  fH2D[h_name]->GetYaxis()->SetTitle("Vertex_{Y} [cm]");
 
   h_name = "vertex_x_vs_z";
-  h2_[h_name] =
+  fH2D[h_name] =
     std::make_unique<TH2D>(h_name.c_str(), h_name.c_str(), z_vtx_binning.n_of_bins, z_vtx_binning.x_min,
                            z_vtx_binning.x_max, x_vtx_binning.n_of_bins, x_vtx_binning.x_min, x_vtx_binning.x_max);
-  h2_[h_name]->GetXaxis()->SetTitle("Vertex_{Z} [cm]");
-  h2_[h_name]->GetYaxis()->SetTitle("Vertex_{X} [cm]");
+  fH2D[h_name]->GetXaxis()->SetTitle("Vertex_{Z} [cm]");
+  fH2D[h_name]->GetYaxis()->SetTitle("Vertex_{X} [cm]");
 
   h_name = "vertex_y_vs_z";
-  h2_[h_name] =
+  fH2D[h_name] =
     std::make_unique<TH2D>(h_name.c_str(), h_name.c_str(), z_vtx_binning.n_of_bins, z_vtx_binning.x_min,
                            z_vtx_binning.x_max, y_vtx_binning.n_of_bins, y_vtx_binning.x_min, y_vtx_binning.x_max);
-  h2_[h_name]->GetXaxis()->SetTitle("Vertex_{Z} [cm]");
-  h2_[h_name]->GetYaxis()->SetTitle("Vertex_{Y} [cm]");
+  fH2D[h_name]->GetXaxis()->SetTitle("Vertex_{Z} [cm]");
+  fH2D[h_name]->GetYaxis()->SetTitle("Vertex_{Y} [cm]");
   // ---- ------------------ ----
 
   // ----        DCA         ----
   for (const char* di : {"x", "y", "z"}) {
     h_name = Form("dca_d%s_vs_x", di);
-    h2_[h_name] =
+    fH2D[h_name] =
       std::make_unique<TH2D>(h_name.c_str(), h_name.c_str(), r_dca_binning.n_of_bins, r_dca_binning.x_min,
                              r_dca_binning.x_max, x_vtx_binning.n_of_bins, x_vtx_binning.x_min, x_vtx_binning.x_max);
-    h2_[h_name]->GetYaxis()->SetTitle("X [cm]");
-    h2_[h_name]->GetXaxis()->SetTitle(Form("DCA_{%s} [cm]", di));
+    fH2D[h_name]->GetYaxis()->SetTitle("X [cm]");
+    fH2D[h_name]->GetXaxis()->SetTitle(Form("DCA_{%s} [cm]", di));
 
     h_name = Form("dca_d%s_vs_y", di);
-    h2_[h_name] =
+    fH2D[h_name] =
       std::make_unique<TH2D>(h_name.c_str(), h_name.c_str(), r_dca_binning.n_of_bins, r_dca_binning.x_min,
                              r_dca_binning.x_max, y_vtx_binning.n_of_bins, y_vtx_binning.x_min, y_vtx_binning.x_max);
-    h2_[h_name]->GetYaxis()->SetTitle("Y [cm]");
-    h2_[h_name]->GetXaxis()->SetTitle(Form("DCA_{%s} [cm]", di));
+    fH2D[h_name]->GetYaxis()->SetTitle("Y [cm]");
+    fH2D[h_name]->GetXaxis()->SetTitle(Form("DCA_{%s} [cm]", di));
 
     h_name = Form("dca_d%s_vs_z", di);
-    h2_[h_name] =
+    fH2D[h_name] =
       std::make_unique<TH2D>(h_name.c_str(), h_name.c_str(), r_dca_binning.n_of_bins, r_dca_binning.x_min,
                              r_dca_binning.x_max, z_vtx_binning.n_of_bins, z_vtx_binning.x_min, z_vtx_binning.x_max);
-    h2_[h_name]->GetYaxis()->SetTitle(Form("Z [cm]"));
-    h2_[h_name]->GetXaxis()->SetTitle(Form("DCA_{%s} [cm]", di));
+    fH2D[h_name]->GetYaxis()->SetTitle(Form("Z [cm]"));
+    fH2D[h_name]->GetXaxis()->SetTitle(Form("DCA_{%s} [cm]", di));
   }
   // ---- ------------------ ----
 
   // ---- Track multiplicity ----
   for (const char* mod : {":all", ":sel"}) {
     h_name      = Form("ca_track_multiplicity%s", mod);
-    h1_[h_name] = std::make_unique<TH1D>(h_name.c_str(), h_name.c_str(), 50, 0, 50);  // HARDCODE
-    h1_[h_name]->GetXaxis()->SetTitle("N_{CATrack}");
-    h1_[h_name]->GetYaxis()->SetTitle("Entries");
+    fH1D[h_name] = std::make_unique<TH1D>(h_name.c_str(), h_name.c_str(), 50, 0, 50);  // HARDCODE
+    fH1D[h_name]->GetXaxis()->SetTitle("N_{CATrack}");
+    fH1D[h_name]->GetYaxis()->SetTitle("Entries");
 
     h_name      = Form("ca_track_chi2%s", mod);
-    h1_[h_name] = std::make_unique<TH1D>(h_name.c_str(), h_name.c_str(), 10000, 0, 10);  // HARDCODE
-    h1_[h_name]->GetXaxis()->SetTitle("Chi2");
-    h1_[h_name]->GetYaxis()->SetTitle("Entries");
+    fH1D[h_name] = std::make_unique<TH1D>(h_name.c_str(), h_name.c_str(), 10000, 0, 10);  // HARDCODE
+    fH1D[h_name]->GetXaxis()->SetTitle("Chi2");
+    fH1D[h_name]->GetYaxis()->SetTitle("Entries");
   }
   // ---- ------------------ ----
 }
 
 void CbmStsEfficiency::CheckEfficiency()
 {
-  LOG(debug) << "Checking efficiency of STS station " << test_layer_ << " using " << glb_trks_.size()
+  LOG(debug) << "Checking efficiency of STS station " << fTestLayer << " using " << fGlbTrks.size()
              << " CbmGlobalTracks";
-  vertex_finder_->SetTracks(glb_trks_);
-  const std::optional<CbmVertex> vertex = vertex_finder_->FindVertex();
+  fVertexFinder->SetTracks(fGlbTrks);
+  const std::optional<CbmVertex> vertex = fVertexFinder->FindVertex();
 
   if (!vertex.has_value()) return;
 
-  if (std::abs(vertex->GetZ()) > max_dis_trg_vtx_) return;
+  if (std::abs(vertex->GetZ()) > fMaxDisTrgVtx) return;
 
-  h2_["vertex_y_vs_x"]->Fill(vertex->GetX(), vertex->GetY());
-  h2_["vertex_x_vs_z"]->Fill(vertex->GetZ(), vertex->GetX());
-  h2_["vertex_y_vs_z"]->Fill(vertex->GetZ(), vertex->GetY());
+  fH2D["vertex_y_vs_x"]->Fill(vertex->GetX(), vertex->GetY());
+  fH2D["vertex_x_vs_z"]->Fill(vertex->GetZ(), vertex->GetX());
+  fH2D["vertex_y_vs_z"]->Fill(vertex->GetZ(), vertex->GetY());
 
   TVector3 vtx(vertex->GetX(), vertex->GetY(), vertex->GetZ());
   std::map<int32_t, std::vector<bool>> hit_used;
-  for (auto trk : glb_trks_) {
+  for (auto trk : fGlbTrks) {
     double trk_tx = trk->GetParamFirst()->GetTx();
     double trk_ty = trk->GetParamFirst()->GetTy();
     double trk_x0 = trk->GetParamFirst()->GetX();
@@ -206,49 +206,49 @@ void CbmStsEfficiency::CheckEfficiency()
     TVector3 e(trk_tx, trk_ty, 1);
     TVector3 trk_to_vtx = ((vtx - p).Cross(e)) * (1. / e.Mag());
 
-    h2_["dca_dx_vs_x"]->Fill(trk_to_vtx.Px(), vtx.Px());
-    h2_["dca_dx_vs_y"]->Fill(trk_to_vtx.Px(), vtx.Py());
-    h2_["dca_dx_vs_z"]->Fill(trk_to_vtx.Px(), vtx.Pz());
+    fH2D["dca_dx_vs_x"]->Fill(trk_to_vtx.Px(), vtx.Px());
+    fH2D["dca_dx_vs_y"]->Fill(trk_to_vtx.Px(), vtx.Py());
+    fH2D["dca_dx_vs_z"]->Fill(trk_to_vtx.Px(), vtx.Pz());
 
-    h2_["dca_dy_vs_x"]->Fill(trk_to_vtx.Py(), vtx.Px());
-    h2_["dca_dy_vs_y"]->Fill(trk_to_vtx.Py(), vtx.Py());
-    h2_["dca_dy_vs_z"]->Fill(trk_to_vtx.Py(), vtx.Pz());
+    fH2D["dca_dy_vs_x"]->Fill(trk_to_vtx.Py(), vtx.Px());
+    fH2D["dca_dy_vs_y"]->Fill(trk_to_vtx.Py(), vtx.Py());
+    fH2D["dca_dy_vs_z"]->Fill(trk_to_vtx.Py(), vtx.Pz());
 
-    h2_["dca_dz_vs_x"]->Fill(trk_to_vtx.Pz(), vtx.Px());
-    h2_["dca_dz_vs_y"]->Fill(trk_to_vtx.Pz(), vtx.Py());
-    h2_["dca_dz_vs_z"]->Fill(trk_to_vtx.Pz(), vtx.Pz());
+    fH2D["dca_dz_vs_x"]->Fill(trk_to_vtx.Pz(), vtx.Px());
+    fH2D["dca_dz_vs_y"]->Fill(trk_to_vtx.Pz(), vtx.Py());
+    fH2D["dca_dz_vs_z"]->Fill(trk_to_vtx.Pz(), vtx.Pz());
 
-    if (trk_to_vtx.Mag() > max_dca_trk_vtx_) continue;
+    if (trk_to_vtx.Mag() > fMaxDCATrkVtx) continue;
 
-    for (int32_t& sensor : sensors_under_test_) {
-      auto hits        = sts_hits_[sensor];
+    for (int32_t& sensor : fDUTList) {
+      auto hits        = fStsHits[sensor];
       size_t n_of_hits = hits.size();
 
       // Extrapolate to the current sensor z-plane
-      double sensor_z    = 0.5 * (sts_geo_info_[sensor][4] + sts_geo_info_[sensor][5]);
+      double sensor_z    = 0.5 * (fStsGeoInfo[sensor][4] + fStsGeoInfo[sensor][5]);
       double predicted_x = trk_x0 + trk_tx * (sensor_z - trk_z0);
       double predicted_y = trk_y0 + trk_ty * (sensor_z - trk_z0);
 
       // Check if the sensor contain the space point
-      if (predicted_x < sts_geo_info_[sensor][0] || predicted_x > sts_geo_info_[sensor][1]
-          || predicted_y < sts_geo_info_[sensor][2] || predicted_y > sts_geo_info_[sensor][3]) {
+      if (predicted_x < fStsGeoInfo[sensor][0] || predicted_x > fStsGeoInfo[sensor][1]
+          || predicted_y < fStsGeoInfo[sensor][2] || predicted_y > fStsGeoInfo[sensor][3]) {
         continue;
       }
 
       int unit = CbmStsAddress::GetElementId(sensor, kStsUnit);
-      h2_[Form("Sts%d_track", unit)]->Fill(predicted_x, predicted_y);
-      h2_[Form("Sts0x%x_track", sensor)]->Fill(predicted_x, predicted_y);
+      fH2D[Form("Sts%d_track", unit)]->Fill(predicted_x, predicted_y);
+      fH2D[Form("Sts0x%x_track", sensor)]->Fill(predicted_x, predicted_y);
 
       if (n_of_hits) {
         /* Block to search in available hits */
         double closest_id  = 0;
-        double dx          = hits[0]->GetX() - predicted_x - residuals_[sensor].mean.Px();
-        double dy          = hits[0]->GetY() - predicted_y - residuals_[sensor].mean.Py();
+        double dx          = hits[0]->GetX() - predicted_x - fResiduals[sensor].mean.Px();
+        double dy          = hits[0]->GetY() - predicted_y - fResiduals[sensor].mean.Py();
         double closest_rho = dx * dx + dy * dy;
 
         for (size_t idx = 1; idx < n_of_hits; idx++) {
-          dx         = hits[idx]->GetX() - predicted_x - residuals_[sensor].mean.Px();
-          dy         = hits[idx]->GetY() - predicted_y - residuals_[sensor].mean.Py();
+          dx         = hits[idx]->GetX() - predicted_x - fResiduals[sensor].mean.Px();
+          dy         = hits[idx]->GetY() - predicted_y - fResiduals[sensor].mean.Py();
           double rho = dx * dx + dy * dy;
 
           if (rho < closest_rho) {
@@ -257,24 +257,24 @@ void CbmStsEfficiency::CheckEfficiency()
           }
         }
 
-        dx = hits[closest_id]->GetX() - predicted_x - residuals_[sensor].mean.Px();
-        dy = hits[closest_id]->GetY() - predicted_y - residuals_[sensor].mean.Py();
+        dx = hits[closest_id]->GetX() - predicted_x - fResiduals[sensor].mean.Px();
+        dy = hits[closest_id]->GetY() - predicted_y - fResiduals[sensor].mean.Py();
 
-        h2_[Form("Sts%d_dx_vs_x", unit)]->Fill(dx, hits[closest_id]->GetX());
-        h2_[Form("Sts%d_dy_vs_x", unit)]->Fill(dy, hits[closest_id]->GetX());
-        h2_[Form("Sts%d_dx_vs_y", unit)]->Fill(dx, hits[closest_id]->GetY());
-        h2_[Form("Sts%d_dy_vs_y", unit)]->Fill(dy, hits[closest_id]->GetY());
+        fH2D[Form("Sts%d_dx_vs_x", unit)]->Fill(dx, hits[closest_id]->GetX());
+        fH2D[Form("Sts%d_dy_vs_x", unit)]->Fill(dy, hits[closest_id]->GetX());
+        fH2D[Form("Sts%d_dx_vs_y", unit)]->Fill(dx, hits[closest_id]->GetY());
+        fH2D[Form("Sts%d_dy_vs_y", unit)]->Fill(dy, hits[closest_id]->GetY());
 
-        h2_[Form("Sts0x%x_dx_vs_x", sensor)]->Fill(dx, hits[closest_id]->GetX());
-        h2_[Form("Sts0x%x_dy_vs_x", sensor)]->Fill(dy, hits[closest_id]->GetX());
-        h2_[Form("Sts0x%x_dx_vs_y", sensor)]->Fill(dx, hits[closest_id]->GetY());
-        h2_[Form("Sts0x%x_dy_vs_y", sensor)]->Fill(dy, hits[closest_id]->GetY());
+        fH2D[Form("Sts0x%x_dx_vs_x", sensor)]->Fill(dx, hits[closest_id]->GetX());
+        fH2D[Form("Sts0x%x_dy_vs_x", sensor)]->Fill(dy, hits[closest_id]->GetX());
+        fH2D[Form("Sts0x%x_dx_vs_y", sensor)]->Fill(dx, hits[closest_id]->GetY());
+        fH2D[Form("Sts0x%x_dy_vs_y", sensor)]->Fill(dy, hits[closest_id]->GetY());
 
         double sensor_resolution =
-          residuals_[sensor].sigma.Mag() != 0 ? residuals_[sensor].sigma.Mag() : default_residual_;
+          fResiduals[sensor].sigma.Mag() != 0 ? fResiduals[sensor].sigma.Mag() : fDefaultResidual;
         if (closest_rho <= 3.0 * sensor_resolution) {
-          h2_[Form("Sts%d_found", unit)]->Fill(predicted_x, predicted_y);
-          h2_[Form("Sts0x%x_found", sensor)]->Fill(predicted_x, predicted_y);
+          fH2D[Form("Sts%d_found", unit)]->Fill(predicted_x, predicted_y);
+          fH2D[Form("Sts0x%x_found", sensor)]->Fill(predicted_x, predicted_y);
         }
       }
 
@@ -330,19 +330,19 @@ TH2D* FindInactiveArea(TH2D* h, int dead_size_x = 10, int dead_size_y = 10)
 void CbmStsEfficiency::Efficiency(uint32_t sensor)
 {
   std::string h_name_base = "";
-  if (sensor == test_layer_) {
+  if (sensor == fTestLayer) {
     h_name_base = Form("Sts%d", sensor);
   }
   else if (sensor > 8) {
-    if (CbmStsAddress::GetElementId(sensor, kStsUnit) != test_layer_) return;
+    if (CbmStsAddress::GetElementId(sensor, kStsUnit) != fTestLayer) return;
     h_name_base = Form("Sts0x%x", sensor);
   }
-  auto found = h2_[Form("%s_found", h_name_base.c_str())].get();
-  auto track = h2_[Form("%s_track", h_name_base.c_str())].get();
+  auto found = fH2D[Form("%s_found", h_name_base.c_str())].get();
+  auto track = fH2D[Form("%s_track", h_name_base.c_str())].get();
 
   if (found == nullptr || track == nullptr) return;
 
-  TH2D* inactive_area = FindInactiveArea(h2_[Form("%s_hit_map", h_name_base.c_str())].get(), 50, 50);
+  TH2D* inactive_area = FindInactiveArea(fH2D[Form("%s_hit_map", h_name_base.c_str())].get(), 50, 50);
 
   // Manual integration
   int n_of_found = 0;
@@ -387,7 +387,7 @@ void CbmStsEfficiency::Efficiency(uint32_t sensor)
 
 void CbmStsEfficiency::FinishTask()
 {
-  for (auto& [element, geo] : sts_geo_info_) {
+  for (auto& [element, geo] : fStsGeoInfo) {
     Efficiency(element);
   }
 
@@ -401,24 +401,24 @@ void CbmStsEfficiency::ProcessEvent(CbmEvent* evt)
 
   for (int hit_evt_idx = 0; hit_evt_idx < nb_sts_hits; hit_evt_idx++) {
     int sts_hit_idx = evt->GetIndex(ECbmDataType::kStsHit, hit_evt_idx);
-    CbmStsHit* hit  = (CbmStsHit*) sts_hit_array_->UncheckedAt(sts_hit_idx);
+    CbmStsHit* hit  = (CbmStsHit*) fStsHitArray->UncheckedAt(sts_hit_idx);
     ProcessHit(hit);
   }
 
   int nb_of_glob_trk = evt->GetNofData(ECbmDataType::kGlobalTrack);
   for (int evt_glob_trk_idx = 0; evt_glob_trk_idx < nb_of_glob_trk; evt_glob_trk_idx++) {
     int glob_trk_idx         = evt->GetIndex(ECbmDataType::kGlobalTrack, evt_glob_trk_idx);
-    CbmGlobalTrack* glob_trk = (CbmGlobalTrack*) glb_trk_array_->UncheckedAt(glob_trk_idx);
+    CbmGlobalTrack* glob_trk = (CbmGlobalTrack*) fGlbTrkArray->UncheckedAt(glob_trk_idx);
     ProcessGlobalTrack(glob_trk);
   }
 
-  h1_["ca_track_multiplicity:all"]->Fill(nb_of_glob_trk);
-  h1_["ca_track_multiplicity:sel"]->Fill(glb_trks_.size());
+  fH1D["ca_track_multiplicity:all"]->Fill(nb_of_glob_trk);
+  fH1D["ca_track_multiplicity:sel"]->Fill(fGlbTrks.size());
 
-  if (glb_trks_.size()) CheckEfficiency();
+  if (fGlbTrks.size()) CheckEfficiency();
 
-  glb_trks_.clear();
-  sts_hits_.clear();
+  fGlbTrks.clear();
+  fStsHits.clear();
 }
 
 void CbmStsEfficiency::ProcessGlobalTrack(CbmGlobalTrack* trk)
@@ -429,47 +429,47 @@ void CbmStsEfficiency::ProcessGlobalTrack(CbmGlobalTrack* trk)
   auto trd_trk_idx  = trk->GetTrdTrackIndex();
   auto tof_trk_idx  = trk->GetTofTrackIndex();
   double trk_p_val  = TMath::Prob(trk->GetChi2(), trk->GetNDF());
-  h1_["ca_track_chi2:all"]->Fill(trk->GetChi2());
+  fH1D["ca_track_chi2:all"]->Fill(trk->GetChi2());
 
   // Apply GlobalTracks cuts
-  int32_t mvd_trk_size = sts_trk_idx != -1 && sts_trk_array_ != nullptr
-                           ? ((CbmStsTrack*) sts_trk_array_->UncheckedAt(sts_trk_idx))->GetNofMvdHits()
+  int32_t mvd_trk_size = sts_trk_idx != -1 && fStsTrkArray != nullptr
+                           ? ((CbmStsTrack*) fStsTrkArray->UncheckedAt(sts_trk_idx))->GetNofMvdHits()
                            : 0;
 
-  int32_t sts_trk_size = sts_trk_idx != -1 && sts_trk_array_ != nullptr
-                           ? ((CbmStsTrack*) sts_trk_array_->UncheckedAt(sts_trk_idx))->GetNofStsHits()
+  int32_t sts_trk_size = sts_trk_idx != -1 && fStsTrkArray != nullptr
+                           ? ((CbmStsTrack*) fStsTrkArray->UncheckedAt(sts_trk_idx))->GetNofStsHits()
                            : 0;
 
-  int32_t rich_trk_size = rich_trk_idx != -1 && rch_trk_array_ != nullptr
-                            ? ((CbmTrack*) rch_trk_array_->UncheckedAt(rich_trk_idx))->GetNofHits()
+  int32_t rich_trk_size = rich_trk_idx != -1 && fRchTrkArray != nullptr
+                            ? ((CbmTrack*) fRchTrkArray->UncheckedAt(rich_trk_idx))->GetNofHits()
                             : 0;
 
-  int32_t much_trk_size = much_trk_idx != -1 && mch_trk_array_ != nullptr
-                            ? ((CbmTrack*) mch_trk_array_->UncheckedAt(much_trk_idx))->GetNofHits()
+  int32_t much_trk_size = much_trk_idx != -1 && fMchTrkArray != nullptr
+                            ? ((CbmTrack*) fMchTrkArray->UncheckedAt(much_trk_idx))->GetNofHits()
                             : 0;
 
-  int32_t trd_trk_size = trd_trk_idx != -1 && trd_trk_array_ != nullptr
-                           ? ((CbmTrack*) trd_trk_array_->UncheckedAt(trd_trk_idx))->GetNofHits()
+  int32_t trd_trk_size = trd_trk_idx != -1 && fTrdTrkArray != nullptr
+                           ? ((CbmTrack*) fTrdTrkArray->UncheckedAt(trd_trk_idx))->GetNofHits()
                            : 0;
 
-  int32_t tof_trk_size = tof_trk_idx != -1 && tof_trk_array_ != nullptr
-                           ? ((CbmTrack*) tof_trk_array_->UncheckedAt(tof_trk_idx))->GetNofHits()
+  int32_t tof_trk_size = tof_trk_idx != -1 && fTofTrkArray != nullptr
+                           ? ((CbmTrack*) fTofTrkArray->UncheckedAt(tof_trk_idx))->GetNofHits()
                            : 0;
 
-  if (analysis_cut_ != nullptr
-      && (!analysis_cut_->Check(CbmCutId::kGlobalTrackMvdSize, mvd_trk_size)
-          || !analysis_cut_->Check(CbmCutId::kGlobalTrackStsSize, sts_trk_size)
-          || !analysis_cut_->Check(CbmCutId::kGlobalTrackRichSize, rich_trk_size)
-          || !analysis_cut_->Check(CbmCutId::kGlobalTrackMuchSize, much_trk_size)
-          || !analysis_cut_->Check(CbmCutId::kGlobalTrackTrdSize, trd_trk_size)
-          || !analysis_cut_->Check(CbmCutId::kGlobalTrackTofSize, tof_trk_size)
-          || !analysis_cut_->Check(CbmCutId::kGlobalTrackChi2, trk->GetChi2())
-          || !analysis_cut_->Check(CbmCutId::kGlobalTrackPval, trk_p_val))) {
+  if (fAnalysisCuts != nullptr
+      && (!fAnalysisCuts->Check(CbmCutId::kGlobalTrackMvdSize, mvd_trk_size)
+          || !fAnalysisCuts->Check(CbmCutId::kGlobalTrackStsSize, sts_trk_size)
+          || !fAnalysisCuts->Check(CbmCutId::kGlobalTrackRichSize, rich_trk_size)
+          || !fAnalysisCuts->Check(CbmCutId::kGlobalTrackMuchSize, much_trk_size)
+          || !fAnalysisCuts->Check(CbmCutId::kGlobalTrackTrdSize, trd_trk_size)
+          || !fAnalysisCuts->Check(CbmCutId::kGlobalTrackTofSize, tof_trk_size)
+          || !fAnalysisCuts->Check(CbmCutId::kGlobalTrackChi2, trk->GetChi2())
+          || !fAnalysisCuts->Check(CbmCutId::kGlobalTrackPval, trk_p_val))) {
     return;
   }
 
-  h1_["ca_track_chi2:sel"]->Fill(trk->GetChi2());
-  glb_trks_.push_back(trk);
+  fH1D["ca_track_chi2:sel"]->Fill(trk->GetChi2());
+  fGlbTrks.push_back(trk);
 }
 
 void CbmStsEfficiency::ProcessHit(CbmStsHit* hit)
@@ -478,25 +478,25 @@ void CbmStsEfficiency::ProcessHit(CbmStsHit* hit)
   uint32_t address = hit->GetAddress();
   uint32_t unit    = CbmStsAddress::GetElementId(address, kStsUnit);
 
-  if (unit != test_layer_) return;
+  if (unit != fTestLayer) return;
 
-  if (analysis_cut_ != nullptr && !analysis_cut_->CheckStsHit(hit, sts_clu_array_)) return;
+  if (fAnalysisCuts != nullptr && !fAnalysisCuts->CheckStsHit(hit, fStsCluArray)) return;
 
-  sts_hits_[address].push_back(hit);
-  h2_[Form("Sts%u_hit_map", unit)]->Fill(hit->GetX(), hit->GetY());
-  h2_[Form("Sts0x%x_hit_map", address)]->Fill(hit->GetX(), hit->GetY());
+  fStsHits[address].push_back(hit);
+  fH2D[Form("Sts%u_hit_map", unit)]->Fill(hit->GetX(), hit->GetY());
+  fH2D[Form("Sts0x%x_hit_map", address)]->Fill(hit->GetX(), hit->GetY());
 }
 
 void CbmStsEfficiency::Exec(Option_t*)
 {
   // Check if CbmEvent
-  if (cbm_evt_array_ != nullptr) {
+  if (fCbmEvtArray != nullptr) {
     LOG(info) << "Running CbmStsEfficiency - Event-like - " << entry_;
 
-    uint32_t nb_events = cbm_evt_array_->GetEntriesFast();
+    uint32_t nb_events = fCbmEvtArray->GetEntriesFast();
     for (uint32_t evt_idx = 0; evt_idx < nb_events; evt_idx++) {
-      CbmEvent* event = (CbmEvent*) cbm_evt_array_->UncheckedAt(evt_idx);
-      if (analysis_cut_ != nullptr && !analysis_cut_->CheckEvent(event)) continue;
+      CbmEvent* event = (CbmEvent*) fCbmEvtArray->UncheckedAt(evt_idx);
+      if (fAnalysisCuts != nullptr && !fAnalysisCuts->CheckEvent(event)) continue;
       LOG(debug) << Form("Process CbmEvent %d / %d", evt_idx, nb_events);
       ProcessEvent(event);
     }
@@ -504,22 +504,22 @@ void CbmStsEfficiency::Exec(Option_t*)
   else {
 
     LOG(info) << "Running CbmStsEfficiency - TS-like - ";
-    uint32_t n_of_hits = sts_hit_array_->GetEntriesFast();
+    uint32_t n_of_hits = fStsHitArray->GetEntriesFast();
     for (uint32_t hit_idx = 0; hit_idx < n_of_hits; hit_idx++) {
-      CbmStsHit* sts_hit = (CbmStsHit*) sts_hit_array_->UncheckedAt(hit_idx);
+      CbmStsHit* sts_hit = (CbmStsHit*) fStsHitArray->UncheckedAt(hit_idx);
       ProcessHit(sts_hit);
     }
-    uint32_t nb_of_glob_trk = glb_trk_array_->GetEntriesFast();
+    uint32_t nb_of_glob_trk = fGlbTrkArray->GetEntriesFast();
     LOG(debug) << Form("Number of GlobalTracks: %u", nb_of_glob_trk);
     for (uint32_t glob_trk_idx = 0; glob_trk_idx < nb_of_glob_trk; glob_trk_idx++) {
-      CbmGlobalTrack* glob_trk = (CbmGlobalTrack*) glb_trk_array_->UncheckedAt(glob_trk_idx);
+      CbmGlobalTrack* glob_trk = (CbmGlobalTrack*) fGlbTrkArray->UncheckedAt(glob_trk_idx);
       ProcessGlobalTrack(glob_trk);
     }
 
-    if (glb_trks_.size()) CheckEfficiency();
+    if (fGlbTrks.size()) CheckEfficiency();
 
-    glb_trks_.clear();
-    sts_hits_.clear();
+    fGlbTrks.clear();
+    fStsHits.clear();
   }
   entry_++;
 }
@@ -530,19 +530,19 @@ InitStatus CbmStsEfficiency::Init()
 
   FairRootManager* ioman = FairRootManager::Instance();
   if (ioman != nullptr) {
-    cbm_evt_array_ = (TClonesArray*) ioman->GetObject("CbmEvent");
+    fCbmEvtArray = (TClonesArray*) ioman->GetObject("CbmEvent");
 
-    glb_trk_array_ = (TClonesArray*) ioman->GetObject("GlobalTrack");
+    fGlbTrkArray = (TClonesArray*) ioman->GetObject("GlobalTrack");
 
-    sts_trk_array_ = (TClonesArray*) ioman->GetObject("StsTrack");
-    rch_trk_array_ = (TClonesArray*) ioman->GetObject("RichTrack");
-    mch_trk_array_ = (TClonesArray*) ioman->GetObject("MuchTrack");
-    trd_trk_array_ = (TClonesArray*) ioman->GetObject("TrdTrack");
-    tof_trk_array_ = (TClonesArray*) ioman->GetObject("TofTrack");
+    fStsTrkArray = (TClonesArray*) ioman->GetObject("StsTrack");
+    fRchTrkArray = (TClonesArray*) ioman->GetObject("RichTrack");
+    fMchTrkArray = (TClonesArray*) ioman->GetObject("MuchTrack");
+    fTrdTrkArray = (TClonesArray*) ioman->GetObject("TrdTrack");
+    fTofTrkArray = (TClonesArray*) ioman->GetObject("TofTrack");
 
-    sts_hit_array_ = (TClonesArray*) ioman->GetObject("StsHit");
+    fStsHitArray = (TClonesArray*) ioman->GetObject("StsHit");
 
-    sts_clu_array_ = (TClonesArray*) ioman->GetObject("StsCluster");
+    fStsCluArray = (TClonesArray*) ioman->GetObject("StsCluster");
   }
 
   LoadSetup();
@@ -550,15 +550,15 @@ InitStatus CbmStsEfficiency::Init()
   BookHistograms();
 
   std::stringstream ss;
-  for (auto s : sensors_under_test_) {
+  for (auto s : fDUTList) {
     ss << Form("\t\t0x%x - U%d L%d M%d\n", s, CbmStsAddress::GetElementId(s, kStsUnit),
                CbmStsAddress::GetElementId(s, kStsLadder), CbmStsAddress::GetElementId(s, kStsModule));
   }
 
-  LOG(info) << "Max vtx target dz: " << max_dis_trg_vtx_;
-  LOG(info) << "Max trk vtx DCA: " << max_dca_trk_vtx_;
-  LOG(info) << "Default residual: " << default_residual_;
-  LOG(info) << "Test layer: " << test_layer_;
+  LOG(info) << "Max vtx target dz: " << fMaxDisTrgVtx;
+  LOG(info) << "Max trk vtx DCA: " << fMaxDCATrkVtx;
+  LOG(info) << "Default residual: " << fDefaultResidual;
+  LOG(info) << "Test layer: " << fTestLayer;
   LOG(info) << "Layer modules:\n" << ss.str();
 
   return kSUCCESS;
@@ -566,7 +566,7 @@ InitStatus CbmStsEfficiency::Init()
 
 void CbmStsEfficiency::SetSensorResidual(int32_t address, TVector3 m, TVector3 s)
 {
-  residuals_[address] = Residual(m, s);
+  fResiduals[address] = Residual(m, s);
 }
 
 void CbmStsEfficiency::SetResidual(std::string file_name)
@@ -580,4 +580,4 @@ void CbmStsEfficiency::SetResidual(std::string file_name)
 }
 
 
-void CbmStsEfficiency::SetVertexFinder(CbmDcaVertexFinder* vtx_finder) { vertex_finder_ = vtx_finder; }
+void CbmStsEfficiency::SetVertexFinder(CbmDcaVertexFinder* vtx_finder) { fVertexFinder = vtx_finder; }
diff --git a/analysis/detectors/sts/CbmStsEfficiency.h b/analysis/detectors/sts/CbmStsEfficiency.h
index b775e0d6a3..29469fb062 100644
--- a/analysis/detectors/sts/CbmStsEfficiency.h
+++ b/analysis/detectors/sts/CbmStsEfficiency.h
@@ -63,31 +63,31 @@ class CbmStsEfficiency : public FairTask, public CbmStsAnaBase {
 
   void SetVertexFinder(CbmDcaVertexFinder*);
 
-  bool draw_opt_{true};
+  bool fDrawOpt{true};
 
  private:
-  uint32_t test_layer_{0};
-  std::vector<int32_t> sensors_under_test_;
-  double max_dis_trg_vtx_{0.25};
-  double max_dca_trk_vtx_{0.25};
-  double default_residual_{0.12};
-  std::map<int32_t, Residual> residuals_;
-
-
-  CbmDcaVertexFinder* vertex_finder_;
-
-  std::vector<CbmGlobalTrack*> glb_trks_;
-  std::map<int32_t, std::vector<CbmStsHit*>> sts_hits_;
-
-  TClonesArray* cbm_evt_array_{nullptr};
-  TClonesArray* glb_trk_array_{nullptr};
-  TClonesArray* sts_trk_array_{nullptr};
-  TClonesArray* rch_trk_array_{nullptr};
-  TClonesArray* mch_trk_array_{nullptr};
-  TClonesArray* trd_trk_array_{nullptr};
-  TClonesArray* tof_trk_array_{nullptr};
-  TClonesArray* sts_hit_array_{nullptr};
-  TClonesArray* sts_clu_array_{nullptr};
+  uint32_t fTestLayer{0};
+  std::vector<int32_t> fDUTList;
+  double fMaxDisTrgVtx{0.25};
+  double fMaxDCATrkVtx{0.25};
+  double fDefaultResidual{0.12};
+  std::map<int32_t, Residual> fResiduals;
+
+
+  CbmDcaVertexFinder* fVertexFinder;
+
+  std::vector<CbmGlobalTrack*> fGlbTrks;
+  std::map<int32_t, std::vector<CbmStsHit*>> fStsHits;
+
+  TClonesArray* fCbmEvtArray{nullptr};
+  TClonesArray* fGlbTrkArray{nullptr};
+  TClonesArray* fStsTrkArray{nullptr};
+  TClonesArray* fRchTrkArray{nullptr};
+  TClonesArray* fMchTrkArray{nullptr};
+  TClonesArray* fTrdTrkArray{nullptr};
+  TClonesArray* fTofTrkArray{nullptr};
+  TClonesArray* fStsHitArray{nullptr};
+  TClonesArray* fStsCluArray{nullptr};
 
   void BookHistograms();
 
diff --git a/analysis/detectors/sts/CbmStsHitAna.cxx b/analysis/detectors/sts/CbmStsHitAna.cxx
index 9af4971f22..65ec4fb00b 100644
--- a/analysis/detectors/sts/CbmStsHitAna.cxx
+++ b/analysis/detectors/sts/CbmStsHitAna.cxx
@@ -10,34 +10,34 @@
 #include <iostream>
 #include <typeinfo>
 
-CbmStsHitAna::CbmStsHitAna() : hit_modifier_({":all"}) {}
+CbmStsHitAna::CbmStsHitAna() : fHitModifier({":all"}) {}
 
-CbmStsHitAna::CbmStsHitAna(std::string cal_par_file) : hit_modifier_({":all"}), calibration_file_(cal_par_file) {}
+CbmStsHitAna::CbmStsHitAna(std::string cal_par_file) : fHitModifier({":all"}), fCalibrationFile(cal_par_file) {}
 
 InitStatus CbmStsHitAna::Init()
 {
-  if (module_par_set_ == nullptr) {
+  if (fModuleParSet == nullptr) {
     LOG(debug) << "Loading charge calibration ...";
-    module_par_set_ = std::make_unique<CbmStsParSetModule>("CbmParSetModule", "STS parameters", "Default");
-    module_par_set_->LoadParASCII(calibration_file_);
+    fModuleParSet = std::make_unique<CbmStsParSetModule>("CbmParSetModule", "STS parameters", "Default");
+    fModuleParSet->LoadParASCII(fCalibrationFile);
   }
 
   FairRootManager* ioman = FairRootManager::Instance();
   if (ioman == nullptr) return kERROR;
 
-  cbm_evt_array_ = (TClonesArray*) ioman->GetObject("CbmEvent");
+  fCbmEvtArray = (TClonesArray*) ioman->GetObject("CbmEvent");
 
-  glb_trk_array_ = (TClonesArray*) ioman->GetObject("GlobalTrack");
-  sts_trk_array_ = (TClonesArray*) ioman->GetObject("StsTrack");
-  rch_trk_array_ = (TClonesArray*) ioman->GetObject("RichTrack");
-  mch_trk_array_ = (TClonesArray*) ioman->GetObject("MuchTrack");
-  trd_trk_array_ = (TClonesArray*) ioman->GetObject("TrdTrack");
-  tof_trk_array_ = (TClonesArray*) ioman->GetObject("TofTrack");
+  fGlbTrkArray = (TClonesArray*) ioman->GetObject("GlobalTrack");
+  fStsTrkArray = (TClonesArray*) ioman->GetObject("StsTrack");
+  fRchTrkArray = (TClonesArray*) ioman->GetObject("RichTrack");
+  fMchTrkArray = (TClonesArray*) ioman->GetObject("MuchTrack");
+  fTrdTrkArray = (TClonesArray*) ioman->GetObject("TrdTrack");
+  fTofTrkArray = (TClonesArray*) ioman->GetObject("TofTrack");
 
-  sts_hit_array_ = (TClonesArray*) ioman->GetObject("StsHit");
-  sts_clu_array_ = (TClonesArray*) ioman->GetObject("StsCluster");
+  fStsHitArray = (TClonesArray*) ioman->GetObject("StsHit");
+  fStsCluArray = (TClonesArray*) ioman->GetObject("StsCluster");
 
-  if (glb_trk_array_) hit_modifier_.push_back(":trk");
+  if (fGlbTrkArray) fHitModifier.push_back(":trk");
 
   LoadSetup();
 
@@ -48,15 +48,15 @@ void CbmStsHitAna::BookHistograms(int32_t address)
 {
   LOG(debug) << Form("Booking histograms for module: 0x%x", address);
 
-  const CbmStsParModule& par_module           = module_par_set_->GetParModule(address);
-  const auto [n_side_binning, p_side_binning] = cbm_sts_utils::ChargeBinning(par_module, max_clu_size_);
+  const CbmStsParModule& par_module           = fModuleParSet->GetParModule(address);
+  const auto [n_side_binning, p_side_binning] = cbm_sts_utils::ChargeBinning(par_module, fMaxCluSize);
 
   std::string h_name;
 
-  double x_min = sts_geo_info_.count(address) ? sts_geo_info_[address][0] : -15;
-  double x_max = sts_geo_info_.count(address) ? sts_geo_info_[address][1] : +15;
-  double y_min = sts_geo_info_.count(address) ? sts_geo_info_[address][2] : -15;
-  double y_max = sts_geo_info_.count(address) ? sts_geo_info_[address][3] : +15;
+  double x_min = fStsGeoInfo.count(address) ? fStsGeoInfo[address][0] : -15;
+  double x_max = fStsGeoInfo.count(address) ? fStsGeoInfo[address][1] : +15;
+  double y_min = fStsGeoInfo.count(address) ? fStsGeoInfo[address][2] : -15;
+  double y_max = fStsGeoInfo.count(address) ? fStsGeoInfo[address][3] : +15;
 
   double t_min = -150 - 0.5 * cbm_sts_utils::kStsClock;
   double t_max = +150 + 0.5 * cbm_sts_utils::kStsClock;
@@ -65,52 +65,52 @@ void CbmStsHitAna::BookHistograms(int32_t address)
   auto y_binning = cbm_sts_utils::HBinning{uint32_t((y_max - y_min) / cbm_sts_utils::kStsDy), y_min, y_max};
   auto t_binning = cbm_sts_utils::HBinning{uint32_t((t_max - t_min) / cbm_sts_utils::kStsClock), t_min, t_max};
 
-  for (const char* mod : hit_modifier_) {
+  for (const char* mod : fHitModifier) {
     h_name      = Form("0x%x_Q_asymmetry%s", address, mod);
-    h1_[h_name] = std::make_unique<TH1D>(h_name.c_str(), h_name.c_str(), 1000, -1.01, +1.01);
+    fH1D[h_name] = std::make_unique<TH1D>(h_name.c_str(), h_name.c_str(), 1000, -1.01, +1.01);
 
     h_name      = Form("0x%x_Qp_vs_Qn%s", address, mod);
-    h2_[h_name] = std::make_unique<TH2D>(h_name.c_str(), h_name.c_str(), n_side_binning.n_of_bins, n_side_binning.x_min,
+    fH2D[h_name] = std::make_unique<TH2D>(h_name.c_str(), h_name.c_str(), n_side_binning.n_of_bins, n_side_binning.x_min,
                                          n_side_binning.x_max, p_side_binning.n_of_bins, p_side_binning.x_min,
                                          p_side_binning.x_max);
 
     h_name      = Form("0x%x_Qp_vs_size%s", address, mod);
-    h2_[h_name] = std::make_unique<TH2D>(h_name.c_str(), h_name.c_str(), p_side_binning.n_of_bins, p_side_binning.x_min,
-                                         p_side_binning.x_max, max_clu_size_, 1, max_clu_size_ + 1);
+    fH2D[h_name] = std::make_unique<TH2D>(h_name.c_str(), h_name.c_str(), p_side_binning.n_of_bins, p_side_binning.x_min,
+                                         p_side_binning.x_max, fMaxCluSize, 1, fMaxCluSize + 1);
 
     h_name      = Form("0x%x_Qn_vs_size%s", address, mod);
-    h2_[h_name] = std::make_unique<TH2D>(h_name.c_str(), h_name.c_str(), n_side_binning.n_of_bins, n_side_binning.x_min,
-                                         n_side_binning.x_max, max_clu_size_, 1, max_clu_size_ + 1);
+    fH2D[h_name] = std::make_unique<TH2D>(h_name.c_str(), h_name.c_str(), n_side_binning.n_of_bins, n_side_binning.x_min,
+                                         n_side_binning.x_max, fMaxCluSize, 1, fMaxCluSize + 1);
 
     h_name      = Form("0x%x_psize_vs_nsize%s", address, mod);
-    h2_[h_name] = std::make_unique<TH2D>(h_name.c_str(), h_name.c_str(), max_clu_size_, 1, max_clu_size_ + 1,
-                                         max_clu_size_, 1, max_clu_size_ + 1);
+    fH2D[h_name] = std::make_unique<TH2D>(h_name.c_str(), h_name.c_str(), fMaxCluSize, 1, fMaxCluSize + 1,
+                                         fMaxCluSize, 1, fMaxCluSize + 1);
 
     h_name      = Form("0x%x_y_vs_x%s", address, mod);
-    h2_[h_name] = std::make_unique<TH2D>(h_name.c_str(), h_name.c_str(), x_binning.n_of_bins, x_binning.x_min,
+    fH2D[h_name] = std::make_unique<TH2D>(h_name.c_str(), h_name.c_str(), x_binning.n_of_bins, x_binning.x_min,
                                          x_binning.x_max, y_binning.n_of_bins, y_binning.x_min, y_binning.x_max);
 
     h_name = Form("0x%x_cluster_dt%s", address, mod);
-    h1_[h_name] =
+    fH1D[h_name] =
       std::make_unique<TH1D>(h_name.c_str(), h_name.c_str(), t_binning.n_of_bins, t_binning.x_min, t_binning.x_max);
   }
 }
 
 void CbmStsHitAna::ProcessEvent(CbmEvent* evt)
 {
-  if (analysis_cut_ != nullptr && !analysis_cut_->CheckEvent(evt)) return;
+  if (fAnalysisCuts != nullptr && !fAnalysisCuts->CheckEvent(evt)) return;
 
   int nb_sts_hits = evt->GetNofData(ECbmDataType::kStsHit);
   for (int hit_evt_idx = 0; hit_evt_idx < nb_sts_hits; hit_evt_idx++) {
     int sts_hit_idx = evt->GetIndex(ECbmDataType::kStsHit, hit_evt_idx);
-    CbmStsHit* hit  = (CbmStsHit*) sts_hit_array_->UncheckedAt(sts_hit_idx);
+    CbmStsHit* hit  = (CbmStsHit*) fStsHitArray->UncheckedAt(sts_hit_idx);
     ProcessHit(hit, false);
   }
 
   int nb_of_glob_trk = evt->GetNofData(ECbmDataType::kGlobalTrack);
   for (int evt_glob_trk_idx = 0; evt_glob_trk_idx < nb_of_glob_trk; evt_glob_trk_idx++) {
     int glob_trk_idx         = evt->GetIndex(ECbmDataType::kGlobalTrack, evt_glob_trk_idx);
-    CbmGlobalTrack* glob_trk = (CbmGlobalTrack*) glb_trk_array_->UncheckedAt(glob_trk_idx);
+    CbmGlobalTrack* glob_trk = (CbmGlobalTrack*) fGlbTrkArray->UncheckedAt(glob_trk_idx);
     ProcessGlobalTrack(glob_trk);
   }
 }
@@ -120,31 +120,31 @@ void CbmStsHitAna::ProcessHit(CbmStsHit* hit, bool belong_to_trk)
   if (hit == nullptr) return;
   int32_t address = hit->GetAddress();
 
-  if (analysis_cut_ != nullptr && !analysis_cut_->CheckStsHit(hit, sts_clu_array_)) {
+  if (fAnalysisCuts != nullptr && !fAnalysisCuts->CheckStsHit(hit, fStsCluArray)) {
     return;
   }
 
-  if (!address_book_.count(address)) {
-    address_book_.insert(address);
+  if (!fAddressBook.count(address)) {
+    fAddressBook.insert(address);
     BookHistograms(address);
   }
 
-  double q_n = cbm_sts_utils::GetHitChargeF(hit, sts_clu_array_);
-  double q_p = cbm_sts_utils::GetHitChargeB(hit, sts_clu_array_);
+  double q_n = cbm_sts_utils::GetHitChargeF(hit, fStsCluArray);
+  double q_p = cbm_sts_utils::GetHitChargeB(hit, fStsCluArray);
 
-  int32_t size_n = cbm_sts_utils::GetHitCluSizeF(hit, sts_clu_array_);
-  int32_t size_p = cbm_sts_utils::GetHitCluSizeB(hit, sts_clu_array_);
+  int32_t size_n = cbm_sts_utils::GetHitCluSizeF(hit, fStsCluArray);
+  int32_t size_p = cbm_sts_utils::GetHitCluSizeB(hit, fStsCluArray);
 
-  const char* mod = hit_modifier_[belong_to_trk];
+  const char* mod = fHitModifier[belong_to_trk];
 
-  h1_[Form("0x%x_Q_asymmetry%s", address, mod)]->Fill(cbm_sts_utils::GetHitChargeAsy(hit, sts_clu_array_));
-  h2_[Form("0x%x_Qp_vs_Qn%s", address, mod)]->Fill(q_n, q_p);
-  h2_[Form("0x%x_Qp_vs_size%s", address, mod)]->Fill(q_p, size_p);
-  h2_[Form("0x%x_Qn_vs_size%s", address, mod)]->Fill(q_n, size_n);
-  h2_[Form("0x%x_psize_vs_nsize%s", address, mod)]->Fill(size_p, size_n);
-  h2_[Form("0x%x_y_vs_x%s", address, mod)]->Fill(hit->GetX(), hit->GetY());
-  h1_[Form("0x%x_cluster_dt%s", address, mod)]->Fill(cbm_sts_utils::GetHitTimeF(hit, sts_clu_array_)
-                                                     - cbm_sts_utils::GetHitTimeB(hit, sts_clu_array_));
+  fH1D[Form("0x%x_Q_asymmetry%s", address, mod)]->Fill(cbm_sts_utils::GetHitChargeAsy(hit, fStsCluArray));
+  fH2D[Form("0x%x_Qp_vs_Qn%s", address, mod)]->Fill(q_n, q_p);
+  fH2D[Form("0x%x_Qp_vs_size%s", address, mod)]->Fill(q_p, size_p);
+  fH2D[Form("0x%x_Qn_vs_size%s", address, mod)]->Fill(q_n, size_n);
+  fH2D[Form("0x%x_psize_vs_nsize%s", address, mod)]->Fill(size_p, size_n);
+  fH2D[Form("0x%x_y_vs_x%s", address, mod)]->Fill(hit->GetX(), hit->GetY());
+  fH1D[Form("0x%x_cluster_dt%s", address, mod)]->Fill(cbm_sts_utils::GetHitTimeF(hit, fStsCluArray)
+                                                     - cbm_sts_utils::GetHitTimeB(hit, fStsCluArray));
 }
 
 void CbmStsHitAna::ProcessGlobalTrack(CbmGlobalTrack* trk)
@@ -157,50 +157,50 @@ void CbmStsHitAna::ProcessGlobalTrack(CbmGlobalTrack* trk)
   float trk_p_val   = TMath::Prob(trk->GetChi2(), trk->GetNDF());
 
   // Apply GlobalTracks cuts
-  int32_t mvd_trk_size = sts_trk_idx != -1 && sts_trk_array_ != nullptr
-                           ? ((CbmStsTrack*) sts_trk_array_->UncheckedAt(sts_trk_idx))->GetNofMvdHits()
+  int32_t mvd_trk_size = sts_trk_idx != -1 && fStsTrkArray != nullptr
+                           ? ((CbmStsTrack*) fStsTrkArray->UncheckedAt(sts_trk_idx))->GetNofMvdHits()
                            : 0;
 
-  int32_t sts_trk_size = sts_trk_idx != -1 && sts_trk_array_ != nullptr
-                           ? ((CbmStsTrack*) sts_trk_array_->UncheckedAt(sts_trk_idx))->GetNofStsHits()
+  int32_t sts_trk_size = sts_trk_idx != -1 && fStsTrkArray != nullptr
+                           ? ((CbmStsTrack*) fStsTrkArray->UncheckedAt(sts_trk_idx))->GetNofStsHits()
                            : 0;
 
-  int32_t rich_trk_size = rich_trk_idx != -1 && rch_trk_array_ != nullptr
-                            ? ((CbmTrack*) rch_trk_array_->UncheckedAt(rich_trk_idx))->GetNofHits()
+  int32_t rich_trk_size = rich_trk_idx != -1 && fRchTrkArray != nullptr
+                            ? ((CbmTrack*) fRchTrkArray->UncheckedAt(rich_trk_idx))->GetNofHits()
                             : 0;
 
-  int32_t much_trk_size = much_trk_idx != -1 && mch_trk_array_ != nullptr
-                            ? ((CbmTrack*) mch_trk_array_->UncheckedAt(much_trk_idx))->GetNofHits()
+  int32_t much_trk_size = much_trk_idx != -1 && fMchTrkArray != nullptr
+                            ? ((CbmTrack*) fMchTrkArray->UncheckedAt(much_trk_idx))->GetNofHits()
                             : 0;
 
-  int32_t trd_trk_size = trd_trk_idx != -1 && trd_trk_array_ != nullptr
-                           ? ((CbmTrack*) trd_trk_array_->UncheckedAt(trd_trk_idx))->GetNofHits()
+  int32_t trd_trk_size = trd_trk_idx != -1 && fTrdTrkArray != nullptr
+                           ? ((CbmTrack*) fTrdTrkArray->UncheckedAt(trd_trk_idx))->GetNofHits()
                            : 0;
 
-  int32_t tof_trk_size = tof_trk_idx != -1 && tof_trk_array_ != nullptr
-                           ? ((CbmTrack*) tof_trk_array_->UncheckedAt(tof_trk_idx))->GetNofHits()
+  int32_t tof_trk_size = tof_trk_idx != -1 && fTofTrkArray != nullptr
+                           ? ((CbmTrack*) fTofTrkArray->UncheckedAt(tof_trk_idx))->GetNofHits()
                            : 0;
 
-  if (analysis_cut_ != nullptr
-      && (!analysis_cut_->Check(CbmCutId::kGlobalTrackMvdSize, mvd_trk_size)
-          || !analysis_cut_->Check(CbmCutId::kGlobalTrackStsSize, sts_trk_size)
-          || !analysis_cut_->Check(CbmCutId::kGlobalTrackRichSize, rich_trk_size)
-          || !analysis_cut_->Check(CbmCutId::kGlobalTrackMuchSize, much_trk_size)
-          || !analysis_cut_->Check(CbmCutId::kGlobalTrackTrdSize, trd_trk_size)
-          || !analysis_cut_->Check(CbmCutId::kGlobalTrackTofSize, tof_trk_size)
-          || !analysis_cut_->Check(CbmCutId::kGlobalTrackChi2, trk->GetChi2())
-          || !analysis_cut_->Check(CbmCutId::kGlobalTrackPval, trk_p_val))) {
+  if (fAnalysisCuts != nullptr
+      && (!fAnalysisCuts->Check(CbmCutId::kGlobalTrackMvdSize, mvd_trk_size)
+          || !fAnalysisCuts->Check(CbmCutId::kGlobalTrackStsSize, sts_trk_size)
+          || !fAnalysisCuts->Check(CbmCutId::kGlobalTrackRichSize, rich_trk_size)
+          || !fAnalysisCuts->Check(CbmCutId::kGlobalTrackMuchSize, much_trk_size)
+          || !fAnalysisCuts->Check(CbmCutId::kGlobalTrackTrdSize, trd_trk_size)
+          || !fAnalysisCuts->Check(CbmCutId::kGlobalTrackTofSize, tof_trk_size)
+          || !fAnalysisCuts->Check(CbmCutId::kGlobalTrackChi2, trk->GetChi2())
+          || !fAnalysisCuts->Check(CbmCutId::kGlobalTrackPval, trk_p_val))) {
     return;
   }
   LOG(debug) << Form("Processing %d StsHit that were attached to a CATrack", sts_trk_size);
-  CbmStsTrack* sts_track = (CbmStsTrack*) sts_trk_array_->UncheckedAt(sts_trk_idx);
+  CbmStsTrack* sts_track = (CbmStsTrack*) fStsTrkArray->UncheckedAt(sts_trk_idx);
 
   // ------------------------------------
   // Process StsHit attached to a CATrack
   // ------------------------------------
   for (int hit_idx = 0; hit_idx < sts_trk_size; hit_idx++) {
     uint32_t sts_hit_idx = sts_track->GetStsHitIndex(hit_idx);
-    CbmStsHit* sts_hit   = (CbmStsHit*) sts_hit_array_->UncheckedAt(sts_hit_idx);
+    CbmStsHit* sts_hit   = (CbmStsHit*) fStsHitArray->UncheckedAt(sts_hit_idx);
     ProcessHit(sts_hit, true);
   }
   // ------------------------------------
@@ -208,14 +208,14 @@ void CbmStsHitAna::ProcessGlobalTrack(CbmGlobalTrack* trk)
 
 void CbmStsHitAna::Exec(Option_t*)
 {
-  if (cbm_evt_array_ != nullptr) {
-    uint32_t nb_events        = cbm_evt_array_->GetEntriesFast();
+  if (fCbmEvtArray != nullptr) {
+    uint32_t nb_events        = fCbmEvtArray->GetEntriesFast();
     double avg_nb_sts_hits    = 0;
     double avg_nb_of_glob_trk = 0;
     for (uint32_t evt_idx = 0; evt_idx < nb_events; evt_idx++) {
-      ProcessEvent((CbmEvent*) cbm_evt_array_->UncheckedAt(evt_idx));
-      avg_nb_sts_hits += ((CbmEvent*) cbm_evt_array_->UncheckedAt(evt_idx))->GetNofData(ECbmDataType::kStsHit);
-      avg_nb_of_glob_trk += ((CbmEvent*) cbm_evt_array_->UncheckedAt(evt_idx))->GetNofData(ECbmDataType::kGlobalTrack);
+      ProcessEvent((CbmEvent*) fCbmEvtArray->UncheckedAt(evt_idx));
+      avg_nb_sts_hits += ((CbmEvent*) fCbmEvtArray->UncheckedAt(evt_idx))->GetNofData(ECbmDataType::kStsHit);
+      avg_nb_of_glob_trk += ((CbmEvent*) fCbmEvtArray->UncheckedAt(evt_idx))->GetNofData(ECbmDataType::kGlobalTrack);
     }
     LOG_IF(info, nb_events) << "Running CbmStsHitAna - Event-like - Entry: " << entry_ << "\tEvents: " << nb_events
                             << "\tAvg StsHit/Events: " << avg_nb_sts_hits / nb_events
@@ -223,10 +223,10 @@ void CbmStsHitAna::Exec(Option_t*)
     LOG_IF(info, !nb_events) << "Running CbmStsHitAna - Event-like - Entry: " << entry_ << "\tEvents: " << nb_events;
   }
   else {
-    uint32_t n_of_hits = sts_hit_array_->GetEntriesFast();
+    uint32_t n_of_hits = fStsHitArray->GetEntriesFast();
     LOG(info) << "Running CbmStsHitAna - Time-like - Entry: " << entry_ << "\tStsHits: " << n_of_hits;
     for (uint32_t hit_idx = 0; hit_idx < n_of_hits; hit_idx++) {
-      CbmStsHit* sts_hit = (CbmStsHit*) sts_hit_array_->UncheckedAt(hit_idx);
+      CbmStsHit* sts_hit = (CbmStsHit*) fStsHitArray->UncheckedAt(hit_idx);
       ProcessHit(sts_hit, false);
     }
   }
@@ -235,10 +235,7 @@ void CbmStsHitAna::Exec(Option_t*)
 
 void CbmStsHitAna::Finish()
 {
-  for (auto& [sensor, pair] : cal_sampled) {
-    std::cout << Form("0x%x %f\t%f\t%f\t%f\n", sensor, pair[0], pair[1], pair[2], pair[3]);
-  }
   SaveToFile();
-  h1_.clear();
-  h2_.clear();
+  fH1D.clear();
+  fH2D.clear();
 }
diff --git a/analysis/detectors/sts/CbmStsHitAna.h b/analysis/detectors/sts/CbmStsHitAna.h
index 95c556bd82..fcefecd4e4 100644
--- a/analysis/detectors/sts/CbmStsHitAna.h
+++ b/analysis/detectors/sts/CbmStsHitAna.h
@@ -63,23 +63,23 @@ class CbmStsHitAna : public FairTask, public CbmStsAnaBase {
   void Finish();
 
  private:
-  uint32_t max_clu_size_{10};
-  std::vector<const char*> hit_modifier_;
+  uint32_t fMaxCluSize{10};
+  std::vector<const char*> fHitModifier;
 
-  std::unique_ptr<CbmStsParSetModule> module_par_set_;
-  std::string calibration_file_;
+  std::unique_ptr<CbmStsParSetModule> fModuleParSet;
+  std::string fCalibrationFile;
 
-  TClonesArray* cbm_evt_array_{nullptr};
+  TClonesArray* fCbmEvtArray{nullptr};
 
-  TClonesArray* glb_trk_array_{nullptr};
-  TClonesArray* sts_trk_array_{nullptr};
-  TClonesArray* rch_trk_array_{nullptr};
-  TClonesArray* mch_trk_array_{nullptr};
-  TClonesArray* trd_trk_array_{nullptr};
-  TClonesArray* tof_trk_array_{nullptr};
+  TClonesArray* fGlbTrkArray{nullptr};
+  TClonesArray* fStsTrkArray{nullptr};
+  TClonesArray* fRchTrkArray{nullptr};
+  TClonesArray* fMchTrkArray{nullptr};
+  TClonesArray* fTrdTrkArray{nullptr};
+  TClonesArray* fTofTrkArray{nullptr};
 
-  TClonesArray* sts_hit_array_{nullptr};
-  TClonesArray* sts_clu_array_{nullptr};
+  TClonesArray* fStsHitArray{nullptr};
+  TClonesArray* fStsCluArray{nullptr};
 
   void BookHistograms(int32_t);
 
@@ -101,8 +101,6 @@ class CbmStsHitAna : public FairTask, public CbmStsAnaBase {
   */
   void ProcessGlobalTrack(CbmGlobalTrack*);
 
-  std::map<int32_t, double[4]> cal_sampled;
-
   ClassDef(CbmStsHitAna, 1);
 };
 #endif
diff --git a/analysis/detectors/sts/CbmStsRecoBeamSpot.cxx b/analysis/detectors/sts/CbmStsRecoBeamSpot.cxx
index a62f68f720..dd8bf2868b 100644
--- a/analysis/detectors/sts/CbmStsRecoBeamSpot.cxx
+++ b/analysis/detectors/sts/CbmStsRecoBeamSpot.cxx
@@ -10,63 +10,63 @@ void CbmStsRecoBeamSpot::AddTarget(CbmTarget* trg) { AddTarget("", trg); }
 void CbmStsRecoBeamSpot::AddTarget(std::string trg_name, CbmTarget* trg)
 {
   if (trg_name.length() == 0) {
-    trg_name = Form("target_%ld", targets_.size());
+    trg_name = Form("target_%ld", fTargets.size());
   }
-  targets_[trg_name] = trg;
+  fTargets[trg_name] = trg;
 }
 
 void CbmStsRecoBeamSpot::BookHistograms()
 {
   std::string h_name;
   std::string h_name_base = "";
-  for (auto& [element_i, geo_i] : sts_geo_info_) {
+  for (auto& [element_i, geo_i] : fStsGeoInfo) {
     if (element_i < 8) continue;
 
-    for (auto& [element_j, geo_j] : sts_geo_info_) {
+    for (auto& [element_j, geo_j] : fStsGeoInfo) {
       if (element_j < 8) continue;
       int32_t unit_i = CbmStsAddress::GetElementId(element_i, kStsUnit);
       int32_t unit_j = CbmStsAddress::GetElementId(element_j, kStsUnit);
 
       if (unit_i >= unit_j) continue;
 
-      for (auto& [trg_name, trg] : targets_) {
+      for (auto& [trg_name, trg] : fTargets) {
         h_name_base = Form("0x%x:0x%x_%s", element_i, element_j, trg_name.c_str());
 
-        bs_range_x_min_ = trg->GetPosition().Px() - 10.;  // HARDCODE
-        bs_range_x_max_ = trg->GetPosition().Px() + 10.;  // HARDCODE
-        bs_range_y_min_ = trg->GetPosition().Py() - 10.;  // HARDCODE
-        bs_range_y_max_ = trg->GetPosition().Py() + 10.;  // HARDCODE
-        bs_range_z_min_ = trg->GetPosition().Pz() - 10.;  // HARDCODE
-        bs_range_z_max_ = trg->GetPosition().Pz() + 10.;  // HARDCODE
+        fSampleRangeXmin = trg->GetPosition().Px() - 10.;  // HARDCODE
+        fSampleRangeXmax = trg->GetPosition().Px() + 10.;  // HARDCODE
+        fSampleRangeYmin = trg->GetPosition().Py() - 10.;  // HARDCODE
+        fSampleRangeYmax = trg->GetPosition().Py() + 10.;  // HARDCODE
+        fSampleRangeZmin = trg->GetPosition().Pz() - 10.;  // HARDCODE
+        fSampleRangeZmax = trg->GetPosition().Pz() + 10.;  // HARDCODE
 
 
-        unsigned int nb_bins_x = (bs_range_x_max_ - bs_range_x_min_) / bs_resolution_x_;
-        unsigned int nb_bins_y = (bs_range_y_max_ - bs_range_y_min_) / bs_resolution_y_;
-        unsigned int nb_bins_z = (bs_range_z_max_ - bs_range_z_min_) / bs_resolution_z_;
+        unsigned int nb_bins_x = (fSampleRangeXmax - fSampleRangeXmin) / fSampleBinSizeX;
+        unsigned int nb_bins_y = (fSampleRangeYmax - fSampleRangeYmin) / fSampleBinSizeY;
+        unsigned int nb_bins_z = (fSampleRangeZmax - fSampleRangeZmin) / fSampleBinSizeZ;
 
         h_name      = Form("%s_Y_vs_X", h_name_base.c_str());
-        h2_[h_name] = std::make_unique<TH2D>(h_name.c_str(), h_name.c_str(), nb_bins_x, bs_range_x_min_,
-                                             bs_range_x_max_, nb_bins_y, bs_range_y_min_, bs_range_y_max_);
-        h2_[h_name]->GetXaxis()->SetTitle("X [cm]");
-        h2_[h_name]->GetYaxis()->SetTitle("Y [cm]");
+        fH2D[h_name] = std::make_unique<TH2D>(h_name.c_str(), h_name.c_str(), nb_bins_x, fSampleRangeXmin,
+                                             fSampleRangeXmax, nb_bins_y, fSampleRangeYmin, fSampleRangeYmax);
+        fH2D[h_name]->GetXaxis()->SetTitle("X [cm]");
+        fH2D[h_name]->GetYaxis()->SetTitle("Y [cm]");
 
         h_name      = Form("%s_X_vs_Z", h_name_base.c_str());
-        h2_[h_name] = std::make_unique<TH2D>(h_name.c_str(), h_name.c_str(), nb_bins_z, bs_range_z_min_,
-                                             bs_range_z_max_, nb_bins_x, bs_range_x_min_, bs_range_x_max_);
-        h2_[h_name]->GetXaxis()->SetTitle("Z [cm]");
-        h2_[h_name]->GetYaxis()->SetTitle("X [cm]");
+        fH2D[h_name] = std::make_unique<TH2D>(h_name.c_str(), h_name.c_str(), nb_bins_z, fSampleRangeZmin,
+                                             fSampleRangeZmax, nb_bins_x, fSampleRangeXmin, fSampleRangeXmax);
+        fH2D[h_name]->GetXaxis()->SetTitle("Z [cm]");
+        fH2D[h_name]->GetYaxis()->SetTitle("X [cm]");
 
         h_name      = Form("%s_Y_vs_Z", h_name_base.c_str());
-        h2_[h_name] = std::make_unique<TH2D>(h_name.c_str(), h_name.c_str(), nb_bins_z, bs_range_z_min_,
-                                             bs_range_z_max_, nb_bins_y, bs_range_y_min_, bs_range_y_max_);
-        h2_[h_name]->GetXaxis()->SetTitle("Z [cm]");
-        h2_[h_name]->GetYaxis()->SetTitle("Y [cm]");
+        fH2D[h_name] = std::make_unique<TH2D>(h_name.c_str(), h_name.c_str(), nb_bins_z, fSampleRangeZmin,
+                                             fSampleRangeZmax, nb_bins_y, fSampleRangeYmin, fSampleRangeYmax);
+        fH2D[h_name]->GetXaxis()->SetTitle("Z [cm]");
+        fH2D[h_name]->GetYaxis()->SetTitle("Y [cm]");
 
         h_name      = Form("%s_Y_beam_vs_X_beam", h_name_base.c_str());
-        h2_[h_name] = std::make_unique<TH2D>(h_name.c_str(), h_name.c_str(), nb_bins_x, bs_range_x_min_,
-                                             bs_range_x_max_, nb_bins_y, bs_range_y_min_, bs_range_y_max_);
-        h2_[h_name]->GetXaxis()->SetTitle("X_beam [cm]");
-        h2_[h_name]->GetYaxis()->SetTitle("Y_beam [cm]");
+        fH2D[h_name] = std::make_unique<TH2D>(h_name.c_str(), h_name.c_str(), nb_bins_x, fSampleRangeXmin,
+                                             fSampleRangeXmax, nb_bins_y, fSampleRangeYmin, fSampleRangeYmax);
+        fH2D[h_name]->GetXaxis()->SetTitle("X_beam [cm]");
+        fH2D[h_name]->GetYaxis()->SetTitle("Y_beam [cm]");
 
       }  // end targets loop
     }    // end sts_i modules loop
@@ -93,39 +93,39 @@ TVector3 CbmStsRecoBeamSpot::ExtrapolateTrackTo(CbmPixelHit* hit_0, CbmPixelHit*
 
 void CbmStsRecoBeamSpot::BeamSpotReco()
 {
-  if (!sts_hits_.size()) return;
+  if (!fStsHits.size()) return;
   for (int sts_unit_i = 0; sts_unit_i < nb_sts_station_ - 1; sts_unit_i++) {
     for (int sts_unit_j = sts_unit_i + 1; sts_unit_j < nb_sts_station_; sts_unit_j++) {
-      for (auto sts_hit_i : sts_hits_[sts_unit_i]) {
-        for (auto sts_hit_j : sts_hits_[sts_unit_j]) {
+      for (auto sts_hit_i : fStsHits[sts_unit_i]) {
+        for (auto sts_hit_j : fStsHits[sts_unit_j]) {
           int32_t sts_address_i = sts_hit_i->GetAddress();
           int32_t sts_address_j = sts_hit_j->GetAddress();
 
-          for (auto& [trg_name, trg] : targets_) {
+          for (auto& [trg_name, trg] : fTargets) {
             TVector3 sol            = ExtrapolateTrackTo(sts_hit_i, sts_hit_j, trg);
             std::string h_name_base = Form("0x%x:0x%x_%s", sts_address_i, sts_address_j, trg_name.c_str());
 
             std::string h_name = Form("%s_X_vs_Z", h_name_base.c_str());
-            h2_[h_name]->Fill(sol.Pz(), sol.Px());
+            fH2D[h_name]->Fill(sol.Pz(), sol.Px());
 
             h_name = Form("%s_Y_vs_Z", h_name_base.c_str());
-            h2_[h_name]->Fill(sol.Pz(), sol.Py());
+            fH2D[h_name]->Fill(sol.Pz(), sol.Py());
 
             h_name = Form("%s_Y_vs_X", h_name_base.c_str());
-            h2_[h_name]->Fill(sol.Px(), sol.Py());
+            fH2D[h_name]->Fill(sol.Px(), sol.Py());
 
             TVector3 sol_beam = sol - trg->GetPosition();
 
             double x_beam = sol_beam.Px() / cos(trg->GetRotation());
             double y_beam = sol_beam.Py();
             h_name        = Form("%s_Y_beam_vs_X_beam", h_name_base.c_str());
-            h2_[h_name]->Fill(x_beam, y_beam);
+            fH2D[h_name]->Fill(x_beam, y_beam);
           }
         }
       }
     }
   }
-  sts_hits_.clear();
+  fStsHits.clear();
 }
 
 
@@ -138,7 +138,7 @@ void CbmStsRecoBeamSpot::ProcessEvent(CbmEvent* evt)
   if (nb_sts_hits > 0)
     for (int hit_evt_idx = 0; hit_evt_idx < nb_sts_hits; hit_evt_idx++) {
       int sts_hit_idx = evt->GetIndex(ECbmDataType::kStsHit, hit_evt_idx);
-      CbmStsHit* hit  = (CbmStsHit*) sts_hit_array_->UncheckedAt(sts_hit_idx);
+      CbmStsHit* hit  = (CbmStsHit*) fStsHitArray->UncheckedAt(sts_hit_idx);
       ProcessHit(hit);
     }
 }
@@ -149,8 +149,8 @@ void CbmStsRecoBeamSpot::ProcessHit(CbmStsHit* hit)
   int32_t address = hit->GetAddress();
   int32_t unit    = CbmStsAddress::GetElementId(address, kStsUnit);
 
-  if (analysis_cut_ != nullptr && analysis_cut_->CheckStsHit(hit, sts_clu_array_)) {
-    sts_hits_[unit].push_back(hit);
+  if (fAnalysisCuts != nullptr && fAnalysisCuts->CheckStsHit(hit, fStsCluArray)) {
+    fStsHits[unit].push_back(hit);
   }
 }
 
@@ -158,13 +158,13 @@ void CbmStsRecoBeamSpot::Exec(Option_t*)
 {
 
   // Check if CbmEvent
-  if (cbm_evt_array_ != nullptr) {
+  if (fCbmEvtArray != nullptr) {
 
-    uint32_t nb_events = cbm_evt_array_->GetEntriesFast();
+    uint32_t nb_events = fCbmEvtArray->GetEntriesFast();
     LOG(info) << "Running CbmStsRecoBeamSpot - Event like - Entry:" << entry_ << "\tEvents: " << nb_events;
     for (uint32_t evt_idx = 0; evt_idx < nb_events; evt_idx++) {
-      CbmEvent* event = (CbmEvent*) cbm_evt_array_->UncheckedAt(evt_idx);
-      if (analysis_cut_ != nullptr && analysis_cut_->CheckEvent(event)) {
+      CbmEvent* event = (CbmEvent*) fCbmEvtArray->UncheckedAt(evt_idx);
+      if (fAnalysisCuts != nullptr && fAnalysisCuts->CheckEvent(event)) {
         ProcessEvent(event);
         BeamSpotReco();
       }
@@ -172,10 +172,10 @@ void CbmStsRecoBeamSpot::Exec(Option_t*)
   }
   else {
 
-    uint32_t n_of_hits = sts_hit_array_->GetEntriesFast();
+    uint32_t n_of_hits = fStsHitArray->GetEntriesFast();
     LOG(info) << "Running CbmStsRecoBeamSpot - Time like - Entry:" << entry_ << "\tStsHit: " << n_of_hits;
     for (uint32_t hit_idx = 0; hit_idx < n_of_hits; hit_idx++) {
-      CbmStsHit* sts_hit = (CbmStsHit*) sts_hit_array_->UncheckedAt(hit_idx);
+      CbmStsHit* sts_hit = (CbmStsHit*) fStsHitArray->UncheckedAt(hit_idx);
       ProcessHit(sts_hit);
     }
     BeamSpotReco();
@@ -190,11 +190,11 @@ InitStatus CbmStsRecoBeamSpot::Init()
   FairRootManager* ioman = FairRootManager::Instance();
   if (ioman == nullptr) return kERROR;
 
-  cbm_evt_array_ = (TClonesArray*) ioman->GetObject("CbmEvent");
-  sts_hit_array_ = (TClonesArray*) ioman->GetObject("StsHit");
-  sts_clu_array_ = (TClonesArray*) ioman->GetObject("StsCluster");
+  fCbmEvtArray = (TClonesArray*) ioman->GetObject("CbmEvent");
+  fStsHitArray = (TClonesArray*) ioman->GetObject("StsHit");
+  fStsCluArray = (TClonesArray*) ioman->GetObject("StsCluster");
 
-  for (auto& [trg_name, trg] : targets_) {
+  for (auto& [trg_name, trg] : fTargets) {
     LOG(debug) << trg_name << ": " << trg->ToString();
   }
 
diff --git a/analysis/detectors/sts/CbmStsRecoBeamSpot.h b/analysis/detectors/sts/CbmStsRecoBeamSpot.h
index a5a524f2a5..8ea1172e79 100644
--- a/analysis/detectors/sts/CbmStsRecoBeamSpot.h
+++ b/analysis/detectors/sts/CbmStsRecoBeamSpot.h
@@ -64,28 +64,28 @@ class CbmStsRecoBeamSpot : public FairTask, public CbmStsAnaBase {
   /* Beam Spot sampling range
    * It is dynamically caculate when multiple targets planes are provided
    */
-  double bs_range_x_min_{-10};  // cm
-  double bs_range_x_max_{+10};  // cm
-  double bs_range_y_min_{-10};  // cm
-  double bs_range_y_max_{+10};  // cm
-  double bs_range_z_min_{-10};  // cm
-  double bs_range_z_max_{+10};  // cm
+  double fSampleRangeXmin{-10};  // cm
+  double fSampleRangeXmax{+10};  // cm
+  double fSampleRangeYmin{-10};  // cm
+  double fSampleRangeYmax{+10};  // cm
+  double fSampleRangeZmin{-10};  // cm
+  double fSampleRangeZmax{+10};  // cm
 
   /* Bin width for Beam Spot 2D histograms */
-  double bs_resolution_x_{0.01};
-  double bs_resolution_y_{0.01};
-  double bs_resolution_z_{0.01};
+  double fSampleBinSizeX{0.01};
+  double fSampleBinSizeY{0.01};
+  double fSampleBinSizeZ{0.01};
 
-  std::vector<CbmStsTrack*> sts_trks_;
-  std::map<int32_t, std::vector<CbmStsHit*>> sts_hits_;
+  std::vector<CbmStsTrack*> fStsTrks;
+  std::map<int32_t, std::vector<CbmStsHit*>> fStsHits;
 
-  std::map<std::string, CbmTarget*> targets_;
+  std::map<std::string, CbmTarget*> fTargets;
 
 
-  TClonesArray* cbm_evt_array_{nullptr};
-  TClonesArray* sts_trk_array_{nullptr};
-  TClonesArray* sts_hit_array_{nullptr};
-  TClonesArray* sts_clu_array_{nullptr};
+  TClonesArray* fCbmEvtArray{nullptr};
+  TClonesArray* fStsTrkArray{nullptr};
+  TClonesArray* fStsHitArray{nullptr};
+  TClonesArray* fStsCluArray{nullptr};
 
   /** \brief Reconstruct the beam spot at each target planes */
   void BeamSpotReco();
diff --git a/analysis/detectors/sts/CbmStsResolution.cxx b/analysis/detectors/sts/CbmStsResolution.cxx
index 6a4a5e5ba7..2f3c2d9a50 100644
--- a/analysis/detectors/sts/CbmStsResolution.cxx
+++ b/analysis/detectors/sts/CbmStsResolution.cxx
@@ -10,14 +10,14 @@
 #include "TPaveStats.h"
 #include "TStyle.h"
 
-CbmStsResolution::CbmStsResolution(double d_max) : d_max_trk_trg_(d_max)
+CbmStsResolution::CbmStsResolution(double d_max) : fImpactParMax(d_max)
 {
   LOG(debug) << "Creating an instance of CbmStsResolution ...";
 }
 
 void CbmStsResolution::BookHistograms()
 {
-  for (auto& [element, geo] : sts_geo_info_) {
+  for (auto& [element, geo] : fStsGeoInfo) {
     std::string h_name_base = element < 8 ? Form("Sts%d", element) : Form("Sts0x%x", element);
 
     LOG(debug) << Form("Booking for %s", h_name_base.c_str());
@@ -39,59 +39,59 @@ void CbmStsResolution::BookHistograms()
     for (auto mod : {":all", ":trk"}) {
       std::string h_name;
       h_name      = Form("%s_dx_vs_x%s", h_name_base.c_str(), mod);
-      h2_[h_name] = std::make_unique<TH2D>(h_name.c_str(), "", nb_bins_r, r_min, r_max, nb_bins_x, x_min, x_max);
-      h2_[h_name]->GetXaxis()->SetTitle(Form("X_{trk} - X_{hit} [cm]"));
-      h2_[h_name]->GetYaxis()->SetTitle("X_{hit} [cm]");
-      h2_[h_name]->GetXaxis()->CenterTitle(true);
-      h2_[h_name]->GetYaxis()->CenterTitle(true);
+      fH2D[h_name] = std::make_unique<TH2D>(h_name.c_str(), "", nb_bins_r, r_min, r_max, nb_bins_x, x_min, x_max);
+      fH2D[h_name]->GetXaxis()->SetTitle(Form("X_{trk} - X_{hit} [cm]"));
+      fH2D[h_name]->GetYaxis()->SetTitle("X_{hit} [cm]");
+      fH2D[h_name]->GetXaxis()->CenterTitle(true);
+      fH2D[h_name]->GetYaxis()->CenterTitle(true);
 
       h_name      = Form("%s_dx_vs_y%s", h_name_base.c_str(), mod);
-      h2_[h_name] = std::make_unique<TH2D>(h_name.c_str(), "", nb_bins_r, r_min, r_max, nb_bins_y, y_min, y_max);
-      h2_[h_name]->GetXaxis()->SetTitle(Form("X_{trk} - X_{hit} [cm]"));
-      h2_[h_name]->GetYaxis()->SetTitle("Y_{hit} [cm]");
-      h2_[h_name]->GetXaxis()->CenterTitle(true);
-      h2_[h_name]->GetYaxis()->CenterTitle(true);
+      fH2D[h_name] = std::make_unique<TH2D>(h_name.c_str(), "", nb_bins_r, r_min, r_max, nb_bins_y, y_min, y_max);
+      fH2D[h_name]->GetXaxis()->SetTitle(Form("X_{trk} - X_{hit} [cm]"));
+      fH2D[h_name]->GetYaxis()->SetTitle("Y_{hit} [cm]");
+      fH2D[h_name]->GetXaxis()->CenterTitle(true);
+      fH2D[h_name]->GetYaxis()->CenterTitle(true);
 
       h_name      = Form("%s_dy_vs_x%s", h_name_base.c_str(), mod);
-      h2_[h_name] = std::make_unique<TH2D>(h_name.c_str(), "", nb_bins_r, r_min, r_max, nb_bins_x, x_min, x_max);
-      h2_[h_name]->GetXaxis()->SetTitle(Form("Y_{trk} - Y_{hit} [cm]"));
-      h2_[h_name]->GetYaxis()->SetTitle("X_{hit} [cm]");
-      h2_[h_name]->GetXaxis()->CenterTitle(true);
-      h2_[h_name]->GetYaxis()->CenterTitle(true);
+      fH2D[h_name] = std::make_unique<TH2D>(h_name.c_str(), "", nb_bins_r, r_min, r_max, nb_bins_x, x_min, x_max);
+      fH2D[h_name]->GetXaxis()->SetTitle(Form("Y_{trk} - Y_{hit} [cm]"));
+      fH2D[h_name]->GetYaxis()->SetTitle("X_{hit} [cm]");
+      fH2D[h_name]->GetXaxis()->CenterTitle(true);
+      fH2D[h_name]->GetYaxis()->CenterTitle(true);
 
       h_name      = Form("%s_dy_vs_y%s", h_name_base.c_str(), mod);
-      h2_[h_name] = std::make_unique<TH2D>(h_name.c_str(), "", nb_bins_r, r_min, r_max, nb_bins_y, y_min, y_max);
-      h2_[h_name]->GetXaxis()->SetTitle(Form("Y_{trk} - Y_{hit} [cm]"));
-      h2_[h_name]->GetYaxis()->SetTitle("Y_{hit} [cm]");
-      h2_[h_name]->GetXaxis()->CenterTitle(true);
-      h2_[h_name]->GetYaxis()->CenterTitle(true);
+      fH2D[h_name] = std::make_unique<TH2D>(h_name.c_str(), "", nb_bins_r, r_min, r_max, nb_bins_y, y_min, y_max);
+      fH2D[h_name]->GetXaxis()->SetTitle(Form("Y_{trk} - Y_{hit} [cm]"));
+      fH2D[h_name]->GetYaxis()->SetTitle("Y_{hit} [cm]");
+      fH2D[h_name]->GetXaxis()->CenterTitle(true);
+      fH2D[h_name]->GetYaxis()->CenterTitle(true);
     }
     if (element < 8) {
       std::string h_name = Form("Sts%d_ref_hits", element);
-      h2_[h_name]        = std::make_unique<TH2D>(h_name.c_str(), "", nb_bins_x, x_min, x_max, nb_bins_y, y_min, y_max);
-      h2_[h_name]->GetXaxis()->SetTitle(Form("X_{TrkHit} [cm]"));
-      h2_[h_name]->GetYaxis()->SetTitle("Y_{TrkHit} [cm]");
-      h2_[h_name]->GetXaxis()->CenterTitle(true);
-      h2_[h_name]->GetYaxis()->CenterTitle(true);
+      fH2D[h_name]        = std::make_unique<TH2D>(h_name.c_str(), "", nb_bins_x, x_min, x_max, nb_bins_y, y_min, y_max);
+      fH2D[h_name]->GetXaxis()->SetTitle(Form("X_{TrkHit} [cm]"));
+      fH2D[h_name]->GetYaxis()->SetTitle("Y_{TrkHit} [cm]");
+      fH2D[h_name]->GetXaxis()->CenterTitle(true);
+      fH2D[h_name]->GetYaxis()->CenterTitle(true);
     }
   }
 }
 
 void CbmStsResolution::ProcessEvent(CbmEvent* evt)
 {
-  if (analysis_cut_ != nullptr && !analysis_cut_->CheckEvent(evt)) return;
+  if (fAnalysisCuts != nullptr && !fAnalysisCuts->CheckEvent(evt)) return;
 
   int nb_sts_hits = evt->GetNofData(ECbmDataType::kStsHit);
   LOG(debug) << Form("Processing event with %d StsHit", nb_sts_hits);
   for (int hit_evt_idx = 0; hit_evt_idx < nb_sts_hits; hit_evt_idx++) {
     int sts_hit_idx = evt->GetIndex(ECbmDataType::kStsHit, hit_evt_idx);
-    CbmStsHit* hit  = (CbmStsHit*) sts_hit_array_->UncheckedAt(sts_hit_idx);
+    CbmStsHit* hit  = (CbmStsHit*) fStsHitArray->UncheckedAt(sts_hit_idx);
     ProcessHit(hit);
   }
   int nb_of_glob_trk = evt->GetNofData(ECbmDataType::kGlobalTrack);
   for (int evt_glob_trk_idx = 0; evt_glob_trk_idx < nb_of_glob_trk; evt_glob_trk_idx++) {
     int glob_trk_idx         = evt->GetIndex(ECbmDataType::kGlobalTrack, evt_glob_trk_idx);
-    CbmGlobalTrack* glob_trk = (CbmGlobalTrack*) glb_trk_array_->UncheckedAt(glob_trk_idx);
+    CbmGlobalTrack* glob_trk = (CbmGlobalTrack*) fGlbTrkArray->UncheckedAt(glob_trk_idx);
     ProcessGlobalTrack(glob_trk);
   }
   BuildResidual();
@@ -99,34 +99,34 @@ void CbmStsResolution::ProcessEvent(CbmEvent* evt)
 
 void CbmStsResolution::BuildResidual()
 {
-  int n_of_units = sts_hits_.size();
+  int n_of_units = fStsHits.size();
 
-  for (auto trk : glb_trks_) {
+  for (auto trk : fGlbTrks) {
     auto sts_trk_idx = trk->GetStsTrackIndex();
     if (sts_trk_idx == -1) continue;
 
-    CbmStsTrack* sts_track = (CbmStsTrack*) sts_trk_array_->UncheckedAt(sts_trk_idx);
-    if (((CbmStsTrack*) sts_trk_array_->UncheckedAt(sts_trk_idx))->GetNofStsHits() != 2) continue;
+    CbmStsTrack* sts_track = (CbmStsTrack*) fStsTrkArray->UncheckedAt(sts_trk_idx);
+    if (((CbmStsTrack*) fStsTrkArray->UncheckedAt(sts_trk_idx))->GetNofStsHits() != 2) continue;
 
-    CbmStsHit* hit_i = (CbmStsHit*) sts_hit_array_->UncheckedAt(sts_track->GetStsHitIndex(0));
-    CbmStsHit* hit_j = (CbmStsHit*) sts_hit_array_->UncheckedAt(sts_track->GetStsHitIndex(1));
+    CbmStsHit* hit_i = (CbmStsHit*) fStsHitArray->UncheckedAt(sts_track->GetStsHitIndex(0));
+    CbmStsHit* hit_j = (CbmStsHit*) fStsHitArray->UncheckedAt(sts_track->GetStsHitIndex(1));
 
     // Charge cut to Sts track hits
-    if (trk_hit_q_min_ > 0
-        && (cbm_sts_utils::GetHitCharge(hit_i, sts_clu_array_) < trk_hit_q_min_
-            || cbm_sts_utils::GetHitCharge(hit_j, sts_clu_array_) < trk_hit_q_min_))
+    if (fTrkHitQmin > 0
+        && (cbm_sts_utils::GetHitCharge(hit_i, fStsCluArray) < fTrkHitQmin
+            || cbm_sts_utils::GetHitCharge(hit_j, fStsCluArray) < fTrkHitQmin))
       continue;
 
     int unit_i = CbmStsAddress::GetElementId(hit_i->GetAddress(), kStsUnit);
     int unit_j = CbmStsAddress::GetElementId(hit_j->GetAddress(), kStsUnit);
 
     // Checkk track crossed eneabled sensors
-    if (active_ref_sensors_.size()) {
-      if (std::find(active_ref_sensors_.begin(), active_ref_sensors_.end(), hit_i->GetAddress())
-          == active_ref_sensors_.end())
+    if (fActiveRefSensors.size()) {
+      if (std::find(fActiveRefSensors.begin(), fActiveRefSensors.end(), hit_i->GetAddress())
+          == fActiveRefSensors.end())
         continue;
-      if (std::find(active_ref_sensors_.begin(), active_ref_sensors_.end(), hit_j->GetAddress())
-          == active_ref_sensors_.end())
+      if (std::find(fActiveRefSensors.begin(), fActiveRefSensors.end(), hit_j->GetAddress())
+          == fActiveRefSensors.end())
         continue;
     }
 
@@ -138,8 +138,8 @@ void CbmStsResolution::BuildResidual()
     double y_j = hit_j->GetY();
     double z_j = hit_j->GetZ();
 
-    h2_[Form("Sts%d_ref_hits", unit_i)]->Fill(x_i, y_i);
-    h2_[Form("Sts%d_ref_hits", unit_j)]->Fill(x_j, y_j);
+    fH2D[Form("Sts%d_ref_hits", unit_i)]->Fill(x_i, y_i);
+    fH2D[Form("Sts%d_ref_hits", unit_j)]->Fill(x_j, y_j);
 
     double x_0, y_0, t_x, t_y;
     if (tracking_use_two_sts_) {
@@ -157,14 +157,14 @@ void CbmStsResolution::BuildResidual()
 
     double d_trk_trg = TMath::Sqrt(x_0 * x_0 + y_0 * y_0);
 
-    if (d_max_trk_trg_ > 0 && d_max_trk_trg_ < d_trk_trg) continue;
+    if (fImpactParMax > 0 && fImpactParMax < d_trk_trg) continue;
 
     for (int uut = 0; uut < n_of_units; uut++) {
       if (uut == unit_i || uut == unit_j) continue;
 
       CbmStsHit* closest_hit = nullptr;
       double min_dist        = 1e+6;
-      for (auto hit_dut : sts_hits_[uut]) {
+      for (auto hit_dut : fStsHits[uut]) {
         double x_dut = hit_dut->GetX();
         double y_dut = hit_dut->GetY();
         double z_dut = hit_dut->GetZ();
@@ -175,15 +175,15 @@ void CbmStsResolution::BuildResidual()
         double dx = x_trk - x_dut;
         double dy = y_trk - y_dut;
 
-        h2_[Form("Sts0x%x_dx_vs_x:all", hit_dut->GetAddress())]->Fill(dx, x_dut);
-        h2_[Form("Sts0x%x_dx_vs_y:all", hit_dut->GetAddress())]->Fill(dx, y_dut);
-        h2_[Form("Sts0x%x_dy_vs_x:all", hit_dut->GetAddress())]->Fill(dy, x_dut);
-        h2_[Form("Sts0x%x_dy_vs_y:all", hit_dut->GetAddress())]->Fill(dy, y_dut);
+        fH2D[Form("Sts0x%x_dx_vs_x:all", hit_dut->GetAddress())]->Fill(dx, x_dut);
+        fH2D[Form("Sts0x%x_dx_vs_y:all", hit_dut->GetAddress())]->Fill(dx, y_dut);
+        fH2D[Form("Sts0x%x_dy_vs_x:all", hit_dut->GetAddress())]->Fill(dy, x_dut);
+        fH2D[Form("Sts0x%x_dy_vs_y:all", hit_dut->GetAddress())]->Fill(dy, y_dut);
 
-        h2_[Form("Sts%d_dx_vs_x:all", uut)]->Fill(dx, x_dut);
-        h2_[Form("Sts%d_dx_vs_y:all", uut)]->Fill(dx, y_dut);
-        h2_[Form("Sts%d_dy_vs_x:all", uut)]->Fill(dy, x_dut);
-        h2_[Form("Sts%d_dy_vs_y:all", uut)]->Fill(dy, y_dut);
+        fH2D[Form("Sts%d_dx_vs_x:all", uut)]->Fill(dx, x_dut);
+        fH2D[Form("Sts%d_dx_vs_y:all", uut)]->Fill(dx, y_dut);
+        fH2D[Form("Sts%d_dy_vs_x:all", uut)]->Fill(dy, x_dut);
+        fH2D[Form("Sts%d_dy_vs_y:all", uut)]->Fill(dy, y_dut);
 
         if (min_dist > dx * dx + dy * dy) {
           min_dist    = dx * dx + dy * dy;
@@ -202,36 +202,36 @@ void CbmStsResolution::BuildResidual()
         double dx = x_trk - x_dut;
         double dy = y_trk - y_dut;
 
-        h2_[Form("Sts0x%x_dx_vs_x:trk", closest_hit->GetAddress())]->Fill(dx, x_dut);
-        h2_[Form("Sts0x%x_dx_vs_y:trk", closest_hit->GetAddress())]->Fill(dx, y_dut);
-        h2_[Form("Sts0x%x_dy_vs_x:trk", closest_hit->GetAddress())]->Fill(dy, x_dut);
-        h2_[Form("Sts0x%x_dy_vs_y:trk", closest_hit->GetAddress())]->Fill(dy, y_dut);
+        fH2D[Form("Sts0x%x_dx_vs_x:trk", closest_hit->GetAddress())]->Fill(dx, x_dut);
+        fH2D[Form("Sts0x%x_dx_vs_y:trk", closest_hit->GetAddress())]->Fill(dx, y_dut);
+        fH2D[Form("Sts0x%x_dy_vs_x:trk", closest_hit->GetAddress())]->Fill(dy, x_dut);
+        fH2D[Form("Sts0x%x_dy_vs_y:trk", closest_hit->GetAddress())]->Fill(dy, y_dut);
 
-        h2_[Form("Sts%d_dx_vs_x:trk", uut)]->Fill(dx, x_dut);
-        h2_[Form("Sts%d_dx_vs_y:trk", uut)]->Fill(dx, y_dut);
-        h2_[Form("Sts%d_dy_vs_x:trk", uut)]->Fill(dy, x_dut);
-        h2_[Form("Sts%d_dy_vs_y:trk", uut)]->Fill(dy, y_dut);
+        fH2D[Form("Sts%d_dx_vs_x:trk", uut)]->Fill(dx, x_dut);
+        fH2D[Form("Sts%d_dx_vs_y:trk", uut)]->Fill(dx, y_dut);
+        fH2D[Form("Sts%d_dy_vs_x:trk", uut)]->Fill(dy, x_dut);
+        fH2D[Form("Sts%d_dy_vs_y:trk", uut)]->Fill(dy, y_dut);
       }
     }  // uut loop
   }    // track loop
 
-  sts_hits_.clear();
-  glb_trks_.clear();
+  fStsHits.clear();
+  fGlbTrks.clear();
 }
 
 void CbmStsResolution::ProcessHit(CbmStsHit* hit)
 {
   if (hit == nullptr) return;
 
-  if (analysis_cut_ != nullptr && !analysis_cut_->CheckStsHit(hit, sts_clu_array_)) return;
+  if (fAnalysisCuts != nullptr && !fAnalysisCuts->CheckStsHit(hit, fStsCluArray)) return;
 
   int32_t address = hit->GetAddress();
   int32_t unit    = CbmStsAddress::GetElementId(address, kStsUnit);
 
-  sts_hits_[unit].push_back(hit);
+  fStsHits[unit].push_back(hit);
 }
 
-void CbmStsResolution::EnableRefSensor(int32_t address) { active_ref_sensors_.push_back(address); }
+void CbmStsResolution::EnableRefSensor(int32_t address) { fActiveRefSensors.push_back(address); }
 
 void CbmStsResolution::ProcessGlobalTrack(CbmGlobalTrack* trk)
 {
@@ -245,59 +245,59 @@ void CbmStsResolution::ProcessGlobalTrack(CbmGlobalTrack* trk)
   float trk_p_val   = TMath::Prob(trk->GetChi2(), trk->GetNDF());
 
   // Apply GlobalTracks cuts
-  int32_t mvd_trk_size = sts_trk_idx != -1 && sts_trk_array_ != nullptr
-                           ? ((CbmStsTrack*) sts_trk_array_->UncheckedAt(sts_trk_idx))->GetNofMvdHits()
+  int32_t mvd_trk_size = sts_trk_idx != -1 && fStsTrkArray != nullptr
+                           ? ((CbmStsTrack*) fStsTrkArray->UncheckedAt(sts_trk_idx))->GetNofMvdHits()
                            : 0;
 
-  int32_t sts_trk_size = sts_trk_idx != -1 && sts_trk_array_ != nullptr
-                           ? ((CbmStsTrack*) sts_trk_array_->UncheckedAt(sts_trk_idx))->GetNofStsHits()
+  int32_t sts_trk_size = sts_trk_idx != -1 && fStsTrkArray != nullptr
+                           ? ((CbmStsTrack*) fStsTrkArray->UncheckedAt(sts_trk_idx))->GetNofStsHits()
                            : 0;
 
-  int32_t rich_trk_size = rich_trk_idx != -1 && rch_trk_array_ != nullptr
-                            ? ((CbmTrack*) rch_trk_array_->UncheckedAt(rich_trk_idx))->GetNofHits()
+  int32_t rich_trk_size = rich_trk_idx != -1 && fRchTrkArray != nullptr
+                            ? ((CbmTrack*) fRchTrkArray->UncheckedAt(rich_trk_idx))->GetNofHits()
                             : 0;
 
-  int32_t much_trk_size = much_trk_idx != -1 && mch_trk_array_ != nullptr
-                            ? ((CbmTrack*) mch_trk_array_->UncheckedAt(much_trk_idx))->GetNofHits()
+  int32_t much_trk_size = much_trk_idx != -1 && fMchTrkArray != nullptr
+                            ? ((CbmTrack*) fMchTrkArray->UncheckedAt(much_trk_idx))->GetNofHits()
                             : 0;
 
-  int32_t trd_trk_size = trd_trk_idx != -1 && trd_trk_array_ != nullptr
-                           ? ((CbmTrack*) trd_trk_array_->UncheckedAt(trd_trk_idx))->GetNofHits()
+  int32_t trd_trk_size = trd_trk_idx != -1 && fTrdTrkArray != nullptr
+                           ? ((CbmTrack*) fTrdTrkArray->UncheckedAt(trd_trk_idx))->GetNofHits()
                            : 0;
 
-  int32_t tof_trk_size = tof_trk_idx != -1 && tof_trk_array_ != nullptr
-                           ? ((CbmTrack*) tof_trk_array_->UncheckedAt(tof_trk_idx))->GetNofHits()
+  int32_t tof_trk_size = tof_trk_idx != -1 && fTofTrkArray != nullptr
+                           ? ((CbmTrack*) fTofTrkArray->UncheckedAt(tof_trk_idx))->GetNofHits()
                            : 0;
 
-  if (analysis_cut_ != nullptr
-      && (!analysis_cut_->Check(CbmCutId::kGlobalTrackMvdSize, mvd_trk_size)
-          || !analysis_cut_->Check(CbmCutId::kGlobalTrackStsSize, sts_trk_size)
-          || !analysis_cut_->Check(CbmCutId::kGlobalTrackRichSize, rich_trk_size)
-          || !analysis_cut_->Check(CbmCutId::kGlobalTrackMuchSize, much_trk_size)
-          || !analysis_cut_->Check(CbmCutId::kGlobalTrackTrdSize, trd_trk_size)
-          || !analysis_cut_->Check(CbmCutId::kGlobalTrackTofSize, tof_trk_size)
-          || !analysis_cut_->Check(CbmCutId::kGlobalTrackChi2, trk->GetChi2())
-          || !analysis_cut_->Check(CbmCutId::kGlobalTrackPval, trk_p_val))) {
+  if (fAnalysisCuts != nullptr
+      && (!fAnalysisCuts->Check(CbmCutId::kGlobalTrackMvdSize, mvd_trk_size)
+          || !fAnalysisCuts->Check(CbmCutId::kGlobalTrackStsSize, sts_trk_size)
+          || !fAnalysisCuts->Check(CbmCutId::kGlobalTrackRichSize, rich_trk_size)
+          || !fAnalysisCuts->Check(CbmCutId::kGlobalTrackMuchSize, much_trk_size)
+          || !fAnalysisCuts->Check(CbmCutId::kGlobalTrackTrdSize, trd_trk_size)
+          || !fAnalysisCuts->Check(CbmCutId::kGlobalTrackTofSize, tof_trk_size)
+          || !fAnalysisCuts->Check(CbmCutId::kGlobalTrackChi2, trk->GetChi2())
+          || !fAnalysisCuts->Check(CbmCutId::kGlobalTrackPval, trk_p_val))) {
     return;
   }
 
-  glb_trks_.push_back(trk);
+  fGlbTrks.push_back(trk);
 }
 
 void CbmStsResolution::Exec(Option_t*)
 {
-  switch (input_type) {
+  switch (fInputType) {
     case kEventMode: {
-      if (cbm_evt_array_ == nullptr) {
+      if (fCbmEvtArray == nullptr) {
         LOG(error) << "Invalid branch for event-mode: Branch CbmEvent -> nullptr";
         break;
       }
 
-      uint32_t nb_events = cbm_evt_array_->GetEntriesFast();
+      uint32_t nb_events = fCbmEvtArray->GetEntriesFast();
       LOG(info) << "Processing entry " << entry_ << "\tCbmEvent: " << nb_events;
 
       for (uint32_t evt_idx = 0; evt_idx < nb_events; evt_idx++) {
-        CbmEvent* event = (CbmEvent*) cbm_evt_array_->UncheckedAt(evt_idx);
+        CbmEvent* event = (CbmEvent*) fCbmEvtArray->UncheckedAt(evt_idx);
         ProcessEvent(event);
       }
       break;
@@ -308,16 +308,16 @@ void CbmStsResolution::Exec(Option_t*)
     case kMCEventMode:
     case kTimeMode:
     default: {
-      uint32_t n_of_hits    = sts_hit_array_->GetEntriesFast();
-      uint32_t n_of_glb_trk = glb_trk_array_->GetEntriesFast();
+      uint32_t n_of_hits    = fStsHitArray->GetEntriesFast();
+      uint32_t n_of_glb_trk = fGlbTrkArray->GetEntriesFast();
       LOG(info) << "Processing entry " << entry_ << "\tStsHit: " << n_of_hits << "\tGlobalTrack: " << n_of_glb_trk;
 
       for (uint32_t hit_idx = 0; hit_idx < n_of_hits; hit_idx++) {
-        ProcessHit((CbmStsHit*) sts_hit_array_->UncheckedAt(hit_idx));
+        ProcessHit((CbmStsHit*) fStsHitArray->UncheckedAt(hit_idx));
       }
 
       for (uint32_t glb_trk_idx = 0; glb_trk_idx < n_of_glb_trk; glb_trk_idx++) {
-        ProcessGlobalTrack((CbmGlobalTrack*) glb_trk_array_->UncheckedAt(glb_trk_idx));
+        ProcessGlobalTrack((CbmGlobalTrack*) fGlbTrkArray->UncheckedAt(glb_trk_idx));
       }
 
       BuildResidual();
@@ -334,17 +334,17 @@ InitStatus CbmStsResolution::Init()
   FairRootManager* ioman = FairRootManager::Instance();
   if (ioman != nullptr) {
 
-    cbm_evt_array_ = (TClonesArray*) ioman->GetObject("CbmEvent");
+    fCbmEvtArray = (TClonesArray*) ioman->GetObject("CbmEvent");
 
-    glb_trk_array_ = (TClonesArray*) ioman->GetObject("GlobalTrack");
-    sts_trk_array_ = (TClonesArray*) ioman->GetObject("StsTrack");
-    rch_trk_array_ = (TClonesArray*) ioman->GetObject("RichTrack");
-    mch_trk_array_ = (TClonesArray*) ioman->GetObject("MuchTrack");
-    trd_trk_array_ = (TClonesArray*) ioman->GetObject("TrdTrack");
-    tof_trk_array_ = (TClonesArray*) ioman->GetObject("TofTrack");
+    fGlbTrkArray = (TClonesArray*) ioman->GetObject("GlobalTrack");
+    fStsTrkArray = (TClonesArray*) ioman->GetObject("StsTrack");
+    fRchTrkArray = (TClonesArray*) ioman->GetObject("RichTrack");
+    fMchTrkArray = (TClonesArray*) ioman->GetObject("MuchTrack");
+    fTrdTrkArray = (TClonesArray*) ioman->GetObject("TrdTrack");
+    fTofTrkArray = (TClonesArray*) ioman->GetObject("TofTrack");
 
-    sts_hit_array_ = (TClonesArray*) ioman->GetObject("StsHit");
-    sts_clu_array_ = (TClonesArray*) ioman->GetObject("StsCluster");
+    fStsHitArray = (TClonesArray*) ioman->GetObject("StsHit");
+    fStsCluArray = (TClonesArray*) ioman->GetObject("StsCluster");
   }
 
   LoadSetup();
diff --git a/analysis/detectors/sts/CbmStsResolution.h b/analysis/detectors/sts/CbmStsResolution.h
index 049787d7c2..a6938e855c 100644
--- a/analysis/detectors/sts/CbmStsResolution.h
+++ b/analysis/detectors/sts/CbmStsResolution.h
@@ -79,38 +79,38 @@ class CbmStsResolution : public FairTask, public CbmStsAnaBase {
   void Exec(Option_t*);
   void Finish();
 
-  void SetInputType(InputType type) { input_type = type; };
+  void SetInputType(InputType type) { fInputType = type; };
 
   void EnableRefSensor(int32_t);
 
-  void SetMinTrkHitQ(double q) { trk_hit_q_min_ = q; }
+  void SetMinTrkHitQ(double q) { fTrkHitQmin = q; }
 
   void TrackUseTwoSts() { tracking_use_two_sts_ = true; }
 
  private:
-  double d_max_trk_trg_{-1};
-  double trk_hit_q_min_{-1};
+  double fImpactParMax{-1};
+  double fTrkHitQmin{-1};
 
-  std::vector<CbmGlobalTrack*> glb_trks_;
-  std::map<int32_t, std::vector<CbmStsHit*>> sts_hits_;
+  std::vector<CbmGlobalTrack*> fGlbTrks;
+  std::map<int32_t, std::vector<CbmStsHit*>> fStsHits;
 
-  InputType input_type = InputType::kEventMode;
+  InputType fInputType = InputType::kEventMode;
 
   bool tracking_use_two_sts_{false};
 
-  std::vector<int32_t> active_ref_sensors_;
+  std::vector<int32_t> fActiveRefSensors;
 
-  TClonesArray* cbm_evt_array_{nullptr};
+  TClonesArray* fCbmEvtArray{nullptr};
 
-  TClonesArray* glb_trk_array_{nullptr};
-  TClonesArray* sts_trk_array_{nullptr};
-  TClonesArray* rch_trk_array_{nullptr};
-  TClonesArray* mch_trk_array_{nullptr};
-  TClonesArray* trd_trk_array_{nullptr};
-  TClonesArray* tof_trk_array_{nullptr};
+  TClonesArray* fGlbTrkArray{nullptr};
+  TClonesArray* fStsTrkArray{nullptr};
+  TClonesArray* fRchTrkArray{nullptr};
+  TClonesArray* fMchTrkArray{nullptr};
+  TClonesArray* fTrdTrkArray{nullptr};
+  TClonesArray* fTofTrkArray{nullptr};
 
-  TClonesArray* sts_hit_array_{nullptr};
-  TClonesArray* sts_clu_array_{nullptr};
+  TClonesArray* fStsHitArray{nullptr};
+  TClonesArray* fStsCluArray{nullptr};
 
   void BookHistograms();
 
diff --git a/analysis/detectors/sts/CbmStsTimeCal.cxx b/analysis/detectors/sts/CbmStsTimeCal.cxx
index 5807b156e9..e7579c8bde 100644
--- a/analysis/detectors/sts/CbmStsTimeCal.cxx
+++ b/analysis/detectors/sts/CbmStsTimeCal.cxx
@@ -33,18 +33,18 @@
 #include <yaml-cpp/node/node.h>
 
 CbmStsTimeCal::CbmStsTimeCal(ECbmModuleId ref_sys, double t_min, double t_max)
-  : time_window_min_(t_min)
-  , time_window_max_(t_max)
-  , time_ref_system_(ref_sys)
+  : fTimeWindowMin(t_min)
+  , fTimeWindowMax(t_max)
+  , fRefSystem(ref_sys)
 {
 }
 
 CbmStsTimeCal::CbmStsTimeCal(int run_id, ECbmModuleId ref_sys, double t_min, double t_max)
 {
-  run_id_          = run_id;
-  time_window_min_ = t_min;
-  time_window_max_ = t_max;
-  time_ref_system_ = ref_sys;
+  fRunId          = run_id;
+  fTimeWindowMin = t_min;
+  fTimeWindowMax = t_max;
+  fRefSystem = ref_sys;
 }
 
 
@@ -52,26 +52,26 @@ InitStatus CbmStsTimeCal::Init()
 {
   FairRootManager* ioman = FairRootManager::Instance();
   if (ioman != nullptr) {
-    digi_manager = CbmDigiManager::Instance();
-    digi_manager->Init();
+    fDigiManager = CbmDigiManager::Instance();
+    fDigiManager->Init();
 
-    cbm_evt_array_ = (TClonesArray*) ioman->GetObject("CbmEvent");
+    fCbmEvtArray = (TClonesArray*) ioman->GetObject("CbmEvent");
 
-    if (!digi_manager->IsPresent(ECbmModuleId::kSts)) LOG(fatal) << GetName() << ": No StsDigi branch in input!";
-    if (!digi_manager->IsPresent(time_ref_system_))
-      LOG(fatal) << GetName() << ": No " << ToString(time_ref_system_) << " branch in input!";
+    if (!fDigiManager->IsPresent(ECbmModuleId::kSts)) LOG(fatal) << GetName() << ": No StsDigi branch in input!";
+    if (!fDigiManager->IsPresent(fRefSystem))
+      LOG(fatal) << GetName() << ": No " << ToString(fRefSystem) << " branch in input!";
 
     LoadWalkFromFile();
 
-    o_path_ = run_id_ > 0 ? Form("%d", run_id_) : ".";
-    if (gSystem->AccessPathName(o_path_.c_str(), kFileExists)) {
-      if (system(("mkdir -p " + o_path_).c_str())) {  // Check output folder
+    fOutputPath = fRunId > 0 ? Form("%d", fRunId) : ".";
+    if (gSystem->AccessPathName(fOutputPath.c_str(), kFileExists)) {
+      if (system(("mkdir -p " + fOutputPath).c_str())) {  // Check output folder
         LOG(warning) << "Could not create output directory\n Setting output path at current location:\n";
       }
     }
-    offset_file_ = std::make_unique<TFile>(Form("%s/cbm_sts_time_cal_offset.root", o_path_.c_str()), "RECREATE");
-    report_file_ = std::make_unique<TFile>(Form("%s/cbm_sts_time_cal_report.root", o_path_.c_str()), "RECREATE");
-    fit_file_    = std::make_unique<TFile>(Form("%s/cbm_sts_time_cal_fits.root", o_path_.c_str()), "RECREATE");
+    fReportOffset = std::make_unique<TFile>(Form("%s/cbm_sts_time_cal_offset.root", fOutputPath.c_str()), "RECREATE");
+    fReportFile = std::make_unique<TFile>(Form("%s/cbm_sts_time_cal_report.root", fOutputPath.c_str()), "RECREATE");
+    fReportFit    = std::make_unique<TFile>(Form("%s/cbm_sts_time_cal_fits.root", fOutputPath.c_str()), "RECREATE");
 
     return kSUCCESS;
   }
@@ -81,11 +81,11 @@ InitStatus CbmStsTimeCal::Init()
 void CbmStsTimeCal::InitTimeWalkMap(int32_t address)
 {
   for (unsigned int asic_idx = 0; asic_idx < 16; asic_idx++) {
-    tw_map[address][asic_idx] = std::vector<double>(32, 0);
-    auto loaded_par           = time_walk_map.Get(address, asic_idx);
+    fWalkMapRaw[address][asic_idx] = std::vector<double>(32, 0);
+    auto loaded_par           = fWalkMap.Get(address, asic_idx);
     if (loaded_par.size() == 31) {
       for (int adc = 1; adc <= 31; adc++) {
-        tw_map[address][asic_idx][adc] = loaded_par[adc - 1];
+        fWalkMapRaw[address][asic_idx][adc] = loaded_par[adc - 1];
       }
     }
   }
@@ -94,18 +94,18 @@ void CbmStsTimeCal::InitTimeWalkMap(int32_t address)
 void CbmStsTimeCal::SetWalkFile(std::string f_name)
 {
   LOG(debug) << Form("Setting user define time calibration file: %s", f_name.c_str());
-  par_file_ = f_name;
+  fParFile = f_name;
 }
 
 void CbmStsTimeCal::LoadWalkFromFile()
 {
-  if (!par_file_.length()) return;
+  if (!fParFile.length()) return;
 
-  if (TString(par_file_.c_str()).EndsWith(".yaml") || TString(par_file_.c_str()).EndsWith(".yml")) {
-    LOG(info) << Form("Loading time calibration from parameter file: %s", par_file_.c_str());
-    time_walk_map       = cbm::algo::yaml::ReadFromFile<cbm::algo::sts::WalkMap>(par_file_);
-    global_time_offset_ = time_walk_map.GetSystemTimeOffset();
-    LOG(info) << "Current system offset: " << global_time_offset_ << " ns";
+  if (TString(fParFile.c_str()).EndsWith(".yaml") || TString(fParFile.c_str()).EndsWith(".yml")) {
+    LOG(info) << Form("Loading time calibration from parameter file: %s", fParFile.c_str());
+    fWalkMap       = cbm::algo::yaml::ReadFromFile<cbm::algo::sts::WalkMap>(fParFile);
+    fGlobalTimeOffset = fWalkMap.GetSystemTimeOffset();
+    LOG(info) << "Current system offset: " << fGlobalTimeOffset << " ns";
   }
 }
 
@@ -114,7 +114,7 @@ void CbmStsTimeCal::BookHistograms(int32_t address)
   LOG(debug) << Form("Booking histograms for module: 0x%x", address);
 
   std::string h_name, h_title;
-  int nb_time_bins = (std::abs(time_window_max_ - time_window_min_) + kStsClock) / kStsClock;
+  int nb_time_bins = (std::abs(fTimeWindowMax - fTimeWindowMin) + kStsClock) / kStsClock;
 
   int unit               = CbmStsAddress::GetElementId(address, kStsUnit);
   int ladd               = CbmStsAddress::GetElementId(address, kStsLadder);
@@ -125,32 +125,32 @@ void CbmStsTimeCal::BookHistograms(int32_t address)
     h_name  = Form("0x%x_%02d", address, asic_idx);
     h_title = Form("%s_%02d", smart_name.c_str(), asic_idx);
 
-    h2_[h_name] =
-      std::make_unique<TH2D>(h_name.c_str(), h_title.c_str(), nb_time_bins, time_window_min_ - 0.5 * kStsClock,
-                             time_window_max_ + 0.5 * kStsClock, 31, 1, 32);
+    fH2D[h_name] =
+      std::make_unique<TH2D>(h_name.c_str(), h_title.c_str(), nb_time_bins, fTimeWindowMin - 0.5 * kStsClock,
+                             fTimeWindowMax + 0.5 * kStsClock, 31, 1, 32);
 
-    h2_[h_name]->GetXaxis()->SetTitle(Form("t_{%s} - t_{StsDigi} [ns]", ToString(time_ref_system_).c_str()));
-    h2_[h_name]->GetYaxis()->SetTitle("Charge_{StsDigi} [ADC]");
+    fH2D[h_name]->GetXaxis()->SetTitle(Form("t_{%s} - t_{StsDigi} [ns]", ToString(fRefSystem).c_str()));
+    fH2D[h_name]->GetYaxis()->SetTitle("Charge_{StsDigi} [ADC]");
   }
 
   h_name      = Form("0x%x_dt_vs_channel", address);
   h_title     = smart_name;
-  h2_[h_name] = std::make_unique<TH2D>(h_name.c_str(), h_title.c_str(), 2048, 0, 2048, nb_time_bins,
-                                       time_window_min_ - 0.5 * kStsClock, time_window_max_ + 0.5 * kStsClock);
+  fH2D[h_name] = std::make_unique<TH2D>(h_name.c_str(), h_title.c_str(), 2048, 0, 2048, nb_time_bins,
+                                       fTimeWindowMin - 0.5 * kStsClock, fTimeWindowMax + 0.5 * kStsClock);
 
-  h2_[h_name]->GetYaxis()->SetTitle(Form("t_{%s} - t_{StsDigi} [ns]", ToString(time_ref_system_).c_str()));
-  h2_[h_name]->GetXaxis()->SetTitle("Channel_{StsDigi}");
+  fH2D[h_name]->GetYaxis()->SetTitle(Form("t_{%s} - t_{StsDigi} [ns]", ToString(fRefSystem).c_str()));
+  fH2D[h_name]->GetXaxis()->SetTitle("Channel_{StsDigi}");
 
-  address_book_.insert(address);
+  fAddressBook.insert(address);
 }
 
 void CbmStsTimeCal::Exec(Option_t*)
 {
   LOG(info) << "Running CbmStsTimeCal - Entry " << entry_;
 
-  if (time_ref_system_ == ECbmModuleId::kBmon) CheckTiming<CbmBmonDigi>();
-  if (time_ref_system_ == ECbmModuleId::kTof) CheckTiming<CbmTofDigi>();
-  if (time_ref_system_ == ECbmModuleId::kRich) CheckTiming<CbmRichDigi>();
+  if (fRefSystem == ECbmModuleId::kBmon) CheckTiming<CbmBmonDigi>();
+  if (fRefSystem == ECbmModuleId::kTof) CheckTiming<CbmTofDigi>();
+  if (fRefSystem == ECbmModuleId::kRich) CheckTiming<CbmRichDigi>();
 
   entry_++;
 }
@@ -158,11 +158,11 @@ void CbmStsTimeCal::Exec(Option_t*)
 template<class Digi>
 void CbmStsTimeCal::CheckTiming()
 {
-  auto sts_digis_ = digi_manager->GetArray<CbmStsDigi>();
-  auto ref_digis_ = digi_manager->GetArray<Digi>();
+  auto sts_digis_ = fDigiManager->GetArray<CbmStsDigi>();
+  auto ref_digis_ = fDigiManager->GetArray<Digi>();
 
-  size_t nb_sts_digis = digi_manager->GetNofDigis(ECbmModuleId::kSts);
-  size_t nb_ref_digis = digi_manager->GetNofDigis(Digi::GetSystem());
+  size_t nb_sts_digis = fDigiManager->GetNofDigis(ECbmModuleId::kSts);
+  size_t nb_ref_digis = fDigiManager->GetNofDigis(Digi::GetSystem());
 
   LOG(info) << nb_sts_digis << "\t" << nb_ref_digis;
 
@@ -171,12 +171,12 @@ void CbmStsTimeCal::CheckTiming()
     const Digi* ref_digi = &ref_digis_[ref_digi_idx];
     double ref_digi_time = ref_digi->GetTime();
 
-    if (analysis_cut_ != nullptr
-        && !analysis_cut_->Check(CbmCutId::kBmonDigiSide, CbmTofAddress::GetChannelSide(ref_digi->GetAddress())))
+    if (fAnalysisCuts != nullptr
+        && !fAnalysisCuts->Check(CbmCutId::kBmonDigiSide, CbmTofAddress::GetChannelSide(ref_digi->GetAddress())))
       continue;
 
-    double first_digi_in_window = ref_digi_time + time_window_min_;
-    double last_digi_in_window  = ref_digi_time + time_window_max_;
+    double first_digi_in_window = ref_digi_time + fTimeWindowMin;
+    double last_digi_in_window  = ref_digi_time + fTimeWindowMax;
     // Find first_digi_in_window
     int lo = 0, hi = nb_sts_digis - 1;
     while (lo < hi) {
@@ -211,7 +211,7 @@ void CbmStsTimeCal::CheckTiming()
       const CbmStsDigi* sts_digi = &sts_digis_[sts_digi_idx];
       int32_t sts_digi_addr      = sts_digi->GetAddress();
 
-      if (!address_book_.count(sts_digi_addr)) {
+      if (!fAddressBook.count(sts_digi_addr)) {
         BookHistograms(sts_digi_addr);
         InitTimeWalkMap(sts_digi_addr);
       }
@@ -221,8 +221,8 @@ void CbmStsTimeCal::CheckTiming()
       int32_t asic_idx      = sts_digi_chan / 128;
       double sts_digi_time  = sts_digi->GetTime();
 
-      h2_[Form("0x%x_%02d", sts_digi_addr, asic_idx)]->Fill(ref_digi_time - sts_digi_time, sts_digi_char);
-      h2_[Form("0x%x_dt_vs_channel", sts_digi_addr)]->Fill(sts_digi_chan, ref_digi_time - sts_digi_time);
+      fH2D[Form("0x%x_%02d", sts_digi_addr, asic_idx)]->Fill(ref_digi_time - sts_digi_time, sts_digi_char);
+      fH2D[Form("0x%x_dt_vs_channel", sts_digi_addr)]->Fill(sts_digi_chan, ref_digi_time - sts_digi_time);
     }  // end sts loop
   }    // end ref loop
 }
@@ -377,7 +377,7 @@ double CbmStsTimeCal::FindModuleOffset(int32_t address)
 {
 
   double module_offset = 0;
-  TH2D* dt_vs_chn      = h2_[Form("0x%x_dt_vs_channel", address)].get();
+  TH2D* dt_vs_chn      = fH2D[Form("0x%x_dt_vs_channel", address)].get();
   if (dt_vs_chn != nullptr) {
     TH1D* p_y = (TH1D*) dt_vs_chn->ProjectionY();
 
@@ -386,7 +386,7 @@ double CbmStsTimeCal::FindModuleOffset(int32_t address)
     FitStsTime offset_fit(p_y);
     TCanvas* drawing = offset_fit.Draw();
     if (drawing != nullptr) {
-      offset_file_->cd();
+      fReportOffset->cd();
       drawing->Write(Form("0x%x_offset", address));
     }
 
@@ -406,7 +406,7 @@ void CbmStsTimeCal::CheckTimeWalk()
 		* For mCBM case, there are usually less than 16 modules so it makes more sense to parallelize the ASIC idx loop
 		* but for the full CBM case, the amount of modules greatly exceeds the number of ASIC per modules (16)
 		*/
-  for (int32_t module : address_book_) {  // loop over modules
+  for (int32_t module : fAddressBook) {  // loop over modules
     double module_offset = FindModuleOffset(module);
     for (unsigned int asic_idx = 0; asic_idx < 16; asic_idx++) {  // loop over ASICs
 
@@ -417,9 +417,9 @@ void CbmStsTimeCal::CheckTimeWalk()
       int n_pts = 0;
 
       std::string h_name = Form("0x%x_%02d", module, asic_idx);
-      if (!h2_.count(h_name)) return;
+      if (!fH2D.count(h_name)) return;
 
-      auto h = h2_[h_name].get();
+      auto h = fH2D[h_name].get();
 
       for (int adc = 1; adc <= 31; adc++) {
         TH1D* h_x = h->ProjectionX(Form("%s_dt", h_name.c_str()), adc, adc);
@@ -428,9 +428,9 @@ void CbmStsTimeCal::CheckTimeWalk()
         TCanvas* drawing = offset_fit.Draw();
         if (drawing != nullptr) {
           std::string fit_folder = Form("0x%x/%02d", module, asic_idx);
-          TDirectory* dir        = (TDirectory*) fit_file_->Get(fit_folder.c_str());
+          TDirectory* dir        = (TDirectory*) fReportFit->Get(fit_folder.c_str());
           if (!dir) {
-            dir = fit_file_->mkdir(fit_folder.c_str());
+            dir = fReportFit->mkdir(fit_folder.c_str());
           }
           dir->cd();
           drawing->Write(Form("0x%x_%02d_%02d", module, asic_idx, adc));
@@ -451,18 +451,18 @@ void CbmStsTimeCal::CheckTimeWalk()
         adc_channel_err[n_pts] = 0;
 
         // Update time walk map
-        tw_map[module][asic_idx][adc] += time_offset[n_pts];
+        fWalkMapRaw[module][asic_idx][adc] += time_offset[n_pts];
 
         n_pts++;
 
       }  // ---- end ADC loop ----
 
-      g1_[h_name] = std::make_unique<TGraphErrors>(n_pts, adc_channel, time_offset, adc_channel_err, time_offset_err);
-      g1_[h_name]->SetTitle(Form("%s : StsDigi_0x%x time off-set", ToString(time_ref_system_).c_str(), module));
-      g1_[h_name]->GetXaxis()->SetTitle("Charge_{StsDigi} [ADC]");
-      g1_[h_name]->GetYaxis()->SetTitle(Form("t_{%s} - t_{StsDigi} [ns]", ToString(time_ref_system_).c_str()));
-      g1_[h_name]->SetMinimum(time_window_min_);
-      g1_[h_name]->SetMaximum(time_window_max_);
+      fG1D[h_name] = std::make_unique<TGraphErrors>(n_pts, adc_channel, time_offset, adc_channel_err, time_offset_err);
+      fG1D[h_name]->SetTitle(Form("%s : StsDigi_0x%x time off-set", ToString(fRefSystem).c_str(), module));
+      fG1D[h_name]->GetXaxis()->SetTitle("Charge_{StsDigi} [ADC]");
+      fG1D[h_name]->GetYaxis()->SetTitle(Form("t_{%s} - t_{StsDigi} [ns]", ToString(fRefSystem).c_str()));
+      fG1D[h_name]->SetMinimum(fTimeWindowMin);
+      fG1D[h_name]->SetMaximum(fTimeWindowMax);
 
     }  // ---- end module loop ----
   }    // ---- end ASICs loop ----
@@ -472,14 +472,14 @@ double CbmStsTimeCal::FindGlobalOffset()
 {
   double setup_offset  = 0;
   double min_sum_sigma = 999;
-  for (int32_t module : address_book_) {  // module loop
+  for (int32_t module : fAddressBook) {  // module loop
     double module_avg_sigma  = 0;
     double module_avg_offset = 0;
     int n_of_values          = 0;
 
     for (unsigned int asic_idx = 0; asic_idx < 16; asic_idx++) {  // asic loop
       std::string h_name = Form("0x%x_%02d", module, asic_idx);
-      auto g             = g1_[h_name].get();
+      auto g             = fG1D[h_name].get();
 
       int n_of_pto    = g->GetN();
       int lower_bound = n_of_pto > 5 ? n_of_pto - 5 : 0;
@@ -510,16 +510,16 @@ double CbmStsTimeCal::FindGlobalOffset()
 
 void CbmStsTimeCal::WriteYAML()
 {
-  std::string o_yaml_file = o_path_ + "/StsTimeCalibration.yaml";
+  std::string o_yaml_file = fOutputPath + "/StsTimeCalibration.yaml";
   LOG(info) << "Writing parameter file to:" << o_yaml_file;
 
   YAML::Emitter walk_map;
   walk_map << YAML::BeginMap;
   walk_map << YAML::Key << "timeOffset";
-  walk_map << YAML::Value << (int) global_time_offset_;
+  walk_map << YAML::Value << (int) fGlobalTimeOffset;
   walk_map << YAML::Key << "WalkMap";
   walk_map << YAML::Value << YAML::BeginMap;
-  for (const auto& [module, asics] : tw_map) {
+  for (const auto& [module, asics] : fWalkMapRaw) {
     walk_map << YAML::Key << fmt::format("0x{:x}", module);
     walk_map << YAML::Value << YAML::BeginSeq;
     for (const auto& [asic, pars] : asics) {
@@ -548,7 +548,7 @@ void CbmStsTimeCal::Finish()
   CheckTimeWalk();
 
   // resize ADC offset vector to 31 channels from 0 [0-30`]
-  for (auto& [module, asics] : tw_map) {        // Loop over modules
+  for (auto& [module, asics] : fWalkMapRaw) {        // Loop over modules
     for (auto& [asic_idx, asic_par] : asics) {  // Loop over ASICs
       for (int adc = 1; adc <= 31; adc++) {     // loop over ADC channels 31 channels [1 - 31]
         asic_par[adc - 1] = asic_par[adc];
@@ -563,8 +563,8 @@ void CbmStsTimeCal::Finish()
   SaveToFile();
 
 
-  h1_.clear();
-  h2_.clear();
+  fH1D.clear();
+  fH2D.clear();
 }
 
 
@@ -580,23 +580,23 @@ void CbmStsTimeCal::DrawResults()
 
   std::unique_ptr<TCanvas> dt_vs_chn = std::make_unique<TCanvas>("dt_vs_chn", "dt_vs_chn", 10, 10, 1024, 1024);
 
-  report_file_->cd();
-  for (int32_t sensor : address_book_) {
+  fReportFile->cd();
+  for (int32_t sensor : fAddressBook) {
     for (int asic_idx = 0; asic_idx < 16; asic_idx++) {
       adc_vs_dt_1d->cd(asic_idx + 1);
-      if (g1_[Form("0x%x_%02d", sensor, asic_idx)] != nullptr) {
-        g1_[Form("0x%x_%02d", sensor, asic_idx)]->Draw("APL");
+      if (fG1D[Form("0x%x_%02d", sensor, asic_idx)] != nullptr) {
+        fG1D[Form("0x%x_%02d", sensor, asic_idx)]->Draw("APL");
       }
 
       adc_vs_dt_2d->cd(asic_idx + 1);
-      if (h2_[Form("0x%x_%02d", sensor, asic_idx)] != nullptr) {
-        h2_[Form("0x%x_%02d", sensor, asic_idx)]->Draw("colz");
+      if (fH2D[Form("0x%x_%02d", sensor, asic_idx)] != nullptr) {
+        fH2D[Form("0x%x_%02d", sensor, asic_idx)]->Draw("colz");
       }
     }
 
     dt_vs_chn->cd();
-    if (h2_[Form("0x%x_dt_vs_channel", sensor)] != nullptr) {
-      h2_[Form("0x%x_dt_vs_channel", sensor)]->Draw("colz");
+    if (fH2D[Form("0x%x_dt_vs_channel", sensor)] != nullptr) {
+      fH2D[Form("0x%x_dt_vs_channel", sensor)]->Draw("colz");
     }
 
     adc_vs_dt_1d->Write(Form("adc_vs_dt_1d_0x%x", sensor));
diff --git a/analysis/detectors/sts/CbmStsTimeCal.h b/analysis/detectors/sts/CbmStsTimeCal.h
index c602ac70f3..a308ec8dfa 100644
--- a/analysis/detectors/sts/CbmStsTimeCal.h
+++ b/analysis/detectors/sts/CbmStsTimeCal.h
@@ -103,24 +103,24 @@ class CbmStsTimeCal : public FairTask, public CbmStsAnaBase {
 
 
  private:
-  double global_time_offset_{0};
-  double time_window_min_{-60};
-  double time_window_max_{+60};
+  double fGlobalTimeOffset{0};
+  double fTimeWindowMin{-60};
+  double fTimeWindowMax{+60};
   const double kStsClock{3.125};
-  std::string par_file_{""};
-  std::string o_path_{""};
+  std::string fParFile{""};
+  std::string fOutputPath{""};
 
-  std::map<int /* Module */, std::map<int /* ASIC */, std::vector<double> /* ADC offset */>> tw_map;
-  cbm::algo::sts::WalkMap time_walk_map;
+  std::map<int /* Module */, std::map<int /* ASIC */, std::vector<double> /* ADC offset */>> fWalkMapRaw;
+  cbm::algo::sts::WalkMap fWalkMap;
 
-  std::unique_ptr<TFile> offset_file_;
-  std::unique_ptr<TFile> fit_file_;
+  std::unique_ptr<TFile> fReportOffset;
+  std::unique_ptr<TFile> fReportFit;
 
-  ECbmModuleId time_ref_system_{ECbmModuleId::kBmon};
+  ECbmModuleId fRefSystem{ECbmModuleId::kBmon};
 
-  CbmDigiManager* digi_manager{nullptr};
+  CbmDigiManager* fDigiManager{nullptr};
 
-  TClonesArray* cbm_evt_array_{nullptr};
+  TClonesArray* fCbmEvtArray{nullptr};
 
   /**
    * @brief Book histograms.
@@ -141,7 +141,7 @@ class CbmStsTimeCal : public FairTask, public CbmStsAnaBase {
   double FindGlobalOffset();
 
   /** \brief Check timing for a specific digi type
-   * It fills StsDigi time difference respect to ref_system Digis histograms
+   * It fills StsDigi time difference respect to fRefSystem Digis histograms
   */
   template<class Digi>
   void CheckTiming();
-- 
GitLab


From d4884e2167009d8eb3e7f422549ef200bda12617 Mon Sep 17 00:00:00 2001
From: Dario Ramirez <d.ramirez@gsi.de>
Date: Wed, 23 Apr 2025 13:17:05 +0200
Subject: [PATCH 18/18] Apply clang-format

---
 analysis/detectors/sts/CbmCut.h               |  4 +--
 analysis/detectors/sts/CbmCutMap.cxx          |  2 +-
 analysis/detectors/sts/CbmDcaVertexFinder.cxx |  2 +-
 analysis/detectors/sts/CbmEventVertexDca.cxx  |  8 ++---
 analysis/detectors/sts/CbmSpillCheck.cxx      |  6 ++--
 analysis/detectors/sts/CbmStsAnaBase.cxx      |  4 +--
 analysis/detectors/sts/CbmStsAnaBase.h        |  6 ++--
 analysis/detectors/sts/CbmStsChannelQA.cxx    | 11 +++---
 analysis/detectors/sts/CbmStsEfficiency.cxx   |  4 +--
 analysis/detectors/sts/CbmStsHitAna.cxx       | 34 +++++++++----------
 analysis/detectors/sts/CbmStsRecoBeamSpot.cxx | 16 ++++-----
 analysis/detectors/sts/CbmStsResolution.cxx   | 16 ++++-----
 analysis/detectors/sts/CbmStsTimeCal.cxx      | 18 +++++-----
 13 files changed, 64 insertions(+), 67 deletions(-)

diff --git a/analysis/detectors/sts/CbmCut.h b/analysis/detectors/sts/CbmCut.h
index 79ff461421..fac886230e 100644
--- a/analysis/detectors/sts/CbmCut.h
+++ b/analysis/detectors/sts/CbmCut.h
@@ -52,12 +52,12 @@ class CbmCut {
 
   void SetMin(T val)
   {
-    min_       = val;
+    min_      = val;
     fMinState = true;
   }
   void SetMax(T val)
   {
-    max_       = val;
+    max_      = val;
     fMaxState = true;
   }
   void SetRange(T min_val, T max_val)
diff --git a/analysis/detectors/sts/CbmCutMap.cxx b/analysis/detectors/sts/CbmCutMap.cxx
index 9e60f33bdf..b055814bee 100644
--- a/analysis/detectors/sts/CbmCutMap.cxx
+++ b/analysis/detectors/sts/CbmCutMap.cxx
@@ -12,7 +12,7 @@ bool CbmCutMap::Check(CbmCutId id, double value)
     fFailedCounter[id] = 0;
     return true;
   }
-  bool check_result        = fCbmCuts[id].Check(value);
+  bool check_result  = fCbmCuts[id].Check(value);
   fFailedCounter[id] = check_result ? fFailedCounter[id] + 1 : fFailedCounter[id];
   return check_result;
 }
diff --git a/analysis/detectors/sts/CbmDcaVertexFinder.cxx b/analysis/detectors/sts/CbmDcaVertexFinder.cxx
index 695f8ea3c1..bd394f0466 100644
--- a/analysis/detectors/sts/CbmDcaVertexFinder.cxx
+++ b/analysis/detectors/sts/CbmDcaVertexFinder.cxx
@@ -66,7 +66,7 @@ void CbmDcaVertexFinder::SetTracks(const std::vector<CbmGlobalTrack*> tracks)
 std::optional<CbmVertex> CbmDcaVertexFinder::FindVertex()
 {
   // Reset the number of track pair used
-  fNbPairs  = 0;
+  fNbPairs     = 0;
   int n_of_trk = fInputTracks.size();
   LOG(debug) << "- PCA - Find event vertex using CbmGlobalTracks: " << n_of_trk;
   TVector3 vtx;
diff --git a/analysis/detectors/sts/CbmEventVertexDca.cxx b/analysis/detectors/sts/CbmEventVertexDca.cxx
index df72d346c2..f5cc0bb53a 100644
--- a/analysis/detectors/sts/CbmEventVertexDca.cxx
+++ b/analysis/detectors/sts/CbmEventVertexDca.cxx
@@ -142,12 +142,12 @@ void CbmEventVertexDca::BookHistograms()
   // ---- ------------------------- ----
 
   // Track multiplicity
-  h_name      = "ca_track_multiplicity_all";
+  h_name       = "ca_track_multiplicity_all";
   fH1D[h_name] = std::make_unique<TH1D>(h_name.c_str(), h_name.c_str(), 50, 0, 50);
   fH1D[h_name]->GetXaxis()->SetTitle("N_{CATrack}");
   fH1D[h_name]->GetYaxis()->SetTitle("Entries");
 
-  h_name      = "ca_track_multiplicity_sel";
+  h_name       = "ca_track_multiplicity_sel";
   fH1D[h_name] = std::make_unique<TH1D>(h_name.c_str(), h_name.c_str(), 50, 0, 50);
   fH1D[h_name]->GetXaxis()->SetTitle("N_{CATrack}");
   fH1D[h_name]->GetYaxis()->SetTitle("Entries");
@@ -338,8 +338,8 @@ InitStatus CbmEventVertexDca::Init()
 
     fStsCluArray = (TClonesArray*) ioman->GetObject("StsCluster");
 
-    fMCTrkArray = (TClonesArray*) ioman->GetObject("MCTrack");
-    input_has_mc  = fMCTrkArray != nullptr;
+    fMCTrkArray  = (TClonesArray*) ioman->GetObject("MCTrack");
+    input_has_mc = fMCTrkArray != nullptr;
   }
 
   LoadSetup();
diff --git a/analysis/detectors/sts/CbmSpillCheck.cxx b/analysis/detectors/sts/CbmSpillCheck.cxx
index e52c916dd7..ca6f883e51 100644
--- a/analysis/detectors/sts/CbmSpillCheck.cxx
+++ b/analysis/detectors/sts/CbmSpillCheck.cxx
@@ -55,8 +55,8 @@ void CbmSpillCheck::Exec(Option_t*)
   LOG(info) << "Running CbmSpillCheck ...";
 
   size_t nb_ref_digis = fDigiManager->GetNofDigis(fRefSystem);
-  fRateMin           = fRateMin == -1 ? nb_ref_digis : std::min(nb_ref_digis, size_t(fRateMin));
-  fRateMax           = fRateMax == -1 ? nb_ref_digis : std::max(nb_ref_digis, size_t(fRateMax));
+  fRateMin            = fRateMin == -1 ? nb_ref_digis : std::min(nb_ref_digis, size_t(fRateMin));
+  fRateMax            = fRateMax == -1 ? nb_ref_digis : std::max(nb_ref_digis, size_t(fRateMax));
   fRefRate.push_back(nb_ref_digis);
 
   for (ECbmModuleId system = ECbmModuleId::kRef; system != ECbmModuleId::kLastModule; ++system) {
@@ -73,7 +73,7 @@ void CbmSpillCheck::Finish()
 {
   double spill_lvl_off = fRateMin + fRateMinPercent * (fRateMax - fRateMin);
   double spill_lvl_on  = fRateMin + fRateMaxPercent * (fRateMax - fRateMin);
-  fSpillStatus        = std::vector<int>(fRefRate.size(), 0);
+  fSpillStatus         = std::vector<int>(fRefRate.size(), 0);
   for (size_t ts_idx = 0; ts_idx < fRefRate.size(); ts_idx++) {
     fSpillStatus[ts_idx] = fRefRate[ts_idx] <= spill_lvl_off ? -1 : (fRefRate[ts_idx] <= spill_lvl_on ? 0 : 1);
     std::cout << fSpillStatus[ts_idx] << std::endl;
diff --git a/analysis/detectors/sts/CbmStsAnaBase.cxx b/analysis/detectors/sts/CbmStsAnaBase.cxx
index fac278da1e..3076f5af47 100644
--- a/analysis/detectors/sts/CbmStsAnaBase.cxx
+++ b/analysis/detectors/sts/CbmStsAnaBase.cxx
@@ -40,7 +40,7 @@ void CbmStsAnaBase::LoadSetup()
   assert(nb_sts_station_ != 0);
 
   for (unsigned short unit_idx = 0; unit_idx < nb_sts_station_; unit_idx++) {
-    CbmStsStation* sts_unit    = sts_setup->GetStation(unit_idx);
+    CbmStsStation* sts_unit  = sts_setup->GetStation(unit_idx);
     fStsGeoInfo[unit_idx]    = std::vector<double>(5, 0);
     fStsGeoInfo[unit_idx][0] = sts_unit->GetXmin();
     fStsGeoInfo[unit_idx][1] = sts_unit->GetXmax();
@@ -62,7 +62,7 @@ void CbmStsAnaBase::LoadSetup()
     TGeoMatrix* sensor_matrix     = sensor_node->GetMatrix();
 
     // const double* local = sensor_shape->GetOrigin();
-    const double* trans       = sensor_matrix->GetTranslation();
+    const double* trans     = sensor_matrix->GetTranslation();
     fStsGeoInfo[address]    = std::vector<double>(6, 0);
     fStsGeoInfo[address][0] = trans[0] - sensor_shape->GetDX();  // Xmin
     fStsGeoInfo[address][1] = trans[0] + sensor_shape->GetDX();  // Xmax
diff --git a/analysis/detectors/sts/CbmStsAnaBase.h b/analysis/detectors/sts/CbmStsAnaBase.h
index 152af21bb0..1dfd3941fc 100644
--- a/analysis/detectors/sts/CbmStsAnaBase.h
+++ b/analysis/detectors/sts/CbmStsAnaBase.h
@@ -71,10 +71,10 @@ class CbmStsAnaBase {
   std::map<std::string, std::unique_ptr<TGraphErrors>> fG1D;  // Map of TGraphErrors objects.
   std::map<std::string, std::unique_ptr<TH1D>> fH1D;          // Map of TH1D objects.
   std::map<std::string, std::unique_ptr<TH2D>> fH2D;          // Map of TH2D objects.
-  std::map<std::string, std::shared_ptr<TH2D>> fH2DShared;         // Map of TH2D objects.
-  std::map<std::string, std::unique_ptr<TCanvas>> fCanvas;   // Map of TH2D objects.
+  std::map<std::string, std::shared_ptr<TH2D>> fH2DShared;    // Map of TH2D objects.
+  std::map<std::string, std::unique_ptr<TCanvas>> fCanvas;    // Map of TH2D objects.
 
-  int nb_sts_station_{8};                                          // Number of STS stations.
+  int nb_sts_station_{8};                                        // Number of STS stations.
   std::unordered_map<int32_t, std::vector<double>> fStsGeoInfo;  // Map of STS geometry information.
 
   std::map<int32_t, std::vector<double>> fUserAlignment;  // Stores the user-defined alignment information.
diff --git a/analysis/detectors/sts/CbmStsChannelQA.cxx b/analysis/detectors/sts/CbmStsChannelQA.cxx
index dd60c57115..d2734a216d 100644
--- a/analysis/detectors/sts/CbmStsChannelQA.cxx
+++ b/analysis/detectors/sts/CbmStsChannelQA.cxx
@@ -74,16 +74,16 @@ void CbmStsChannelQA::BookHistograms(int32_t address)
     fH2D[h_name]->GetYaxis()->SetTitle("Charge_{StsDigi} [ADC]");
 
     LOG(debug) << h_name;
-    h_name      = Form("0x%x_dt_vs_charge%s", address, modifier);
+    h_name       = Form("0x%x_dt_vs_charge%s", address, modifier);
     fH2D[h_name] = std::make_unique<TH2D>(h_name.c_str(), h_name.c_str(), 31, 1, 32, t_binning.n_of_bins,
-                                         t_binning.x_min, t_binning.x_max);
+                                          t_binning.x_min, t_binning.x_max);
     fH2D[h_name]->GetYaxis()->SetTitle("Charge_{StsDigi} [ADC]");
     fH2D[h_name]->GetYaxis()->SetTitle("Time difference [ns]");
 
     LOG(debug) << h_name;
-    h_name      = Form("0x%x_dt_vs_channel%s", address, modifier);
+    h_name       = Form("0x%x_dt_vs_channel%s", address, modifier);
     fH2D[h_name] = std::make_unique<TH2D>(h_name.c_str(), h_name.c_str(), 2048, 0, 2048, t_binning.n_of_bins,
-                                         t_binning.x_min, t_binning.x_max);
+                                          t_binning.x_min, t_binning.x_max);
     fH2D[h_name]->GetXaxis()->SetTitle("Channel_{StsDigi}");
     fH2D[h_name]->GetYaxis()->SetTitle("Time difference [ns]");
   }
@@ -114,8 +114,7 @@ void CbmStsChannelQA::Exec(Option_t*)
   **/
   int fSpillStatus = 0;
   if (fSpillThresholds.has_value()) {
-    fSpillStatus =
-      nb_ref_digis <= fSpillThresholds->first ? -1 : (nb_ref_digis <= fSpillThresholds->second ? 0 : 1);
+    fSpillStatus = nb_ref_digis <= fSpillThresholds->first ? -1 : (nb_ref_digis <= fSpillThresholds->second ? 0 : 1);
   }
 
   std::string str_spill;
diff --git a/analysis/detectors/sts/CbmStsEfficiency.cxx b/analysis/detectors/sts/CbmStsEfficiency.cxx
index 30ddb383c4..7823ea455b 100644
--- a/analysis/detectors/sts/CbmStsEfficiency.cxx
+++ b/analysis/detectors/sts/CbmStsEfficiency.cxx
@@ -164,12 +164,12 @@ void CbmStsEfficiency::BookHistograms()
 
   // ---- Track multiplicity ----
   for (const char* mod : {":all", ":sel"}) {
-    h_name      = Form("ca_track_multiplicity%s", mod);
+    h_name       = Form("ca_track_multiplicity%s", mod);
     fH1D[h_name] = std::make_unique<TH1D>(h_name.c_str(), h_name.c_str(), 50, 0, 50);  // HARDCODE
     fH1D[h_name]->GetXaxis()->SetTitle("N_{CATrack}");
     fH1D[h_name]->GetYaxis()->SetTitle("Entries");
 
-    h_name      = Form("ca_track_chi2%s", mod);
+    h_name       = Form("ca_track_chi2%s", mod);
     fH1D[h_name] = std::make_unique<TH1D>(h_name.c_str(), h_name.c_str(), 10000, 0, 10);  // HARDCODE
     fH1D[h_name]->GetXaxis()->SetTitle("Chi2");
     fH1D[h_name]->GetYaxis()->SetTitle("Entries");
diff --git a/analysis/detectors/sts/CbmStsHitAna.cxx b/analysis/detectors/sts/CbmStsHitAna.cxx
index 65ec4fb00b..15785ec3d6 100644
--- a/analysis/detectors/sts/CbmStsHitAna.cxx
+++ b/analysis/detectors/sts/CbmStsHitAna.cxx
@@ -66,29 +66,29 @@ void CbmStsHitAna::BookHistograms(int32_t address)
   auto t_binning = cbm_sts_utils::HBinning{uint32_t((t_max - t_min) / cbm_sts_utils::kStsClock), t_min, t_max};
 
   for (const char* mod : fHitModifier) {
-    h_name      = Form("0x%x_Q_asymmetry%s", address, mod);
+    h_name       = Form("0x%x_Q_asymmetry%s", address, mod);
     fH1D[h_name] = std::make_unique<TH1D>(h_name.c_str(), h_name.c_str(), 1000, -1.01, +1.01);
 
-    h_name      = Form("0x%x_Qp_vs_Qn%s", address, mod);
-    fH2D[h_name] = std::make_unique<TH2D>(h_name.c_str(), h_name.c_str(), n_side_binning.n_of_bins, n_side_binning.x_min,
-                                         n_side_binning.x_max, p_side_binning.n_of_bins, p_side_binning.x_min,
-                                         p_side_binning.x_max);
+    h_name       = Form("0x%x_Qp_vs_Qn%s", address, mod);
+    fH2D[h_name] = std::make_unique<TH2D>(h_name.c_str(), h_name.c_str(), n_side_binning.n_of_bins,
+                                          n_side_binning.x_min, n_side_binning.x_max, p_side_binning.n_of_bins,
+                                          p_side_binning.x_min, p_side_binning.x_max);
 
-    h_name      = Form("0x%x_Qp_vs_size%s", address, mod);
-    fH2D[h_name] = std::make_unique<TH2D>(h_name.c_str(), h_name.c_str(), p_side_binning.n_of_bins, p_side_binning.x_min,
-                                         p_side_binning.x_max, fMaxCluSize, 1, fMaxCluSize + 1);
+    h_name       = Form("0x%x_Qp_vs_size%s", address, mod);
+    fH2D[h_name] = std::make_unique<TH2D>(h_name.c_str(), h_name.c_str(), p_side_binning.n_of_bins,
+                                          p_side_binning.x_min, p_side_binning.x_max, fMaxCluSize, 1, fMaxCluSize + 1);
 
-    h_name      = Form("0x%x_Qn_vs_size%s", address, mod);
-    fH2D[h_name] = std::make_unique<TH2D>(h_name.c_str(), h_name.c_str(), n_side_binning.n_of_bins, n_side_binning.x_min,
-                                         n_side_binning.x_max, fMaxCluSize, 1, fMaxCluSize + 1);
+    h_name       = Form("0x%x_Qn_vs_size%s", address, mod);
+    fH2D[h_name] = std::make_unique<TH2D>(h_name.c_str(), h_name.c_str(), n_side_binning.n_of_bins,
+                                          n_side_binning.x_min, n_side_binning.x_max, fMaxCluSize, 1, fMaxCluSize + 1);
 
-    h_name      = Form("0x%x_psize_vs_nsize%s", address, mod);
-    fH2D[h_name] = std::make_unique<TH2D>(h_name.c_str(), h_name.c_str(), fMaxCluSize, 1, fMaxCluSize + 1,
-                                         fMaxCluSize, 1, fMaxCluSize + 1);
+    h_name       = Form("0x%x_psize_vs_nsize%s", address, mod);
+    fH2D[h_name] = std::make_unique<TH2D>(h_name.c_str(), h_name.c_str(), fMaxCluSize, 1, fMaxCluSize + 1, fMaxCluSize,
+                                          1, fMaxCluSize + 1);
 
-    h_name      = Form("0x%x_y_vs_x%s", address, mod);
+    h_name       = Form("0x%x_y_vs_x%s", address, mod);
     fH2D[h_name] = std::make_unique<TH2D>(h_name.c_str(), h_name.c_str(), x_binning.n_of_bins, x_binning.x_min,
-                                         x_binning.x_max, y_binning.n_of_bins, y_binning.x_min, y_binning.x_max);
+                                          x_binning.x_max, y_binning.n_of_bins, y_binning.x_min, y_binning.x_max);
 
     h_name = Form("0x%x_cluster_dt%s", address, mod);
     fH1D[h_name] =
@@ -144,7 +144,7 @@ void CbmStsHitAna::ProcessHit(CbmStsHit* hit, bool belong_to_trk)
   fH2D[Form("0x%x_psize_vs_nsize%s", address, mod)]->Fill(size_p, size_n);
   fH2D[Form("0x%x_y_vs_x%s", address, mod)]->Fill(hit->GetX(), hit->GetY());
   fH1D[Form("0x%x_cluster_dt%s", address, mod)]->Fill(cbm_sts_utils::GetHitTimeF(hit, fStsCluArray)
-                                                     - cbm_sts_utils::GetHitTimeB(hit, fStsCluArray));
+                                                      - cbm_sts_utils::GetHitTimeB(hit, fStsCluArray));
 }
 
 void CbmStsHitAna::ProcessGlobalTrack(CbmGlobalTrack* trk)
diff --git a/analysis/detectors/sts/CbmStsRecoBeamSpot.cxx b/analysis/detectors/sts/CbmStsRecoBeamSpot.cxx
index dd8bf2868b..16ed149009 100644
--- a/analysis/detectors/sts/CbmStsRecoBeamSpot.cxx
+++ b/analysis/detectors/sts/CbmStsRecoBeamSpot.cxx
@@ -44,27 +44,27 @@ void CbmStsRecoBeamSpot::BookHistograms()
         unsigned int nb_bins_y = (fSampleRangeYmax - fSampleRangeYmin) / fSampleBinSizeY;
         unsigned int nb_bins_z = (fSampleRangeZmax - fSampleRangeZmin) / fSampleBinSizeZ;
 
-        h_name      = Form("%s_Y_vs_X", h_name_base.c_str());
+        h_name       = Form("%s_Y_vs_X", h_name_base.c_str());
         fH2D[h_name] = std::make_unique<TH2D>(h_name.c_str(), h_name.c_str(), nb_bins_x, fSampleRangeXmin,
-                                             fSampleRangeXmax, nb_bins_y, fSampleRangeYmin, fSampleRangeYmax);
+                                              fSampleRangeXmax, nb_bins_y, fSampleRangeYmin, fSampleRangeYmax);
         fH2D[h_name]->GetXaxis()->SetTitle("X [cm]");
         fH2D[h_name]->GetYaxis()->SetTitle("Y [cm]");
 
-        h_name      = Form("%s_X_vs_Z", h_name_base.c_str());
+        h_name       = Form("%s_X_vs_Z", h_name_base.c_str());
         fH2D[h_name] = std::make_unique<TH2D>(h_name.c_str(), h_name.c_str(), nb_bins_z, fSampleRangeZmin,
-                                             fSampleRangeZmax, nb_bins_x, fSampleRangeXmin, fSampleRangeXmax);
+                                              fSampleRangeZmax, nb_bins_x, fSampleRangeXmin, fSampleRangeXmax);
         fH2D[h_name]->GetXaxis()->SetTitle("Z [cm]");
         fH2D[h_name]->GetYaxis()->SetTitle("X [cm]");
 
-        h_name      = Form("%s_Y_vs_Z", h_name_base.c_str());
+        h_name       = Form("%s_Y_vs_Z", h_name_base.c_str());
         fH2D[h_name] = std::make_unique<TH2D>(h_name.c_str(), h_name.c_str(), nb_bins_z, fSampleRangeZmin,
-                                             fSampleRangeZmax, nb_bins_y, fSampleRangeYmin, fSampleRangeYmax);
+                                              fSampleRangeZmax, nb_bins_y, fSampleRangeYmin, fSampleRangeYmax);
         fH2D[h_name]->GetXaxis()->SetTitle("Z [cm]");
         fH2D[h_name]->GetYaxis()->SetTitle("Y [cm]");
 
-        h_name      = Form("%s_Y_beam_vs_X_beam", h_name_base.c_str());
+        h_name       = Form("%s_Y_beam_vs_X_beam", h_name_base.c_str());
         fH2D[h_name] = std::make_unique<TH2D>(h_name.c_str(), h_name.c_str(), nb_bins_x, fSampleRangeXmin,
-                                             fSampleRangeXmax, nb_bins_y, fSampleRangeYmin, fSampleRangeYmax);
+                                              fSampleRangeXmax, nb_bins_y, fSampleRangeYmin, fSampleRangeYmax);
         fH2D[h_name]->GetXaxis()->SetTitle("X_beam [cm]");
         fH2D[h_name]->GetYaxis()->SetTitle("Y_beam [cm]");
 
diff --git a/analysis/detectors/sts/CbmStsResolution.cxx b/analysis/detectors/sts/CbmStsResolution.cxx
index 2f3c2d9a50..ba67102876 100644
--- a/analysis/detectors/sts/CbmStsResolution.cxx
+++ b/analysis/detectors/sts/CbmStsResolution.cxx
@@ -38,28 +38,28 @@ void CbmStsResolution::BookHistograms()
 
     for (auto mod : {":all", ":trk"}) {
       std::string h_name;
-      h_name      = Form("%s_dx_vs_x%s", h_name_base.c_str(), mod);
+      h_name       = Form("%s_dx_vs_x%s", h_name_base.c_str(), mod);
       fH2D[h_name] = std::make_unique<TH2D>(h_name.c_str(), "", nb_bins_r, r_min, r_max, nb_bins_x, x_min, x_max);
       fH2D[h_name]->GetXaxis()->SetTitle(Form("X_{trk} - X_{hit} [cm]"));
       fH2D[h_name]->GetYaxis()->SetTitle("X_{hit} [cm]");
       fH2D[h_name]->GetXaxis()->CenterTitle(true);
       fH2D[h_name]->GetYaxis()->CenterTitle(true);
 
-      h_name      = Form("%s_dx_vs_y%s", h_name_base.c_str(), mod);
+      h_name       = Form("%s_dx_vs_y%s", h_name_base.c_str(), mod);
       fH2D[h_name] = std::make_unique<TH2D>(h_name.c_str(), "", nb_bins_r, r_min, r_max, nb_bins_y, y_min, y_max);
       fH2D[h_name]->GetXaxis()->SetTitle(Form("X_{trk} - X_{hit} [cm]"));
       fH2D[h_name]->GetYaxis()->SetTitle("Y_{hit} [cm]");
       fH2D[h_name]->GetXaxis()->CenterTitle(true);
       fH2D[h_name]->GetYaxis()->CenterTitle(true);
 
-      h_name      = Form("%s_dy_vs_x%s", h_name_base.c_str(), mod);
+      h_name       = Form("%s_dy_vs_x%s", h_name_base.c_str(), mod);
       fH2D[h_name] = std::make_unique<TH2D>(h_name.c_str(), "", nb_bins_r, r_min, r_max, nb_bins_x, x_min, x_max);
       fH2D[h_name]->GetXaxis()->SetTitle(Form("Y_{trk} - Y_{hit} [cm]"));
       fH2D[h_name]->GetYaxis()->SetTitle("X_{hit} [cm]");
       fH2D[h_name]->GetXaxis()->CenterTitle(true);
       fH2D[h_name]->GetYaxis()->CenterTitle(true);
 
-      h_name      = Form("%s_dy_vs_y%s", h_name_base.c_str(), mod);
+      h_name       = Form("%s_dy_vs_y%s", h_name_base.c_str(), mod);
       fH2D[h_name] = std::make_unique<TH2D>(h_name.c_str(), "", nb_bins_r, r_min, r_max, nb_bins_y, y_min, y_max);
       fH2D[h_name]->GetXaxis()->SetTitle(Form("Y_{trk} - Y_{hit} [cm]"));
       fH2D[h_name]->GetYaxis()->SetTitle("Y_{hit} [cm]");
@@ -68,7 +68,7 @@ void CbmStsResolution::BookHistograms()
     }
     if (element < 8) {
       std::string h_name = Form("Sts%d_ref_hits", element);
-      fH2D[h_name]        = std::make_unique<TH2D>(h_name.c_str(), "", nb_bins_x, x_min, x_max, nb_bins_y, y_min, y_max);
+      fH2D[h_name]       = std::make_unique<TH2D>(h_name.c_str(), "", nb_bins_x, x_min, x_max, nb_bins_y, y_min, y_max);
       fH2D[h_name]->GetXaxis()->SetTitle(Form("X_{TrkHit} [cm]"));
       fH2D[h_name]->GetYaxis()->SetTitle("Y_{TrkHit} [cm]");
       fH2D[h_name]->GetXaxis()->CenterTitle(true);
@@ -122,11 +122,9 @@ void CbmStsResolution::BuildResidual()
 
     // Checkk track crossed eneabled sensors
     if (fActiveRefSensors.size()) {
-      if (std::find(fActiveRefSensors.begin(), fActiveRefSensors.end(), hit_i->GetAddress())
-          == fActiveRefSensors.end())
+      if (std::find(fActiveRefSensors.begin(), fActiveRefSensors.end(), hit_i->GetAddress()) == fActiveRefSensors.end())
         continue;
-      if (std::find(fActiveRefSensors.begin(), fActiveRefSensors.end(), hit_j->GetAddress())
-          == fActiveRefSensors.end())
+      if (std::find(fActiveRefSensors.begin(), fActiveRefSensors.end(), hit_j->GetAddress()) == fActiveRefSensors.end())
         continue;
     }
 
diff --git a/analysis/detectors/sts/CbmStsTimeCal.cxx b/analysis/detectors/sts/CbmStsTimeCal.cxx
index e7579c8bde..2df8ae3053 100644
--- a/analysis/detectors/sts/CbmStsTimeCal.cxx
+++ b/analysis/detectors/sts/CbmStsTimeCal.cxx
@@ -41,10 +41,10 @@ CbmStsTimeCal::CbmStsTimeCal(ECbmModuleId ref_sys, double t_min, double t_max)
 
 CbmStsTimeCal::CbmStsTimeCal(int run_id, ECbmModuleId ref_sys, double t_min, double t_max)
 {
-  fRunId          = run_id;
+  fRunId         = run_id;
   fTimeWindowMin = t_min;
   fTimeWindowMax = t_max;
-  fRefSystem = ref_sys;
+  fRefSystem     = ref_sys;
 }
 
 
@@ -70,7 +70,7 @@ InitStatus CbmStsTimeCal::Init()
       }
     }
     fReportOffset = std::make_unique<TFile>(Form("%s/cbm_sts_time_cal_offset.root", fOutputPath.c_str()), "RECREATE");
-    fReportFile = std::make_unique<TFile>(Form("%s/cbm_sts_time_cal_report.root", fOutputPath.c_str()), "RECREATE");
+    fReportFile   = std::make_unique<TFile>(Form("%s/cbm_sts_time_cal_report.root", fOutputPath.c_str()), "RECREATE");
     fReportFit    = std::make_unique<TFile>(Form("%s/cbm_sts_time_cal_fits.root", fOutputPath.c_str()), "RECREATE");
 
     return kSUCCESS;
@@ -82,7 +82,7 @@ void CbmStsTimeCal::InitTimeWalkMap(int32_t address)
 {
   for (unsigned int asic_idx = 0; asic_idx < 16; asic_idx++) {
     fWalkMapRaw[address][asic_idx] = std::vector<double>(32, 0);
-    auto loaded_par           = fWalkMap.Get(address, asic_idx);
+    auto loaded_par                = fWalkMap.Get(address, asic_idx);
     if (loaded_par.size() == 31) {
       for (int adc = 1; adc <= 31; adc++) {
         fWalkMapRaw[address][asic_idx][adc] = loaded_par[adc - 1];
@@ -103,7 +103,7 @@ void CbmStsTimeCal::LoadWalkFromFile()
 
   if (TString(fParFile.c_str()).EndsWith(".yaml") || TString(fParFile.c_str()).EndsWith(".yml")) {
     LOG(info) << Form("Loading time calibration from parameter file: %s", fParFile.c_str());
-    fWalkMap       = cbm::algo::yaml::ReadFromFile<cbm::algo::sts::WalkMap>(fParFile);
+    fWalkMap          = cbm::algo::yaml::ReadFromFile<cbm::algo::sts::WalkMap>(fParFile);
     fGlobalTimeOffset = fWalkMap.GetSystemTimeOffset();
     LOG(info) << "Current system offset: " << fGlobalTimeOffset << " ns";
   }
@@ -133,10 +133,10 @@ void CbmStsTimeCal::BookHistograms(int32_t address)
     fH2D[h_name]->GetYaxis()->SetTitle("Charge_{StsDigi} [ADC]");
   }
 
-  h_name      = Form("0x%x_dt_vs_channel", address);
-  h_title     = smart_name;
+  h_name       = Form("0x%x_dt_vs_channel", address);
+  h_title      = smart_name;
   fH2D[h_name] = std::make_unique<TH2D>(h_name.c_str(), h_title.c_str(), 2048, 0, 2048, nb_time_bins,
-                                       fTimeWindowMin - 0.5 * kStsClock, fTimeWindowMax + 0.5 * kStsClock);
+                                        fTimeWindowMin - 0.5 * kStsClock, fTimeWindowMax + 0.5 * kStsClock);
 
   fH2D[h_name]->GetYaxis()->SetTitle(Form("t_{%s} - t_{StsDigi} [ns]", ToString(fRefSystem).c_str()));
   fH2D[h_name]->GetXaxis()->SetTitle("Channel_{StsDigi}");
@@ -548,7 +548,7 @@ void CbmStsTimeCal::Finish()
   CheckTimeWalk();
 
   // resize ADC offset vector to 31 channels from 0 [0-30`]
-  for (auto& [module, asics] : fWalkMapRaw) {        // Loop over modules
+  for (auto& [module, asics] : fWalkMapRaw) {   // Loop over modules
     for (auto& [asic_idx, asic_par] : asics) {  // Loop over ASICs
       for (int adc = 1; adc <= 31; adc++) {     // loop over ADC channels 31 channels [1 - 31]
         asic_par[adc - 1] = asic_par[adc];
-- 
GitLab