From 307432229d8f5804e3ab18b5528fe8e4d558a475 Mon Sep 17 00:00:00 2001
From: Radoslaw Karabowicz <r.karabowicz@gsi.de>
Date: Wed, 27 Nov 2024 12:19:09 +0100
Subject: [PATCH 01/16] det(must): Add first version of the MUST detector

The commit does not changes anything in the build process of cbmroot.
It only introduces first version of the MUST detector directories
to: 'core/data', 'core/detectors', 'sim/detectors' and 'macro'.
---
 core/data/CMakeLists.txt                 |   2 +
 core/data/CbmDataLinkDef.h               |   2 +
 core/data/must/CbmMustPoint.cxx          |  72 ++++
 core/data/must/CbmMustPoint.h            | 137 ++++++++
 core/detectors/must/CMakeLists.txt       |  44 +++
 core/detectors/must/CbmGeoMust.cxx       |  45 +++
 core/detectors/must/CbmGeoMust.h         |  41 +++
 core/detectors/must/CbmGeoMustPar.cxx    |  70 ++++
 core/detectors/must/CbmGeoMustPar.h      |  53 +++
 core/detectors/must/CbmMustBaseLinkDef.h |  16 +
 core/detectors/must/CbmMustContFact.cxx  |  61 ++++
 core/detectors/must/CbmMustContFact.h    |  35 ++
 core/detectors/must/CbmMustTube.cxx      |  93 ++++++
 core/detectors/must/CbmMustTube.h        |  49 +++
 macro/must/run_sim.C                     | 135 ++++++++
 sim/detectors/must/CMakeLists.txt        |  35 ++
 sim/detectors/must/CbmMust.cxx           | 405 +++++++++++++++++++++++
 sim/detectors/must/CbmMust.h             | 186 +++++++++++
 sim/detectors/must/CbmMustSimLinkDef.h   |  13 +
 19 files changed, 1494 insertions(+)
 create mode 100644 core/data/must/CbmMustPoint.cxx
 create mode 100644 core/data/must/CbmMustPoint.h
 create mode 100644 core/detectors/must/CMakeLists.txt
 create mode 100644 core/detectors/must/CbmGeoMust.cxx
 create mode 100644 core/detectors/must/CbmGeoMust.h
 create mode 100644 core/detectors/must/CbmGeoMustPar.cxx
 create mode 100644 core/detectors/must/CbmGeoMustPar.h
 create mode 100644 core/detectors/must/CbmMustBaseLinkDef.h
 create mode 100644 core/detectors/must/CbmMustContFact.cxx
 create mode 100644 core/detectors/must/CbmMustContFact.h
 create mode 100644 core/detectors/must/CbmMustTube.cxx
 create mode 100644 core/detectors/must/CbmMustTube.h
 create mode 100644 macro/must/run_sim.C
 create mode 100644 sim/detectors/must/CMakeLists.txt
 create mode 100644 sim/detectors/must/CbmMust.cxx
 create mode 100644 sim/detectors/must/CbmMust.h
 create mode 100644 sim/detectors/must/CbmMustSimLinkDef.h

diff --git a/core/data/CMakeLists.txt b/core/data/CMakeLists.txt
index b5b59dd07..bb9bd8567 100644
--- a/core/data/CMakeLists.txt
+++ b/core/data/CMakeLists.txt
@@ -108,6 +108,8 @@ set(SRCS
   fsd/CbmFsdPoint.cxx
   fsd/CbmFsdAddress.cxx
 
+  must/CbmMustPoint.cxx
+
   global/CbmGlobalTrack.cxx
   global/CbmVertex.cxx
   global/CbmTrackParam.cxx
diff --git a/core/data/CbmDataLinkDef.h b/core/data/CbmDataLinkDef.h
index b418995a9..45b359ce4 100644
--- a/core/data/CbmDataLinkDef.h
+++ b/core/data/CbmDataLinkDef.h
@@ -109,6 +109,8 @@
 #pragma link C++ namespace CbmFsdAddress;
 #pragma link C++ enum CbmFsdAddress::Level;
 
+#pragma link C++ class CbmMustPoint + ;
+
 // --- data/global
 #pragma link C++ class CbmGlobalTrack + ;
 #pragma link C++ class CbmVertex + ;
diff --git a/core/data/must/CbmMustPoint.cxx b/core/data/must/CbmMustPoint.cxx
new file mode 100644
index 000000000..23c330423
--- /dev/null
+++ b/core/data/must/CbmMustPoint.cxx
@@ -0,0 +1,72 @@
+/* Copyright (C) 2004-2024 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
+   SPDX-License-Identifier: GPL-3.0-only
+   Authors: Radoslaw Karabowicz */
+
+// -------------------------------------------------------------------------
+// -----                      CbmMustPoint source file                 -----
+// -----                  Created 2024-11-26 by R. Karabowicz          -----
+// -------------------------------------------------------------------------
+
+#include "CbmMustPoint.h"
+
+#include "CbmDefs.h"  // for kMCTrack
+
+#include <FairLink.h>     // for FairLink
+#include <FairMCPoint.h>  // for FairMCPoint
+
+#include <iostream>
+#include "math.h"
+#include "FairLogger.h"
+using std::cout;
+using std::endl;
+
+// -----   Default constructor   -------------------------------------------
+CbmMustPoint::CbmMustPoint()
+  : FairMCPoint(), fX_out_local(0), fY_out_local(0), fZ_out_local(0), fX_in_local(0.), fY_in_local(0), fZ_in_local(0), fPx_out(0), fPy_out(0), fPz_out(0), fPx_in(0), fPy_in(0),
+    fPz_in(0), fMass(0), fTubeID(0), fChamberID(0), fLayerID(0)
+{
+}
+// -------------------------------------------------------------------------
+
+// -----   Standard constructor   ------------------------------------------
+CbmMustPoint::CbmMustPoint(Int_t trackID, Int_t detID, Int_t tubeID, Int_t chamberID, Int_t layerID, TVector3 pos, TVector3 posInLocal, TVector3 posOutLocal, TVector3 momIn,
+                         TVector3 momOut, Double_t tof, Double_t length, Double_t eLoss, Double_t mass)
+  : FairMCPoint(trackID, detID, pos, momIn, tof, length, eLoss), fX_out_local(posOutLocal.X()), fY_out_local(posOutLocal.Y()), fZ_out_local(posOutLocal.Z()),
+    fX_in_local(posInLocal.X()), fY_in_local(posInLocal.Y()), fZ_in_local(posInLocal.Z()), fPx_out(momOut.Px()), fPy_out(momOut.Py()), fPz_out(momOut.Pz()), fPx_in(momIn.Px()),
+    fPy_in(momIn.Py()), fPz_in(momIn.Pz()), fMass(mass), fTubeID(tubeID), fChamberID(chamberID), fLayerID(layerID)
+{
+  // reset MC momentum
+  fPx = (momIn.Px() + momOut.Px()) / 2.;
+  fPy = (momIn.Py() + momOut.Py()) / 2.;
+  fPz = (momIn.Pz() + momOut.Pz()) / 2.;
+  SetLink(FairLink(ToIntegralType(ECbmDataType::kMCTrack), trackID));
+}
+// -------------------------------------------------------------------------
+
+// -----   Destructor   ----------------------------------------------------
+CbmMustPoint::~CbmMustPoint() {}
+// -------------------------------------------------------------------------
+
+// -----   Copy constructor   ------------------------------------------
+CbmMustPoint::CbmMustPoint(const CbmMustPoint &point)
+  : FairMCPoint(point.fTrackID, point.fDetectorID, TVector3(point.fX, point.fY, point.fZ), TVector3(point.fPx, point.fPy, point.fPz), point.fTime, point.fLength, point.fELoss,
+                point.fEventId),
+    fX_out_local(point.fX_out_local), fY_out_local(point.fY_out_local), fZ_out_local(point.fZ_out_local), fX_in_local(point.fX_in_local), fY_in_local(point.fY_in_local),
+    fZ_in_local(point.fZ_in_local), fPx_out(point.fPx_out), fPy_out(point.fPy_out), fPz_out(point.fPz_out), fPx_in(point.fPx_in), fPy_in(point.fPy_in), fPz_in(point.fPz_in),
+    fMass(point.fMass), fTubeID(point.fTubeID), fChamberID(point.fChamberID), fLayerID(point.fLayerID)
+{
+}
+// -------------------------------------------------------------------------
+
+// -----   Public method Print   -------------------------------------------
+void CbmMustPoint::Print(const Option_t *opt) const
+{
+  LOG(info) << " CbmMustPoint: MUST Point for track " << fTrackID << " in detector " << fDetectorID;
+  cout << "    Position (" << fX << ", " << fY << ", " << fZ << ") cm" << endl;
+  cout << "    Momentum (" << fPx << ", " << fPy << ", " << fPz << ") GeV" << endl;
+  cout << "    Time " << fTime << " ns,  Length " << fLength << " cm,  Energy loss " << fELoss * 1.0e06 << " keV"
+       << " opt=" << opt << endl;
+}
+// -------------------------------------------------------------------------
+
+ClassImp(CbmMustPoint)
diff --git a/core/data/must/CbmMustPoint.h b/core/data/must/CbmMustPoint.h
new file mode 100644
index 000000000..9c7d8deee
--- /dev/null
+++ b/core/data/must/CbmMustPoint.h
@@ -0,0 +1,137 @@
+/* Copyright (C) 2004-2024 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
+   SPDX-License-Identifier: GPL-3.0-only
+   Authors: Radoslaw Karabowicz */
+
+// -------------------------------------------------------------------------
+// -----                      CbmMustPoint header file                 -----
+// -----                  Created 2024-11-26 by R. Karabowicz          -----
+// -------------------------------------------------------------------------
+
+#ifndef CBMMUSTPOINT_H
+#define CBMMUSTPOINT_H
+
+#include "TObject.h"
+#include "TVector3.h"
+#include "FairMCPoint.h"
+
+class CbmMustPoint : public FairMCPoint {
+
+ public:
+  /** Default constructor **/
+  CbmMustPoint();
+
+  /** Constructor with arguments
+   *@param trackID       Index of MCTrack
+   *@param detID         Detector ID
+   *tubeID               Number of tube
+   *ChamberID            number of chamber
+   *LayerID
+   *@param pos           Coordinates at wire center of active volume [cm]
+   *@param posInLocal    Local coordinates at entrance to active volume [cm]
+   *@param posOutLocal   Local coordinates at exit of active volume [cm]
+   *@param momIn         Momentum of track at entrance [GeV]
+   *@param momOut        Momentum of track at exit [GeV]
+   *@param tof           Time since event start [ns]
+   *@param length        Track length since creation [cm]
+   *@param eLoss         Energy deposit [GeV]
+   **/
+  CbmMustPoint(Int_t trackID, Int_t detID, Int_t tubeID, Int_t chamberID, Int_t layerID, TVector3 pos, TVector3 posInLocal, TVector3 posOutLocal, TVector3 momIn, TVector3 momOut,
+              Double_t tof, Double_t length, Double_t eLoss, Double_t mass);
+
+  /** Copy constructor **/
+  CbmMustPoint(const CbmMustPoint &point);
+
+  /** Destructor **/
+  virtual ~CbmMustPoint();
+
+  // da cancellare
+  Double_t GetXtot() const { return GetX(); }
+  Double_t GetYtot() const { return GetY(); }
+  Double_t GetZtot() const { return GetZ(); }
+
+  Double_t GetPxOut() const { return fPx_out; }
+  Double_t GetPyOut() const { return fPy_out; }
+  Double_t GetPzOut() const { return fPz_out; }
+
+  //////
+
+  /** Accessors **/
+  Double_t GetXOutLocal() const { return fX_out_local; }
+  Double_t GetYOutLocal() const { return fY_out_local; }
+  Double_t GetZOutLocal() const { return fZ_out_local; }
+  Double_t GetXInLocal() const { return fX_in_local; }
+  Double_t GetYInLocal() const { return fY_in_local; }
+  Double_t GetZInLocal() const { return fZ_in_local; }
+
+  // Double_t GetXWireDirection() const { return fX_wire_dir; }
+  // Double_t GetYWireDirection() const { return fY_wire_dir; }
+  // Double_t GetZWireDirection() const { return fZ_wire_dir; }
+
+  Double_t GetMass() const { return fMass; }
+
+  void PositionOutLocal(TVector3 &pos) { pos.SetXYZ(fX_out_local, fY_out_local, fZ_out_local); }
+  void PositionInLocal(TVector3 &pos) { pos.SetXYZ(fX_in_local, fY_in_local, fZ_in_local); }
+  void MomentumOut(TVector3 &mom) { mom.SetXYZ(fPx_out, fPy_out, fPz_out); }
+  // void WireDirection(TVector3& wire) { wire.SetXYZ(fX_wire_dir, fY_wire_dir, fZ_wire_dir); }
+
+  /** Modifiers **/
+  void SetPositionOutLocal(TVector3 pos);
+  void SetPositionInLocal(TVector3 pos);
+  void SetMomentumOut(TVector3 mom);
+  // void SetWireDirection(TVector3 wire);
+
+  // tube ID // CHECK added
+  void SetTubeID(Int_t tubeid) { fTubeID = tubeid; }
+  Int_t GetTubeID() { return fTubeID; }
+  void SetChamberID(Int_t chamberid) { fChamberID = chamberid; }
+  void SetLayerID(Int_t layerid) { fLayerID = layerid; }
+  Int_t GetChamberID() { return fChamberID; }
+  Int_t GetLayerID() { return fLayerID; }
+
+  /** Output to screen **/
+  virtual void Print(const Option_t *opt) const;
+
+ protected:
+  // exit coordinates in straw frame
+  Double_t fX_out_local, fY_out_local, fZ_out_local;
+  // entry coordinates in straw frame
+  Double_t fX_in_local, fY_in_local, fZ_in_local;
+
+  Double_t fPx_out, fPy_out, fPz_out;
+  Double_t fPx_in, fPy_in, fPz_in;
+  // wire direction
+  // Double_t fX_wire_dir, fY_wire_dir, fZ_wire_dir;
+
+  // particle mass
+  Double_t fMass;
+  Int_t fTubeID;
+  Int_t fChamberID;
+  Int_t fLayerID;
+
+  //////
+
+  ClassDef(CbmMustPoint, 1)
+};
+
+inline void CbmMustPoint::SetPositionOutLocal(TVector3 pos)
+{
+  fX_out_local = pos.X();
+  fY_out_local = pos.Y();
+  fZ_out_local = pos.Z();
+}
+
+inline void CbmMustPoint::SetPositionInLocal(TVector3 pos)
+{
+  fX_in_local = pos.X();
+  fY_in_local = pos.Y();
+  fZ_in_local = pos.Z();
+}
+
+inline void CbmMustPoint::SetMomentumOut(TVector3 mom)
+{
+  fPx_out = mom.Px();
+  fPy_out = mom.Py();
+  fPz_out = mom.Pz();
+}
+
+#endif
diff --git a/core/detectors/must/CMakeLists.txt b/core/detectors/must/CMakeLists.txt
new file mode 100644
index 000000000..5aab621de
--- /dev/null
+++ b/core/detectors/must/CMakeLists.txt
@@ -0,0 +1,44 @@
+set(INCLUDE_DIRECTORIES
+  ${CMAKE_CURRENT_SOURCE_DIR}
+  )
+
+
+set(SRCS
+  CbmGeoMust.cxx
+  CbmGeoMustPar.cxx
+  CbmMustContFact.cxx
+  CbmMustTube.cxx
+)
+
+
+# ---- Enable OpenMP  -------------------------------------
+find_package(OpenMP)
+if (OPENMP_FOUND)
+  set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
+  set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
+endif()
+# ---------------------------------------------------------
+
+set(LIBRARY_NAME CbmMustBase)
+set(LINKDEF ${LIBRARY_NAME}LinkDef.h)
+set(PUBLIC_DEPENDENCIES
+  FairRoot::Base
+  FairRoot::ParBase
+  CbmBase
+  ROOT::Core
+  ROOT::Geom
+  ROOT::Gpad
+  ROOT::Hist
+  ROOT::MathCore
+  ROOT::Physics
+  )
+
+set(PRIVATE_DEPENDENCIES
+  FairLogger::FairLogger
+  CbmData
+  ROOT::Graf
+  ROOT::MLP
+  ROOT::Tree
+  )
+
+generate_cbm_library()
diff --git a/core/detectors/must/CbmGeoMust.cxx b/core/detectors/must/CbmGeoMust.cxx
new file mode 100644
index 000000000..68f7f7465
--- /dev/null
+++ b/core/detectors/must/CbmGeoMust.cxx
@@ -0,0 +1,45 @@
+/* Copyright (C) 2004-2024 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
+   SPDX-License-Identifier: GPL-3.0-only
+   Authors: Radoslaw Karabowicz */
+
+////////////////////////////////////////////////////////////////////////////
+// CbmGeoMust source file
+//
+// Class for geometry of MUST
+//
+// authors: Radoslaw Karabowicz, GSI, 2024
+//
+// modified from CbmGeoFts by Nafija Ibrišimović in 2023
+////////////////////////////////////////////////////////////////////////////
+
+#include "CbmGeoMust.h"
+// from FairRoot
+#include <FairGeoNode.h>
+// from fmt
+#include <fmt/core.h>
+
+ClassImp(CbmGeoMust)
+
+  CbmGeoMust::CbmGeoMust()
+{
+  // Constructor
+  fName = "must";
+  maxSectors = 0;
+  maxModules = 40;
+}
+
+const char *CbmGeoMust::getModuleName(Int_t m)
+{
+  // Returns the module name of MUST number m
+  modName = fmt::format("must{:02d}", m + 1);
+
+  return modName.c_str();
+}
+
+const char *CbmGeoMust::getEleName(Int_t m)
+{
+  // Returns the element name of MUST number m
+  eleName = fmt::format("must{:02d}", m + 1);
+
+  return eleName.c_str();
+}
diff --git a/core/detectors/must/CbmGeoMust.h b/core/detectors/must/CbmGeoMust.h
new file mode 100644
index 000000000..95dadf489
--- /dev/null
+++ b/core/detectors/must/CbmGeoMust.h
@@ -0,0 +1,41 @@
+/* Copyright (C) 2004-2024 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
+   SPDX-License-Identifier: GPL-3.0-only
+   Authors: Radoslaw Karabowicz */
+
+////////////////////////////////////////////////////////////////////////////
+// CbmGeoMust header file
+//
+// Class for geometry of MUST
+//
+// authors: Radoslaw Karabowicz, GSI, 2024
+//
+// modified from CbmGeoFts by Nafija Ibrišimović in 2023
+////////////////////////////////////////////////////////////////////////////
+
+#ifndef CBMGEOMUST_H
+#define CBMGEOMUST_H
+
+// from FairRoot
+#include <FairGeoSet.h>
+
+class CbmGeoMust : public FairGeoSet {
+ protected:
+  std::string modName; // name of module
+  std::string eleName; // substring for elements in module
+ public:
+  CbmGeoMust();
+  ~CbmGeoMust() {}
+  const char *getModuleName(Int_t);
+  const char *getEleName(Int_t);
+  inline Int_t getModNumInMod(const TString &);
+  ClassDef(CbmGeoMust, 0) // Class for Must
+};
+
+inline Int_t CbmGeoMust::getModNumInMod(const TString &name)
+{
+  // returns the module index from module name
+
+  return (Int_t)(name[2] - '0') - 1;
+}
+
+#endif /* !CBMGEOMUST_H */
diff --git a/core/detectors/must/CbmGeoMustPar.cxx b/core/detectors/must/CbmGeoMustPar.cxx
new file mode 100644
index 000000000..1d88b58f3
--- /dev/null
+++ b/core/detectors/must/CbmGeoMustPar.cxx
@@ -0,0 +1,70 @@
+/* Copyright (C) 2004-2024 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
+   SPDX-License-Identifier: GPL-3.0-only
+   Authors: Radoslaw Karabowicz */
+
+////////////////////////////////////////////////////////////////////////////
+// CbmGeoMustPar source file
+//
+// Class for geometry parameters of MUST
+//
+// authors: Radoslaw Karabowicz, GSI, 2024
+//
+// modified from CbmGeoFtsPar by Nafija Ibrišimović in 2023
+////////////////////////////////////////////////////////////////////////////
+
+#include "CbmGeoMustPar.h"
+// from FairRoot
+#include <FairParamList.h>
+// standard
+#include <iostream>
+#include <iomanip>
+
+ClassImp(CbmGeoMustPar)
+
+  CbmGeoMustPar::CbmGeoMustPar(const char *name, const char *title, const char *context)
+  : FairParGenericSet(name, title, context), fGeoSensNodes(new TObjArray()), fGeoPassNodes(new TObjArray()), fGeoType(-1), fTubeInRad(0), fTubeOutRad(0)
+{
+}
+
+CbmGeoMustPar::~CbmGeoMustPar(void) {}
+
+void CbmGeoMustPar::clear(void)
+{
+  if (fGeoSensNodes) {
+    fGeoSensNodes->Delete();
+    delete fGeoSensNodes;
+  }
+  if (fGeoPassNodes) {
+    fGeoPassNodes->Delete();
+    delete fGeoPassNodes;
+  }
+}
+
+void CbmGeoMustPar::putParams(FairParamList *l)
+{
+  if (!l)
+    return;
+  l->addObject("FairGeoNodes Sensitive List", fGeoSensNodes);
+  l->addObject("FairGeoNodes Passive List", fGeoPassNodes);
+  l->add("Tube Innen Radius", fTubeInRad);
+  l->add("Tube Outer Radius", fTubeOutRad);
+  l->add("Geometry Type", fGeoType);
+}
+
+Bool_t CbmGeoMustPar::getParams(FairParamList *l)
+{
+  if (!l)
+    return kFALSE;
+  if (!l->fillObject("FairGeoNodes Sensitive List", fGeoSensNodes))
+    return kFALSE;
+  if (!l->fillObject("FairGeoNodes Passive List", fGeoPassNodes))
+    return kFALSE;
+  if (!l->fill("Tube Innen Radius", &fTubeInRad))
+    return kFALSE;
+  if (!l->fill("Tube Outer Radius", &fTubeOutRad))
+    return kFALSE;
+  if (!l->fill("Geometry Type", &fGeoType))
+    return kFALSE;
+
+  return kTRUE;
+}
diff --git a/core/detectors/must/CbmGeoMustPar.h b/core/detectors/must/CbmGeoMustPar.h
new file mode 100644
index 000000000..107b3b331
--- /dev/null
+++ b/core/detectors/must/CbmGeoMustPar.h
@@ -0,0 +1,53 @@
+/* Copyright (C) 2004-2024 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
+   SPDX-License-Identifier: GPL-3.0-only
+   Authors: Radoslaw Karabowicz */
+
+////////////////////////////////////////////////////////////////////////////
+// CbmGeoMustPar header file
+//
+// Class for geometry parameters of MUST
+//
+// authors: Radoslaw Karabowicz, GSI, 2024
+//
+// modified from CbmGeoFtsPar by Nafija Ibrišimović in 2023
+////////////////////////////////////////////////////////////////////////////
+
+#ifndef CBMGEOMUSTPAR_H
+#define CBMGEOMUSTPAR_H
+// from FairRoot
+#include <FairParGenericSet.h>
+// from ROOT
+#include <TH1F.h>
+#include <TObjArray.h>
+
+class CbmGeoMustPar : public FairParGenericSet {
+ private:
+  TObjArray *fGeoSensNodes;         /** List of FairGeoNodes for sensitive volumes*/
+  TObjArray *fGeoPassNodes;         /** List of FairGeoNodes for sensitive volumes*/
+  Int_t fGeoType;                   // modif
+  Double_t fTubeInRad, fTubeOutRad; // modif
+
+  CbmGeoMustPar(const CbmGeoMustPar &L);
+  CbmGeoMustPar &operator=(const CbmGeoMustPar &) { return *this; }
+
+ public:
+  CbmGeoMustPar(const char *name = "CbmGeoMustPar", const char *title = "Must Geometry Parameters", const char *context = "TestDefaultContext");
+  ~CbmGeoMustPar(void);
+  void clear(void);
+  void putParams(FairParamList *);
+  Bool_t getParams(FairParamList *);
+  TObjArray *GetGeoSensitiveNodes() { return fGeoSensNodes; }
+  TObjArray *GetGeoPassiveNodes() { return fGeoPassNodes; }
+
+  // Additional function
+  void SetGeometryType(Int_t geoType) { fGeoType = geoType; }
+  void SetTubeInRad(Double_t inrad) { fTubeInRad = inrad; }
+  void SetTubeOutRad(Double_t outrad) { fTubeOutRad = outrad; }
+  Int_t GetGeometryType() { return (Int_t)fGeoType; };
+  Double_t GetTubeInRad() { return (Double_t)fTubeInRad; };
+  Double_t GetTubeOutRad() { return (Double_t)fTubeOutRad; };
+
+  ClassDef(CbmGeoMustPar, 1)
+};
+
+#endif /* !CBMGEOMUSTPAR_H */
diff --git a/core/detectors/must/CbmMustBaseLinkDef.h b/core/detectors/must/CbmMustBaseLinkDef.h
new file mode 100644
index 000000000..46e589816
--- /dev/null
+++ b/core/detectors/must/CbmMustBaseLinkDef.h
@@ -0,0 +1,16 @@
+/* Copyright (C) 2020-2021 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
+   SPDX-License-Identifier: GPL-3.0-only
+   Authors: Volker Friese [committer] */
+
+#ifdef __CINT__
+
+#pragma link off all globals;
+#pragma link off all classes;
+#pragma link off all functions;
+
+#pragma link C++ class CbmGeoMust + ;
+#pragma link C++ class CbmGeoMustPar + ;
+#pragma link C++ class CbmMustContFact + ;
+#pragma link C++ class CbmMustTube + ;
+
+#endif /* __CINT__ */
diff --git a/core/detectors/must/CbmMustContFact.cxx b/core/detectors/must/CbmMustContFact.cxx
new file mode 100644
index 000000000..f4e8483a3
--- /dev/null
+++ b/core/detectors/must/CbmMustContFact.cxx
@@ -0,0 +1,61 @@
+/* Copyright (C) 2004-2024 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
+   SPDX-License-Identifier: GPL-3.0-only
+   Authors: Radoslaw Karabowicz */
+
+////////////////////////////////////////////////////////////////////////////
+// CbmMustContFact source file
+//
+// Factory for the parameter containers in libMust
+//
+// authors: Radoslaw Karabowicz, GSI, 2024
+//
+// modified from CbmMustContFact by Nafija Ibrišimović in 2023
+////////////////////////////////////////////////////////////////////////////
+
+#include "CbmMustContFact.h"
+// from CbnRoot, this library
+#include "CbmGeoMustPar.h"
+// from FairRoot
+#include <FairRuntimeDb.h>
+#include <FairParRootFileIo.h>
+#include <FairParAsciiFileIo.h>
+// standard
+#include <iostream>
+#include <iomanip>
+
+ClassImp(CbmMustContFact)
+
+  static CbmMustContFact gCbmMustContFact;
+
+CbmMustContFact::CbmMustContFact()
+{
+  // Constructor (called when the library is loaded)
+  fName = "CbmMustContFact";
+  fTitle = "Factory for parameter containers in libMust";
+  setAllContainers();
+  FairRuntimeDb::instance()->addContFactory(this);
+}
+
+void CbmMustContFact::setAllContainers()
+{
+  /** Creates the Container objects with all accepted contexts and adds them to
+   *  the list of containers for the MUST library.*/
+  FairContainer *p1 = new FairContainer("CbmGeoMustPar", "Must Geometry Parameters", "TestDefaultContext");
+  p1->addContext("TestNonDefaultContext");
+  containers->Add(p1);
+}
+
+FairParSet *CbmMustContFact::createContainer(FairContainer *c)
+{
+  /** Calls the constructor of the corresponding parameter container.
+   * For an actual context, which is not an empty string and not the default context
+   * of this container, the name is concatinated with the context. */
+  const char *name = c->GetName();
+  std::cout << "[MUST] CbmMustContFact createContainer name " << name << std::endl;
+  FairParSet *p = 0;
+
+  if (strcmp(name, "CbmGeoMustPar") == 0) {
+    p = new CbmGeoMustPar(c->getConcatName().Data(), c->GetTitle(), c->getContext());
+  }
+  return p;
+}
diff --git a/core/detectors/must/CbmMustContFact.h b/core/detectors/must/CbmMustContFact.h
new file mode 100644
index 000000000..61e9a5edd
--- /dev/null
+++ b/core/detectors/must/CbmMustContFact.h
@@ -0,0 +1,35 @@
+/* Copyright (C) 2004-2024 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
+   SPDX-License-Identifier: GPL-3.0-only
+   Authors: Radoslaw Karabowicz */
+
+////////////////////////////////////////////////////////////////////////////
+// CbmMustContFact header file
+//
+// Factory for the parameter containers in libMust
+//
+// authors: Radoslaw Karabowicz, GSI, 2024
+//
+// modified from CbmMustContFact by Nafija Ibrišimović in 2023
+////////////////////////////////////////////////////////////////////////////
+
+#ifndef CBMMUSTCONTFACT_H
+#define CBMMUSTCONTFACT_H
+
+// from FairRoot
+#include <FairContFact.h>
+
+class FairContainer;
+
+class CbmMustContFact : public FairContFact {
+ private:
+  void setAllContainers();
+
+ public:
+  CbmMustContFact();
+  ~CbmMustContFact() {}
+  FairParSet *createContainer(FairContainer *);
+  //  void  activateParIo(FairParIo* io);
+  ClassDef(CbmMustContFact, 0) // Factory for all MUST parameter containers
+};
+
+#endif /* !CBMMUSTCONTFACT_H */
diff --git a/core/detectors/must/CbmMustTube.cxx b/core/detectors/must/CbmMustTube.cxx
new file mode 100644
index 000000000..876245ff3
--- /dev/null
+++ b/core/detectors/must/CbmMustTube.cxx
@@ -0,0 +1,93 @@
+/* Copyright (C) 2004-2024 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
+   SPDX-License-Identifier: GPL-3.0-only
+   Authors: Radoslaw Karabowicz */
+
+////////////////////////////////////////////////////////////////////////////
+// CbmMustTube header file
+//
+// Copied from PndFtsTube
+//
+// authors: Radoslaw Karabowicz, GSI, 2024
+////////////////////////////////////////////////////////////////////////////
+
+#include "CbmMustTube.h"
+// standard
+#include <iostream>
+
+CbmMustTube::CbmMustTube() : fCenPosition(TVector3(0, 0, 0)), fRotationMatrix(TMatrixT<double>(3, 3)), fRadIn(0), fRadOut(0), fHalfLength(0)
+{
+  fRotationMatrix[0][0] = -1.;
+  fRotationMatrix[0][1] = -1.;
+  fRotationMatrix[0][2] = -1.;
+
+  fRotationMatrix[1][0] = -1.;
+  fRotationMatrix[1][1] = -1.;
+  fRotationMatrix[1][2] = -1.;
+
+  fRotationMatrix[2][0] = -1.;
+  fRotationMatrix[2][1] = -1.;
+  fRotationMatrix[2][2] = -1.;
+}
+
+CbmMustTube::CbmMustTube(CbmMustTube &tube)
+  : TObject(tube), fCenPosition(tube.GetPosition()), fRotationMatrix(TMatrixT<double>(3, 3)), fRadIn(tube.GetRadIn()), fRadOut(tube.GetRadOut()), fHalfLength(tube.GetHalfLength())
+{
+  fRotationMatrix.ResizeTo(3, 3);
+  fRotationMatrix = tube.GetRotationMatrix();
+}
+
+CbmMustTube::CbmMustTube(Double_t x, Double_t y, Double_t z, Double_t r11, Double_t r12, Double_t r13, Double_t r21, Double_t r22, Double_t r23, Double_t r31, Double_t r32,
+                     Double_t r33, Double_t radin, Double_t radout, Double_t hl)
+  : fCenPosition(TVector3(x, y, z)), fRotationMatrix(TMatrixT<double>(3, 3)), fRadIn(radin), fRadOut(radout), fHalfLength(hl)
+{
+
+  fRotationMatrix[0][0] = r11;
+  fRotationMatrix[0][1] = r12;
+  fRotationMatrix[0][2] = r13;
+
+  fRotationMatrix[1][0] = r21;
+  fRotationMatrix[1][1] = r22;
+  fRotationMatrix[1][2] = r23;
+
+  fRotationMatrix[2][0] = r31;
+  fRotationMatrix[2][1] = r32;
+  fRotationMatrix[2][2] = r33;
+}
+
+CbmMustTube::~CbmMustTube()
+{
+  //  fCenPosition.Delete();
+  //  fRotationMatrix.Delete();
+}
+
+TVector3 CbmMustTube::GetPosition() const
+{
+  return fCenPosition;
+}
+
+TMatrixT<Double_t> CbmMustTube::GetRotationMatrix() const
+{
+  return fRotationMatrix;
+}
+
+Double_t CbmMustTube::GetRadIn() const
+{
+  return fRadIn;
+}
+
+Double_t CbmMustTube::GetRadOut() const
+{
+  return fRadOut;
+}
+
+Double_t CbmMustTube::GetHalfLength() const
+{
+  return fHalfLength;
+}
+
+TVector3 CbmMustTube::GetWireDirection() const
+{
+  return TVector3(fRotationMatrix[0][2], fRotationMatrix[1][2], fRotationMatrix[2][2]);
+}
+
+ClassImp(CbmMustTube)
diff --git a/core/detectors/must/CbmMustTube.h b/core/detectors/must/CbmMustTube.h
new file mode 100644
index 000000000..224547f5f
--- /dev/null
+++ b/core/detectors/must/CbmMustTube.h
@@ -0,0 +1,49 @@
+/* Copyright (C) 2004-2024 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
+   SPDX-License-Identifier: GPL-3.0-only
+   Authors: Radoslaw Karabowicz */
+
+////////////////////////////////////////////////////////////////////////////
+// CbmMustTube header file
+//
+// Copied from PndFtsTube
+//
+// authors: Radoslaw Karabowicz, GSI, 2024
+////////////////////////////////////////////////////////////////////////////
+
+#ifndef CBMMUSTTUBE_H
+#define CBMMUSTTUBE_H 1
+
+// from ROOT
+#include "TVector3.h"
+#include "TMatrixT.h"
+#include "TObject.h"
+
+class CbmMustTube : public TObject {
+
+ public:
+  /** Default constructor **/
+  CbmMustTube();
+  CbmMustTube(CbmMustTube &tube);
+
+  ~CbmMustTube();
+  CbmMustTube(Double_t x, Double_t y, Double_t z, Double_t r11, Double_t r12, Double_t r13, Double_t r21, Double_t r22, Double_t r23, Double_t r31, Double_t r32, Double_t r33,
+            Double_t radin, Double_t radout, Double_t hl);
+
+  TVector3 GetPosition() const;
+  TMatrixT<Double_t> GetRotationMatrix() const;
+  Double_t GetRadIn() const;
+  Double_t GetRadOut() const;
+  Double_t GetHalfLength() const;
+  TVector3 GetWireDirection() const;
+
+  bool IsSkew() const { return (0. != GetWireDirection().X()); }
+
+ private:
+  TVector3 fCenPosition;
+  TMatrixT<double> fRotationMatrix;
+  Double_t fRadIn, fRadOut, fHalfLength;
+
+  ClassDef(CbmMustTube, 1);
+};
+
+#endif
diff --git a/macro/must/run_sim.C b/macro/must/run_sim.C
new file mode 100644
index 000000000..23fc129f8
--- /dev/null
+++ b/macro/must/run_sim.C
@@ -0,0 +1,135 @@
+/* Copyright (C) 2004-2024 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
+   SPDX-License-Identifier: GPL-3.0-only
+   Authors: Radoslaw Karabowicz */
+
+int run_sim(Int_t nEvents = 10000, Int_t pid = 13, Float_t p1 = 10.0, Float_t p2 = 10.0)
+{
+  // 2212 proton
+  TStopwatch timer;
+  timer.Start();
+  gDebug = 0;
+
+  TString dir = getenv("VMCWORKDIR");
+
+  TString tut_configdir = dir + "/sim/transport/gconfig/";
+  gSystem->Setenv("CONFIG_DIR", tut_configdir.Data());
+
+  FairRunSim *fRun = new FairRunSim();
+
+  // set the MC version used
+  fRun->SetName("TGeant4");
+
+  // Cave geometry
+  TString caveGeom = "cave.geo";
+  // Target geometry
+  TString targetGeom = "tpassive/targetbox_v22c.gdml";
+  // Beam pipe geometry
+  TString pipeGeom = "pipe/pipe_v22d.geo.root";
+  // Magnet geometry and field map
+  TString magnetGeom  = "magnet/magnet_v22b.geo.root";
+  TString fieldMap    = "field_v22d";
+  Double_t fieldZ     = 50.;  // z position of field centre
+  Double_t fieldScale = 1.;   // field scaling factor
+
+  std::string outFile = "points.root";
+  std::string parFile = "params.root";
+
+  fRun->SetSink(new FairRootFileSink(outFile));
+
+  // Fill the Parameter containers for this run
+  //-------------------------------------------
+
+  FairRuntimeDb *rtdb = fRun->GetRuntimeDb();
+  Bool_t kParameterMerged = kTRUE;
+  FairParRootFileIo *output = new FairParRootFileIo(kParameterMerged);
+  output->open(parFile.c_str());
+  rtdb->setOutput(output);
+
+  // Set Material file Name
+  fRun->SetMaterials("media.geo");
+
+
+  // -----   Create geometry   ----------------------------------------------
+  FairModule* cave = new CbmCave("CAVE");
+  cave->SetGeometryFileName(caveGeom);
+  fRun->AddModule(cave);
+
+  FairModule* pipe = new CbmPipe("PIPE");
+  pipe->SetGeometryFileName(pipeGeom);
+  fRun->AddModule(pipe);
+
+  //  FairModule* target = new CbmTarget("Target");
+  //  target->SetGeometryFileName(targetGeom);
+  //  fRun->AddModule(target);
+
+  FairModule* magnet = new CbmMagnet("MAGNET");
+  magnet->SetGeometryFileName(magnetGeom);
+  fRun->AddModule(magnet);
+  
+  FairDetector *must = new CbmMust("MUST", kTRUE);
+  must->SetGeometryFileName("must/must.geo");
+  fRun->AddModule(must);
+
+  // Create and Set Event Generator
+  //-------------------------------
+
+  FairPrimaryGenerator *primGen = new FairPrimaryGenerator();
+  fRun->SetGenerator(primGen);
+
+  // Box Generator
+  FairBoxGenerator *boxGen = new FairBoxGenerator(pid, 100); // 13=muon; 2212=proton 1 = multipl.
+  if (p2 < 0.)
+    p2 = p1;
+  boxGen->SetPRange(p1, p1);    // GeV/c //setPRange vs setPtRange
+  boxGen->SetPhiRange(45, 45);  // Azimuth angle range [degree]
+  boxGen->SetThetaRange(20, 20); // Polar angle in lab system range [degree]
+  boxGen->SetCosTheta();
+  boxGen->SetXYZ(0., 0., 0.);
+  primGen->AddGenerator(boxGen);
+
+  fRun->SetStoreTraj(kTRUE);
+  fRun->SetBeamMom(15.);
+
+  // -----   Create magnetic field   ----------------------------------------
+  CbmFieldMap* magField = new CbmFieldMapSym3(fieldMap);
+  magField->SetPosition(0., 0., fieldZ);
+  magField->SetScale(fieldScale);
+  fRun->SetField(magField);
+  
+  fRun->Init();
+
+  // Transport nEvents
+  // -----------------
+  fRun->Run(nEvents);
+
+  rtdb->saveOutput();
+  rtdb->print();
+
+  timer.Stop();
+  Double_t rtime = timer.RealTime();
+  Double_t ctime = timer.CpuTime();
+  printf("RealTime=%f seconds, CpuTime=%f seconds\n", rtime, ctime);
+
+  TChain chain("cbmsim");
+  chain.Add(outFile.c_str());
+  auto nofE = chain.GetEntries();
+  auto nofT = chain.Draw("MCTrack.fPx", "", "goff");
+  auto nofP = chain.Draw("MUSTPoint.fPx", "", "goff");
+  cout << "Output chain has " << nofE << " events, " << nofT << " tracks, " << nofP << " points." << endl;
+
+  if (nofE < nEvents) {
+    std::cerr << "Not enough events (" << nofE << " < " << nEvents << ") in the output chain." << endl;
+    return 1;
+  }
+  if (nofT < nEvents) {
+    std::cerr << "Not enough tracks (" << nofT << " < " << nEvents << ") in the output chain." << endl;
+    return 1;
+  }
+  if (nofP < nEvents * 10) {
+    std::cerr << "Not enough points (" << nofP << " < " << nEvents * 10 << ") in the output chain." << endl;
+    return 1;
+  }
+  cout << "Simulation successful." << endl;
+
+  return 0;
+}
diff --git a/sim/detectors/must/CMakeLists.txt b/sim/detectors/must/CMakeLists.txt
new file mode 100644
index 000000000..41bb26c30
--- /dev/null
+++ b/sim/detectors/must/CMakeLists.txt
@@ -0,0 +1,35 @@
+set(INCLUDE_DIRECTORIES
+  ${CMAKE_CURRENT_SOURCE_DIR}
+  )
+
+
+set(SRCS
+  CbmMust.cxx
+  )
+
+
+set(LIBRARY_NAME CbmMustSim)
+set(LINKDEF ${LIBRARY_NAME}LinkDef.h)
+set(PUBLIC_DEPENDENCIES
+  CbmBase
+  CbmData
+  CbmMustBase
+  FairRoot::Base
+  ROOT::Core
+  ROOT::Hist
+  ROOT::MathCore
+  )
+
+set(PRIVATE_DEPENDENCIES
+  CbmSimBase
+  FairRoot::ParBase
+  ROOT::EG
+  ROOT::Geom
+  ROOT::Gpad
+  ROOT::Physics
+  ROOT::RIO
+  )
+
+generate_cbm_library()
+
+
diff --git a/sim/detectors/must/CbmMust.cxx b/sim/detectors/must/CbmMust.cxx
new file mode 100644
index 000000000..9722a8096
--- /dev/null
+++ b/sim/detectors/must/CbmMust.cxx
@@ -0,0 +1,405 @@
+/* Copyright (C) 2004-2024 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
+   SPDX-License-Identifier: GPL-3.0-only
+   Authors: Radoslaw Karabowicz */
+
+////////////////////////////////////////////////////////////////////////////
+// CbmMust source file
+//
+// Class for simulation of MUST
+//
+// authors: Radoslaw Karabowicz, GSI, 2024
+//
+// modified from CbmMust by Nafija Ibrišimović in 2023
+////////////////////////////////////////////////////////////////////////////
+
+#include "CbmMust.h"
+// from CbmRoot, this library
+#include "CbmGeoMustPar.h"
+#include "CbmGeoMust.h"
+#include "CbmDefs.h"
+#include "CbmStack.h"
+#include "CbmMustMapCreator.h"
+// from FairRoot
+#include <FairRun.h>
+#include <FairGeoInterface.h>
+#include <FairGeoLoader.h>
+#include <FairGeoNode.h>
+#include <FairGeoRootBuilder.h>
+#include <FairRootManager.h>
+#include <FairRuntimeDb.h>
+#include <FairVolume.h>
+#include <FairLogger.h>
+// from ROOT
+#include <TClonesArray.h>
+#include <TLorentzVector.h>
+#include <TParticle.h>
+#include <TVirtualMC.h>
+#include <TGeoMatrix.h>
+#include <TObjArray.h>
+#include <TGeoTube.h>
+#include <TGeoMedium.h>
+#include <TGeoVolume.h>
+// standard
+#include <iostream>
+
+using std::string;
+
+// TODO: read this from geant initialization
+#define innerStrawDiameter 1.
+// #define redefineLambdaChargedDecay 0
+
+// -----   Default constructor   -------------------------------------------
+CbmMust::CbmMust()
+  : fTrackID(0), fVolumeID(0), fPos(0, 0, 0, 0), fPosIn(0, 0, 0, 0), fPosOut(0, 0, 0, 0), fPosInLocal(0, 0, 0, 0), fPosOutLocal(0, 0, 0, 0), fMomIn(0, 0, 0, 0),
+    fMomOut(0, 0, 0, 0), fTime(0), fLength(0), fELoss(0), fMass(0), fIsInitialized(kFALSE), fPosIndex(0), fMustCollection(nullptr), fpostot(0, 0, 0, 0), fpostotin(0, 0, 0, 0),
+    fpostotout(0, 0, 0, 0), fPassNodes(), valid(kFALSE), fGeoType(0)
+{
+  fMustCollection = new TClonesArray("CbmMustPoint");
+  fVerboseLevel = 0;
+}
+// -------------------------------------------------------------------------
+
+// -----   Standard constructor   ------------------------------------------
+CbmMust::CbmMust(const char *name, Bool_t active)
+  : FairDetector(name, active), fTrackID(0), fVolumeID(0), fPos(0, 0, 0, 0), fPosIn(0, 0, 0, 0), fPosOut(0, 0, 0, 0), fPosInLocal(0, 0, 0, 0), fPosOutLocal(0, 0, 0, 0),
+    fMomIn(0, 0, 0, 0), fMomOut(0, 0, 0, 0), fTime(0), fLength(0), fELoss(0), fMass(0), fIsInitialized(kFALSE), fPosIndex(0), fMustCollection(nullptr), fpostot(0, 0, 0, 0),
+    fpostotin(0, 0, 0, 0), fpostotout(0, 0, 0, 0), fPassNodes(), valid(kFALSE), fGeoType(0)
+{
+  fMustCollection = new TClonesArray("CbmMustPoint");
+  fVerboseLevel = 0;
+  fGeoType = 1; // CHECK
+}
+// -------------------------------------------------------------------------
+
+// -----   Destructor   ----------------------------------------------------
+CbmMust::~CbmMust()
+{
+  if (fMustCollection) {
+    fMustCollection->Delete();
+    delete fMustCollection;
+  }
+}
+// -------------------------------------------------------------------------
+
+// -----   Private method GetSquaredDistanceFromWire -----------------------
+float CbmMust::GetSquaredDistanceFromWire()
+{
+  TLorentzVector entryPosition;
+
+  float positionInMother[3], positionInStraw[3];
+
+  gMC->TrackPosition(entryPosition);
+  positionInMother[0] = entryPosition.X();
+  positionInMother[1] = entryPosition.Y();
+  positionInMother[2] = entryPosition.Z();
+  gMC->Gmtod(positionInMother, positionInStraw, 1);
+
+  return positionInStraw[0] * positionInStraw[0] + positionInStraw[1] * positionInStraw[1];
+}
+// -------------------------------------------------------------------------
+
+bool CbmMust::Split(string &aDest, string &aSrc, char aDelim)
+{
+  if (aSrc.empty())
+    return false;
+
+  string::size_type pos = aSrc.find(aDelim);
+
+  aDest = aSrc.substr(0, pos);
+
+  if (pos != string::npos)
+    aSrc = aSrc.substr(pos + 1);
+  else
+    aSrc = "";
+
+  return true;
+}
+
+string CbmMust::GetStringPart(string &aSrc, Int_t part, char aDelim)
+{
+  string retval = "", sub;
+
+  int counter = 0;
+
+  while (Split(sub, aSrc, aDelim)) {
+    if (counter == part) {
+      retval = sub;
+      break;
+    }
+    counter++;
+  }
+
+  return retval;
+}
+
+// -----   Public method ProcessHits  --------------------------------------
+Bool_t CbmMust::ProcessHits(FairVolume *vol)
+{
+
+  // TParticle* particle =  gMC->GetStack()->GetCurrentTrack(); //[R.K. 01/2017] unused variable?
+  // TGeoMedium *medium = (TGeoMedium*) vol->getGeoNode()->getRootVolume()->GetMedium(); //[R.K. 01/2017] unused variable?
+  // Double_t epsil = medium->GetParam(6); //[R.K. 01/2017] unused variable?
+
+  TString vol_name(gMC->CurrentVolName());
+  TGeoHMatrix M;
+  gMC->GetTransformation(gMC->CurrentVolPath(), M);
+  TString name(gMC->CurrentVolName());
+
+  if (gMC->TrackCharge() != 0.) {
+
+    if (gMC->IsTrackEntering()) {
+      valid = kTRUE;
+
+      // Set parameters at entrance of volume. Reset ELoss.
+      fELoss = 0.;
+      fTime = gMC->TrackTime() * 1.0e09;
+      fLength = gMC->TrackLength();
+      gMC->TrackPosition(fPos);
+      gMC->TrackMomentum(fMomIn);
+      gMC->TrackPosition(fpostotin);        // da cancellare
+      Double_t globalPos[3] = {0., 0., 0.}; // stt1 modified
+      Double_t localPos[3] = {0., 0., 0.};  // stt1 modified
+
+      globalPos[0] = fPos.X();
+      globalPos[1] = fPos.Y();
+      globalPos[2] = fPos.Z();
+
+      gMC->Gmtod(globalPos, localPos, 1);
+      fPosInLocal.SetXYZM(localPos[0], localPos[1], localPos[2], 0.0);
+    }
+
+    // Sum energy loss for all steps in the active volume
+    fELoss += gMC->Edep();
+
+    // Create CbmMustPoint at exit of active volume -- but not into the wire
+    if (gMC->IsTrackExiting() && valid == kTRUE) {
+      valid = kFALSE;
+      fTrackID = gMC->GetStack()->GetCurrentTrackNumber();
+      fVolumeID = static_cast<int>(ECbmModuleId::kEcal); // vol->getMCid();
+
+      if (fTrackID != 0) {
+        if (fVerboseLevel > 2)
+          LOG(info) << "[MUST] test Vol----------" << vol->getMCid();
+        if (fVerboseLevel > 2)
+          LOG(info) << "fTrackID-----" << fTrackID;
+      }
+
+      fMass = gMC->TrackMass(); // mass (GeV)
+      gMC->TrackPosition(fPosOut);
+      gMC->TrackMomentum(fMomOut);
+      gMC->TrackPosition(fpostotout);       // da cancellare
+      Double_t globalPos[3] = {0., 0., 0.}; // stt1 modified
+      Double_t localPos[3] = {0., 0., 0.};  // stt1 modified
+
+      gMC->Gdtom(localPos, globalPos, 1);
+
+      fPos.SetXYZM(globalPos[0], globalPos[1], globalPos[2], 0.0);
+
+      globalPos[0] = fPosOut.X();
+      globalPos[1] = fPosOut.Y();
+      globalPos[2] = fPosOut.Z();
+
+      gMC->Gmtod(globalPos, localPos, 1);
+      fPosOutLocal.SetXYZM(localPos[0], localPos[1], localPos[2], 0.0);
+
+      // string basename("stt1tube");
+      string basename;
+      TString volumename;
+      string hashmark("#"), volName, fullName, number, specialname, volPath(gMC->CurrentVolPath()), volPath2(gMC->CurrentVolPath());
+
+      volumename = volPath;
+      volName = GetStringPart(volPath, 2, '/');
+      number = GetStringPart(volName, 1, '_');
+
+      if (fTrackID != 0) {
+        if (fVerboseLevel > 2)
+          LOG(info) << "[MUST] befor Mapper------";
+      }
+
+      fpostot.SetXYZM((fpostotin.X() + fpostotout.X()) / 2., (fpostotin.Y() + fpostotout.Y()) / 2., (fpostotin.Z() + fpostotout.Z()) / 2., 0.0);
+
+      // CHECK map creator-------------------------------------------------
+      // CbmMustMapCreator *mapper = new CbmMustMapCreator(fGeotype);
+      // testTubeID=tube number as in the geometry file....
+      // we need to calculate the real number in order to have a different
+      // number for each tube (also for up and down short tubes)
+      //      Int_t tubeID    = fMapper->GetTubeIDFromPath(gMC->CurrentVolPath());
+      Int_t chamberID = fMapper->GetChamberIDFromPath(gMC->CurrentVolPath());
+      Int_t layerID = fMapper->GetLayerID(chamberID, gMC->CurrentVolPath());
+      // LOG(info)<<"LAYERID==========="<<layerID;
+      // tubeID=at each tube corresponds only one id number.....
+      Int_t totTubeID = fMapper->GetTubeIDTot(chamberID, layerID, gMC->CurrentVolPath());
+      // LOG(info)<<gMC->CurrentVolPath() << " -> " << "CbmMust.cxx. layer + chamber + tubeID -> totTubeId = "<<layerID<<" + "<<chamberID<<" + "<<tubeID<<" -> "<<totTubeID;
+      ////----------------------------------------------------------------
+
+      AddHit(fTrackID, fVolumeID, totTubeID, chamberID, layerID, TVector3(fpostot.X(), fpostot.Y(), fpostot.Z()), TVector3(fPosInLocal.X(), fPosInLocal.Y(), fPosInLocal.Z()),
+             TVector3(fPosOutLocal.X(), fPosOutLocal.Y(), fPosOutLocal.Z()), TVector3(fMomIn.Px(), fMomIn.Py(), fMomIn.Pz()), TVector3(fMomOut.Px(), fMomOut.Py(), fMomOut.Pz()),
+             fTime, fLength, fELoss, fMass);
+
+      if (fTrackID != 0) {
+        if (fVerboseLevel > 2)
+          LOG(info) << "AddHit CbmMust.cxx= " << fTrackID;
+      }
+
+      // Increment number of stt points for TParticle
+      CbmStack *stack = (CbmStack *)gMC->GetStack();
+      stack->AddPoint(ECbmModuleId::kEcal);
+      ResetParameters();
+    }
+  }
+
+  return kTRUE;
+}
+// -------------------------------------------------------------------------
+
+// -----   Public method EndOfEvent   --------------------------------------
+void CbmMust::EndOfEvent()
+{
+  if (fVerboseLevel)
+    Print();
+  fMustCollection->Delete();
+  fPosIndex = 0;
+}
+// -------------------------------------------------------------------------
+
+// -----   Public method Register   ----------------------------------------
+void CbmMust::Register()
+{
+  FairRootManager::Instance()->Register("MUSTPoint", "Must", fMustCollection, kTRUE);
+}
+// -------------------------------------------------------------------------
+
+// -----   Public method GetCollection   -----------------------------------
+TClonesArray *CbmMust::GetCollection(Int_t iColl) const
+{
+  if (iColl == 0)
+    return fMustCollection;
+  else
+    return nullptr;
+}
+// -------------------------------------------------------------------------
+
+// -----   Public method Print   -------------------------------------------
+void CbmMust::Print(Option_t *) const
+{
+  Int_t nHits = fMustCollection->GetEntriesFast();
+
+  LOG(info) << " CbmMust: " << nHits << " points registered in this event.";
+
+  if (fVerboseLevel > 1)
+    for (Int_t i = 0; i < nHits; i++)
+      (*fMustCollection)[i]->Print();
+}
+// -------------------------------------------------------------------------
+
+// -----   Public method Reset   -------------------------------------------
+void CbmMust::Reset()
+{
+  fMustCollection->Delete();
+  ResetParameters();
+}
+// -------------------------------------------------------------------------
+
+// -----   Public method CopyClones   --------------------------------------
+void CbmMust::CopyClones(TClonesArray *cl1, TClonesArray *cl2, Int_t offset)
+{
+  Int_t nEntries = cl1->GetEntriesFast();
+
+  LOG(info) << " CbmMust: " << nEntries << " entries to add.";
+
+  TClonesArray &clref = *cl2;
+
+  CbmMustPoint *oldpoint = nullptr;
+  for (Int_t i = 0; i < nEntries; i++) {
+    oldpoint = (CbmMustPoint *)cl1->At(i);
+
+    Int_t index = oldpoint->GetTrackID() + offset;
+
+    oldpoint->SetTrackID(index);
+    new (clref[fPosIndex]) CbmMustPoint(*oldpoint);
+    fPosIndex++;
+  }
+  LOG(info) << " CbmMust: " << cl2->GetEntriesFast() << " merged entries.";
+}
+// -------------------------------------------------------------------------
+
+void CbmMust::Initialize()
+{
+  LOG(info) << " -I- Initializing CbmMust()";
+  FairDetector::Initialize();
+}
+
+// -----   Public method ConstructGeometry   -------------------------------
+void CbmMust::ConstructGeometry()
+{
+  FairGeoLoader *geoLoad = FairGeoLoader::Instance();
+  FairGeoInterface *geoFace = geoLoad->getGeoInterface();
+  CbmGeoMust *Geo = new CbmGeoMust();
+  Geo->setGeomFile(GetGeometryFileName());
+  geoFace->addGeoModule(Geo);
+
+  Bool_t rc = geoFace->readSet(Geo);
+  if (rc)
+    Geo->create(geoLoad->getGeoBuilder());
+
+  TList *volList = Geo->getListOfVolumes();
+
+  // store geo parameter
+  FairRun *fRun = FairRun::Instance();
+  FairRuntimeDb *rtdb = FairRun::Instance()->GetRuntimeDb();
+  CbmGeoMustPar *par;
+  par = (CbmGeoMustPar *)(rtdb->getContainer("CbmGeoMustPar"));
+  rtdb->getListOfContainers()->Print();
+  TObjArray *fSensNodes = par->GetGeoSensitiveNodes();
+  fPassNodes = par->GetGeoPassiveNodes();
+
+  TListIter iter(volList);
+  FairGeoNode *node = nullptr;
+  FairGeoVolume *aVol = nullptr;
+
+  while ((node = (FairGeoNode *)iter.Next())) {
+    aVol = dynamic_cast<FairGeoVolume *>(node);
+    // if (fGeoType == 2)
+    //  LOG(info) << "Volume " << aVol->GetName() << " is" << (node->isSensitive() ? "" : " not") << " sensitive";
+    if (node->isSensitive()) {
+      fSensNodes->AddLast(aVol);
+    } else {
+      fPassNodes->AddLast(aVol);
+    }
+  }
+
+  par->SetGeometryType(fGeoType);
+  if (fGeoType == 1) {
+    par->SetTubeInRad(0.4903 / 2.); // cm
+    par->SetTubeOutRad(0.00127);    // cm
+  } else {
+    LOG(fatal) << "[MUST] GeoType " << fGeoType << " not supported";
+  }
+
+  par->setChanged();
+  par->setInputVersion(fRun->GetRunId(), 1);
+  ProcessNodes(volList);
+
+  fMapper = new CbmMustMapCreator(fGeoType);
+}
+// -------------------------------------------------------------------------
+
+// -----   Private method AddHit   -----------------------------------------
+CbmMustPoint *CbmMust::AddHit(Int_t trackID, Int_t detID, Int_t tubeID, Int_t chamberID, Int_t layerID, TVector3 pos, TVector3 posInLocal, TVector3 posOutLocal, TVector3 momIn,
+                          TVector3 momOut, Double_t time, Double_t length, Double_t eLoss, Double_t mass) // da cancellare postot
+{
+  TClonesArray &clref = *fMustCollection;
+
+  Int_t size = clref.GetEntriesFast();
+
+  CbmMustPoint *pointnew = new (clref[size]) CbmMustPoint(trackID, detID, tubeID, chamberID, layerID, pos, posInLocal, posOutLocal, momIn, momOut, time, length, eLoss, mass);
+
+  pointnew->SetTubeID(tubeID);
+  pointnew->SetChamberID(chamberID);
+  pointnew->SetLayerID(layerID);
+
+  return pointnew;
+}
+// -------------------------------------------------------------------------
+
+ClassImp(CbmMust)
diff --git a/sim/detectors/must/CbmMust.h b/sim/detectors/must/CbmMust.h
new file mode 100644
index 000000000..416e10b92
--- /dev/null
+++ b/sim/detectors/must/CbmMust.h
@@ -0,0 +1,186 @@
+/* Copyright (C) 2004-2024 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
+   SPDX-License-Identifier: GPL-3.0-only
+   Authors: Radoslaw Karabowicz */
+
+////////////////////////////////////////////////////////////////////////////
+// CbmMust header file
+//
+// Class for simulation of MUST
+//
+// authors: Radoslaw Karabowicz, GSI, 2024
+//
+// modified from CbmMust by Nafija Ibrišimović in 2023
+////////////////////////////////////////////////////////////////////////////
+
+#ifndef CBMMUST_H
+#define CBMMUST_H
+
+// from CbmRoot, this library
+#include "CbmGeoMustPar.h"
+#include "CbmMustMapCreator.h"
+// from CbmRoot, CbmData
+#include <CbmMustPoint.h>
+// from FairRoot
+#include <FairDetector.h>
+#include <FairRun.h>
+// from ROOT
+#include <TClonesArray.h>
+#include <TLorentzVector.h>
+#include <TVector3.h>
+// standard
+#include <string>
+#include <sstream>
+
+class TClonesArray;
+class FairVolume;
+
+class CbmMust : public FairDetector {
+
+ public:
+  /** Default constructor **/
+  CbmMust();
+
+  /** Standard constructor.
+   *@param name    detetcor name
+   *@param active  sensitivity flag
+   **/
+  CbmMust(const char *name, Bool_t active);
+
+  /** Destructor **/
+  virtual ~CbmMust();
+
+  /** Virtual method ProcessHits
+   **
+   ** Defines the action to be taken when a step is inside the
+   ** active volume. Creates CbmMustPoints and adds them to the
+   ** collection.
+   *@param vol  Pointer to the active volume
+   **/
+  virtual Bool_t ProcessHits(FairVolume *vol = 0) override;
+
+  /** Virtual method EndOfEvent
+   **
+   ** If verbosity level is set, print hit collection at the
+   ** end of the event and resets it afterwards.
+   **/
+  virtual void EndOfEvent() override;
+
+  /** Virtual method Register
+   **
+   ** Registers the hit collection in the ROOT manager.
+   **/
+  virtual void Register() override;
+
+  /** Accessor to the hit collection **/
+  virtual TClonesArray *GetCollection(Int_t iColl) const override;
+
+  /** Virtual method Print
+   **
+   ** Screen output of hit collection.
+   **/
+  virtual void Print(Option_t * /*option*/ = "") const override;
+
+  /** Virtual method Reset
+   **
+   ** Clears the hit collection
+   **/
+  virtual void Reset() override;
+
+  virtual void Initialize() override;
+
+  /** Virtual method CopyClones
+   **
+   ** Copies the hit collection with a given track index offset
+   *@param cl1     Origin
+   *@param cl2     Target
+   *@param offset  Index offset
+   **/
+  virtual void CopyClones(TClonesArray *cl1, TClonesArray *cl2, Int_t offset) override;
+
+  /** Virtual method Construct geometry
+   **
+   ** Constructs the STT geometry
+   **/
+  virtual void ConstructGeometry() override;
+
+ private:
+  /** GFTrack information to be stored until the track leaves the
+      active volume. **/
+  Int_t fTrackID;              //!  track index
+  Int_t fVolumeID;             //!  volume id
+  TLorentzVector fPos;         //!  wire position in global frame
+  TLorentzVector fPosIn;       //!  entry position in global frame
+  TLorentzVector fPosOut;      //!  exit position in global frame
+  TLorentzVector fPosInLocal;  //!  entry position in straw frame
+  TLorentzVector fPosOutLocal; //!  exit position in straw frame
+  TLorentzVector fMomIn;       //!  momentum
+  TLorentzVector fMomOut;      //!  momentum
+  Double_t fTime;              //!  time
+  Double_t fLength;            //!  length
+  Double_t fELoss;             //!  energy loss
+  Double_t fMass;              //!  particle mass
+  Bool_t fIsInitialized;
+
+  Int_t fPosIndex;             //!
+  TClonesArray *fMustCollection; //! Hit collection
+  TLorentzVector fpostot;      // global frame hit position (in)// da cancellare
+  TLorentzVector fpostotin;    // global frame hit position (in)// da cancellare
+  TLorentzVector fpostotout;   // global frame hit position (in)// da cancellare
+
+  TObjArray *fPassNodes; //!
+  // geometry type
+  Bool_t valid;
+  Int_t fGeoType;
+
+  CbmMustMapCreator *fMapper; //!
+
+  /** Private method AddHit
+   **
+   ** Adds a CbmTrdPoint to the HitCollection
+   **/
+  CbmMustPoint *AddHit(Int_t trackID, Int_t detID, Int_t tubeID, Int_t chamberID, Int_t layerID, TVector3 pos, TVector3 posInLocal, TVector3 posOutLocal, TVector3 momIn,
+                     TVector3 momOut, Double_t time, Double_t length, Double_t eLoss, Double_t mass);
+
+  std::string GetStringPart(std::string &aSrc, Int_t part, char aDelim);
+  bool Split(std::string &aDest, std::string &aSrc, char aDelim);
+
+  /** Private method ResetParameters
+   **
+   ** Resets the private members for the track parameters
+   **/
+  void ResetParameters();
+
+  /** Private method GetSquaredDistanceFromWire
+   **
+   ** Returns the square of the distance of the current trackpoint to the wire
+   *@return     distance
+   **/
+  float GetSquaredDistanceFromWire();
+
+  CbmMust(const CbmMust &L);
+  CbmMust &operator=(const CbmMust &) { return *this; }
+
+  ClassDef(CbmMust, 1)
+};
+
+inline void CbmMust::ResetParameters()
+{
+  fTrackID = fVolumeID = 0;
+  fPos.SetXYZM(0.0, 0.0, 0.0, 0.0);
+  fPosInLocal.SetXYZM(0.0, 0.0, 0.0, 0.0);
+  fPosOutLocal.SetXYZM(0.0, 0.0, 0.0, 0.0);
+  fMomIn.SetXYZM(0.0, 0.0, 0.0, 0.0);
+  fMomOut.SetXYZM(0.0, 0.0, 0.0, 0.0);
+  fTime = fLength = fELoss = 0;
+  fPosIndex = 0;
+  fpostot.SetXYZM(0.0, 0.0, 0.0, 0.0);    // da cancellare
+  fpostotin.SetXYZM(0.0, 0.0, 0.0, 0.0);  // da cancellare
+  fpostotout.SetXYZM(0.0, 0.0, 0.0, 0.0); // da cancellare
+  fPosIn.SetXYZM(0.0, 0.0, 0.0, 0.0);
+  fPosOut.SetXYZM(0.0, 0.0, 0.0, 0.0);
+  fMass = 0;
+  fIsInitialized = kFALSE;
+  valid = kFALSE;
+}
+
+#endif // CBMMUST_H
diff --git a/sim/detectors/must/CbmMustSimLinkDef.h b/sim/detectors/must/CbmMustSimLinkDef.h
new file mode 100644
index 000000000..e42383441
--- /dev/null
+++ b/sim/detectors/must/CbmMustSimLinkDef.h
@@ -0,0 +1,13 @@
+/* Copyright (C) 2020 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
+   SPDX-License-Identifier: GPL-3.0-only
+   Authors: Volker Friese [committer] */
+
+#ifdef __CINT__
+
+#pragma link off all globals;
+#pragma link off all classes;
+#pragma link off all functions;
+
+#pragma link C++ class CbmMust + ;
+
+#endif /* __CINT__ */
-- 
GitLab


From 71263f7a29fc22c5ea0a22b4ab6cbd0cbc861b1a Mon Sep 17 00:00:00 2001
From: Radoslaw Karabowicz <r.karabowicz@gsi.de>
Date: Wed, 27 Nov 2024 12:24:26 +0100
Subject: [PATCH 02/16] det(must): Compile the MUST software

Introduce proper changes to the `cbmroot` changes
to compile MUST classes.
---
 core/CMakeLists.txt          | 1 +
 core/data/CMakeLists.txt     | 1 +
 sim/detectors/CMakeLists.txt | 1 +
 3 files changed, 3 insertions(+)

diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt
index 7fa667426..cf78e94fe 100644
--- a/core/CMakeLists.txt
+++ b/core/CMakeLists.txt
@@ -15,6 +15,7 @@ add_subdirectory(detectors/tof)
 add_subdirectory(detectors/sts)
 add_subdirectory(detectors/psd)
 add_subdirectory(detectors/fsd)
+add_subdirectory(detectors/must)
 
 If(ROOT_opengl_FOUND)
   Message(STATUS "OpenGL support found. Build the eventdisplay.")
diff --git a/core/data/CMakeLists.txt b/core/data/CMakeLists.txt
index bb9bd8567..a3de47eb9 100644
--- a/core/data/CMakeLists.txt
+++ b/core/data/CMakeLists.txt
@@ -15,6 +15,7 @@ set(INCLUDE_DIRECTORIES
   ${CMAKE_CURRENT_SOURCE_DIR}/rich
   ${CMAKE_CURRENT_SOURCE_DIR}/psd
   ${CMAKE_CURRENT_SOURCE_DIR}/fsd
+  ${CMAKE_CURRENT_SOURCE_DIR}/must
   ${CMAKE_CURRENT_SOURCE_DIR}/global
   )
 
diff --git a/sim/detectors/CMakeLists.txt b/sim/detectors/CMakeLists.txt
index aa91290cd..ebbc2b7d8 100644
--- a/sim/detectors/CMakeLists.txt
+++ b/sim/detectors/CMakeLists.txt
@@ -10,3 +10,4 @@ add_subdirectory(tof)
 add_subdirectory(fsd)
 add_subdirectory(psd)
 add_subdirectory(bmon)
+add_subdirectory(must)
-- 
GitLab


From 8d89b3d2cb4a04cfcba631d4550330c158027476 Mon Sep 17 00:00:00 2001
From: Radoslaw Karabowicz <r.karabowicz@gsi.de>
Date: Wed, 18 Dec 2024 11:49:03 +0100
Subject: [PATCH 03/16] det(must): Add changes to read root geometry

Changed CbmMustPoint to reflect the root geometry.
Introduced fLayerID, fModuleID, fStrawID,
removed unneeded variables and the map creator.

Changed CbmMust detector to read geometry from root file.

Changed run_sim macro accordingly.
---
 core/data/must/CbmMustPoint.cxx | 18 ++++-----
 core/data/must/CbmMustPoint.h   | 24 ++++++------
 macro/must/run_sim.C            | 10 ++---
 sim/detectors/must/CbmMust.cxx  | 65 ++++++++++++++-------------------
 sim/detectors/must/CbmMust.h    | 17 ++++++---
 5 files changed, 65 insertions(+), 69 deletions(-)

diff --git a/core/data/must/CbmMustPoint.cxx b/core/data/must/CbmMustPoint.cxx
index 23c330423..71c0b0636 100644
--- a/core/data/must/CbmMustPoint.cxx
+++ b/core/data/must/CbmMustPoint.cxx
@@ -23,17 +23,17 @@ using std::endl;
 // -----   Default constructor   -------------------------------------------
 CbmMustPoint::CbmMustPoint()
   : FairMCPoint(), fX_out_local(0), fY_out_local(0), fZ_out_local(0), fX_in_local(0.), fY_in_local(0), fZ_in_local(0), fPx_out(0), fPy_out(0), fPz_out(0), fPx_in(0), fPy_in(0),
-    fPz_in(0), fMass(0), fTubeID(0), fChamberID(0), fLayerID(0)
+    fPz_in(0), fMass(0), fLayerID(0), fModuleID(0), fStrawID(0)
 {
 }
 // -------------------------------------------------------------------------
 
 // -----   Standard constructor   ------------------------------------------
-CbmMustPoint::CbmMustPoint(Int_t trackID, Int_t detID, Int_t tubeID, Int_t chamberID, Int_t layerID, TVector3 pos, TVector3 posInLocal, TVector3 posOutLocal, TVector3 momIn,
+CbmMustPoint::CbmMustPoint(Int_t trackID, Int_t detID, Int_t layerID, Int_t moduleID, Int_t strawID, TVector3 pos, TVector3 posInLocal, TVector3 posOutLocal, TVector3 momIn,
                          TVector3 momOut, Double_t tof, Double_t length, Double_t eLoss, Double_t mass)
   : FairMCPoint(trackID, detID, pos, momIn, tof, length, eLoss), fX_out_local(posOutLocal.X()), fY_out_local(posOutLocal.Y()), fZ_out_local(posOutLocal.Z()),
     fX_in_local(posInLocal.X()), fY_in_local(posInLocal.Y()), fZ_in_local(posInLocal.Z()), fPx_out(momOut.Px()), fPy_out(momOut.Py()), fPz_out(momOut.Pz()), fPx_in(momIn.Px()),
-    fPy_in(momIn.Py()), fPz_in(momIn.Pz()), fMass(mass), fTubeID(tubeID), fChamberID(chamberID), fLayerID(layerID)
+    fPy_in(momIn.Py()), fPz_in(momIn.Pz()), fMass(mass), fLayerID(layerID), fModuleID(moduleID), fStrawID(strawID)
 {
   // reset MC momentum
   fPx = (momIn.Px() + momOut.Px()) / 2.;
@@ -53,7 +53,7 @@ CbmMustPoint::CbmMustPoint(const CbmMustPoint &point)
                 point.fEventId),
     fX_out_local(point.fX_out_local), fY_out_local(point.fY_out_local), fZ_out_local(point.fZ_out_local), fX_in_local(point.fX_in_local), fY_in_local(point.fY_in_local),
     fZ_in_local(point.fZ_in_local), fPx_out(point.fPx_out), fPy_out(point.fPy_out), fPz_out(point.fPz_out), fPx_in(point.fPx_in), fPy_in(point.fPy_in), fPz_in(point.fPz_in),
-    fMass(point.fMass), fTubeID(point.fTubeID), fChamberID(point.fChamberID), fLayerID(point.fLayerID)
+    fMass(point.fMass), fLayerID(point.fLayerID), fModuleID(point.fModuleID), fStrawID(point.fStrawID)
 {
 }
 // -------------------------------------------------------------------------
@@ -61,11 +61,11 @@ CbmMustPoint::CbmMustPoint(const CbmMustPoint &point)
 // -----   Public method Print   -------------------------------------------
 void CbmMustPoint::Print(const Option_t *opt) const
 {
-  LOG(info) << " CbmMustPoint: MUST Point for track " << fTrackID << " in detector " << fDetectorID;
-  cout << "    Position (" << fX << ", " << fY << ", " << fZ << ") cm" << endl;
-  cout << "    Momentum (" << fPx << ", " << fPy << ", " << fPz << ") GeV" << endl;
-  cout << "    Time " << fTime << " ns,  Length " << fLength << " cm,  Energy loss " << fELoss * 1.0e06 << " keV"
-       << " opt=" << opt << endl;
+    LOG(info) << " CbmMustPoint: MUST Point for track " << fTrackID << " in det/lay/mod/str " << fDetectorID << "/" << fLayerID << "/" << fModuleID << "/" << fStrawID;
+    LOG(info) << "    Position (" << fX << ", " << fY << ", " << fZ << ") cm";
+    LOG(info) << "    Momentum (" << fPx << ", " << fPy << ", " << fPz << ") GeV";
+    LOG(info) << "    Time " << fTime << " ns,  Length " << fLength << " cm,  Energy loss " << fELoss * 1.0e06 << " keV"
+              << " opt=" << opt;
 }
 // -------------------------------------------------------------------------
 
diff --git a/core/data/must/CbmMustPoint.h b/core/data/must/CbmMustPoint.h
index 9c7d8deee..a0a1f99cd 100644
--- a/core/data/must/CbmMustPoint.h
+++ b/core/data/must/CbmMustPoint.h
@@ -23,9 +23,9 @@ class CbmMustPoint : public FairMCPoint {
   /** Constructor with arguments
    *@param trackID       Index of MCTrack
    *@param detID         Detector ID
-   *tubeID               Number of tube
-   *ChamberID            number of chamber
-   *LayerID
+   *@param LayerID       MUST layerID (1...12)
+   *@param moduleID      moduleID in layer (1...36)
+   *@param strawID       strawID in module (1...128)
    *@param pos           Coordinates at wire center of active volume [cm]
    *@param posInLocal    Local coordinates at entrance to active volume [cm]
    *@param posOutLocal   Local coordinates at exit of active volume [cm]
@@ -35,7 +35,7 @@ class CbmMustPoint : public FairMCPoint {
    *@param length        Track length since creation [cm]
    *@param eLoss         Energy deposit [GeV]
    **/
-  CbmMustPoint(Int_t trackID, Int_t detID, Int_t tubeID, Int_t chamberID, Int_t layerID, TVector3 pos, TVector3 posInLocal, TVector3 posOutLocal, TVector3 momIn, TVector3 momOut,
+  CbmMustPoint(Int_t trackID, Int_t detID, Int_t layerID, Int_t moduleID, Int_t strawID, TVector3 pos, TVector3 posInLocal, TVector3 posOutLocal, TVector3 momIn, TVector3 momOut,
               Double_t tof, Double_t length, Double_t eLoss, Double_t mass);
 
   /** Copy constructor **/
@@ -81,12 +81,12 @@ class CbmMustPoint : public FairMCPoint {
   // void SetWireDirection(TVector3 wire);
 
   // tube ID // CHECK added
-  void SetTubeID(Int_t tubeid) { fTubeID = tubeid; }
-  Int_t GetTubeID() { return fTubeID; }
-  void SetChamberID(Int_t chamberid) { fChamberID = chamberid; }
-  void SetLayerID(Int_t layerid) { fLayerID = layerid; }
-  Int_t GetChamberID() { return fChamberID; }
-  Int_t GetLayerID() { return fLayerID; }
+  Int_t GetLayerID () { return fLayerID; }
+  Int_t GetModuleID() { return fModuleID; }
+  Int_t GetStrawID () { return fStrawID; }
+  void  SetLayerID (Int_t layerid)  { fLayerID  = layerid;  }
+  void  SetModuleID(Int_t moduleid) { fModuleID = moduleid; }
+  void  SetStrawID (Int_t strawid)  { fStrawID  = strawid;  }
 
   /** Output to screen **/
   virtual void Print(const Option_t *opt) const;
@@ -104,9 +104,9 @@ class CbmMustPoint : public FairMCPoint {
 
   // particle mass
   Double_t fMass;
-  Int_t fTubeID;
-  Int_t fChamberID;
   Int_t fLayerID;
+  Int_t fModuleID;
+  Int_t fStrawID;
 
   //////
 
diff --git a/macro/must/run_sim.C b/macro/must/run_sim.C
index 23fc129f8..9364eb322 100644
--- a/macro/must/run_sim.C
+++ b/macro/must/run_sim.C
@@ -2,7 +2,7 @@
    SPDX-License-Identifier: GPL-3.0-only
    Authors: Radoslaw Karabowicz */
 
-int run_sim(Int_t nEvents = 10000, Int_t pid = 13, Float_t p1 = 10.0, Float_t p2 = 10.0)
+int run_sim(Int_t nEvents = 10, Int_t pid = 13, Float_t p1 = 10.0, Float_t p2 = 10.0)
 {
   // 2212 proton
   TStopwatch timer;
@@ -67,7 +67,7 @@ int run_sim(Int_t nEvents = 10000, Int_t pid = 13, Float_t p1 = 10.0, Float_t p2
   fRun->AddModule(magnet);
   
   FairDetector *must = new CbmMust("MUST", kTRUE);
-  must->SetGeometryFileName("must/must.geo");
+  must->SetGeometryFileName("must/must_v24a_mcbm.geo.root");
   fRun->AddModule(must);
 
   // Create and Set Event Generator
@@ -80,9 +80,9 @@ int run_sim(Int_t nEvents = 10000, Int_t pid = 13, Float_t p1 = 10.0, Float_t p2
   FairBoxGenerator *boxGen = new FairBoxGenerator(pid, 100); // 13=muon; 2212=proton 1 = multipl.
   if (p2 < 0.)
     p2 = p1;
-  boxGen->SetPRange(p1, p1);    // GeV/c //setPRange vs setPtRange
-  boxGen->SetPhiRange(45, 45);  // Azimuth angle range [degree]
-  boxGen->SetThetaRange(20, 20); // Polar angle in lab system range [degree]
+  boxGen->SetPRange(p1, p2);    // GeV/c //setPRange vs setPtRange
+  boxGen->SetPhiRange(270, 450);  // Azimuth angle range [degree]
+  boxGen->SetThetaRange(6, 22); // Polar angle in lab system range [degree]
   boxGen->SetCosTheta();
   boxGen->SetXYZ(0., 0., 0.);
   primGen->AddGenerator(boxGen);
diff --git a/sim/detectors/must/CbmMust.cxx b/sim/detectors/must/CbmMust.cxx
index 9722a8096..59f3eee44 100644
--- a/sim/detectors/must/CbmMust.cxx
+++ b/sim/detectors/must/CbmMust.cxx
@@ -18,7 +18,8 @@
 #include "CbmGeoMust.h"
 #include "CbmDefs.h"
 #include "CbmStack.h"
-#include "CbmMustMapCreator.h"
+// from CbmRoot
+#include "CbmGeometryUtils.h"
 // from FairRoot
 #include <FairRun.h>
 #include <FairGeoInterface.h>
@@ -135,7 +136,7 @@ string CbmMust::GetStringPart(string &aSrc, Int_t part, char aDelim)
 // -----   Public method ProcessHits  --------------------------------------
 Bool_t CbmMust::ProcessHits(FairVolume *vol)
 {
-
+    //    LOG(info) << "ProcessHits called!";
   // TParticle* particle =  gMC->GetStack()->GetCurrentTrack(); //[R.K. 01/2017] unused variable?
   // TGeoMedium *medium = (TGeoMedium*) vol->getGeoNode()->getRootVolume()->GetMedium(); //[R.K. 01/2017] unused variable?
   // Double_t epsil = medium->GetParam(6); //[R.K. 01/2017] unused variable?
@@ -202,37 +203,18 @@ Bool_t CbmMust::ProcessHits(FairVolume *vol)
       gMC->Gmtod(globalPos, localPos, 1);
       fPosOutLocal.SetXYZM(localPos[0], localPos[1], localPos[2], 0.0);
 
-      // string basename("stt1tube");
-      string basename;
-      TString volumename;
-      string hashmark("#"), volName, fullName, number, specialname, volPath(gMC->CurrentVolPath()), volPath2(gMC->CurrentVolPath());
-
-      volumename = volPath;
-      volName = GetStringPart(volPath, 2, '/');
-      number = GetStringPart(volName, 1, '_');
-
-      if (fTrackID != 0) {
-        if (fVerboseLevel > 2)
-          LOG(info) << "[MUST] befor Mapper------";
-      }
+      string volPath(gMC->CurrentVolPath());
 
       fpostot.SetXYZM((fpostotin.X() + fpostotout.X()) / 2., (fpostotin.Y() + fpostotout.Y()) / 2., (fpostotin.Z() + fpostotout.Z()) / 2., 0.0);
 
-      // CHECK map creator-------------------------------------------------
-      // CbmMustMapCreator *mapper = new CbmMustMapCreator(fGeotype);
-      // testTubeID=tube number as in the geometry file....
-      // we need to calculate the real number in order to have a different
-      // number for each tube (also for up and down short tubes)
-      //      Int_t tubeID    = fMapper->GetTubeIDFromPath(gMC->CurrentVolPath());
-      Int_t chamberID = fMapper->GetChamberIDFromPath(gMC->CurrentVolPath());
-      Int_t layerID = fMapper->GetLayerID(chamberID, gMC->CurrentVolPath());
-      // LOG(info)<<"LAYERID==========="<<layerID;
-      // tubeID=at each tube corresponds only one id number.....
-      Int_t totTubeID = fMapper->GetTubeIDTot(chamberID, layerID, gMC->CurrentVolPath());
-      // LOG(info)<<gMC->CurrentVolPath() << " -> " << "CbmMust.cxx. layer + chamber + tubeID -> totTubeId = "<<layerID<<" + "<<chamberID<<" + "<<tubeID<<" -> "<<totTubeID;
-      ////----------------------------------------------------------------
-
-      AddHit(fTrackID, fVolumeID, totTubeID, chamberID, layerID, TVector3(fpostot.X(), fpostot.Y(), fpostot.Z()), TVector3(fPosInLocal.X(), fPosInLocal.Y(), fPosInLocal.Z()),
+      LOG(debug) << " --> " << volPath;
+      volPath = volPath.substr(volPath.find("strawAssembly_")+14,8);
+      int layerId   = atoi(volPath.substr(1,2).c_str());
+      int moduleId  = atoi(volPath.substr(3,2).c_str());
+      int strawId   = atoi(volPath.substr(5,3).c_str());
+      LOG(debug) <<  " l/m/t = " << layerId << "/" << moduleId << "/" << strawId;
+
+      AddHit(fTrackID, fVolumeID, layerId, moduleId, strawId, TVector3(fpostot.X(), fpostot.Y(), fpostot.Z()), TVector3(fPosInLocal.X(), fPosInLocal.Y(), fPosInLocal.Z()),
              TVector3(fPosOutLocal.X(), fPosOutLocal.Y(), fPosOutLocal.Z()), TVector3(fMomIn.Px(), fMomIn.Py(), fMomIn.Pz()), TVector3(fMomOut.Px(), fMomOut.Py(), fMomOut.Pz()),
              fTime, fLength, fELoss, fMass);
 
@@ -332,6 +314,18 @@ void CbmMust::Initialize()
 // -----   Public method ConstructGeometry   -------------------------------
 void CbmMust::ConstructGeometry()
 {
+
+  TString fileName = GetGeometryFileName();
+
+  // --- Only ROOT geometries are supported
+  if (fileName.EndsWith(".root")) {
+      LOG(info) << "Constructing Must geometry from ROOT file " << fileName.Data();
+      TGeoCombiTrans* fCombiTrans = NULL;
+      Cbm::GeometryUtils::ImportRootGeometry(fgeoName, this, fCombiTrans);
+      return;
+  }
+  LOG(info) << "Constructing Must geometry from text file " << fileName.Data();
+
   FairGeoLoader *geoLoad = FairGeoLoader::Instance();
   FairGeoInterface *geoFace = geoLoad->getGeoInterface();
   CbmGeoMust *Geo = new CbmGeoMust();
@@ -380,23 +374,18 @@ void CbmMust::ConstructGeometry()
   par->setInputVersion(fRun->GetRunId(), 1);
   ProcessNodes(volList);
 
-  fMapper = new CbmMustMapCreator(fGeoType);
 }
 // -------------------------------------------------------------------------
 
 // -----   Private method AddHit   -----------------------------------------
-CbmMustPoint *CbmMust::AddHit(Int_t trackID, Int_t detID, Int_t tubeID, Int_t chamberID, Int_t layerID, TVector3 pos, TVector3 posInLocal, TVector3 posOutLocal, TVector3 momIn,
-                          TVector3 momOut, Double_t time, Double_t length, Double_t eLoss, Double_t mass) // da cancellare postot
+CbmMustPoint *CbmMust::AddHit(Int_t trackID, Int_t detID, Int_t layID, Int_t modID, Int_t strID, TVector3 pos, TVector3 posInLocal, TVector3 posOutLocal, TVector3 momIn,
+                              TVector3 momOut, Double_t time, Double_t length, Double_t eLoss, Double_t mass)
 {
   TClonesArray &clref = *fMustCollection;
 
   Int_t size = clref.GetEntriesFast();
 
-  CbmMustPoint *pointnew = new (clref[size]) CbmMustPoint(trackID, detID, tubeID, chamberID, layerID, pos, posInLocal, posOutLocal, momIn, momOut, time, length, eLoss, mass);
-
-  pointnew->SetTubeID(tubeID);
-  pointnew->SetChamberID(chamberID);
-  pointnew->SetLayerID(layerID);
+  CbmMustPoint *pointnew = new (clref[size]) CbmMustPoint(trackID, detID, layID, modID, strID, pos, posInLocal, posOutLocal, momIn, momOut, time, length, eLoss, mass);
 
   return pointnew;
 }
diff --git a/sim/detectors/must/CbmMust.h b/sim/detectors/must/CbmMust.h
index 416e10b92..825e87cdd 100644
--- a/sim/detectors/must/CbmMust.h
+++ b/sim/detectors/must/CbmMust.h
@@ -17,7 +17,6 @@
 
 // from CbmRoot, this library
 #include "CbmGeoMustPar.h"
-#include "CbmMustMapCreator.h"
 // from CbmRoot, CbmData
 #include <CbmMustPoint.h>
 // from FairRoot
@@ -65,6 +64,16 @@ class CbmMust : public FairDetector {
    **/
   virtual void EndOfEvent() override;
 
+  /** @brief Check whether a volume is sensitive.
+		 **
+		 ** @param(name)  Volume name
+		 ** @value        kTRUE if volume is sensitive, else kFALSE
+		 **
+		 ** The decision is based on the volume name (has to contain "Sensor").
+		 ** Virtual from FairModule.
+		 **/
+  virtual Bool_t IsSensitive(const std::string& name) override { return (TString(name).Contains("active") ? kTRUE : kFALSE); }
+
   /** Virtual method Register
    **
    ** Registers the hit collection in the ROOT manager.
@@ -132,14 +141,12 @@ class CbmMust : public FairDetector {
   Bool_t valid;
   Int_t fGeoType;
 
-  CbmMustMapCreator *fMapper; //!
-
   /** Private method AddHit
    **
    ** Adds a CbmTrdPoint to the HitCollection
    **/
-  CbmMustPoint *AddHit(Int_t trackID, Int_t detID, Int_t tubeID, Int_t chamberID, Int_t layerID, TVector3 pos, TVector3 posInLocal, TVector3 posOutLocal, TVector3 momIn,
-                     TVector3 momOut, Double_t time, Double_t length, Double_t eLoss, Double_t mass);
+  CbmMustPoint *AddHit(Int_t trackID, Int_t detID, Int_t layID, Int_t modID, Int_t strID, TVector3 pos, TVector3 posInLocal, TVector3 posOutLocal, TVector3 momIn,
+                       TVector3 momOut, Double_t time, Double_t length, Double_t eLoss, Double_t mass);
 
   std::string GetStringPart(std::string &aSrc, Int_t part, char aDelim);
   bool Split(std::string &aDest, std::string &aSrc, char aDelim);
-- 
GitLab


From 94f903d2eca5ab1ba5e909b41d85fb593e250ef3 Mon Sep 17 00:00:00 2001
From: Radoslaw Karabowicz <r.karabowicz@gsi.de>
Date: Thu, 30 Jan 2025 11:14:36 +0100
Subject: [PATCH 04/16] feat(must): Add MUST geometry parameter classes

CbmMustGeoScheme allows access to MUST geometry
via CbmMustStation, CbmMustLayer, CbmMustModule and CbmMustTube arrays.

Design based on CbmMuchGeoScheme.
---
 core/detectors/must/CMakeLists.txt       |   4 +
 core/detectors/must/CbmMustBaseLinkDef.h |   4 +
 core/detectors/must/CbmMustGeoScheme.cxx | 192 +++++++++++++++++++++++
 core/detectors/must/CbmMustGeoScheme.h   |  92 +++++++++++
 core/detectors/must/CbmMustLayer.cxx     |  84 ++++++++++
 core/detectors/must/CbmMustLayer.h       |  72 +++++++++
 core/detectors/must/CbmMustModule.cxx    |  80 ++++++++++
 core/detectors/must/CbmMustModule.h      |  72 +++++++++
 core/detectors/must/CbmMustStation.cxx   |  81 ++++++++++
 core/detectors/must/CbmMustStation.h     |  60 +++++++
 core/detectors/must/CbmMustTube.cxx      |  14 +-
 core/detectors/must/CbmMustTube.h        |  55 ++++---
 12 files changed, 783 insertions(+), 27 deletions(-)
 create mode 100644 core/detectors/must/CbmMustGeoScheme.cxx
 create mode 100644 core/detectors/must/CbmMustGeoScheme.h
 create mode 100644 core/detectors/must/CbmMustLayer.cxx
 create mode 100644 core/detectors/must/CbmMustLayer.h
 create mode 100644 core/detectors/must/CbmMustModule.cxx
 create mode 100644 core/detectors/must/CbmMustModule.h
 create mode 100644 core/detectors/must/CbmMustStation.cxx
 create mode 100644 core/detectors/must/CbmMustStation.h

diff --git a/core/detectors/must/CMakeLists.txt b/core/detectors/must/CMakeLists.txt
index 5aab621de..9a533cd76 100644
--- a/core/detectors/must/CMakeLists.txt
+++ b/core/detectors/must/CMakeLists.txt
@@ -7,6 +7,10 @@ set(SRCS
   CbmGeoMust.cxx
   CbmGeoMustPar.cxx
   CbmMustContFact.cxx
+  CbmMustGeoScheme.cxx
+  CbmMustStation.cxx
+  CbmMustLayer.cxx
+  CbmMustModule.cxx
   CbmMustTube.cxx
 )
 
diff --git a/core/detectors/must/CbmMustBaseLinkDef.h b/core/detectors/must/CbmMustBaseLinkDef.h
index 46e589816..d994d020b 100644
--- a/core/detectors/must/CbmMustBaseLinkDef.h
+++ b/core/detectors/must/CbmMustBaseLinkDef.h
@@ -11,6 +11,10 @@
 #pragma link C++ class CbmGeoMust + ;
 #pragma link C++ class CbmGeoMustPar + ;
 #pragma link C++ class CbmMustContFact + ;
+#pragma link C++ class CbmMustGeoScheme + ;
+#pragma link C++ class CbmMustStation + ;
+#pragma link C++ class CbmMustLayer + ;
+#pragma link C++ class CbmMustModule + ;
 #pragma link C++ class CbmMustTube + ;
 
 #endif /* __CINT__ */
diff --git a/core/detectors/must/CbmMustGeoScheme.cxx b/core/detectors/must/CbmMustGeoScheme.cxx
new file mode 100644
index 000000000..7cd7e5471
--- /dev/null
+++ b/core/detectors/must/CbmMustGeoScheme.cxx
@@ -0,0 +1,192 @@
+/* Copyright (C) 2004-2025 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
+   SPDX-License-Identifier: GPL-3.0-only
+   Authors: Radoslaw Karabowicz */
+/** CbmMustGeoScheme
+ *@author  R.Karabowicz <r.karabowicz@gsi.de>
+ *@version 1.0
+ *@since   2025.01.08
+ **
+ ** Based on CbmMuchGeoScheme by Evgeny Kryshen <e.kryshen@gsi.de>
+ **
+ **/
+#include "CbmMustGeoScheme.h"
+
+#include "CbmMustLayer.h"            // for CbmMustLayer
+#include "CbmMustStation.h"          // for CbmMustStation
+
+#include <Logger.h>  // for LOG
+
+#include <TArrayD.h>       // for TArrayD
+#include <TArrayI.h>       // for TArrayI
+#include <TClonesArray.h>  // for TClonesArray
+#include <TFile.h>         // for TFile, gFile
+#include <TGeoBBox.h>      // for TGeoBBox
+#include <TGeoTube.h>      // for TGeoTube
+#include <TGeoManager.h>   // for TGeoManager, gGeoManager
+#include <TGeoNode.h>      // for TGeoNode
+#include <TGeoVolume.h>    // for TGeoVolume
+#include <TMath.h>         // for Cos, Sqrt
+#include <TObjArray.h>     // for TObjArray
+#include <TObject.h>       // for TObject
+#include <TVector3.h>      // for TVector3
+
+#include <cassert>    // for assert
+#include <stdexcept>  // for out_of_range
+#include <utility>    // for pair
+#include <vector>
+
+#include <math.h>  // for sqrt
+
+using std::vector;
+
+CbmMustGeoScheme* CbmMustGeoScheme::fInstance = nullptr;
+
+// -------------------------------------------------------------------------
+CbmMustGeoScheme::CbmMustGeoScheme()
+  : TObject()
+{
+  LOG(debug) << "CbmMustGeoScheme created";
+}
+// -------------------------------------------------------------------------
+
+// -------------------------------------------------------------------------
+CbmMustGeoScheme::~CbmMustGeoScheme()
+{
+
+  if (fInstance != nullptr) delete fInstance;
+}
+// -------------------------------------------------------------------------
+
+
+// -------------------------------------------------------------------------
+CbmMustGeoScheme* CbmMustGeoScheme::Instance()
+{
+
+  if (!fInstance) fInstance = new CbmMustGeoScheme();
+  return fInstance;
+}
+// -------------------------------------------------------------------------
+
+// -------------------------------------------------------------------------
+void CbmMustGeoScheme::Init(TObjArray* stations)
+{
+  if (!fInitialized) {
+    fStations = stations;
+    fInitialized = kTRUE;
+  }
+  LOG(debug) << "CbmMustGeoScheme init successful";
+}
+// -------------------------------------------------------------------------
+
+
+// -------------------------------------------------------------------------
+void CbmMustGeoScheme::Init(TString parFileName)
+{
+
+  /// Save old global file and folder pointer to avoid messing with FairRoot
+  TFile* oldFile     = gFile;
+  TDirectory* oldDir = gDirectory;
+
+  TFile* file         = new TFile(parFileName);
+  LOG_IF(fatal, !file) << "File " << parFileName << " does not exist";
+  TObjArray* stations = file->Get<TObjArray>("stations");
+  LOG_IF(fatal, !stations) << "No TObjArray stations found in file " << parFileName;
+  file->Close();
+  file->Delete();
+
+  /// Restore old global file and folder pointer to avoid messing with FairRoot
+  gFile      = oldFile;
+  gDirectory = oldDir;
+
+  Init(stations);
+}
+// -------------------------------------------------------------------------
+
+
+// -------------------------------------------------------------------------
+CbmMustStation* CbmMustGeoScheme::GetStation(int iStation) const
+{
+
+  if (!fStations) return nullptr;
+  Bool_t result = (iStation >= 0) || (iStation < fStations->GetEntriesFast());
+
+  return result ? (CbmMustStation*) fStations->At(iStation) : nullptr;
+}
+// -------------------------------------------------------------------------
+
+CbmMustStation* CbmMustGeoScheme::FindStation(int detid)
+{
+    if ( !fStations )
+        fStations = new TObjArray();
+    for (Int_t iobj = 0; iobj < fStations->GetEntriesFast(); iobj++) {
+        CbmMustStation* tempStation = (CbmMustStation*)(fStations->At(iobj));
+        if ( tempStation->GetDetectorId() == detid )
+            return tempStation;
+    }
+    return nullptr;
+}
+
+bool CbmMustGeoScheme::AddStation(CbmMustStation* station)
+{
+    for (Int_t iobj = 0; iobj < fStations->GetEntriesFast(); iobj++) {
+        CbmMustStation* tempStation = (CbmMustStation*)(fStations->At(iobj));
+        if ( tempStation->GetDetectorId() == station->GetDetectorId() )
+            return false;
+    }
+        
+    fStations->Add(station);
+    return true;
+}
+
+void CbmMustGeoScheme::Show() {
+    LOG(info) << "MustGeoScheme:";
+    for (Int_t iobj = 0; iobj < fStations->GetEntriesFast(); iobj++) {
+        CbmMustStation* tempStation = (CbmMustStation*)(fStations->At(iobj));
+        tempStation->Show();
+    }
+}
+
+// -------------------------------------------------------------------------
+void CbmMustGeoScheme::StoreGeoScheme()
+{
+
+  /// Save old global file and folder pointer to avoid messing with FairRoot
+  TFile* oldFile     = gFile;
+  TDirectory* oldDir = gDirectory;
+
+  std::string geoSchemeFileName("must_geoScheme.root");
+  TFile* file         = new TFile(geoSchemeFileName.c_str(),"recreate");
+  LOG_IF(fatal, !file) << "File " << geoSchemeFileName << " does not exist";
+  file->WriteObject(fStations,"stations");
+  //  fStations->Write();
+  file->Close();
+  file->Delete();
+
+  /// Restore old global file and folder pointer to avoid messing with FairRoot
+  gFile      = oldFile;
+  gDirectory = oldDir;
+}
+// -------------------------------------------------------------------------
+CbmMustLayer* CbmMustGeoScheme::GetLayer(int iStation, int iLayer) const
+{
+
+  CbmMustStation* station = GetStation(iStation);
+  return station ? station->GetLayer(iLayer) : nullptr;
+}
+// -------------------------------------------------------------------------
+
+// -------------------------------------------------------------------------
+void CbmMustGeoScheme::NavigateTo(const TString& path)
+{
+  gGeoManager->cd(path.Data());
+  //    fGeoPathHash;
+  //  fGeoPathHash      = path.Hash();
+  TGeoVolume* fCurrentVolume    = gGeoManager->GetCurrentVolume();
+  //  TGeoBBox*   fVolumeBoxShape   = (TGeoBBox*) fCurrentVolume->GetShape();
+  Double_t local[3] = {0., 0., 0.};
+  gGeoManager->LocalToMaster(local, fGlobal);
+  //  LOG(info) << "position: " << fGlobal[0] << "," << fGlobal[1] << "," << fGlobal[2];
+}
+// -------------------------------------------------------------------------
+
+ClassImp(CbmMustGeoScheme)
diff --git a/core/detectors/must/CbmMustGeoScheme.h b/core/detectors/must/CbmMustGeoScheme.h
new file mode 100644
index 000000000..f6f40858c
--- /dev/null
+++ b/core/detectors/must/CbmMustGeoScheme.h
@@ -0,0 +1,92 @@
+/* Copyright (C) 2004-2025 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
+   SPDX-License-Identifier: GPL-3.0-only
+   Authors: Radoslaw Karabowicz */
+
+// -------------------------------------------------------------------------
+// -----                   CbmMustGeoScheme header file                -----
+// -----                  Created 18/02/08  by E. Kryshen              -----
+// -----                  Modified 08/01/2025 by R. Karabowicz         -----
+// -------------------------------------------------------------------------
+
+/** CbmMustGeoScheme
+ *@author  R.Karabowicz <r.karabowicz@gsi.de>
+ *@version 1.0
+ *@since   2025.01.08
+ **
+ ** Based on CbmMuchGeoScheme by Evgeny Kryshen <e.kryshen@gsi.de>
+ **
+ **/
+
+#ifndef CbmMustGeoScheme_H
+#define CbmMustGeoScheme_H 1
+
+#include <Rtypes.h>      // for THashConsistencyHolder, ClassDef
+#include <RtypesCore.h>  // for Int_t, Double_t, Bool_t, Float_t, Char_t
+#include <TArrayC.h>     // for TArrayC
+#include <TArrayD.h>     // for TArrayD
+#include <TArrayI.h>     // for TArrayI
+#include <TGeoBBox.h>    // for TGeoBBox
+#include <TGeoCone.h>    // for TGeoCone
+#include <TObjArray.h>   // for TObjArray
+#include <TObject.h>     // for TObject
+#include <TString.h>     // for TString
+#include <TVector3.h>    // for TVector3
+
+#include <map>     // for map
+#include <vector>  // for vector
+
+class CbmMustLayer;
+class CbmMustModule;
+class CbmMustStation;
+class TGeoHMatrix;
+class TGeoNode;
+class TGeoTrap;
+class TGeoVolume;
+
+class CbmMustGeoScheme : public TObject {
+
+public:
+    /** Destructor.     */
+    ~CbmMustGeoScheme();
+    //void Init(Bool_t isSimulation = kFALSE);
+    static CbmMustGeoScheme* Instance();
+    /** Gets whether the geometry scheme is initialized. */
+    Bool_t IsInitialized() { return fInitialized; }
+
+    // Get geometry objects by indices
+    TObjArray* GetStations() const {return fStations;};
+    CbmMustStation* GetStation(int iStation) const;
+    CbmMustLayer* GetLayer(int iStation, int iLayer) const;
+
+    int GetNStations() const { return fStations->GetEntriesFast(); }
+
+    CbmMustStation* FindStation(int detid);
+    bool AddStation(CbmMustStation* station);
+    void Show();
+    void StoreGeoScheme();
+
+    void Init(TObjArray* stations);
+    void Init(TString parFileName);
+
+    void NavigateTo(const TString& path);
+    // void NavigateToBBox(const TString& path);
+    // void NavigateToTube(const TString& path);
+
+    TVector3 GetGlobal()  { return TVector3(fGlobal); }
+    
+private:
+    static CbmMustGeoScheme* fInstance;
+
+    CbmMustGeoScheme();
+
+    bool       fInitialized {false};
+    TObjArray* fStations    {nullptr};   //!
+    double     fGlobal[3]   {0.,0.,0.};
+    
+    CbmMustGeoScheme(const CbmMustGeoScheme&);
+    CbmMustGeoScheme& operator=(const CbmMustGeoScheme&);
+
+    ClassDef(CbmMustGeoScheme, 1);
+};
+
+#endif
diff --git a/core/detectors/must/CbmMustLayer.cxx b/core/detectors/must/CbmMustLayer.cxx
new file mode 100644
index 000000000..21bd3d780
--- /dev/null
+++ b/core/detectors/must/CbmMustLayer.cxx
@@ -0,0 +1,84 @@
+/* Copyright (C) 2004-2025 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
+   SPDX-License-Identifier: GPL-3.0-only
+   Authors: Radoslaw Karabowicz */
+
+/** CbmMustLayer.cxx
+ *@author  R.Karabowicz <r.karabowicz@gsi.de>
+ *@version 1.0
+ *@since   2025.01.08
+ **
+ ** This class holds the transport geometry parameters
+ ** of one MuST tracking layer.
+ ** Based on CbmMuchLayer by  M.Ryzhinskiy <m.ryzhinskiy@gsi.de>
+ **
+ **/
+#include "CbmMustLayer.h"
+
+#include <Logger.h>  // for LOG
+
+#include <TMathBase.h>  // for Abs
+#include <TObject.h>    // for TObject
+#include <TVector3.h>   // for TVector3
+
+// -----   Default constructor   -------------------------------------------
+CbmMustLayer::CbmMustLayer()
+  : TObject()
+{
+}
+// -------------------------------------------------------------------------
+
+// -----   Standard constructor   ------------------------------------------
+CbmMustLayer::CbmMustLayer(int detId, double z, double zRel)
+  : TObject()
+  , fDetectorId(detId)
+  , fZ(z)
+  , fZtoStationCenter(zRel)
+{
+}
+// -------------------------------------------------------------------------
+
+// -----   Standard constructor   ------------------------------------------
+CbmMustLayer::CbmMustLayer(int iStation, int iLayer, double z, double zRel)
+  : TObject()
+  , fDetectorId(iStation*1e7+iLayer*1e5)
+  , fZ(z)
+  , fZtoStationCenter(zRel)
+
+{
+}
+// -------------------------------------------------------------------------
+
+// -----   Destructor   ----------------------------------------------------
+CbmMustLayer::~CbmMustLayer() {}
+// -------------------------------------------------------------------------
+
+CbmMustModule* CbmMustLayer::FindModule(int detid)
+{
+    for (Int_t iobj = 0; iobj < fModules.GetEntriesFast(); iobj++) {
+        CbmMustModule* tempModule = (CbmMustModule*)(fModules.At(iobj));
+        if ( tempModule->GetDetectorId() == detid )
+            return tempModule;
+    }
+    return nullptr;
+}
+
+bool CbmMustLayer::AddModule(CbmMustModule* module) {
+    for (Int_t iobj = 0; iobj < fModules.GetEntriesFast(); iobj++) {
+        CbmMustModule* tempModule = (CbmMustModule*)(fModules.At(iobj));
+        if ( tempModule->GetDetectorId() == module->GetDetectorId() )
+            return false;
+    }
+        
+    fModules.Add(module);
+    return true;
+}
+
+void CbmMustLayer::Show() {
+    LOG(info) << "    Layer " << fDetectorId << " (@ z = " << fZ << "):";
+    for (Int_t iobj = 0; iobj < fModules.GetEntriesFast(); iobj++) {
+        CbmMustModule* tempModule = (CbmMustModule*)(fModules.At(iobj));
+        tempModule->Show();
+    }
+}
+
+ClassImp(CbmMustLayer)
diff --git a/core/detectors/must/CbmMustLayer.h b/core/detectors/must/CbmMustLayer.h
new file mode 100644
index 000000000..7f282b3f1
--- /dev/null
+++ b/core/detectors/must/CbmMustLayer.h
@@ -0,0 +1,72 @@
+/* Copyright (C) 2004-2025 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
+   SPDX-License-Identifier: GPL-3.0-only
+   Authors: Radoslaw Karabowicz */
+
+/** CbmMustLayer.h
+ *@author  R.Karabowicz <r.karabowicz@gsi.de>
+ *@version 1.0
+ *@since   2025.01.08
+ **
+ ** This class holds the transport geometry parameters
+ ** of one MuST tracking layer.
+ ** Based on CbmMuchLayer by  M.Ryzhinskiy <m.ryzhinskiy@gsi.de>
+ **
+ **/
+
+
+#ifndef CBMMUSTLAYER_H
+#define CBMMUSTLAYER_H 1
+
+#include <Rtypes.h>      // for THashConsistencyHolder, ClassDef
+#include <RtypesCore.h>  // for Double_t, Int_t, Bool_t, Double32_t
+#include <TObject.h>     // for TObject
+#include <TObjArray.h>   // for TObjArray
+#include "CbmMustModule.h"
+
+class CbmMustLayer : public TObject {
+
+public:
+    /** Default constructor **/
+    CbmMustLayer();
+
+    /** Standard constructor
+     *@param detId     Detector ID
+     *@param z         z position of layer center [cm]
+     *@param zRel      z position of layer center relative to station center [cm]
+     **/
+    CbmMustLayer(int detId, double z, double zRel);
+
+    /** Standard constructor
+     *@param iStation  Station index
+     *@param iLayer    Layer index
+     *@param z         z position of layer center [cm]
+     *@param zRel      z position of layer center relative to station center [cm]
+     **/
+    CbmMustLayer(int iStation, int iLayer, double z, double zRel);
+
+    /** Destructor **/
+    virtual ~CbmMustLayer();
+
+    /** Accessors **/
+    int GetDetectorId() const { return fDetectorId; }
+    double GetZ() const { return fZ; }
+    double GetZtoStationCenter() const { return fZtoStationCenter; }
+
+    int GetNModules() const { return fModules.GetEntriesFast(); }
+
+    CbmMustModule* GetModule(int iModule) const { return (CbmMustModule*) fModules.At(iModule); }
+
+    CbmMustModule* FindModule(int detid);
+    bool AddModule(CbmMustModule* module);
+    void Show();
+
+protected:
+    int fDetectorId {0};           // Unique detector ID
+    double fZ {0.};
+    double fZtoStationCenter {0.};  // Relative position of the layer center with respect
+                               // to the station center
+    TObjArray fModules;     // Array of CbmMustModules
+
+  ClassDef(CbmMustLayer, 1);
+};
+#endif
diff --git a/core/detectors/must/CbmMustModule.cxx b/core/detectors/must/CbmMustModule.cxx
new file mode 100644
index 000000000..2bd5689e3
--- /dev/null
+++ b/core/detectors/must/CbmMustModule.cxx
@@ -0,0 +1,80 @@
+/* Copyright (C) 2004-2025 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
+   SPDX-License-Identifier: GPL-3.0-only
+   Authors: Radoslaw Karabowicz */
+
+/** CbmMustModule.cxx
+ *@author  R.Karabowicz <r.karabowicz@gsi.de>
+ *@version 1.0
+ *@since   2025.01.08
+ **
+ ** This class holds geometry parameters of must modules
+ ** Based on CbmMuchModule by M.Ryzhinskiy <m.ryzhinskiy@gsi.de>
+ **
+ **/
+#include "CbmMustModule.h"
+
+#include <Logger.h>  // for LOG
+
+#include <TObject.h>     // for TObject
+#include <TVector3.h>  // for TVector3
+
+// -----   Default constructor   -------------------------------------------
+CbmMustModule::CbmMustModule()
+  : TObject()
+  , fDetectorId(0)
+  , fPosition(TVector3())
+  , fDirection(TVector3())
+{
+}
+// -------------------------------------------------------------------------
+
+
+// -----   Standard constructor   ------------------------------------------
+CbmMustModule::CbmMustModule(int iStation, int iLayer, int iModule, TVector3 position, TVector3 direction)
+  : TObject()
+  , fDetectorId(iStation*1e7+iLayer*1e5+iModule*1e3)
+  , fPosition(position)
+  , fDirection(direction)
+{
+}
+// -------------------------------------------------------------------------
+
+CbmMustTube* CbmMustModule::FindTube(int detid)
+{
+    for (Int_t iobj = 0; iobj < fTubes.GetEntriesFast(); iobj++) {
+        CbmMustTube* tempTube = (CbmMustTube*)(fTubes.At(iobj));
+        if ( tempTube->GetTubeNumber() == detid )
+            return tempTube;
+    }
+    return nullptr;
+}
+
+bool CbmMustModule::AddTube(CbmMustTube* tube) {
+    for (Int_t iobj = 0; iobj < fTubes.GetEntriesFast(); iobj++) {
+        CbmMustTube* tempTube = (CbmMustTube*)(fTubes.At(iobj));
+        if ( tempTube->GetTubeNumber() == tube->GetTubeNumber() )
+            return false;
+    }
+    fTubes.Add(tube);
+    return true;
+}
+
+void CbmMustModule::Show() {
+    LOG(info) << "      Module " << fDetectorId << " (@ (" << fPosition.X() << "," << fPosition.Y() << "," << fPosition.Z() << ") -> (" << fDirection.X() << "," << fDirection.Y() << "," << fDirection.Z() << "):";
+    std::string tubeString(128, '.');
+    std::string tubeNumbDec(128, '0');
+    std::string tubeNumbOne(128, '0');
+    for (Int_t iobj = 0; iobj < fTubes.GetEntriesFast(); iobj++) {
+        CbmMustTube* tempTube = (CbmMustTube*)(fTubes.At(iobj));
+        //        if ( iobj == 0 )
+            LOG(info) << "        Tube " << tempTube->GetDetectorId() << " @ " << tempTube->GetPosition().X() << "," << tempTube->GetPosition().Y() << "," << tempTube->GetPosition().Z();
+        tubeNumbDec[iobj] = char(tempTube->GetTubeNumber()/10+48);
+        tubeNumbOne[iobj] = char(tempTube->GetTubeNumber()%10+48);
+        tubeString[tempTube->GetTubeNumber()-1] = '*';
+    }
+    LOG(info) << "        Tubes " << tubeString;
+    LOG(info) << "            - " << tubeNumbDec;
+    LOG(info) << "            - " << tubeNumbOne;
+}
+
+ClassImp(CbmMustModule)
diff --git a/core/detectors/must/CbmMustModule.h b/core/detectors/must/CbmMustModule.h
new file mode 100644
index 000000000..777996e86
--- /dev/null
+++ b/core/detectors/must/CbmMustModule.h
@@ -0,0 +1,72 @@
+/* Copyright (C) 2004-2025 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
+   SPDX-License-Identifier: GPL-3.0-only
+   Authors: Radoslaw Karabowicz */
+
+/** CbmMustModule.h
+ *@author  R.Karabowicz <r.karabowicz@gsi.de>
+ *@version 1.0
+ *@since   2025.01.08
+ **
+ ** This class holds geometry parameters of must modules
+ ** Based on CbmMuchModule by M.Ryzhinskiy <m.ryzhinskiy@gsi.de>
+ **
+ **/
+
+#ifndef CBMMUSTMODULE_H
+#define CBMMUSTMODULE_H 1
+
+#include <Rtypes.h>      // for THashConsistencyHolder, ClassDef
+#include <RtypesCore.h>  // for Color_t
+#include <TObjArray.h>   // for TObjArray
+#include <TObject.h>       // for TObject
+#include <TVector3.h>    // for TVector3
+#include "CbmMustTube.h"
+
+#include <map>      // for multimap
+#include <utility>  // for pair
+
+class CbmMustModule : public TObject {
+public:
+    /** Default constructor **/
+    CbmMustModule();
+    /** Standard constructor
+     *@param iStation  Station index
+     *@param iLayer    Layer index
+     *@param iModule   Module index
+     *@param position  Location of the module center in global c.s. (all dimensions in [cm])
+     *@param direction Direction of the module
+     **/
+    CbmMustModule(int iStation, int iLayer, int iModule, TVector3 position, TVector3 direction);
+    /** Destructor **/
+    virtual ~CbmMustModule() {}
+
+    /** Accessors */
+    int GetDetectorId() const { return fDetectorId; }
+    TVector3 GetPosition() const { return fPosition; }
+    TVector3 GetDirection() const { return fDirection; }
+
+    int GetNTubes() const { return fTubes.GetEntriesFast(); }
+
+    CbmMustTube* GetTube(int iTube) const { return (CbmMustTube*) fTubes.At(iTube); }
+
+    CbmMustTube* FindTube(int detid);
+    bool AddTube(CbmMustTube* tube);
+    void SortTubes() { fTubes.Sort(); }
+    void Show();
+
+    virtual bool InitModule() { return kTRUE; }
+    virtual void DrawModule(Color_t) {}
+
+protected:
+    int fDetectorId;        // Unique detector ID
+    TVector3 fPosition;       // Location vector of the module center in global c.s. (all dimensions in [cm])
+    TVector3 fDirection;       // Direction vector of the module
+    TObjArray fTubes;     // Array of CbmMustTubes
+
+private:
+  CbmMustModule(const CbmMustModule&);
+  CbmMustModule& operator=(const CbmMustModule&);
+
+  ClassDef(CbmMustModule, 2);
+};
+#endif
diff --git a/core/detectors/must/CbmMustStation.cxx b/core/detectors/must/CbmMustStation.cxx
new file mode 100644
index 000000000..ea637e011
--- /dev/null
+++ b/core/detectors/must/CbmMustStation.cxx
@@ -0,0 +1,81 @@
+/* Copyright (C) 2004-2025 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
+   SPDX-License-Identifier: GPL-3.0-only
+   Authors: Radoslaw Karabowicz */
+
+/** CbmMustStation.cxx
+ *@author  R.Karabowicz <r.karabowicz@gsi.de>
+ *@version 1.0
+ *@since   2025.01.08
+ **
+ ** This class holds the transport geometry parameters
+ ** of one Must tracking station.
+ ** Based on CbmMuchStation by M.Ryzhinskiy <m.ryzhinskiy@gsi.de>
+ **/
+#include "CbmMustStation.h"
+
+#include "CbmMustLayer.h"    // for CbmMustLayer
+
+#include <Logger.h>  // for LOG
+
+#include <TMathBase.h>  // for Abs
+#include <TObjArray.h>  // for TObjArray
+
+// -----   Default constructor   -------------------------------------------
+CbmMustStation::CbmMustStation()
+  : TObject()
+  , fDetectorId(0)
+  , fZ(0.)
+  , fLayers()
+{
+}
+// -------------------------------------------------------------------------
+
+// -----   Standard constructor   ------------------------------------------
+CbmMustStation::CbmMustStation(int iStation, double z)
+  : TObject()
+  , fDetectorId(iStation*1e7)
+  , fZ(z)
+  , fLayers()
+{
+}
+// -------------------------------------------------------------------------
+
+// -----   Destructor   ----------------------------------------------------
+CbmMustStation::~CbmMustStation() {}
+// -------------------------------------------------------------------------
+
+// -----   Public method AddSector   ---------------------------------------
+CbmMustLayer* CbmMustStation::FindLayer(int detid)
+{
+    for (Int_t iobj = 0; iobj < fLayers.GetEntriesFast(); iobj++) {
+        CbmMustLayer* tempLayer = (CbmMustLayer*)(fLayers.At(iobj));
+        if ( tempLayer->GetDetectorId() == detid )
+            return tempLayer;
+    }
+    return nullptr;
+}
+// -------------------------------------------------------------------------
+
+// -----   Public method AddSector   ---------------------------------------
+bool CbmMustStation::AddLayer(CbmMustLayer* layer)
+{
+    for (Int_t iobj = 0; iobj < fLayers.GetEntriesFast(); iobj++) {
+        CbmMustLayer* tempLayer = (CbmMustLayer*)(fLayers.At(iobj));
+        if ( tempLayer->GetDetectorId() == layer->GetDetectorId() )
+            return false;
+    }
+
+    fLayers.Add(layer);
+    return true;
+}
+// -------------------------------------------------------------------------
+
+void CbmMustStation::Show() {
+    LOG(info) << "  Station " << fDetectorId << " (@ z = " << fZ << "):";
+    for (Int_t iobj = 0; iobj < fLayers.GetEntriesFast(); iobj++) {
+        CbmMustLayer* tempLayer = (CbmMustLayer*)(fLayers.At(iobj));
+        tempLayer->Show();
+    }
+}
+
+ClassImp(CbmMustStation)
diff --git a/core/detectors/must/CbmMustStation.h b/core/detectors/must/CbmMustStation.h
new file mode 100644
index 000000000..dcec28c37
--- /dev/null
+++ b/core/detectors/must/CbmMustStation.h
@@ -0,0 +1,60 @@
+/* Copyright (C) 2004-2025 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
+   SPDX-License-Identifier: GPL-3.0-only
+   Authors: Radoslaw Karabowicz */
+
+/** CbmMustStation.h
+ *@author  R.Karabowicz <r.karabowicz@gsi.de>
+ *@version 1.0
+ *@since   2025.01.08
+ **
+ ** This class holds the transport geometry parameters
+ ** of one Must tracking station.
+ ** Based on CbmMuchStation by M.Ryzhinskiy <m.ryzhinskiy@gsi.de>
+ **
+ **/
+
+
+#ifndef CBMMUSTSTATION_H
+#define CBMMUSTSTATION_H 1
+
+#include "CbmMustLayer.h"  // for CbmMustLayer
+
+#include <Rtypes.h>      // for THashConsistencyHolder, ClassDef
+#include <TObjArray.h>   // for TObjArray
+#include <TObject.h>     // for TObject
+
+class CbmMustStation : public TObject {
+public:
+  /** Default constructor **/
+  CbmMustStation();
+
+
+  /** Standard constructor
+  *@param iStation  Station index
+  *@param z         z position of station center in global cs [cm]
+  **/
+  CbmMustStation(int iStation, double z);
+
+
+  /** Destructor **/
+  virtual ~CbmMustStation();
+
+  /** Accessors **/
+  int GetDetectorId() const { return fDetectorId; }
+  double GetZ() const { return fZ; }
+  int GetNLayers() const { return fLayers.GetEntriesFast(); }
+
+  CbmMustLayer* GetLayer(int iLayer) const { return (CbmMustLayer*) fLayers.At(iLayer); }
+
+  /** Add one sector to the array **/
+    CbmMustLayer* FindLayer(int detid);
+    bool AddLayer(CbmMustLayer* layer);
+    void Show();
+
+protected:
+  int fDetectorId;     // Unique detector ID
+  double fZ;         // z position of station center (midplane) [cm] in global cs
+  TObjArray fLayers;     // Array of CbmMustLayers
+  ClassDef(CbmMustStation, 1);
+};
+#endif
diff --git a/core/detectors/must/CbmMustTube.cxx b/core/detectors/must/CbmMustTube.cxx
index 876245ff3..4b39cfb99 100644
--- a/core/detectors/must/CbmMustTube.cxx
+++ b/core/detectors/must/CbmMustTube.cxx
@@ -30,15 +30,15 @@ CbmMustTube::CbmMustTube() : fCenPosition(TVector3(0, 0, 0)), fRotationMatrix(TM
 }
 
 CbmMustTube::CbmMustTube(CbmMustTube &tube)
-  : TObject(tube), fCenPosition(tube.GetPosition()), fRotationMatrix(TMatrixT<double>(3, 3)), fRadIn(tube.GetRadIn()), fRadOut(tube.GetRadOut()), fHalfLength(tube.GetHalfLength())
+    : TObject(tube), fTubeNumber(tube.GetTubeNumber()), fCenPosition(tube.GetPosition()), fRotationMatrix(TMatrixT<double>(3, 3)), fRadIn(tube.GetRadIn()), fRadOut(tube.GetRadOut()), fHalfLength(tube.GetHalfLength())
 {
   fRotationMatrix.ResizeTo(3, 3);
   fRotationMatrix = tube.GetRotationMatrix();
 }
 
-CbmMustTube::CbmMustTube(Double_t x, Double_t y, Double_t z, Double_t r11, Double_t r12, Double_t r13, Double_t r21, Double_t r22, Double_t r23, Double_t r31, Double_t r32,
+CbmMustTube::CbmMustTube(int detectorId, int tubeNumber, Double_t x, Double_t y, Double_t z, Double_t r11, Double_t r12, Double_t r13, Double_t r21, Double_t r22, Double_t r23, Double_t r31, Double_t r32,
                      Double_t r33, Double_t radin, Double_t radout, Double_t hl)
-  : fCenPosition(TVector3(x, y, z)), fRotationMatrix(TMatrixT<double>(3, 3)), fRadIn(radin), fRadOut(radout), fHalfLength(hl)
+    : fDetectorId(detectorId), fTubeNumber(tubeNumber), fCenPosition(TVector3(x, y, z)), fRotationMatrix(TMatrixT<double>(3, 3)), fRadIn(radin), fRadOut(radout), fHalfLength(hl)
 {
 
   fRotationMatrix[0][0] = r11;
@@ -90,4 +90,12 @@ TVector3 CbmMustTube::GetWireDirection() const
   return TVector3(fRotationMatrix[0][2], fRotationMatrix[1][2], fRotationMatrix[2][2]);
 }
 
+Int_t CbmMustTube::Compare(const TObject *obj) const {
+    if ( ((CbmMustTube*)obj)->GetTubeNumber() == this->GetTubeNumber() )
+        return 0;
+    if ( ((CbmMustTube*)obj)->GetTubeNumber() < this->GetTubeNumber() )
+        return 1;
+    return -1;
+}
+
 ClassImp(CbmMustTube)
diff --git a/core/detectors/must/CbmMustTube.h b/core/detectors/must/CbmMustTube.h
index 224547f5f..71f189c3a 100644
--- a/core/detectors/must/CbmMustTube.h
+++ b/core/detectors/must/CbmMustTube.h
@@ -20,30 +20,37 @@
 
 class CbmMustTube : public TObject {
 
- public:
-  /** Default constructor **/
-  CbmMustTube();
-  CbmMustTube(CbmMustTube &tube);
-
-  ~CbmMustTube();
-  CbmMustTube(Double_t x, Double_t y, Double_t z, Double_t r11, Double_t r12, Double_t r13, Double_t r21, Double_t r22, Double_t r23, Double_t r31, Double_t r32, Double_t r33,
-            Double_t radin, Double_t radout, Double_t hl);
-
-  TVector3 GetPosition() const;
-  TMatrixT<Double_t> GetRotationMatrix() const;
-  Double_t GetRadIn() const;
-  Double_t GetRadOut() const;
-  Double_t GetHalfLength() const;
-  TVector3 GetWireDirection() const;
-
-  bool IsSkew() const { return (0. != GetWireDirection().X()); }
-
- private:
-  TVector3 fCenPosition;
-  TMatrixT<double> fRotationMatrix;
-  Double_t fRadIn, fRadOut, fHalfLength;
-
-  ClassDef(CbmMustTube, 1);
+public:
+    /** Default constructor **/
+    CbmMustTube();
+    CbmMustTube(CbmMustTube &tube);
+
+    ~CbmMustTube();
+    CbmMustTube(int detectorId, int tubeNumber, Double_t x, Double_t y, Double_t z, Double_t r11, Double_t r12, Double_t r13, Double_t r21, Double_t r22, Double_t r23, Double_t r31, Double_t r32, Double_t r33,
+                Double_t radin, Double_t radout, Double_t hl);
+
+    int GetDetectorId() const {return fDetectorId;}
+    int GetTubeNumber() const {return fTubeNumber;}
+    TVector3 GetPosition() const;
+    TMatrixT<Double_t> GetRotationMatrix() const;
+    Double_t GetRadIn() const;
+    Double_t GetRadOut() const;
+    Double_t GetHalfLength() const;
+    TVector3 GetWireDirection() const;
+
+    bool IsSkew() const { return (0. != GetWireDirection().X()); }
+
+    Int_t Compare(const TObject *obj) const override;
+    Bool_t IsSortable() const override {return kTRUE;}
+
+private:
+    int fDetectorId {0};
+    int fTubeNumber {0};
+    TVector3 fCenPosition;
+    TMatrixT<double> fRotationMatrix;
+    Double_t fRadIn, fRadOut, fHalfLength;
+
+    ClassDef(CbmMustTube, 1);
 };
 
 #endif
-- 
GitLab


From 3f4dc0cc222bed656764db8bffe64915eea08cdb Mon Sep 17 00:00:00 2001
From: Radoslaw Karabowicz <r.karabowicz@gsi.de>
Date: Thu, 30 Jan 2025 11:22:34 +0100
Subject: [PATCH 05/16] feat(must): Add way to generate MUST parameters during
 simulation

The CbmMust class is now able to produce CbmMustGeoScheme
while running simulation.
Currenty works only for the mcbm setup.
The functionality is disable on default.
---
 sim/detectors/must/CbmMust.cxx | 134 +++++++++++++++++++++++----------
 sim/detectors/must/CbmMust.h   |   4 +-
 2 files changed, 95 insertions(+), 43 deletions(-)

diff --git a/sim/detectors/must/CbmMust.cxx b/sim/detectors/must/CbmMust.cxx
index 59f3eee44..df2be2ed6 100644
--- a/sim/detectors/must/CbmMust.cxx
+++ b/sim/detectors/must/CbmMust.cxx
@@ -14,9 +14,14 @@
 
 #include "CbmMust.h"
 // from CbmRoot, this library
+#include "CbmDefs.h"
 #include "CbmGeoMustPar.h"
 #include "CbmGeoMust.h"
-#include "CbmDefs.h"
+#include "CbmMustGeoScheme.h"
+#include "CbmMustStation.h"
+#include "CbmMustLayer.h"
+#include "CbmMustModule.h"
+#include "CbmMustTube.h"
 #include "CbmStack.h"
 // from CbmRoot
 #include "CbmGeometryUtils.h"
@@ -99,40 +104,6 @@ float CbmMust::GetSquaredDistanceFromWire()
 }
 // -------------------------------------------------------------------------
 
-bool CbmMust::Split(string &aDest, string &aSrc, char aDelim)
-{
-  if (aSrc.empty())
-    return false;
-
-  string::size_type pos = aSrc.find(aDelim);
-
-  aDest = aSrc.substr(0, pos);
-
-  if (pos != string::npos)
-    aSrc = aSrc.substr(pos + 1);
-  else
-    aSrc = "";
-
-  return true;
-}
-
-string CbmMust::GetStringPart(string &aSrc, Int_t part, char aDelim)
-{
-  string retval = "", sub;
-
-  int counter = 0;
-
-  while (Split(sub, aSrc, aDelim)) {
-    if (counter == part) {
-      retval = sub;
-      break;
-    }
-    counter++;
-  }
-
-  return retval;
-}
-
 // -----   Public method ProcessHits  --------------------------------------
 Bool_t CbmMust::ProcessHits(FairVolume *vol)
 {
@@ -145,7 +116,7 @@ Bool_t CbmMust::ProcessHits(FairVolume *vol)
   TGeoHMatrix M;
   gMC->GetTransformation(gMC->CurrentVolPath(), M);
   TString name(gMC->CurrentVolName());
-
+  //  LOG(info) << "\"" << gMC->CurrentVolPath() << "\" - \"" << gMC->CurrentVolName() << "\"";
   if (gMC->TrackCharge() != 0.) {
 
     if (gMC->IsTrackEntering()) {
@@ -208,10 +179,70 @@ Bool_t CbmMust::ProcessHits(FairVolume *vol)
       fpostot.SetXYZM((fpostotin.X() + fpostotout.X()) / 2., (fpostotin.Y() + fpostotout.Y()) / 2., (fpostotin.Z() + fpostotout.Z()) / 2., 0.0);
 
       LOG(debug) << " --> " << volPath;
-      volPath = volPath.substr(volPath.find("strawAssembly_")+14,8);
-      int layerId   = atoi(volPath.substr(1,2).c_str());
-      int moduleId  = atoi(volPath.substr(3,2).c_str());
-      int strawId   = atoi(volPath.substr(5,3).c_str());
+      string strawName = volPath.substr(volPath.find("strawAssembly_")+14,8);
+      int statId    = 1;
+      int layerId   = atoi(strawName.substr(1,2).c_str());
+      int moduleId  = atoi(strawName.substr(3,2).c_str());
+      int strawId   = atoi(strawName.substr(5,3).c_str());
+
+      if ( 1 == 0 ) {
+          CbmMustGeoScheme* mustGeoScheme = CbmMustGeoScheme::Instance();
+          // add station
+          int detId = statId*1e7;
+          CbmMustStation* mustStation = mustGeoScheme->FindStation(detId);
+          if ( !mustStation ) {
+              LOG(info) << "STATION --> " << volPath;
+              string statPath = volPath.substr(0,volPath.find("/layer"));
+              LOG(info) << "STATION --> " << statPath;
+              mustGeoScheme->NavigateTo(statPath);
+              TVector3 globPos = mustGeoScheme->GetGlobal();
+              mustStation = new CbmMustStation(statId,globPos[2]); // change z!
+          }
+          mustGeoScheme->AddStation(mustStation);
+          // add layer
+          detId = detId + layerId*1e5;
+          CbmMustLayer* mustLayer = mustStation->FindLayer(detId);
+          if ( !mustLayer ) {
+              LOG(info) << "LAYER --> " << volPath;
+              string layerPath = volPath.substr(0,volPath.find("/module"));
+              LOG(info) << "LAYER --> " << layerPath;
+              mustGeoScheme->NavigateTo(volPath);
+              TVector3 globPos = mustGeoScheme->GetGlobal();
+              mustLayer = new CbmMustLayer(statId,layerId,globPos[2],globPos[2]-mustStation->GetZ());
+          }
+          mustStation->AddLayer(mustLayer);
+          // add module
+          detId = detId + moduleId*1e3;
+          CbmMustModule* mustModule = mustLayer->FindModule(detId);
+          TVector3 directionVector(0.,1.,0.);
+          if ( layerId == 2 || layerId == 3 ) {
+              double angle = 5.*TMath::DegToRad();
+              if ( layerId == 3 ) angle = -angle;
+              directionVector[0] = TMath::Sin(angle);
+              directionVector[1] = TMath::Cos(angle);
+          }
+          if ( !mustModule ) {
+              mustGeoScheme->NavigateTo(volPath);
+              TVector3 globPos = mustGeoScheme->GetGlobal();
+              mustModule = new CbmMustModule(statId,layerId,moduleId,globPos,directionVector);
+          }
+          mustLayer->AddModule(mustModule);
+          // add tube
+          detId = detId + strawId;
+          CbmMustTube* mustTube = mustModule->FindTube(detId);
+          if ( !mustTube ) {
+              mustGeoScheme->NavigateTo(volPath);
+              TVector3 globPos = mustGeoScheme->GetGlobal();
+              mustTube = new CbmMustTube(detId,strawId,
+                                         globPos[0],globPos[1],globPos[2],
+                                         directionVector[1],-directionVector[0],0.,
+                                         directionVector[0], directionVector[1],0.,
+                                         0.,0.,1.,
+                                         0.0127,0.49,110.);
+          }
+          mustModule->AddTube(mustTube);
+      }
+
       LOG(debug) <<  " l/m/t = " << layerId << "/" << moduleId << "/" << strawId;
 
       AddHit(fTrackID, fVolumeID, layerId, moduleId, strawId, TVector3(fpostot.X(), fpostot.Y(), fpostot.Z()), TVector3(fPosInLocal.X(), fPosInLocal.Y(), fPosInLocal.Z()),
@@ -241,6 +272,29 @@ void CbmMust::EndOfEvent()
     Print();
   fMustCollection->Delete();
   fPosIndex = 0;
+
+  if ( 1 == 0 ) {
+      int nofTubes = 0;
+      TObjArray* stations = CbmMustGeoScheme::Instance()->GetStations();
+      for (Int_t iobj = 0; iobj < stations->GetEntriesFast(); iobj++) {
+          CbmMustStation* tempStation = (CbmMustStation*)(stations->At(iobj));
+          for ( int ilay = 0 ; ilay < tempStation->GetNLayers() ; ilay++ ) {
+              CbmMustLayer* tempLayer = tempStation->GetLayer(ilay);
+              for ( int imod = 0 ; imod < tempLayer->GetNModules() ; imod++ ) {
+                  CbmMustModule* tempModule = tempLayer->GetModule(imod);
+                  tempModule->SortTubes();
+                  nofTubes += tempModule->GetNTubes();
+              }
+          }
+      }
+
+      LOG(info) << "got " << nofTubes << " tubes";
+      if ( nofTubes == 256 && !fGeoSchemeSaved ) {
+          CbmMustGeoScheme::Instance()->Show();
+          CbmMustGeoScheme::Instance()->StoreGeoScheme();
+          fGeoSchemeSaved = true;
+      }
+  }
 }
 // -------------------------------------------------------------------------
 
diff --git a/sim/detectors/must/CbmMust.h b/sim/detectors/must/CbmMust.h
index 825e87cdd..03b6269e2 100644
--- a/sim/detectors/must/CbmMust.h
+++ b/sim/detectors/must/CbmMust.h
@@ -140,6 +140,7 @@ class CbmMust : public FairDetector {
   // geometry type
   Bool_t valid;
   Int_t fGeoType;
+    bool fGeoSchemeSaved{false};
 
   /** Private method AddHit
    **
@@ -148,9 +149,6 @@ class CbmMust : public FairDetector {
   CbmMustPoint *AddHit(Int_t trackID, Int_t detID, Int_t layID, Int_t modID, Int_t strID, TVector3 pos, TVector3 posInLocal, TVector3 posOutLocal, TVector3 momIn,
                        TVector3 momOut, Double_t time, Double_t length, Double_t eLoss, Double_t mass);
 
-  std::string GetStringPart(std::string &aSrc, Int_t part, char aDelim);
-  bool Split(std::string &aDest, std::string &aSrc, char aDelim);
-
   /** Private method ResetParameters
    **
    ** Resets the private members for the track parameters
-- 
GitLab


From 130c6d432799c4eeed5f6b698f6cf53de375213f Mon Sep 17 00:00:00 2001
From: Radoslaw Karabowicz <r.karabowicz@gsi.de>
Date: Wed, 26 Feb 2025 15:57:59 +0100
Subject: [PATCH 06/16] feat(must): Implement fAddress to CbmMustPoint and use
 it

Add fAddress to the CbmMustPoint, changed constructors
and getters.
Changed CbmMustGeoScheme and CbmMust to use it.
Applied format to many files.
---
 core/data/must/CbmMustPoint.cxx          |  77 +++--
 core/data/must/CbmMustPoint.h            |  49 ++-
 core/detectors/must/CbmGeoMust.cxx       |   6 +-
 core/detectors/must/CbmGeoMust.h         |  14 +-
 core/detectors/must/CbmGeoMustPar.cxx    |  36 ++-
 core/detectors/must/CbmGeoMustPar.h      |  29 +-
 core/detectors/must/CbmMustContFact.cxx  |  16 +-
 core/detectors/must/CbmMustContFact.h    |   4 +-
 core/detectors/must/CbmMustGeoScheme.cxx | 105 ++++---
 core/detectors/must/CbmMustGeoScheme.h   |  75 ++---
 core/detectors/must/CbmMustLayer.cxx     |  61 ++--
 core/detectors/must/CbmMustLayer.h       |  60 ++--
 core/detectors/must/CbmMustModule.cxx    |  80 +++--
 core/detectors/must/CbmMustModule.h      |  59 ++--
 core/detectors/must/CbmMustStation.cxx   |  67 ++--
 core/detectors/must/CbmMustStation.h     |  31 +-
 core/detectors/must/CbmMustTube.cxx      |  72 ++---
 core/detectors/must/CbmMustTube.h        |  69 ++---
 macro/must/run_sim.C                     |  25 +-
 sim/detectors/must/CbmMust.cxx           | 372 +++++++++++++----------
 sim/detectors/must/CbmMust.h             |  80 ++---
 21 files changed, 749 insertions(+), 638 deletions(-)

diff --git a/core/data/must/CbmMustPoint.cxx b/core/data/must/CbmMustPoint.cxx
index 71c0b0636..155de2cac 100644
--- a/core/data/must/CbmMustPoint.cxx
+++ b/core/data/must/CbmMustPoint.cxx
@@ -10,30 +10,54 @@
 #include "CbmMustPoint.h"
 
 #include "CbmDefs.h"  // for kMCTrack
+#include "FairLogger.h"
+#include "math.h"
 
 #include <FairLink.h>     // for FairLink
 #include <FairMCPoint.h>  // for FairMCPoint
 
 #include <iostream>
-#include "math.h"
-#include "FairLogger.h"
 using std::cout;
 using std::endl;
 
 // -----   Default constructor   -------------------------------------------
 CbmMustPoint::CbmMustPoint()
-  : FairMCPoint(), fX_out_local(0), fY_out_local(0), fZ_out_local(0), fX_in_local(0.), fY_in_local(0), fZ_in_local(0), fPx_out(0), fPy_out(0), fPz_out(0), fPx_in(0), fPy_in(0),
-    fPz_in(0), fMass(0), fLayerID(0), fModuleID(0), fStrawID(0)
+  : FairMCPoint()
+  , fX_out_local(0)
+  , fY_out_local(0)
+  , fZ_out_local(0)
+  , fX_in_local(0.)
+  , fY_in_local(0)
+  , fZ_in_local(0)
+  , fPx_out(0)
+  , fPy_out(0)
+  , fPz_out(0)
+  , fPx_in(0)
+  , fPy_in(0)
+  , fPz_in(0)
+  , fAddress(0)
 {
 }
 // -------------------------------------------------------------------------
 
 // -----   Standard constructor   ------------------------------------------
-CbmMustPoint::CbmMustPoint(Int_t trackID, Int_t detID, Int_t layerID, Int_t moduleID, Int_t strawID, TVector3 pos, TVector3 posInLocal, TVector3 posOutLocal, TVector3 momIn,
-                         TVector3 momOut, Double_t tof, Double_t length, Double_t eLoss, Double_t mass)
-  : FairMCPoint(trackID, detID, pos, momIn, tof, length, eLoss), fX_out_local(posOutLocal.X()), fY_out_local(posOutLocal.Y()), fZ_out_local(posOutLocal.Z()),
-    fX_in_local(posInLocal.X()), fY_in_local(posInLocal.Y()), fZ_in_local(posInLocal.Z()), fPx_out(momOut.Px()), fPy_out(momOut.Py()), fPz_out(momOut.Pz()), fPx_in(momIn.Px()),
-    fPy_in(momIn.Py()), fPz_in(momIn.Pz()), fMass(mass), fLayerID(layerID), fModuleID(moduleID), fStrawID(strawID)
+CbmMustPoint::CbmMustPoint(Int_t trackID, Int_t detID, uint32_t address, TVector3 pos, TVector3 posInLocal,
+                           TVector3 posOutLocal, TVector3 momIn, TVector3 momOut, Double_t tof, Double_t length,
+                           Double_t eLoss)
+  : FairMCPoint(trackID, detID, pos, momIn, tof, length, eLoss)
+  , fX_out_local(posOutLocal.X())
+  , fY_out_local(posOutLocal.Y())
+  , fZ_out_local(posOutLocal.Z())
+  , fX_in_local(posInLocal.X())
+  , fY_in_local(posInLocal.Y())
+  , fZ_in_local(posInLocal.Z())
+  , fPx_out(momOut.Px())
+  , fPy_out(momOut.Py())
+  , fPz_out(momOut.Pz())
+  , fPx_in(momIn.Px())
+  , fPy_in(momIn.Py())
+  , fPz_in(momIn.Pz())
+  , fAddress(address)
 {
   // reset MC momentum
   fPx = (momIn.Px() + momOut.Px()) / 2.;
@@ -48,24 +72,35 @@ CbmMustPoint::~CbmMustPoint() {}
 // -------------------------------------------------------------------------
 
 // -----   Copy constructor   ------------------------------------------
-CbmMustPoint::CbmMustPoint(const CbmMustPoint &point)
-  : FairMCPoint(point.fTrackID, point.fDetectorID, TVector3(point.fX, point.fY, point.fZ), TVector3(point.fPx, point.fPy, point.fPz), point.fTime, point.fLength, point.fELoss,
-                point.fEventId),
-    fX_out_local(point.fX_out_local), fY_out_local(point.fY_out_local), fZ_out_local(point.fZ_out_local), fX_in_local(point.fX_in_local), fY_in_local(point.fY_in_local),
-    fZ_in_local(point.fZ_in_local), fPx_out(point.fPx_out), fPy_out(point.fPy_out), fPz_out(point.fPz_out), fPx_in(point.fPx_in), fPy_in(point.fPy_in), fPz_in(point.fPz_in),
-    fMass(point.fMass), fLayerID(point.fLayerID), fModuleID(point.fModuleID), fStrawID(point.fStrawID)
+CbmMustPoint::CbmMustPoint(const CbmMustPoint& point)
+  : FairMCPoint(point.fTrackID, point.fDetectorID, TVector3(point.fX, point.fY, point.fZ),
+                TVector3(point.fPx, point.fPy, point.fPz), point.fTime, point.fLength, point.fELoss, point.fEventId)
+  , fX_out_local(point.fX_out_local)
+  , fY_out_local(point.fY_out_local)
+  , fZ_out_local(point.fZ_out_local)
+  , fX_in_local(point.fX_in_local)
+  , fY_in_local(point.fY_in_local)
+  , fZ_in_local(point.fZ_in_local)
+  , fPx_out(point.fPx_out)
+  , fPy_out(point.fPy_out)
+  , fPz_out(point.fPz_out)
+  , fPx_in(point.fPx_in)
+  , fPy_in(point.fPy_in)
+  , fPz_in(point.fPz_in)
+  , fAddress(point.fAddress)
 {
 }
 // -------------------------------------------------------------------------
 
 // -----   Public method Print   -------------------------------------------
-void CbmMustPoint::Print(const Option_t *opt) const
+void CbmMustPoint::Print(const Option_t* opt) const
 {
-    LOG(info) << " CbmMustPoint: MUST Point for track " << fTrackID << " in det/lay/mod/str " << fDetectorID << "/" << fLayerID << "/" << fModuleID << "/" << fStrawID;
-    LOG(info) << "    Position (" << fX << ", " << fY << ", " << fZ << ") cm";
-    LOG(info) << "    Momentum (" << fPx << ", " << fPy << ", " << fPz << ") GeV";
-    LOG(info) << "    Time " << fTime << " ns,  Length " << fLength << " cm,  Energy loss " << fELoss * 1.0e06 << " keV"
-              << " opt=" << opt;
+  LOG(info) << " CbmMustPoint: MUST Point for track " << fTrackID << " in det/lay/mod/str " << fDetectorID << " / "
+            << fAddress;
+  LOG(info) << "    Position (" << fX << ", " << fY << ", " << fZ << ") cm";
+  LOG(info) << "    Momentum (" << fPx << ", " << fPy << ", " << fPz << ") GeV";
+  LOG(info) << "    Time " << fTime << " ns,  Length " << fLength << " cm,  Energy loss " << fELoss * 1.0e06 << " keV"
+            << " opt=" << opt;
 }
 // -------------------------------------------------------------------------
 
diff --git a/core/data/must/CbmMustPoint.h b/core/data/must/CbmMustPoint.h
index a0a1f99cd..8ed3d760d 100644
--- a/core/data/must/CbmMustPoint.h
+++ b/core/data/must/CbmMustPoint.h
@@ -10,9 +10,9 @@
 #ifndef CBMMUSTPOINT_H
 #define CBMMUSTPOINT_H
 
+#include "FairMCPoint.h"
 #include "TObject.h"
 #include "TVector3.h"
-#include "FairMCPoint.h"
 
 class CbmMustPoint : public FairMCPoint {
 
@@ -23,9 +23,7 @@ class CbmMustPoint : public FairMCPoint {
   /** Constructor with arguments
    *@param trackID       Index of MCTrack
    *@param detID         Detector ID
-   *@param LayerID       MUST layerID (1...12)
-   *@param moduleID      moduleID in layer (1...36)
-   *@param strawID       strawID in module (1...128)
+   *@param address       Detector address   
    *@param pos           Coordinates at wire center of active volume [cm]
    *@param posInLocal    Local coordinates at entrance to active volume [cm]
    *@param posOutLocal   Local coordinates at exit of active volume [cm]
@@ -35,11 +33,11 @@ class CbmMustPoint : public FairMCPoint {
    *@param length        Track length since creation [cm]
    *@param eLoss         Energy deposit [GeV]
    **/
-  CbmMustPoint(Int_t trackID, Int_t detID, Int_t layerID, Int_t moduleID, Int_t strawID, TVector3 pos, TVector3 posInLocal, TVector3 posOutLocal, TVector3 momIn, TVector3 momOut,
-              Double_t tof, Double_t length, Double_t eLoss, Double_t mass);
+  CbmMustPoint(Int_t trackID, Int_t detID, uint32_t address, TVector3 pos, TVector3 posInLocal, TVector3 posOutLocal,
+               TVector3 momIn, TVector3 momOut, Double_t tof, Double_t length, Double_t eLoss);
 
   /** Copy constructor **/
-  CbmMustPoint(const CbmMustPoint &point);
+  CbmMustPoint(const CbmMustPoint& point);
 
   /** Destructor **/
   virtual ~CbmMustPoint();
@@ -67,11 +65,9 @@ class CbmMustPoint : public FairMCPoint {
   // Double_t GetYWireDirection() const { return fY_wire_dir; }
   // Double_t GetZWireDirection() const { return fZ_wire_dir; }
 
-  Double_t GetMass() const { return fMass; }
-
-  void PositionOutLocal(TVector3 &pos) { pos.SetXYZ(fX_out_local, fY_out_local, fZ_out_local); }
-  void PositionInLocal(TVector3 &pos) { pos.SetXYZ(fX_in_local, fY_in_local, fZ_in_local); }
-  void MomentumOut(TVector3 &mom) { mom.SetXYZ(fPx_out, fPy_out, fPz_out); }
+  void PositionOutLocal(TVector3& pos) { pos.SetXYZ(fX_out_local, fY_out_local, fZ_out_local); }
+  void PositionInLocal(TVector3& pos) { pos.SetXYZ(fX_in_local, fY_in_local, fZ_in_local); }
+  void MomentumOut(TVector3& mom) { mom.SetXYZ(fPx_out, fPy_out, fPz_out); }
   // void WireDirection(TVector3& wire) { wire.SetXYZ(fX_wire_dir, fY_wire_dir, fZ_wire_dir); }
 
   /** Modifiers **/
@@ -80,16 +76,13 @@ class CbmMustPoint : public FairMCPoint {
   void SetMomentumOut(TVector3 mom);
   // void SetWireDirection(TVector3 wire);
 
-  // tube ID // CHECK added
-  Int_t GetLayerID () { return fLayerID; }
-  Int_t GetModuleID() { return fModuleID; }
-  Int_t GetStrawID () { return fStrawID; }
-  void  SetLayerID (Int_t layerid)  { fLayerID  = layerid;  }
-  void  SetModuleID(Int_t moduleid) { fModuleID = moduleid; }
-  void  SetStrawID (Int_t strawid)  { fStrawID  = strawid;  }
+  Int_t GetStationId() const { return (fAddress >> 26) & 15; }
+  Int_t GetLayerId() const { return (fAddress >> 24) & 3; }
+  Int_t GetModuleId() const { return (fAddress >> 18) & 63; }
+  Int_t GetStrawId() const { return (fAddress >> 11) & 127; }
 
   /** Output to screen **/
-  virtual void Print(const Option_t *opt) const;
+  virtual void Print(const Option_t* opt) const;
 
  protected:
   // exit coordinates in straw frame
@@ -99,14 +92,14 @@ class CbmMustPoint : public FairMCPoint {
 
   Double_t fPx_out, fPy_out, fPz_out;
   Double_t fPx_in, fPy_in, fPz_in;
-  // wire direction
-  // Double_t fX_wire_dir, fY_wire_dir, fZ_wire_dir;
-
-  // particle mass
-  Double_t fMass;
-  Int_t fLayerID;
-  Int_t fModuleID;
-  Int_t fStrawID;
+
+  // Address composition:
+  //  4 bits  0 -  3    kMust ???
+  //  2 bits  4 -  5    station id (0...3)
+  //  2 bits  6 -  7    layer id (0...3) in module
+  //  6 bits  8 - 13    module id (0...63) in layer
+  //  7 bits 14 - 20    straw id (0...127) in straw
+  uint32_t fAddress{0};
 
   //////
 
diff --git a/core/detectors/must/CbmGeoMust.cxx b/core/detectors/must/CbmGeoMust.cxx
index 68f7f7465..8916dbf1a 100644
--- a/core/detectors/must/CbmGeoMust.cxx
+++ b/core/detectors/must/CbmGeoMust.cxx
@@ -23,12 +23,12 @@ ClassImp(CbmGeoMust)
   CbmGeoMust::CbmGeoMust()
 {
   // Constructor
-  fName = "must";
+  fName      = "must";
   maxSectors = 0;
   maxModules = 40;
 }
 
-const char *CbmGeoMust::getModuleName(Int_t m)
+const char* CbmGeoMust::getModuleName(Int_t m)
 {
   // Returns the module name of MUST number m
   modName = fmt::format("must{:02d}", m + 1);
@@ -36,7 +36,7 @@ const char *CbmGeoMust::getModuleName(Int_t m)
   return modName.c_str();
 }
 
-const char *CbmGeoMust::getEleName(Int_t m)
+const char* CbmGeoMust::getEleName(Int_t m)
 {
   // Returns the element name of MUST number m
   eleName = fmt::format("must{:02d}", m + 1);
diff --git a/core/detectors/must/CbmGeoMust.h b/core/detectors/must/CbmGeoMust.h
index 95dadf489..eadd01cca 100644
--- a/core/detectors/must/CbmGeoMust.h
+++ b/core/detectors/must/CbmGeoMust.h
@@ -20,18 +20,18 @@
 
 class CbmGeoMust : public FairGeoSet {
  protected:
-  std::string modName; // name of module
-  std::string eleName; // substring for elements in module
+  std::string modName;  // name of module
+  std::string eleName;  // substring for elements in module
  public:
   CbmGeoMust();
   ~CbmGeoMust() {}
-  const char *getModuleName(Int_t);
-  const char *getEleName(Int_t);
-  inline Int_t getModNumInMod(const TString &);
-  ClassDef(CbmGeoMust, 0) // Class for Must
+  const char* getModuleName(Int_t);
+  const char* getEleName(Int_t);
+  inline Int_t getModNumInMod(const TString&);
+  ClassDef(CbmGeoMust, 0)  // Class for Must
 };
 
-inline Int_t CbmGeoMust::getModNumInMod(const TString &name)
+inline Int_t CbmGeoMust::getModNumInMod(const TString& name)
 {
   // returns the module index from module name
 
diff --git a/core/detectors/must/CbmGeoMustPar.cxx b/core/detectors/must/CbmGeoMustPar.cxx
index 1d88b58f3..2f6e228e1 100644
--- a/core/detectors/must/CbmGeoMustPar.cxx
+++ b/core/detectors/must/CbmGeoMustPar.cxx
@@ -16,13 +16,18 @@
 // from FairRoot
 #include <FairParamList.h>
 // standard
-#include <iostream>
 #include <iomanip>
+#include <iostream>
 
 ClassImp(CbmGeoMustPar)
 
-  CbmGeoMustPar::CbmGeoMustPar(const char *name, const char *title, const char *context)
-  : FairParGenericSet(name, title, context), fGeoSensNodes(new TObjArray()), fGeoPassNodes(new TObjArray()), fGeoType(-1), fTubeInRad(0), fTubeOutRad(0)
+  CbmGeoMustPar::CbmGeoMustPar(const char* name, const char* title, const char* context)
+  : FairParGenericSet(name, title, context)
+  , fGeoSensNodes(new TObjArray())
+  , fGeoPassNodes(new TObjArray())
+  , fGeoType(-1)
+  , fTubeInRad(0)
+  , fTubeOutRad(0)
 {
 }
 
@@ -40,10 +45,9 @@ void CbmGeoMustPar::clear(void)
   }
 }
 
-void CbmGeoMustPar::putParams(FairParamList *l)
+void CbmGeoMustPar::putParams(FairParamList* l)
 {
-  if (!l)
-    return;
+  if (!l) return;
   l->addObject("FairGeoNodes Sensitive List", fGeoSensNodes);
   l->addObject("FairGeoNodes Passive List", fGeoPassNodes);
   l->add("Tube Innen Radius", fTubeInRad);
@@ -51,20 +55,14 @@ void CbmGeoMustPar::putParams(FairParamList *l)
   l->add("Geometry Type", fGeoType);
 }
 
-Bool_t CbmGeoMustPar::getParams(FairParamList *l)
+Bool_t CbmGeoMustPar::getParams(FairParamList* l)
 {
-  if (!l)
-    return kFALSE;
-  if (!l->fillObject("FairGeoNodes Sensitive List", fGeoSensNodes))
-    return kFALSE;
-  if (!l->fillObject("FairGeoNodes Passive List", fGeoPassNodes))
-    return kFALSE;
-  if (!l->fill("Tube Innen Radius", &fTubeInRad))
-    return kFALSE;
-  if (!l->fill("Tube Outer Radius", &fTubeOutRad))
-    return kFALSE;
-  if (!l->fill("Geometry Type", &fGeoType))
-    return kFALSE;
+  if (!l) return kFALSE;
+  if (!l->fillObject("FairGeoNodes Sensitive List", fGeoSensNodes)) return kFALSE;
+  if (!l->fillObject("FairGeoNodes Passive List", fGeoPassNodes)) return kFALSE;
+  if (!l->fill("Tube Innen Radius", &fTubeInRad)) return kFALSE;
+  if (!l->fill("Tube Outer Radius", &fTubeOutRad)) return kFALSE;
+  if (!l->fill("Geometry Type", &fGeoType)) return kFALSE;
 
   return kTRUE;
 }
diff --git a/core/detectors/must/CbmGeoMustPar.h b/core/detectors/must/CbmGeoMustPar.h
index 107b3b331..9c9ddf76c 100644
--- a/core/detectors/must/CbmGeoMustPar.h
+++ b/core/detectors/must/CbmGeoMustPar.h
@@ -22,30 +22,31 @@
 
 class CbmGeoMustPar : public FairParGenericSet {
  private:
-  TObjArray *fGeoSensNodes;         /** List of FairGeoNodes for sensitive volumes*/
-  TObjArray *fGeoPassNodes;         /** List of FairGeoNodes for sensitive volumes*/
-  Int_t fGeoType;                   // modif
-  Double_t fTubeInRad, fTubeOutRad; // modif
+  TObjArray* fGeoSensNodes;          /** List of FairGeoNodes for sensitive volumes*/
+  TObjArray* fGeoPassNodes;          /** List of FairGeoNodes for sensitive volumes*/
+  Int_t fGeoType;                    // modif
+  Double_t fTubeInRad, fTubeOutRad;  // modif
 
-  CbmGeoMustPar(const CbmGeoMustPar &L);
-  CbmGeoMustPar &operator=(const CbmGeoMustPar &) { return *this; }
+  CbmGeoMustPar(const CbmGeoMustPar& L);
+  CbmGeoMustPar& operator=(const CbmGeoMustPar&) { return *this; }
 
  public:
-  CbmGeoMustPar(const char *name = "CbmGeoMustPar", const char *title = "Must Geometry Parameters", const char *context = "TestDefaultContext");
+  CbmGeoMustPar(const char* name = "CbmGeoMustPar", const char* title = "Must Geometry Parameters",
+                const char* context = "TestDefaultContext");
   ~CbmGeoMustPar(void);
   void clear(void);
-  void putParams(FairParamList *);
-  Bool_t getParams(FairParamList *);
-  TObjArray *GetGeoSensitiveNodes() { return fGeoSensNodes; }
-  TObjArray *GetGeoPassiveNodes() { return fGeoPassNodes; }
+  void putParams(FairParamList*);
+  Bool_t getParams(FairParamList*);
+  TObjArray* GetGeoSensitiveNodes() { return fGeoSensNodes; }
+  TObjArray* GetGeoPassiveNodes() { return fGeoPassNodes; }
 
   // Additional function
   void SetGeometryType(Int_t geoType) { fGeoType = geoType; }
   void SetTubeInRad(Double_t inrad) { fTubeInRad = inrad; }
   void SetTubeOutRad(Double_t outrad) { fTubeOutRad = outrad; }
-  Int_t GetGeometryType() { return (Int_t)fGeoType; };
-  Double_t GetTubeInRad() { return (Double_t)fTubeInRad; };
-  Double_t GetTubeOutRad() { return (Double_t)fTubeOutRad; };
+  Int_t GetGeometryType() { return (Int_t) fGeoType; };
+  Double_t GetTubeInRad() { return (Double_t) fTubeInRad; };
+  Double_t GetTubeOutRad() { return (Double_t) fTubeOutRad; };
 
   ClassDef(CbmGeoMustPar, 1)
 };
diff --git a/core/detectors/must/CbmMustContFact.cxx b/core/detectors/must/CbmMustContFact.cxx
index f4e8483a3..cb34a6956 100644
--- a/core/detectors/must/CbmMustContFact.cxx
+++ b/core/detectors/must/CbmMustContFact.cxx
@@ -16,12 +16,12 @@
 // from CbnRoot, this library
 #include "CbmGeoMustPar.h"
 // from FairRoot
-#include <FairRuntimeDb.h>
-#include <FairParRootFileIo.h>
 #include <FairParAsciiFileIo.h>
+#include <FairParRootFileIo.h>
+#include <FairRuntimeDb.h>
 // standard
-#include <iostream>
 #include <iomanip>
+#include <iostream>
 
 ClassImp(CbmMustContFact)
 
@@ -30,7 +30,7 @@ ClassImp(CbmMustContFact)
 CbmMustContFact::CbmMustContFact()
 {
   // Constructor (called when the library is loaded)
-  fName = "CbmMustContFact";
+  fName  = "CbmMustContFact";
   fTitle = "Factory for parameter containers in libMust";
   setAllContainers();
   FairRuntimeDb::instance()->addContFactory(this);
@@ -40,19 +40,19 @@ void CbmMustContFact::setAllContainers()
 {
   /** Creates the Container objects with all accepted contexts and adds them to
    *  the list of containers for the MUST library.*/
-  FairContainer *p1 = new FairContainer("CbmGeoMustPar", "Must Geometry Parameters", "TestDefaultContext");
+  FairContainer* p1 = new FairContainer("CbmGeoMustPar", "Must Geometry Parameters", "TestDefaultContext");
   p1->addContext("TestNonDefaultContext");
   containers->Add(p1);
 }
 
-FairParSet *CbmMustContFact::createContainer(FairContainer *c)
+FairParSet* CbmMustContFact::createContainer(FairContainer* c)
 {
   /** Calls the constructor of the corresponding parameter container.
    * For an actual context, which is not an empty string and not the default context
    * of this container, the name is concatinated with the context. */
-  const char *name = c->GetName();
+  const char* name = c->GetName();
   std::cout << "[MUST] CbmMustContFact createContainer name " << name << std::endl;
-  FairParSet *p = 0;
+  FairParSet* p = 0;
 
   if (strcmp(name, "CbmGeoMustPar") == 0) {
     p = new CbmGeoMustPar(c->getConcatName().Data(), c->GetTitle(), c->getContext());
diff --git a/core/detectors/must/CbmMustContFact.h b/core/detectors/must/CbmMustContFact.h
index 61e9a5edd..2deaaca9e 100644
--- a/core/detectors/must/CbmMustContFact.h
+++ b/core/detectors/must/CbmMustContFact.h
@@ -27,9 +27,9 @@ class CbmMustContFact : public FairContFact {
  public:
   CbmMustContFact();
   ~CbmMustContFact() {}
-  FairParSet *createContainer(FairContainer *);
+  FairParSet* createContainer(FairContainer*);
   //  void  activateParIo(FairParIo* io);
-  ClassDef(CbmMustContFact, 0) // Factory for all MUST parameter containers
+  ClassDef(CbmMustContFact, 0)  // Factory for all MUST parameter containers
 };
 
 #endif /* !CBMMUSTCONTFACT_H */
diff --git a/core/detectors/must/CbmMustGeoScheme.cxx b/core/detectors/must/CbmMustGeoScheme.cxx
index 7cd7e5471..d64e60209 100644
--- a/core/detectors/must/CbmMustGeoScheme.cxx
+++ b/core/detectors/must/CbmMustGeoScheme.cxx
@@ -1,6 +1,6 @@
-/* Copyright (C) 2004-2025 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
+/* Copyright (C) 2025 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
    SPDX-License-Identifier: GPL-3.0-only
-   Authors: Radoslaw Karabowicz */
+   Authors: Radosław Karabowicz [committer] */
 /** CbmMustGeoScheme
  *@author  R.Karabowicz <r.karabowicz@gsi.de>
  *@version 1.0
@@ -11,8 +11,10 @@
  **/
 #include "CbmMustGeoScheme.h"
 
-#include "CbmMustLayer.h"            // for CbmMustLayer
-#include "CbmMustStation.h"          // for CbmMustStation
+#include "CbmMustLayer.h"  // for CbmMustLayer
+#include "CbmMustModule.h"
+#include "CbmMustStation.h"  // for CbmMustStation
+#include "CbmMustTube.h"
 
 #include <Logger.h>  // for LOG
 
@@ -21,15 +23,16 @@
 #include <TClonesArray.h>  // for TClonesArray
 #include <TFile.h>         // for TFile, gFile
 #include <TGeoBBox.h>      // for TGeoBBox
-#include <TGeoTube.h>      // for TGeoTube
 #include <TGeoManager.h>   // for TGeoManager, gGeoManager
 #include <TGeoNode.h>      // for TGeoNode
+#include <TGeoTube.h>      // for TGeoTube
 #include <TGeoVolume.h>    // for TGeoVolume
 #include <TMath.h>         // for Cos, Sqrt
 #include <TObjArray.h>     // for TObjArray
 #include <TObject.h>       // for TObject
 #include <TVector3.h>      // for TVector3
 
+#include <bitset>     // for bitset
 #include <cassert>    // for assert
 #include <stdexcept>  // for out_of_range
 #include <utility>    // for pair
@@ -42,11 +45,7 @@ using std::vector;
 CbmMustGeoScheme* CbmMustGeoScheme::fInstance = nullptr;
 
 // -------------------------------------------------------------------------
-CbmMustGeoScheme::CbmMustGeoScheme()
-  : TObject()
-{
-  LOG(debug) << "CbmMustGeoScheme created";
-}
+CbmMustGeoScheme::CbmMustGeoScheme() : TObject() { LOG(debug) << "CbmMustGeoScheme created"; }
 // -------------------------------------------------------------------------
 
 // -------------------------------------------------------------------------
@@ -71,14 +70,13 @@ CbmMustGeoScheme* CbmMustGeoScheme::Instance()
 void CbmMustGeoScheme::Init(TObjArray* stations)
 {
   if (!fInitialized) {
-    fStations = stations;
+    fStations    = stations;
     fInitialized = kTRUE;
   }
   LOG(debug) << "CbmMustGeoScheme init successful";
 }
 // -------------------------------------------------------------------------
 
-
 // -------------------------------------------------------------------------
 void CbmMustGeoScheme::Init(TString parFileName)
 {
@@ -87,7 +85,7 @@ void CbmMustGeoScheme::Init(TString parFileName)
   TFile* oldFile     = gFile;
   TDirectory* oldDir = gDirectory;
 
-  TFile* file         = new TFile(parFileName);
+  TFile* file = new TFile(parFileName);
   LOG_IF(fatal, !file) << "File " << parFileName << " does not exist";
   TObjArray* stations = file->Get<TObjArray>("stations");
   LOG_IF(fatal, !stations) << "No TObjArray stations found in file " << parFileName;
@@ -102,6 +100,31 @@ void CbmMustGeoScheme::Init(TString parFileName)
 }
 // -------------------------------------------------------------------------
 
+// -------------------------------------------------------------------------
+uint32_t CbmMustGeoScheme::GetAddress(int statId, int layId, int modId, int strawId)
+{
+  // Address composition:
+  //  4 bits  0 -  3    kMust ???
+  //  2 bits  4 -  5    station id (0...3)
+  //  2 bits  6 -  7    layer id (0...3) in module
+  //  6 bits  8 - 13    module id (0...63) in layer
+  //  7 bits 14 - 20    straw id (0...127) in straw
+  uint32_t address{15};  // replace with kMust
+  address = address << 2;
+  address += statId;
+  address = address << 2;
+  address += layId;
+  address = address << 6;
+  address += modId;
+  address = address << 7;
+  address += strawId;
+  address = address << 11;
+  std::bitset<32> x(address);
+  LOG(debug) << "   D S L     M      S          E";
+  LOG(debug) << x;
+  return address;
+}
+// -------------------------------------------------------------------------
 
 // -------------------------------------------------------------------------
 CbmMustStation* CbmMustGeoScheme::GetStation(int iStation) const
@@ -116,34 +139,40 @@ CbmMustStation* CbmMustGeoScheme::GetStation(int iStation) const
 
 CbmMustStation* CbmMustGeoScheme::FindStation(int detid)
 {
-    if ( !fStations )
-        fStations = new TObjArray();
-    for (Int_t iobj = 0; iobj < fStations->GetEntriesFast(); iobj++) {
-        CbmMustStation* tempStation = (CbmMustStation*)(fStations->At(iobj));
-        if ( tempStation->GetDetectorId() == detid )
-            return tempStation;
-    }
-    return nullptr;
+  if (!fStations) fStations = new TObjArray();
+  for (Int_t iobj = 0; iobj < fStations->GetEntriesFast(); iobj++) {
+    CbmMustStation* tempStation = (CbmMustStation*) (fStations->At(iobj));
+    if (tempStation->GetDetectorId() == detid) return tempStation;
+  }
+  return nullptr;
+}
+
+CbmMustTube* CbmMustGeoScheme::GetTube(int detid)
+{
+  int stationid            = detid / 1e7 - 1;
+  CbmMustStation* tempStat = GetStation(stationid);
+  //    LOG(info) << "trying to get tube " << detid % 10000000 << " from station " << stationid;
+  return tempStat ? tempStat->GetTube(detid % 10000000) : nullptr;
 }
 
 bool CbmMustGeoScheme::AddStation(CbmMustStation* station)
 {
-    for (Int_t iobj = 0; iobj < fStations->GetEntriesFast(); iobj++) {
-        CbmMustStation* tempStation = (CbmMustStation*)(fStations->At(iobj));
-        if ( tempStation->GetDetectorId() == station->GetDetectorId() )
-            return false;
-    }
-        
-    fStations->Add(station);
-    return true;
+  for (Int_t iobj = 0; iobj < fStations->GetEntriesFast(); iobj++) {
+    CbmMustStation* tempStation = (CbmMustStation*) (fStations->At(iobj));
+    if (tempStation->GetDetectorId() == station->GetDetectorId()) return false;
+  }
+
+  fStations->Add(station);
+  return true;
 }
 
-void CbmMustGeoScheme::Show() {
-    LOG(info) << "MustGeoScheme:";
-    for (Int_t iobj = 0; iobj < fStations->GetEntriesFast(); iobj++) {
-        CbmMustStation* tempStation = (CbmMustStation*)(fStations->At(iobj));
-        tempStation->Show();
-    }
+void CbmMustGeoScheme::Show()
+{
+  LOG(info) << "MustGeoScheme:";
+  for (Int_t iobj = 0; iobj < fStations->GetEntriesFast(); iobj++) {
+    CbmMustStation* tempStation = (CbmMustStation*) (fStations->At(iobj));
+    tempStation->Show();
+  }
 }
 
 // -------------------------------------------------------------------------
@@ -155,9 +184,9 @@ void CbmMustGeoScheme::StoreGeoScheme()
   TDirectory* oldDir = gDirectory;
 
   std::string geoSchemeFileName("must_geoScheme.root");
-  TFile* file         = new TFile(geoSchemeFileName.c_str(),"recreate");
+  TFile* file = new TFile(geoSchemeFileName.c_str(), "recreate");
   LOG_IF(fatal, !file) << "File " << geoSchemeFileName << " does not exist";
-  file->WriteObject(fStations,"stations");
+  file->WriteObject(fStations, "stations");
   //  fStations->Write();
   file->Close();
   file->Delete();
@@ -181,7 +210,7 @@ void CbmMustGeoScheme::NavigateTo(const TString& path)
   gGeoManager->cd(path.Data());
   //    fGeoPathHash;
   //  fGeoPathHash      = path.Hash();
-  TGeoVolume* fCurrentVolume    = gGeoManager->GetCurrentVolume();
+  TGeoVolume* fCurrentVolume = gGeoManager->GetCurrentVolume();
   //  TGeoBBox*   fVolumeBoxShape   = (TGeoBBox*) fCurrentVolume->GetShape();
   Double_t local[3] = {0., 0., 0.};
   gGeoManager->LocalToMaster(local, fGlobal);
diff --git a/core/detectors/must/CbmMustGeoScheme.h b/core/detectors/must/CbmMustGeoScheme.h
index f6f40858c..ddcd6a7cd 100644
--- a/core/detectors/must/CbmMustGeoScheme.h
+++ b/core/detectors/must/CbmMustGeoScheme.h
@@ -1,6 +1,6 @@
-/* Copyright (C) 2004-2025 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
+/* Copyright (C) 2025 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
    SPDX-License-Identifier: GPL-3.0-only
-   Authors: Radoslaw Karabowicz */
+   Authors: Radosław Karabowicz [committer] */
 
 // -------------------------------------------------------------------------
 // -----                   CbmMustGeoScheme header file                -----
@@ -35,6 +35,7 @@
 #include <map>     // for map
 #include <vector>  // for vector
 
+class CbmMustTube;
 class CbmMustLayer;
 class CbmMustModule;
 class CbmMustStation;
@@ -45,48 +46,52 @@ class TGeoVolume;
 
 class CbmMustGeoScheme : public TObject {
 
-public:
-    /** Destructor.     */
-    ~CbmMustGeoScheme();
-    //void Init(Bool_t isSimulation = kFALSE);
-    static CbmMustGeoScheme* Instance();
-    /** Gets whether the geometry scheme is initialized. */
-    Bool_t IsInitialized() { return fInitialized; }
+ public:
+  /** Destructor.     */
+  ~CbmMustGeoScheme();
+  //void Init(Bool_t isSimulation = kFALSE);
+  static CbmMustGeoScheme* Instance();
+  /** Gets whether the geometry scheme is initialized. */
+  Bool_t IsInitialized() { return fInitialized; }
 
-    // Get geometry objects by indices
-    TObjArray* GetStations() const {return fStations;};
-    CbmMustStation* GetStation(int iStation) const;
-    CbmMustLayer* GetLayer(int iStation, int iLayer) const;
+  // Get geometry objects by indices
+  TObjArray* GetStations() const { return fStations; };
+  CbmMustStation* GetStation(int iStation) const;
+  CbmMustLayer* GetLayer(int iStation, int iLayer) const;
 
-    int GetNStations() const { return fStations->GetEntriesFast(); }
+  uint32_t GetAddress(int statId, int layId, int modId, int strawId);
 
-    CbmMustStation* FindStation(int detid);
-    bool AddStation(CbmMustStation* station);
-    void Show();
-    void StoreGeoScheme();
+  int GetNStations() const { return fStations->GetEntriesFast(); }
 
-    void Init(TObjArray* stations);
-    void Init(TString parFileName);
+  CbmMustTube* GetTube(int detid);
 
-    void NavigateTo(const TString& path);
-    // void NavigateToBBox(const TString& path);
-    // void NavigateToTube(const TString& path);
+  CbmMustStation* FindStation(int detid);
+  bool AddStation(CbmMustStation* station);
+  void Show();
+  void StoreGeoScheme();
 
-    TVector3 GetGlobal()  { return TVector3(fGlobal); }
-    
-private:
-    static CbmMustGeoScheme* fInstance;
+  void Init(TObjArray* stations);
+  void Init(TString parFileName);
 
-    CbmMustGeoScheme();
+  void NavigateTo(const TString& path);
+  // void NavigateToBBox(const TString& path);
+  // void NavigateToTube(const TString& path);
 
-    bool       fInitialized {false};
-    TObjArray* fStations    {nullptr};   //!
-    double     fGlobal[3]   {0.,0.,0.};
-    
-    CbmMustGeoScheme(const CbmMustGeoScheme&);
-    CbmMustGeoScheme& operator=(const CbmMustGeoScheme&);
+  TVector3 GetGlobal() { return TVector3(fGlobal); }
 
-    ClassDef(CbmMustGeoScheme, 1);
+ private:
+  static CbmMustGeoScheme* fInstance;
+
+  CbmMustGeoScheme();
+
+  bool fInitialized{false};
+  TObjArray* fStations{nullptr};  //!
+  double fGlobal[3]{0., 0., 0.};
+
+  CbmMustGeoScheme(const CbmMustGeoScheme&);
+  CbmMustGeoScheme& operator=(const CbmMustGeoScheme&);
+
+  ClassDef(CbmMustGeoScheme, 1);
 };
 
 #endif
diff --git a/core/detectors/must/CbmMustLayer.cxx b/core/detectors/must/CbmMustLayer.cxx
index 21bd3d780..1422079cb 100644
--- a/core/detectors/must/CbmMustLayer.cxx
+++ b/core/detectors/must/CbmMustLayer.cxx
@@ -1,6 +1,6 @@
-/* Copyright (C) 2004-2025 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
+/* Copyright (C) 2025 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
    SPDX-License-Identifier: GPL-3.0-only
-   Authors: Radoslaw Karabowicz */
+   Authors: Radosław Karabowicz [committer] */
 
 /** CbmMustLayer.cxx
  *@author  R.Karabowicz <r.karabowicz@gsi.de>
@@ -21,10 +21,7 @@
 #include <TVector3.h>   // for TVector3
 
 // -----   Default constructor   -------------------------------------------
-CbmMustLayer::CbmMustLayer()
-  : TObject()
-{
-}
+CbmMustLayer::CbmMustLayer() : TObject() {}
 // -------------------------------------------------------------------------
 
 // -----   Standard constructor   ------------------------------------------
@@ -40,7 +37,7 @@ CbmMustLayer::CbmMustLayer(int detId, double z, double zRel)
 // -----   Standard constructor   ------------------------------------------
 CbmMustLayer::CbmMustLayer(int iStation, int iLayer, double z, double zRel)
   : TObject()
-  , fDetectorId(iStation*1e7+iLayer*1e5)
+  , fDetectorId(iStation * 1e7 + iLayer * 1e5)
   , fZ(z)
   , fZtoStationCenter(zRel)
 
@@ -52,33 +49,41 @@ CbmMustLayer::CbmMustLayer(int iStation, int iLayer, double z, double zRel)
 CbmMustLayer::~CbmMustLayer() {}
 // -------------------------------------------------------------------------
 
+CbmMustTube* CbmMustLayer::GetTube(int detid)
+{
+  int moduleid              = detid / 1e3 - 1;
+  CbmMustModule* tempModule = GetModule(moduleid);
+  //    LOG(info) << "trying to get tube " << detid % 1000 << " from module " << moduleid;
+  return tempModule ? tempModule->GetTube(detid % 1000 - 1) : nullptr;
+}
+
 CbmMustModule* CbmMustLayer::FindModule(int detid)
 {
-    for (Int_t iobj = 0; iobj < fModules.GetEntriesFast(); iobj++) {
-        CbmMustModule* tempModule = (CbmMustModule*)(fModules.At(iobj));
-        if ( tempModule->GetDetectorId() == detid )
-            return tempModule;
-    }
-    return nullptr;
+  for (Int_t iobj = 0; iobj < fModules.GetEntriesFast(); iobj++) {
+    CbmMustModule* tempModule = (CbmMustModule*) (fModules.At(iobj));
+    if (tempModule->GetDetectorId() == detid) return tempModule;
+  }
+  return nullptr;
 }
 
-bool CbmMustLayer::AddModule(CbmMustModule* module) {
-    for (Int_t iobj = 0; iobj < fModules.GetEntriesFast(); iobj++) {
-        CbmMustModule* tempModule = (CbmMustModule*)(fModules.At(iobj));
-        if ( tempModule->GetDetectorId() == module->GetDetectorId() )
-            return false;
-    }
-        
-    fModules.Add(module);
-    return true;
+bool CbmMustLayer::AddModule(CbmMustModule* module)
+{
+  for (Int_t iobj = 0; iobj < fModules.GetEntriesFast(); iobj++) {
+    CbmMustModule* tempModule = (CbmMustModule*) (fModules.At(iobj));
+    if (tempModule->GetDetectorId() == module->GetDetectorId()) return false;
+  }
+
+  fModules.Add(module);
+  return true;
 }
 
-void CbmMustLayer::Show() {
-    LOG(info) << "    Layer " << fDetectorId << " (@ z = " << fZ << "):";
-    for (Int_t iobj = 0; iobj < fModules.GetEntriesFast(); iobj++) {
-        CbmMustModule* tempModule = (CbmMustModule*)(fModules.At(iobj));
-        tempModule->Show();
-    }
+void CbmMustLayer::Show()
+{
+  LOG(info) << "    Layer " << fDetectorId << " (@ z = " << fZ << "):";
+  for (Int_t iobj = 0; iobj < fModules.GetEntriesFast(); iobj++) {
+    CbmMustModule* tempModule = (CbmMustModule*) (fModules.At(iobj));
+    tempModule->Show();
+  }
 }
 
 ClassImp(CbmMustLayer)
diff --git a/core/detectors/must/CbmMustLayer.h b/core/detectors/must/CbmMustLayer.h
index 7f282b3f1..1c60c30e6 100644
--- a/core/detectors/must/CbmMustLayer.h
+++ b/core/detectors/must/CbmMustLayer.h
@@ -1,6 +1,6 @@
-/* Copyright (C) 2004-2025 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
+/* Copyright (C) 2025 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
    SPDX-License-Identifier: GPL-3.0-only
-   Authors: Radoslaw Karabowicz */
+   Authors: Radosław Karabowicz [committer] */
 
 /** CbmMustLayer.h
  *@author  R.Karabowicz <r.karabowicz@gsi.de>
@@ -17,55 +17,59 @@
 #ifndef CBMMUSTLAYER_H
 #define CBMMUSTLAYER_H 1
 
+#include "CbmMustModule.h"
+#include "CbmMustTube.h"
+
 #include <Rtypes.h>      // for THashConsistencyHolder, ClassDef
 #include <RtypesCore.h>  // for Double_t, Int_t, Bool_t, Double32_t
-#include <TObject.h>     // for TObject
 #include <TObjArray.h>   // for TObjArray
-#include "CbmMustModule.h"
+#include <TObject.h>     // for TObject
 
 class CbmMustLayer : public TObject {
 
-public:
-    /** Default constructor **/
-    CbmMustLayer();
+ public:
+  /** Default constructor **/
+  CbmMustLayer();
 
-    /** Standard constructor
+  /** Standard constructor
      *@param detId     Detector ID
      *@param z         z position of layer center [cm]
      *@param zRel      z position of layer center relative to station center [cm]
      **/
-    CbmMustLayer(int detId, double z, double zRel);
+  CbmMustLayer(int detId, double z, double zRel);
 
-    /** Standard constructor
+  /** Standard constructor
      *@param iStation  Station index
      *@param iLayer    Layer index
      *@param z         z position of layer center [cm]
      *@param zRel      z position of layer center relative to station center [cm]
      **/
-    CbmMustLayer(int iStation, int iLayer, double z, double zRel);
+  CbmMustLayer(int iStation, int iLayer, double z, double zRel);
+
+  /** Destructor **/
+  virtual ~CbmMustLayer();
 
-    /** Destructor **/
-    virtual ~CbmMustLayer();
+  /** Accessors **/
+  int GetDetectorId() const { return fDetectorId; }
+  double GetZ() const { return fZ; }
+  double GetZtoStationCenter() const { return fZtoStationCenter; }
 
-    /** Accessors **/
-    int GetDetectorId() const { return fDetectorId; }
-    double GetZ() const { return fZ; }
-    double GetZtoStationCenter() const { return fZtoStationCenter; }
+  int GetNModules() const { return fModules.GetEntriesFast(); }
 
-    int GetNModules() const { return fModules.GetEntriesFast(); }
+  CbmMustModule* GetModule(int iModule) const { return (CbmMustModule*) fModules.At(iModule); }
 
-    CbmMustModule* GetModule(int iModule) const { return (CbmMustModule*) fModules.At(iModule); }
+  CbmMustTube* GetTube(int detid);
 
-    CbmMustModule* FindModule(int detid);
-    bool AddModule(CbmMustModule* module);
-    void Show();
+  CbmMustModule* FindModule(int detid);
+  bool AddModule(CbmMustModule* module);
+  void Show();
 
-protected:
-    int fDetectorId {0};           // Unique detector ID
-    double fZ {0.};
-    double fZtoStationCenter {0.};  // Relative position of the layer center with respect
-                               // to the station center
-    TObjArray fModules;     // Array of CbmMustModules
+ protected:
+  int fDetectorId{0};  // Unique detector ID
+  double fZ{0.};
+  double fZtoStationCenter{0.};  // Relative position of the layer center with respect
+                                 // to the station center
+  TObjArray fModules;            // Array of CbmMustModules
 
   ClassDef(CbmMustLayer, 1);
 };
diff --git a/core/detectors/must/CbmMustModule.cxx b/core/detectors/must/CbmMustModule.cxx
index 2bd5689e3..26502ec98 100644
--- a/core/detectors/must/CbmMustModule.cxx
+++ b/core/detectors/must/CbmMustModule.cxx
@@ -1,6 +1,6 @@
-/* Copyright (C) 2004-2025 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
+/* Copyright (C) 2025 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
    SPDX-License-Identifier: GPL-3.0-only
-   Authors: Radoslaw Karabowicz */
+   Authors: Radosław Karabowicz [committer] */
 
 /** CbmMustModule.cxx
  *@author  R.Karabowicz <r.karabowicz@gsi.de>
@@ -15,24 +15,18 @@
 
 #include <Logger.h>  // for LOG
 
-#include <TObject.h>     // for TObject
+#include <TObject.h>   // for TObject
 #include <TVector3.h>  // for TVector3
 
 // -----   Default constructor   -------------------------------------------
-CbmMustModule::CbmMustModule()
-  : TObject()
-  , fDetectorId(0)
-  , fPosition(TVector3())
-  , fDirection(TVector3())
-{
-}
+CbmMustModule::CbmMustModule() : TObject(), fDetectorId(0), fPosition(TVector3()), fDirection(TVector3()) {}
 // -------------------------------------------------------------------------
 
 
 // -----   Standard constructor   ------------------------------------------
 CbmMustModule::CbmMustModule(int iStation, int iLayer, int iModule, TVector3 position, TVector3 direction)
   : TObject()
-  , fDetectorId(iStation*1e7+iLayer*1e5+iModule*1e3)
+  , fDetectorId(iStation * 1e7 + iLayer * 1e5 + iModule * 1e3)
   , fPosition(position)
   , fDirection(direction)
 {
@@ -41,40 +35,44 @@ CbmMustModule::CbmMustModule(int iStation, int iLayer, int iModule, TVector3 pos
 
 CbmMustTube* CbmMustModule::FindTube(int detid)
 {
-    for (Int_t iobj = 0; iobj < fTubes.GetEntriesFast(); iobj++) {
-        CbmMustTube* tempTube = (CbmMustTube*)(fTubes.At(iobj));
-        if ( tempTube->GetTubeNumber() == detid )
-            return tempTube;
-    }
-    return nullptr;
+  for (Int_t iobj = 0; iobj < fTubes.GetEntriesFast(); iobj++) {
+    CbmMustTube* tempTube = (CbmMustTube*) (fTubes.At(iobj));
+    if (tempTube->GetTubeNumber() == detid) return tempTube;
+  }
+  return nullptr;
 }
 
-bool CbmMustModule::AddTube(CbmMustTube* tube) {
-    for (Int_t iobj = 0; iobj < fTubes.GetEntriesFast(); iobj++) {
-        CbmMustTube* tempTube = (CbmMustTube*)(fTubes.At(iobj));
-        if ( tempTube->GetTubeNumber() == tube->GetTubeNumber() )
-            return false;
-    }
-    fTubes.Add(tube);
-    return true;
+bool CbmMustModule::AddTube(CbmMustTube* tube)
+{
+  for (Int_t iobj = 0; iobj < fTubes.GetEntriesFast(); iobj++) {
+    CbmMustTube* tempTube = (CbmMustTube*) (fTubes.At(iobj));
+    if (tempTube->GetTubeNumber() == tube->GetTubeNumber()) return false;
+  }
+  fTubes.Add(tube);
+  return true;
 }
 
-void CbmMustModule::Show() {
-    LOG(info) << "      Module " << fDetectorId << " (@ (" << fPosition.X() << "," << fPosition.Y() << "," << fPosition.Z() << ") -> (" << fDirection.X() << "," << fDirection.Y() << "," << fDirection.Z() << "):";
-    std::string tubeString(128, '.');
-    std::string tubeNumbDec(128, '0');
-    std::string tubeNumbOne(128, '0');
-    for (Int_t iobj = 0; iobj < fTubes.GetEntriesFast(); iobj++) {
-        CbmMustTube* tempTube = (CbmMustTube*)(fTubes.At(iobj));
-        //        if ( iobj == 0 )
-            LOG(info) << "        Tube " << tempTube->GetDetectorId() << " @ " << tempTube->GetPosition().X() << "," << tempTube->GetPosition().Y() << "," << tempTube->GetPosition().Z();
-        tubeNumbDec[iobj] = char(tempTube->GetTubeNumber()/10+48);
-        tubeNumbOne[iobj] = char(tempTube->GetTubeNumber()%10+48);
-        tubeString[tempTube->GetTubeNumber()-1] = '*';
-    }
-    LOG(info) << "        Tubes " << tubeString;
-    LOG(info) << "            - " << tubeNumbDec;
-    LOG(info) << "            - " << tubeNumbOne;
+void CbmMustModule::Show()
+{
+  LOG(info) << "      Module " << fDetectorId << " (@ (" << fPosition.X() << "," << fPosition.Y() << ","
+            << fPosition.Z() << ") -> (" << fDirection.X() << "," << fDirection.Y() << "," << fDirection.Z() << "):";
+  std::string tubeString(128, '.');
+  std::string tubeNumbDec(128, '0');
+  std::string tubeNumbOne(128, '0');
+  for (Int_t iobj = 0; iobj < fTubes.GetEntriesFast(); iobj++) {
+    CbmMustTube* tempTube = (CbmMustTube*) (fTubes.At(iobj));
+    //        if ( iobj == 0 )
+    LOG(info) << "        Tube " << tempTube->GetDetectorId() << "  @ " << tempTube->GetPosition().X() << ","
+              << tempTube->GetPosition().Y() << "," << tempTube->GetPosition().Z() << " -> "
+              << tempTube->GetWireDirection().X() << "," << tempTube->GetWireDirection().Y() << ","
+              << tempTube->GetWireDirection().Z();
+    tubeNumbDec[iobj]                         = char(tempTube->GetTubeNumber() / 10 + 48);
+    tubeNumbOne[iobj]                         = char(tempTube->GetTubeNumber() % 10 + 48);
+    tubeString[tempTube->GetTubeNumber() - 1] = '*';
+  }
+  LOG(info) << "        Tubes " << tubeString;
+  LOG(info) << "            - " << tubeNumbDec;
+  LOG(info) << "            - " << tubeNumbOne;
 }
 
 ClassImp(CbmMustModule)
diff --git a/core/detectors/must/CbmMustModule.h b/core/detectors/must/CbmMustModule.h
index 777996e86..65f96123c 100644
--- a/core/detectors/must/CbmMustModule.h
+++ b/core/detectors/must/CbmMustModule.h
@@ -1,6 +1,6 @@
-/* Copyright (C) 2004-2025 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
+/* Copyright (C) 2025 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
    SPDX-License-Identifier: GPL-3.0-only
-   Authors: Radoslaw Karabowicz */
+   Authors: Radosław Karabowicz [committer] */
 
 /** CbmMustModule.h
  *@author  R.Karabowicz <r.karabowicz@gsi.de>
@@ -15,55 +15,56 @@
 #ifndef CBMMUSTMODULE_H
 #define CBMMUSTMODULE_H 1
 
+#include "CbmMustTube.h"
+
 #include <Rtypes.h>      // for THashConsistencyHolder, ClassDef
 #include <RtypesCore.h>  // for Color_t
 #include <TObjArray.h>   // for TObjArray
-#include <TObject.h>       // for TObject
+#include <TObject.h>     // for TObject
 #include <TVector3.h>    // for TVector3
-#include "CbmMustTube.h"
 
 #include <map>      // for multimap
 #include <utility>  // for pair
 
 class CbmMustModule : public TObject {
-public:
-    /** Default constructor **/
-    CbmMustModule();
-    /** Standard constructor
+ public:
+  /** Default constructor **/
+  CbmMustModule();
+  /** Standard constructor
      *@param iStation  Station index
      *@param iLayer    Layer index
      *@param iModule   Module index
      *@param position  Location of the module center in global c.s. (all dimensions in [cm])
      *@param direction Direction of the module
      **/
-    CbmMustModule(int iStation, int iLayer, int iModule, TVector3 position, TVector3 direction);
-    /** Destructor **/
-    virtual ~CbmMustModule() {}
+  CbmMustModule(int iStation, int iLayer, int iModule, TVector3 position, TVector3 direction);
+  /** Destructor **/
+  virtual ~CbmMustModule() {}
 
-    /** Accessors */
-    int GetDetectorId() const { return fDetectorId; }
-    TVector3 GetPosition() const { return fPosition; }
-    TVector3 GetDirection() const { return fDirection; }
+  /** Accessors */
+  int GetDetectorId() const { return fDetectorId; }
+  TVector3 GetPosition() const { return fPosition; }
+  TVector3 GetDirection() const { return fDirection; }
 
-    int GetNTubes() const { return fTubes.GetEntriesFast(); }
+  int GetNTubes() const { return fTubes.GetEntriesFast(); }
 
-    CbmMustTube* GetTube(int iTube) const { return (CbmMustTube*) fTubes.At(iTube); }
+  CbmMustTube* GetTube(int iTube) const { return (CbmMustTube*) fTubes.At(iTube); }
 
-    CbmMustTube* FindTube(int detid);
-    bool AddTube(CbmMustTube* tube);
-    void SortTubes() { fTubes.Sort(); }
-    void Show();
+  CbmMustTube* FindTube(int detid);
+  bool AddTube(CbmMustTube* tube);
+  void SortTubes() { fTubes.Sort(); }
+  void Show();
 
-    virtual bool InitModule() { return kTRUE; }
-    virtual void DrawModule(Color_t) {}
+  virtual bool InitModule() { return kTRUE; }
+  virtual void DrawModule(Color_t) {}
 
-protected:
-    int fDetectorId;        // Unique detector ID
-    TVector3 fPosition;       // Location vector of the module center in global c.s. (all dimensions in [cm])
-    TVector3 fDirection;       // Direction vector of the module
-    TObjArray fTubes;     // Array of CbmMustTubes
+ protected:
+  int fDetectorId;      // Unique detector ID
+  TVector3 fPosition;   // Location vector of the module center in global c.s. (all dimensions in [cm])
+  TVector3 fDirection;  // Direction vector of the module
+  TObjArray fTubes;     // Array of CbmMustTubes
 
-private:
+ private:
   CbmMustModule(const CbmMustModule&);
   CbmMustModule& operator=(const CbmMustModule&);
 
diff --git a/core/detectors/must/CbmMustStation.cxx b/core/detectors/must/CbmMustStation.cxx
index ea637e011..b72c53e05 100644
--- a/core/detectors/must/CbmMustStation.cxx
+++ b/core/detectors/must/CbmMustStation.cxx
@@ -1,6 +1,6 @@
-/* Copyright (C) 2004-2025 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
+/* Copyright (C) 2025 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
    SPDX-License-Identifier: GPL-3.0-only
-   Authors: Radoslaw Karabowicz */
+   Authors: Radosław Karabowicz [committer] */
 
 /** CbmMustStation.cxx
  *@author  R.Karabowicz <r.karabowicz@gsi.de>
@@ -13,7 +13,7 @@
  **/
 #include "CbmMustStation.h"
 
-#include "CbmMustLayer.h"    // for CbmMustLayer
+#include "CbmMustLayer.h"  // for CbmMustLayer
 
 #include <Logger.h>  // for LOG
 
@@ -21,61 +21,56 @@
 #include <TObjArray.h>  // for TObjArray
 
 // -----   Default constructor   -------------------------------------------
-CbmMustStation::CbmMustStation()
-  : TObject()
-  , fDetectorId(0)
-  , fZ(0.)
-  , fLayers()
-{
-}
+CbmMustStation::CbmMustStation() : TObject(), fDetectorId(0), fZ(0.), fLayers() {}
 // -------------------------------------------------------------------------
 
 // -----   Standard constructor   ------------------------------------------
-CbmMustStation::CbmMustStation(int iStation, double z)
-  : TObject()
-  , fDetectorId(iStation*1e7)
-  , fZ(z)
-  , fLayers()
-{
-}
+CbmMustStation::CbmMustStation(int iStation, double z) : TObject(), fDetectorId(iStation * 1e7), fZ(z), fLayers() {}
 // -------------------------------------------------------------------------
 
 // -----   Destructor   ----------------------------------------------------
 CbmMustStation::~CbmMustStation() {}
 // -------------------------------------------------------------------------
 
+CbmMustTube* CbmMustStation::GetTube(int detid)
+{
+  int layerid           = detid / 1e5 - 1;
+  CbmMustLayer* tempLay = GetLayer(layerid);
+  //    LOG(info) << "trying to get tube " << detid % 100000 << " from layer " << layerid;
+  return tempLay ? tempLay->GetTube(detid % 100000) : nullptr;
+}
+
 // -----   Public method AddSector   ---------------------------------------
 CbmMustLayer* CbmMustStation::FindLayer(int detid)
 {
-    for (Int_t iobj = 0; iobj < fLayers.GetEntriesFast(); iobj++) {
-        CbmMustLayer* tempLayer = (CbmMustLayer*)(fLayers.At(iobj));
-        if ( tempLayer->GetDetectorId() == detid )
-            return tempLayer;
-    }
-    return nullptr;
+  for (Int_t iobj = 0; iobj < fLayers.GetEntriesFast(); iobj++) {
+    CbmMustLayer* tempLayer = (CbmMustLayer*) (fLayers.At(iobj));
+    if (tempLayer->GetDetectorId() == detid) return tempLayer;
+  }
+  return nullptr;
 }
 // -------------------------------------------------------------------------
 
 // -----   Public method AddSector   ---------------------------------------
 bool CbmMustStation::AddLayer(CbmMustLayer* layer)
 {
-    for (Int_t iobj = 0; iobj < fLayers.GetEntriesFast(); iobj++) {
-        CbmMustLayer* tempLayer = (CbmMustLayer*)(fLayers.At(iobj));
-        if ( tempLayer->GetDetectorId() == layer->GetDetectorId() )
-            return false;
-    }
+  for (Int_t iobj = 0; iobj < fLayers.GetEntriesFast(); iobj++) {
+    CbmMustLayer* tempLayer = (CbmMustLayer*) (fLayers.At(iobj));
+    if (tempLayer->GetDetectorId() == layer->GetDetectorId()) return false;
+  }
 
-    fLayers.Add(layer);
-    return true;
+  fLayers.Add(layer);
+  return true;
 }
 // -------------------------------------------------------------------------
 
-void CbmMustStation::Show() {
-    LOG(info) << "  Station " << fDetectorId << " (@ z = " << fZ << "):";
-    for (Int_t iobj = 0; iobj < fLayers.GetEntriesFast(); iobj++) {
-        CbmMustLayer* tempLayer = (CbmMustLayer*)(fLayers.At(iobj));
-        tempLayer->Show();
-    }
+void CbmMustStation::Show()
+{
+  LOG(info) << "  Station " << fDetectorId << " (@ z = " << fZ << "):";
+  for (Int_t iobj = 0; iobj < fLayers.GetEntriesFast(); iobj++) {
+    CbmMustLayer* tempLayer = (CbmMustLayer*) (fLayers.At(iobj));
+    tempLayer->Show();
+  }
 }
 
 ClassImp(CbmMustStation)
diff --git a/core/detectors/must/CbmMustStation.h b/core/detectors/must/CbmMustStation.h
index dcec28c37..9f9ad649b 100644
--- a/core/detectors/must/CbmMustStation.h
+++ b/core/detectors/must/CbmMustStation.h
@@ -1,6 +1,6 @@
-/* Copyright (C) 2004-2025 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
+/* Copyright (C) 2025 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
    SPDX-License-Identifier: GPL-3.0-only
-   Authors: Radoslaw Karabowicz */
+   Authors: Radosław Karabowicz [committer] */
 
 /** CbmMustStation.h
  *@author  R.Karabowicz <r.karabowicz@gsi.de>
@@ -18,13 +18,14 @@
 #define CBMMUSTSTATION_H 1
 
 #include "CbmMustLayer.h"  // for CbmMustLayer
+#include "CbmMustTube.h"
 
-#include <Rtypes.h>      // for THashConsistencyHolder, ClassDef
-#include <TObjArray.h>   // for TObjArray
-#include <TObject.h>     // for TObject
+#include <Rtypes.h>     // for THashConsistencyHolder, ClassDef
+#include <TObjArray.h>  // for TObjArray
+#include <TObject.h>    // for TObject
 
 class CbmMustStation : public TObject {
-public:
+ public:
   /** Default constructor **/
   CbmMustStation();
 
@@ -44,17 +45,19 @@ public:
   double GetZ() const { return fZ; }
   int GetNLayers() const { return fLayers.GetEntriesFast(); }
 
+  CbmMustTube* GetTube(int detid);
+
   CbmMustLayer* GetLayer(int iLayer) const { return (CbmMustLayer*) fLayers.At(iLayer); }
 
   /** Add one sector to the array **/
-    CbmMustLayer* FindLayer(int detid);
-    bool AddLayer(CbmMustLayer* layer);
-    void Show();
-
-protected:
-  int fDetectorId;     // Unique detector ID
-  double fZ;         // z position of station center (midplane) [cm] in global cs
-  TObjArray fLayers;     // Array of CbmMustLayers
+  CbmMustLayer* FindLayer(int detid);
+  bool AddLayer(CbmMustLayer* layer);
+  void Show();
+
+ protected:
+  int fDetectorId;    // Unique detector ID
+  double fZ;          // z position of station center (midplane) [cm] in global cs
+  TObjArray fLayers;  // Array of CbmMustLayers
   ClassDef(CbmMustStation, 1);
 };
 #endif
diff --git a/core/detectors/must/CbmMustTube.cxx b/core/detectors/must/CbmMustTube.cxx
index 4b39cfb99..0481e23cc 100644
--- a/core/detectors/must/CbmMustTube.cxx
+++ b/core/detectors/must/CbmMustTube.cxx
@@ -1,6 +1,6 @@
-/* Copyright (C) 2004-2024 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
+/* Copyright (C) 2025 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
    SPDX-License-Identifier: GPL-3.0-only
-   Authors: Radoslaw Karabowicz */
+   Authors: Radosław Karabowicz [committer] */
 
 ////////////////////////////////////////////////////////////////////////////
 // CbmMustTube header file
@@ -14,7 +14,12 @@
 // standard
 #include <iostream>
 
-CbmMustTube::CbmMustTube() : fCenPosition(TVector3(0, 0, 0)), fRotationMatrix(TMatrixT<double>(3, 3)), fRadIn(0), fRadOut(0), fHalfLength(0)
+CbmMustTube::CbmMustTube()
+  : fCenPosition(TVector3(0, 0, 0))
+  , fRotationMatrix(TMatrixT<double>(3, 3))
+  , fRadIn(0)
+  , fRadOut(0)
+  , fHalfLength(0)
 {
   fRotationMatrix[0][0] = -1.;
   fRotationMatrix[0][1] = -1.;
@@ -29,16 +34,29 @@ CbmMustTube::CbmMustTube() : fCenPosition(TVector3(0, 0, 0)), fRotationMatrix(TM
   fRotationMatrix[2][2] = -1.;
 }
 
-CbmMustTube::CbmMustTube(CbmMustTube &tube)
-    : TObject(tube), fTubeNumber(tube.GetTubeNumber()), fCenPosition(tube.GetPosition()), fRotationMatrix(TMatrixT<double>(3, 3)), fRadIn(tube.GetRadIn()), fRadOut(tube.GetRadOut()), fHalfLength(tube.GetHalfLength())
+CbmMustTube::CbmMustTube(CbmMustTube& tube)
+  : TObject(tube)
+  , fTubeNumber(tube.GetTubeNumber())
+  , fCenPosition(tube.GetPosition())
+  , fRotationMatrix(TMatrixT<double>(3, 3))
+  , fRadIn(tube.GetRadIn())
+  , fRadOut(tube.GetRadOut())
+  , fHalfLength(tube.GetHalfLength())
 {
   fRotationMatrix.ResizeTo(3, 3);
   fRotationMatrix = tube.GetRotationMatrix();
 }
 
-CbmMustTube::CbmMustTube(int detectorId, int tubeNumber, Double_t x, Double_t y, Double_t z, Double_t r11, Double_t r12, Double_t r13, Double_t r21, Double_t r22, Double_t r23, Double_t r31, Double_t r32,
-                     Double_t r33, Double_t radin, Double_t radout, Double_t hl)
-    : fDetectorId(detectorId), fTubeNumber(tubeNumber), fCenPosition(TVector3(x, y, z)), fRotationMatrix(TMatrixT<double>(3, 3)), fRadIn(radin), fRadOut(radout), fHalfLength(hl)
+CbmMustTube::CbmMustTube(int detectorId, int tubeNumber, Double_t x, Double_t y, Double_t z, Double_t r11, Double_t r12,
+                         Double_t r13, Double_t r21, Double_t r22, Double_t r23, Double_t r31, Double_t r32,
+                         Double_t r33, Double_t radin, Double_t radout, Double_t hl)
+  : fDetectorId(detectorId)
+  , fTubeNumber(tubeNumber)
+  , fCenPosition(TVector3(x, y, z))
+  , fRotationMatrix(TMatrixT<double>(3, 3))
+  , fRadIn(radin)
+  , fRadOut(radout)
+  , fHalfLength(hl)
 {
 
   fRotationMatrix[0][0] = r11;
@@ -60,42 +78,26 @@ CbmMustTube::~CbmMustTube()
   //  fRotationMatrix.Delete();
 }
 
-TVector3 CbmMustTube::GetPosition() const
-{
-  return fCenPosition;
-}
+TVector3 CbmMustTube::GetPosition() const { return fCenPosition; }
 
-TMatrixT<Double_t> CbmMustTube::GetRotationMatrix() const
-{
-  return fRotationMatrix;
-}
+TMatrixT<Double_t> CbmMustTube::GetRotationMatrix() const { return fRotationMatrix; }
 
-Double_t CbmMustTube::GetRadIn() const
-{
-  return fRadIn;
-}
+Double_t CbmMustTube::GetRadIn() const { return fRadIn; }
 
-Double_t CbmMustTube::GetRadOut() const
-{
-  return fRadOut;
-}
+Double_t CbmMustTube::GetRadOut() const { return fRadOut; }
 
-Double_t CbmMustTube::GetHalfLength() const
-{
-  return fHalfLength;
-}
+Double_t CbmMustTube::GetHalfLength() const { return fHalfLength; }
 
 TVector3 CbmMustTube::GetWireDirection() const
 {
-  return TVector3(fRotationMatrix[0][2], fRotationMatrix[1][2], fRotationMatrix[2][2]);
+  return TVector3(-fRotationMatrix[0][1], fRotationMatrix[1][1], fRotationMatrix[2][1]);
 }
 
-Int_t CbmMustTube::Compare(const TObject *obj) const {
-    if ( ((CbmMustTube*)obj)->GetTubeNumber() == this->GetTubeNumber() )
-        return 0;
-    if ( ((CbmMustTube*)obj)->GetTubeNumber() < this->GetTubeNumber() )
-        return 1;
-    return -1;
+Int_t CbmMustTube::Compare(const TObject* obj) const
+{
+  if (((CbmMustTube*) obj)->GetTubeNumber() == this->GetTubeNumber()) return 0;
+  if (((CbmMustTube*) obj)->GetTubeNumber() < this->GetTubeNumber()) return 1;
+  return -1;
 }
 
 ClassImp(CbmMustTube)
diff --git a/core/detectors/must/CbmMustTube.h b/core/detectors/must/CbmMustTube.h
index 71f189c3a..ae5d3bf29 100644
--- a/core/detectors/must/CbmMustTube.h
+++ b/core/detectors/must/CbmMustTube.h
@@ -1,6 +1,6 @@
-/* Copyright (C) 2004-2024 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
+/* Copyright (C) 2025 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
    SPDX-License-Identifier: GPL-3.0-only
-   Authors: Radoslaw Karabowicz */
+   Authors: Radosław Karabowicz [committer] */
 
 ////////////////////////////////////////////////////////////////////////////
 // CbmMustTube header file
@@ -14,43 +14,44 @@
 #define CBMMUSTTUBE_H 1
 
 // from ROOT
-#include "TVector3.h"
 #include "TMatrixT.h"
 #include "TObject.h"
+#include "TVector3.h"
 
 class CbmMustTube : public TObject {
 
-public:
-    /** Default constructor **/
-    CbmMustTube();
-    CbmMustTube(CbmMustTube &tube);
-
-    ~CbmMustTube();
-    CbmMustTube(int detectorId, int tubeNumber, Double_t x, Double_t y, Double_t z, Double_t r11, Double_t r12, Double_t r13, Double_t r21, Double_t r22, Double_t r23, Double_t r31, Double_t r32, Double_t r33,
-                Double_t radin, Double_t radout, Double_t hl);
-
-    int GetDetectorId() const {return fDetectorId;}
-    int GetTubeNumber() const {return fTubeNumber;}
-    TVector3 GetPosition() const;
-    TMatrixT<Double_t> GetRotationMatrix() const;
-    Double_t GetRadIn() const;
-    Double_t GetRadOut() const;
-    Double_t GetHalfLength() const;
-    TVector3 GetWireDirection() const;
-
-    bool IsSkew() const { return (0. != GetWireDirection().X()); }
-
-    Int_t Compare(const TObject *obj) const override;
-    Bool_t IsSortable() const override {return kTRUE;}
-
-private:
-    int fDetectorId {0};
-    int fTubeNumber {0};
-    TVector3 fCenPosition;
-    TMatrixT<double> fRotationMatrix;
-    Double_t fRadIn, fRadOut, fHalfLength;
-
-    ClassDef(CbmMustTube, 1);
+ public:
+  /** Default constructor **/
+  CbmMustTube();
+  CbmMustTube(CbmMustTube& tube);
+
+  ~CbmMustTube();
+  CbmMustTube(int detectorId, int tubeNumber, Double_t x, Double_t y, Double_t z, Double_t r11, Double_t r12,
+              Double_t r13, Double_t r21, Double_t r22, Double_t r23, Double_t r31, Double_t r32, Double_t r33,
+              Double_t radin, Double_t radout, Double_t hl);
+
+  int GetDetectorId() const { return fDetectorId; }
+  int GetTubeNumber() const { return fTubeNumber; }
+  TVector3 GetPosition() const;
+  TMatrixT<Double_t> GetRotationMatrix() const;
+  Double_t GetRadIn() const;
+  Double_t GetRadOut() const;
+  Double_t GetHalfLength() const;
+  TVector3 GetWireDirection() const;
+
+  bool IsSkew() const { return (0. != GetWireDirection().X()); }
+
+  Int_t Compare(const TObject* obj) const override;
+  Bool_t IsSortable() const override { return kTRUE; }
+
+ private:
+  int fDetectorId{0};
+  int fTubeNumber{0};
+  TVector3 fCenPosition;
+  TMatrixT<double> fRotationMatrix;
+  Double_t fRadIn, fRadOut, fHalfLength;
+
+  ClassDef(CbmMustTube, 1);
 };
 
 #endif
diff --git a/macro/must/run_sim.C b/macro/must/run_sim.C
index 9364eb322..a0f503fe7 100644
--- a/macro/must/run_sim.C
+++ b/macro/must/run_sim.C
@@ -14,7 +14,7 @@ int run_sim(Int_t nEvents = 10, Int_t pid = 13, Float_t p1 = 10.0, Float_t p2 =
   TString tut_configdir = dir + "/sim/transport/gconfig/";
   gSystem->Setenv("CONFIG_DIR", tut_configdir.Data());
 
-  FairRunSim *fRun = new FairRunSim();
+  FairRunSim* fRun = new FairRunSim();
 
   // set the MC version used
   fRun->SetName("TGeant4");
@@ -39,9 +39,9 @@ int run_sim(Int_t nEvents = 10, Int_t pid = 13, Float_t p1 = 10.0, Float_t p2 =
   // Fill the Parameter containers for this run
   //-------------------------------------------
 
-  FairRuntimeDb *rtdb = fRun->GetRuntimeDb();
-  Bool_t kParameterMerged = kTRUE;
-  FairParRootFileIo *output = new FairParRootFileIo(kParameterMerged);
+  FairRuntimeDb* rtdb       = fRun->GetRuntimeDb();
+  Bool_t kParameterMerged   = kTRUE;
+  FairParRootFileIo* output = new FairParRootFileIo(kParameterMerged);
   output->open(parFile.c_str());
   rtdb->setOutput(output);
 
@@ -65,24 +65,23 @@ int run_sim(Int_t nEvents = 10, Int_t pid = 13, Float_t p1 = 10.0, Float_t p2 =
   FairModule* magnet = new CbmMagnet("MAGNET");
   magnet->SetGeometryFileName(magnetGeom);
   fRun->AddModule(magnet);
-  
-  FairDetector *must = new CbmMust("MUST", kTRUE);
+
+  FairDetector* must = new CbmMust("MUST", kTRUE);
   must->SetGeometryFileName("must/must_v24a_mcbm.geo.root");
   fRun->AddModule(must);
 
   // Create and Set Event Generator
   //-------------------------------
 
-  FairPrimaryGenerator *primGen = new FairPrimaryGenerator();
+  FairPrimaryGenerator* primGen = new FairPrimaryGenerator();
   fRun->SetGenerator(primGen);
 
   // Box Generator
-  FairBoxGenerator *boxGen = new FairBoxGenerator(pid, 100); // 13=muon; 2212=proton 1 = multipl.
-  if (p2 < 0.)
-    p2 = p1;
-  boxGen->SetPRange(p1, p2);    // GeV/c //setPRange vs setPtRange
+  FairBoxGenerator* boxGen = new FairBoxGenerator(pid, 100);  // 13=muon; 2212=proton 1 = multipl.
+  if (p2 < 0.) p2 = p1;
+  boxGen->SetPRange(p1, p2);      // GeV/c //setPRange vs setPtRange
   boxGen->SetPhiRange(270, 450);  // Azimuth angle range [degree]
-  boxGen->SetThetaRange(6, 22); // Polar angle in lab system range [degree]
+  boxGen->SetThetaRange(6, 22);   // Polar angle in lab system range [degree]
   boxGen->SetCosTheta();
   boxGen->SetXYZ(0., 0., 0.);
   primGen->AddGenerator(boxGen);
@@ -95,7 +94,7 @@ int run_sim(Int_t nEvents = 10, Int_t pid = 13, Float_t p1 = 10.0, Float_t p2 =
   magField->SetPosition(0., 0., fieldZ);
   magField->SetScale(fieldScale);
   fRun->SetField(magField);
-  
+
   fRun->Init();
 
   // Transport nEvents
diff --git a/sim/detectors/must/CbmMust.cxx b/sim/detectors/must/CbmMust.cxx
index df2be2ed6..f490a35e8 100644
--- a/sim/detectors/must/CbmMust.cxx
+++ b/sim/detectors/must/CbmMust.cxx
@@ -15,36 +15,36 @@
 #include "CbmMust.h"
 // from CbmRoot, this library
 #include "CbmDefs.h"
-#include "CbmGeoMustPar.h"
 #include "CbmGeoMust.h"
+#include "CbmGeoMustPar.h"
 #include "CbmMustGeoScheme.h"
-#include "CbmMustStation.h"
 #include "CbmMustLayer.h"
 #include "CbmMustModule.h"
+#include "CbmMustStation.h"
 #include "CbmMustTube.h"
 #include "CbmStack.h"
 // from CbmRoot
 #include "CbmGeometryUtils.h"
 // from FairRoot
-#include <FairRun.h>
 #include <FairGeoInterface.h>
 #include <FairGeoLoader.h>
 #include <FairGeoNode.h>
 #include <FairGeoRootBuilder.h>
+#include <FairLogger.h>
 #include <FairRootManager.h>
+#include <FairRun.h>
 #include <FairRuntimeDb.h>
 #include <FairVolume.h>
-#include <FairLogger.h>
 // from ROOT
 #include <TClonesArray.h>
-#include <TLorentzVector.h>
-#include <TParticle.h>
-#include <TVirtualMC.h>
 #include <TGeoMatrix.h>
-#include <TObjArray.h>
-#include <TGeoTube.h>
 #include <TGeoMedium.h>
+#include <TGeoTube.h>
 #include <TGeoVolume.h>
+#include <TLorentzVector.h>
+#include <TObjArray.h>
+#include <TParticle.h>
+#include <TVirtualMC.h>
 // standard
 #include <iostream>
 
@@ -56,24 +56,63 @@ using std::string;
 
 // -----   Default constructor   -------------------------------------------
 CbmMust::CbmMust()
-  : fTrackID(0), fVolumeID(0), fPos(0, 0, 0, 0), fPosIn(0, 0, 0, 0), fPosOut(0, 0, 0, 0), fPosInLocal(0, 0, 0, 0), fPosOutLocal(0, 0, 0, 0), fMomIn(0, 0, 0, 0),
-    fMomOut(0, 0, 0, 0), fTime(0), fLength(0), fELoss(0), fMass(0), fIsInitialized(kFALSE), fPosIndex(0), fMustCollection(nullptr), fpostot(0, 0, 0, 0), fpostotin(0, 0, 0, 0),
-    fpostotout(0, 0, 0, 0), fPassNodes(), valid(kFALSE), fGeoType(0)
+  : fTrackID(0)
+  , fVolumeID(0)
+  , fPos(0, 0, 0, 0)
+  , fPosIn(0, 0, 0, 0)
+  , fPosOut(0, 0, 0, 0)
+  , fPosInLocal(0, 0, 0, 0)
+  , fPosOutLocal(0, 0, 0, 0)
+  , fMomIn(0, 0, 0, 0)
+  , fMomOut(0, 0, 0, 0)
+  , fTime(0)
+  , fLength(0)
+  , fELoss(0)
+  , fMass(0)
+  , fIsInitialized(kFALSE)
+  , fPosIndex(0)
+  , fMustCollection(nullptr)
+  , fpostot(0, 0, 0, 0)
+  , fpostotin(0, 0, 0, 0)
+  , fpostotout(0, 0, 0, 0)
+  , fPassNodes()
+  , valid(kFALSE)
+  , fGeoType(0)
 {
   fMustCollection = new TClonesArray("CbmMustPoint");
-  fVerboseLevel = 0;
+  fVerboseLevel   = 0;
 }
 // -------------------------------------------------------------------------
 
 // -----   Standard constructor   ------------------------------------------
-CbmMust::CbmMust(const char *name, Bool_t active)
-  : FairDetector(name, active), fTrackID(0), fVolumeID(0), fPos(0, 0, 0, 0), fPosIn(0, 0, 0, 0), fPosOut(0, 0, 0, 0), fPosInLocal(0, 0, 0, 0), fPosOutLocal(0, 0, 0, 0),
-    fMomIn(0, 0, 0, 0), fMomOut(0, 0, 0, 0), fTime(0), fLength(0), fELoss(0), fMass(0), fIsInitialized(kFALSE), fPosIndex(0), fMustCollection(nullptr), fpostot(0, 0, 0, 0),
-    fpostotin(0, 0, 0, 0), fpostotout(0, 0, 0, 0), fPassNodes(), valid(kFALSE), fGeoType(0)
+CbmMust::CbmMust(const char* name, Bool_t active)
+  : FairDetector(name, active)
+  , fTrackID(0)
+  , fVolumeID(0)
+  , fPos(0, 0, 0, 0)
+  , fPosIn(0, 0, 0, 0)
+  , fPosOut(0, 0, 0, 0)
+  , fPosInLocal(0, 0, 0, 0)
+  , fPosOutLocal(0, 0, 0, 0)
+  , fMomIn(0, 0, 0, 0)
+  , fMomOut(0, 0, 0, 0)
+  , fTime(0)
+  , fLength(0)
+  , fELoss(0)
+  , fMass(0)
+  , fIsInitialized(kFALSE)
+  , fPosIndex(0)
+  , fMustCollection(nullptr)
+  , fpostot(0, 0, 0, 0)
+  , fpostotin(0, 0, 0, 0)
+  , fpostotout(0, 0, 0, 0)
+  , fPassNodes()
+  , valid(kFALSE)
+  , fGeoType(0)
 {
   fMustCollection = new TClonesArray("CbmMustPoint");
-  fVerboseLevel = 0;
-  fGeoType = 1; // CHECK
+  fVerboseLevel   = 0;
+  fGeoType        = 1;  // CHECK
 }
 // -------------------------------------------------------------------------
 
@@ -105,9 +144,9 @@ float CbmMust::GetSquaredDistanceFromWire()
 // -------------------------------------------------------------------------
 
 // -----   Public method ProcessHits  --------------------------------------
-Bool_t CbmMust::ProcessHits(FairVolume *vol)
+Bool_t CbmMust::ProcessHits(FairVolume* vol)
 {
-    //    LOG(info) << "ProcessHits called!";
+  //    LOG(info) << "ProcessHits called!";
   // TParticle* particle =  gMC->GetStack()->GetCurrentTrack(); //[R.K. 01/2017] unused variable?
   // TGeoMedium *medium = (TGeoMedium*) vol->getGeoNode()->getRootVolume()->GetMedium(); //[R.K. 01/2017] unused variable?
   // Double_t epsil = medium->GetParam(6); //[R.K. 01/2017] unused variable?
@@ -123,14 +162,14 @@ Bool_t CbmMust::ProcessHits(FairVolume *vol)
       valid = kTRUE;
 
       // Set parameters at entrance of volume. Reset ELoss.
-      fELoss = 0.;
-      fTime = gMC->TrackTime() * 1.0e09;
+      fELoss  = 0.;
+      fTime   = gMC->TrackTime() * 1.0e09;
       fLength = gMC->TrackLength();
       gMC->TrackPosition(fPos);
       gMC->TrackMomentum(fMomIn);
-      gMC->TrackPosition(fpostotin);        // da cancellare
-      Double_t globalPos[3] = {0., 0., 0.}; // stt1 modified
-      Double_t localPos[3] = {0., 0., 0.};  // stt1 modified
+      gMC->TrackPosition(fpostotin);         // da cancellare
+      Double_t globalPos[3] = {0., 0., 0.};  // stt1 modified
+      Double_t localPos[3]  = {0., 0., 0.};  // stt1 modified
 
       globalPos[0] = fPos.X();
       globalPos[1] = fPos.Y();
@@ -145,23 +184,21 @@ Bool_t CbmMust::ProcessHits(FairVolume *vol)
 
     // Create CbmMustPoint at exit of active volume -- but not into the wire
     if (gMC->IsTrackExiting() && valid == kTRUE) {
-      valid = kFALSE;
-      fTrackID = gMC->GetStack()->GetCurrentTrackNumber();
-      fVolumeID = static_cast<int>(ECbmModuleId::kEcal); // vol->getMCid();
+      valid     = kFALSE;
+      fTrackID  = gMC->GetStack()->GetCurrentTrackNumber();
+      fVolumeID = static_cast<int>(ECbmModuleId::kEcal);  // vol->getMCid();
 
       if (fTrackID != 0) {
-        if (fVerboseLevel > 2)
-          LOG(info) << "[MUST] test Vol----------" << vol->getMCid();
-        if (fVerboseLevel > 2)
-          LOG(info) << "fTrackID-----" << fTrackID;
+        if (fVerboseLevel > 2) LOG(info) << "[MUST] test Vol----------" << vol->getMCid();
+        if (fVerboseLevel > 2) LOG(info) << "fTrackID-----" << fTrackID;
       }
 
-      fMass = gMC->TrackMass(); // mass (GeV)
+      fMass = gMC->TrackMass();  // mass (GeV)
       gMC->TrackPosition(fPosOut);
       gMC->TrackMomentum(fMomOut);
-      gMC->TrackPosition(fpostotout);       // da cancellare
-      Double_t globalPos[3] = {0., 0., 0.}; // stt1 modified
-      Double_t localPos[3] = {0., 0., 0.};  // stt1 modified
+      gMC->TrackPosition(fpostotout);        // da cancellare
+      Double_t globalPos[3] = {0., 0., 0.};  // stt1 modified
+      Double_t localPos[3]  = {0., 0., 0.};  // stt1 modified
 
       gMC->Gdtom(localPos, globalPos, 1);
 
@@ -176,86 +213,87 @@ Bool_t CbmMust::ProcessHits(FairVolume *vol)
 
       string volPath(gMC->CurrentVolPath());
 
-      fpostot.SetXYZM((fpostotin.X() + fpostotout.X()) / 2., (fpostotin.Y() + fpostotout.Y()) / 2., (fpostotin.Z() + fpostotout.Z()) / 2., 0.0);
+      fpostot.SetXYZM((fpostotin.X() + fpostotout.X()) / 2., (fpostotin.Y() + fpostotout.Y()) / 2.,
+                      (fpostotin.Z() + fpostotout.Z()) / 2., 0.0);
 
       LOG(debug) << " --> " << volPath;
-      string strawName = volPath.substr(volPath.find("strawAssembly_")+14,8);
-      int statId    = 1;
-      int layerId   = atoi(strawName.substr(1,2).c_str());
-      int moduleId  = atoi(strawName.substr(3,2).c_str());
-      int strawId   = atoi(strawName.substr(5,3).c_str());
-
-      if ( 1 == 0 ) {
-          CbmMustGeoScheme* mustGeoScheme = CbmMustGeoScheme::Instance();
-          // add station
-          int detId = statId*1e7;
-          CbmMustStation* mustStation = mustGeoScheme->FindStation(detId);
-          if ( !mustStation ) {
-              LOG(info) << "STATION --> " << volPath;
-              string statPath = volPath.substr(0,volPath.find("/layer"));
-              LOG(info) << "STATION --> " << statPath;
-              mustGeoScheme->NavigateTo(statPath);
-              TVector3 globPos = mustGeoScheme->GetGlobal();
-              mustStation = new CbmMustStation(statId,globPos[2]); // change z!
-          }
-          mustGeoScheme->AddStation(mustStation);
-          // add layer
-          detId = detId + layerId*1e5;
-          CbmMustLayer* mustLayer = mustStation->FindLayer(detId);
-          if ( !mustLayer ) {
-              LOG(info) << "LAYER --> " << volPath;
-              string layerPath = volPath.substr(0,volPath.find("/module"));
-              LOG(info) << "LAYER --> " << layerPath;
-              mustGeoScheme->NavigateTo(volPath);
-              TVector3 globPos = mustGeoScheme->GetGlobal();
-              mustLayer = new CbmMustLayer(statId,layerId,globPos[2],globPos[2]-mustStation->GetZ());
-          }
-          mustStation->AddLayer(mustLayer);
-          // add module
-          detId = detId + moduleId*1e3;
-          CbmMustModule* mustModule = mustLayer->FindModule(detId);
-          TVector3 directionVector(0.,1.,0.);
-          if ( layerId == 2 || layerId == 3 ) {
-              double angle = 5.*TMath::DegToRad();
-              if ( layerId == 3 ) angle = -angle;
-              directionVector[0] = TMath::Sin(angle);
-              directionVector[1] = TMath::Cos(angle);
-          }
-          if ( !mustModule ) {
-              mustGeoScheme->NavigateTo(volPath);
-              TVector3 globPos = mustGeoScheme->GetGlobal();
-              mustModule = new CbmMustModule(statId,layerId,moduleId,globPos,directionVector);
-          }
-          mustLayer->AddModule(mustModule);
-          // add tube
-          detId = detId + strawId;
-          CbmMustTube* mustTube = mustModule->FindTube(detId);
-          if ( !mustTube ) {
-              mustGeoScheme->NavigateTo(volPath);
-              TVector3 globPos = mustGeoScheme->GetGlobal();
-              mustTube = new CbmMustTube(detId,strawId,
-                                         globPos[0],globPos[1],globPos[2],
-                                         directionVector[1],-directionVector[0],0.,
-                                         directionVector[0], directionVector[1],0.,
-                                         0.,0.,1.,
-                                         0.0127,0.49,110.);
-          }
-          mustModule->AddTube(mustTube);
+      string strawName = volPath.substr(volPath.find("strawAssembly_") + 14, 8);
+      int statId       = 0;
+      int layerId      = atoi(strawName.substr(1, 2).c_str()) - 1;
+      int moduleId     = atoi(strawName.substr(3, 2).c_str()) - 1;
+      int strawId      = atoi(strawName.substr(5, 3).c_str()) - 1;
+
+      uint32_t address = CbmMustGeoScheme::Instance()->GetAddress(statId, layerId, moduleId, strawId);
+
+      if (1 == 0) {
+        CbmMustGeoScheme* mustGeoScheme = CbmMustGeoScheme::Instance();
+        // add station
+        int detId                   = statId * 1e7;
+        CbmMustStation* mustStation = mustGeoScheme->FindStation(detId);
+        if (!mustStation) {
+          LOG(info) << "STATION --> " << volPath;
+          string statPath = volPath.substr(0, volPath.find("/layer"));
+          LOG(info) << "STATION --> " << statPath;
+          mustGeoScheme->NavigateTo(statPath);
+          TVector3 globPos = mustGeoScheme->GetGlobal();
+          mustStation      = new CbmMustStation(statId, globPos[2]);  // change z!
+        }
+        mustGeoScheme->AddStation(mustStation);
+        // add layer
+        detId                   = detId + layerId * 1e5;
+        CbmMustLayer* mustLayer = mustStation->FindLayer(detId);
+        if (!mustLayer) {
+          LOG(info) << "LAYER --> " << volPath;
+          string layerPath = volPath.substr(0, volPath.find("/module"));
+          LOG(info) << "LAYER --> " << layerPath;
+          mustGeoScheme->NavigateTo(volPath);
+          TVector3 globPos = mustGeoScheme->GetGlobal();
+          mustLayer        = new CbmMustLayer(statId, layerId, globPos[2], globPos[2] - mustStation->GetZ());
+        }
+        mustStation->AddLayer(mustLayer);
+        // add module
+        detId                     = detId + moduleId * 1e3;
+        CbmMustModule* mustModule = mustLayer->FindModule(detId);
+        TVector3 directionVector(0., 1., 0.);
+        if (layerId == 2 || layerId == 3) {
+          double angle = 5. * TMath::DegToRad();
+          if (layerId == 3) angle = -angle;
+          directionVector[0] = TMath::Sin(angle);
+          directionVector[1] = TMath::Cos(angle);
+        }
+        if (!mustModule) {
+          mustGeoScheme->NavigateTo(volPath);
+          TVector3 globPos = mustGeoScheme->GetGlobal();
+          mustModule       = new CbmMustModule(statId, layerId, moduleId, globPos, directionVector);
+        }
+        mustLayer->AddModule(mustModule);
+        // add tube
+        detId                 = detId + strawId;
+        CbmMustTube* mustTube = mustModule->FindTube(detId);
+        if (!mustTube) {
+          mustGeoScheme->NavigateTo(volPath);
+          TVector3 globPos = mustGeoScheme->GetGlobal();
+          mustTube =
+            new CbmMustTube(detId, strawId, globPos[0], globPos[1], globPos[2], directionVector[1], -directionVector[0],
+                            0., directionVector[0], directionVector[1], 0., 0., 0., 1., 0.0127, 0.49, 110.);
+        }
+        mustModule->AddTube(mustTube);
       }
 
-      LOG(debug) <<  " l/m/t = " << layerId << "/" << moduleId << "/" << strawId;
+      LOG(debug) << " l/m/t = " << layerId << "/" << moduleId << "/" << strawId;
 
-      AddHit(fTrackID, fVolumeID, layerId, moduleId, strawId, TVector3(fpostot.X(), fpostot.Y(), fpostot.Z()), TVector3(fPosInLocal.X(), fPosInLocal.Y(), fPosInLocal.Z()),
-             TVector3(fPosOutLocal.X(), fPosOutLocal.Y(), fPosOutLocal.Z()), TVector3(fMomIn.Px(), fMomIn.Py(), fMomIn.Pz()), TVector3(fMomOut.Px(), fMomOut.Py(), fMomOut.Pz()),
-             fTime, fLength, fELoss, fMass);
+      AddHit(fTrackID, fVolumeID, address, TVector3(fpostot.X(), fpostot.Y(), fpostot.Z()),
+             TVector3(fPosInLocal.X(), fPosInLocal.Y(), fPosInLocal.Z()),
+             TVector3(fPosOutLocal.X(), fPosOutLocal.Y(), fPosOutLocal.Z()),
+             TVector3(fMomIn.Px(), fMomIn.Py(), fMomIn.Pz()), TVector3(fMomOut.Px(), fMomOut.Py(), fMomOut.Pz()), fTime,
+             fLength, fELoss);
 
       if (fTrackID != 0) {
-        if (fVerboseLevel > 2)
-          LOG(info) << "AddHit CbmMust.cxx= " << fTrackID;
+        if (fVerboseLevel > 2) LOG(info) << "AddHit CbmMust.cxx= " << fTrackID;
       }
 
       // Increment number of stt points for TParticle
-      CbmStack *stack = (CbmStack *)gMC->GetStack();
+      CbmStack* stack = (CbmStack*) gMC->GetStack();
       stack->AddPoint(ECbmModuleId::kEcal);
       ResetParameters();
     }
@@ -268,45 +306,41 @@ Bool_t CbmMust::ProcessHits(FairVolume *vol)
 // -----   Public method EndOfEvent   --------------------------------------
 void CbmMust::EndOfEvent()
 {
-  if (fVerboseLevel)
-    Print();
+  if (fVerboseLevel) Print();
   fMustCollection->Delete();
   fPosIndex = 0;
 
-  if ( 1 == 0 ) {
-      int nofTubes = 0;
-      TObjArray* stations = CbmMustGeoScheme::Instance()->GetStations();
-      for (Int_t iobj = 0; iobj < stations->GetEntriesFast(); iobj++) {
-          CbmMustStation* tempStation = (CbmMustStation*)(stations->At(iobj));
-          for ( int ilay = 0 ; ilay < tempStation->GetNLayers() ; ilay++ ) {
-              CbmMustLayer* tempLayer = tempStation->GetLayer(ilay);
-              for ( int imod = 0 ; imod < tempLayer->GetNModules() ; imod++ ) {
-                  CbmMustModule* tempModule = tempLayer->GetModule(imod);
-                  tempModule->SortTubes();
-                  nofTubes += tempModule->GetNTubes();
-              }
-          }
+  if (1 == 0) {
+    int nofTubes        = 0;
+    TObjArray* stations = CbmMustGeoScheme::Instance()->GetStations();
+    for (Int_t iobj = 0; iobj < stations->GetEntriesFast(); iobj++) {
+      CbmMustStation* tempStation = (CbmMustStation*) (stations->At(iobj));
+      for (int ilay = 0; ilay < tempStation->GetNLayers(); ilay++) {
+        CbmMustLayer* tempLayer = tempStation->GetLayer(ilay);
+        for (int imod = 0; imod < tempLayer->GetNModules(); imod++) {
+          CbmMustModule* tempModule = tempLayer->GetModule(imod);
+          tempModule->SortTubes();
+          nofTubes += tempModule->GetNTubes();
+        }
       }
+    }
 
-      LOG(info) << "got " << nofTubes << " tubes";
-      if ( nofTubes == 256 && !fGeoSchemeSaved ) {
-          CbmMustGeoScheme::Instance()->Show();
-          CbmMustGeoScheme::Instance()->StoreGeoScheme();
-          fGeoSchemeSaved = true;
-      }
+    LOG(info) << "got " << nofTubes << " tubes";
+    if (nofTubes == 256 && !fGeoSchemeSaved) {
+      CbmMustGeoScheme::Instance()->Show();
+      CbmMustGeoScheme::Instance()->StoreGeoScheme();
+      fGeoSchemeSaved = true;
+    }
   }
 }
 // -------------------------------------------------------------------------
 
 // -----   Public method Register   ----------------------------------------
-void CbmMust::Register()
-{
-  FairRootManager::Instance()->Register("MUSTPoint", "Must", fMustCollection, kTRUE);
-}
+void CbmMust::Register() { FairRootManager::Instance()->Register("MUSTPoint", "Must", fMustCollection, kTRUE); }
 // -------------------------------------------------------------------------
 
 // -----   Public method GetCollection   -----------------------------------
-TClonesArray *CbmMust::GetCollection(Int_t iColl) const
+TClonesArray* CbmMust::GetCollection(Int_t iColl) const
 {
   if (iColl == 0)
     return fMustCollection;
@@ -316,7 +350,7 @@ TClonesArray *CbmMust::GetCollection(Int_t iColl) const
 // -------------------------------------------------------------------------
 
 // -----   Public method Print   -------------------------------------------
-void CbmMust::Print(Option_t *) const
+void CbmMust::Print(Option_t*) const
 {
   Int_t nHits = fMustCollection->GetEntriesFast();
 
@@ -337,17 +371,17 @@ void CbmMust::Reset()
 // -------------------------------------------------------------------------
 
 // -----   Public method CopyClones   --------------------------------------
-void CbmMust::CopyClones(TClonesArray *cl1, TClonesArray *cl2, Int_t offset)
+void CbmMust::CopyClones(TClonesArray* cl1, TClonesArray* cl2, Int_t offset)
 {
   Int_t nEntries = cl1->GetEntriesFast();
 
   LOG(info) << " CbmMust: " << nEntries << " entries to add.";
 
-  TClonesArray &clref = *cl2;
+  TClonesArray& clref = *cl2;
 
-  CbmMustPoint *oldpoint = nullptr;
+  CbmMustPoint* oldpoint = nullptr;
   for (Int_t i = 0; i < nEntries; i++) {
-    oldpoint = (CbmMustPoint *)cl1->At(i);
+    oldpoint = (CbmMustPoint*) cl1->At(i);
 
     Int_t index = oldpoint->GetTrackID() + offset;
 
@@ -373,73 +407,77 @@ void CbmMust::ConstructGeometry()
 
   // --- Only ROOT geometries are supported
   if (fileName.EndsWith(".root")) {
-      LOG(info) << "Constructing Must geometry from ROOT file " << fileName.Data();
-      TGeoCombiTrans* fCombiTrans = NULL;
-      Cbm::GeometryUtils::ImportRootGeometry(fgeoName, this, fCombiTrans);
-      return;
+    LOG(info) << "Constructing Must geometry from ROOT file " << fileName.Data();
+    TGeoCombiTrans* fCombiTrans = NULL;
+    Cbm::GeometryUtils::ImportRootGeometry(fgeoName, this, fCombiTrans);
+    return;
   }
   LOG(info) << "Constructing Must geometry from text file " << fileName.Data();
 
-  FairGeoLoader *geoLoad = FairGeoLoader::Instance();
-  FairGeoInterface *geoFace = geoLoad->getGeoInterface();
-  CbmGeoMust *Geo = new CbmGeoMust();
+  FairGeoLoader* geoLoad    = FairGeoLoader::Instance();
+  FairGeoInterface* geoFace = geoLoad->getGeoInterface();
+  CbmGeoMust* Geo           = new CbmGeoMust();
   Geo->setGeomFile(GetGeometryFileName());
   geoFace->addGeoModule(Geo);
 
   Bool_t rc = geoFace->readSet(Geo);
-  if (rc)
-    Geo->create(geoLoad->getGeoBuilder());
+  if (rc) Geo->create(geoLoad->getGeoBuilder());
 
-  TList *volList = Geo->getListOfVolumes();
+  TList* volList = Geo->getListOfVolumes();
 
   // store geo parameter
-  FairRun *fRun = FairRun::Instance();
-  FairRuntimeDb *rtdb = FairRun::Instance()->GetRuntimeDb();
-  CbmGeoMustPar *par;
-  par = (CbmGeoMustPar *)(rtdb->getContainer("CbmGeoMustPar"));
+  FairRun* fRun       = FairRun::Instance();
+  FairRuntimeDb* rtdb = FairRun::Instance()->GetRuntimeDb();
+  CbmGeoMustPar* par;
+  par = (CbmGeoMustPar*) (rtdb->getContainer("CbmGeoMustPar"));
   rtdb->getListOfContainers()->Print();
-  TObjArray *fSensNodes = par->GetGeoSensitiveNodes();
-  fPassNodes = par->GetGeoPassiveNodes();
+  TObjArray* fSensNodes = par->GetGeoSensitiveNodes();
+  fPassNodes            = par->GetGeoPassiveNodes();
 
   TListIter iter(volList);
-  FairGeoNode *node = nullptr;
-  FairGeoVolume *aVol = nullptr;
+  FairGeoNode* node   = nullptr;
+  FairGeoVolume* aVol = nullptr;
 
-  while ((node = (FairGeoNode *)iter.Next())) {
-    aVol = dynamic_cast<FairGeoVolume *>(node);
+  while ((node = (FairGeoNode*) iter.Next())) {
+    aVol = dynamic_cast<FairGeoVolume*>(node);
     // if (fGeoType == 2)
     //  LOG(info) << "Volume " << aVol->GetName() << " is" << (node->isSensitive() ? "" : " not") << " sensitive";
     if (node->isSensitive()) {
       fSensNodes->AddLast(aVol);
-    } else {
+    }
+    else {
       fPassNodes->AddLast(aVol);
     }
   }
 
   par->SetGeometryType(fGeoType);
   if (fGeoType == 1) {
-    par->SetTubeInRad(0.4903 / 2.); // cm
-    par->SetTubeOutRad(0.00127);    // cm
-  } else {
+    par->SetTubeInRad(0.4903 / 2.);  // cm
+    par->SetTubeOutRad(0.00127);     // cm
+  }
+  else {
     LOG(fatal) << "[MUST] GeoType " << fGeoType << " not supported";
   }
 
   par->setChanged();
   par->setInputVersion(fRun->GetRunId(), 1);
   ProcessNodes(volList);
-
 }
 // -------------------------------------------------------------------------
 
 // -----   Private method AddHit   -----------------------------------------
-CbmMustPoint *CbmMust::AddHit(Int_t trackID, Int_t detID, Int_t layID, Int_t modID, Int_t strID, TVector3 pos, TVector3 posInLocal, TVector3 posOutLocal, TVector3 momIn,
-                              TVector3 momOut, Double_t time, Double_t length, Double_t eLoss, Double_t mass)
+CbmMustPoint* CbmMust::AddHit(Int_t trackID, Int_t detID, uint32_t address, TVector3 pos, TVector3 posInLocal,
+                              TVector3 posOutLocal, TVector3 momIn, TVector3 momOut, Double_t time, Double_t length,
+                              Double_t eLoss)
 {
-  TClonesArray &clref = *fMustCollection;
+  TClonesArray& clref = *fMustCollection;
 
   Int_t size = clref.GetEntriesFast();
 
-  CbmMustPoint *pointnew = new (clref[size]) CbmMustPoint(trackID, detID, layID, modID, strID, pos, posInLocal, posOutLocal, momIn, momOut, time, length, eLoss, mass);
+  CbmMustPoint* pointnew = new (clref[size])
+    CbmMustPoint(trackID, detID, address, pos, posInLocal, posOutLocal, momIn, momOut, time, length, eLoss);
+  LOG(debug) << pointnew->GetStationId() << " - " << pointnew->GetLayerId() << " - " << pointnew->GetModuleId() << " - "
+             << pointnew->GetStrawId();
 
   return pointnew;
 }
diff --git a/sim/detectors/must/CbmMust.h b/sim/detectors/must/CbmMust.h
index 03b6269e2..781259ffc 100644
--- a/sim/detectors/must/CbmMust.h
+++ b/sim/detectors/must/CbmMust.h
@@ -27,8 +27,8 @@
 #include <TLorentzVector.h>
 #include <TVector3.h>
 // standard
-#include <string>
 #include <sstream>
+#include <string>
 
 class TClonesArray;
 class FairVolume;
@@ -43,7 +43,7 @@ class CbmMust : public FairDetector {
    *@param name    detetcor name
    *@param active  sensitivity flag
    **/
-  CbmMust(const char *name, Bool_t active);
+  CbmMust(const char* name, Bool_t active);
 
   /** Destructor **/
   virtual ~CbmMust();
@@ -55,7 +55,7 @@ class CbmMust : public FairDetector {
    ** collection.
    *@param vol  Pointer to the active volume
    **/
-  virtual Bool_t ProcessHits(FairVolume *vol = 0) override;
+  virtual Bool_t ProcessHits(FairVolume* vol = 0) override;
 
   /** Virtual method EndOfEvent
    **
@@ -72,7 +72,10 @@ class CbmMust : public FairDetector {
 		 ** The decision is based on the volume name (has to contain "Sensor").
 		 ** Virtual from FairModule.
 		 **/
-  virtual Bool_t IsSensitive(const std::string& name) override { return (TString(name).Contains("active") ? kTRUE : kFALSE); }
+  virtual Bool_t IsSensitive(const std::string& name) override
+  {
+    return (TString(name).Contains("active") ? kTRUE : kFALSE);
+  }
 
   /** Virtual method Register
    **
@@ -81,13 +84,13 @@ class CbmMust : public FairDetector {
   virtual void Register() override;
 
   /** Accessor to the hit collection **/
-  virtual TClonesArray *GetCollection(Int_t iColl) const override;
+  virtual TClonesArray* GetCollection(Int_t iColl) const override;
 
   /** Virtual method Print
    **
    ** Screen output of hit collection.
    **/
-  virtual void Print(Option_t * /*option*/ = "") const override;
+  virtual void Print(Option_t* /*option*/ = "") const override;
 
   /** Virtual method Reset
    **
@@ -104,7 +107,7 @@ class CbmMust : public FairDetector {
    *@param cl2     Target
    *@param offset  Index offset
    **/
-  virtual void CopyClones(TClonesArray *cl1, TClonesArray *cl2, Int_t offset) override;
+  virtual void CopyClones(TClonesArray* cl1, TClonesArray* cl2, Int_t offset) override;
 
   /** Virtual method Construct geometry
    **
@@ -115,39 +118,40 @@ class CbmMust : public FairDetector {
  private:
   /** GFTrack information to be stored until the track leaves the
       active volume. **/
-  Int_t fTrackID;              //!  track index
-  Int_t fVolumeID;             //!  volume id
-  TLorentzVector fPos;         //!  wire position in global frame
-  TLorentzVector fPosIn;       //!  entry position in global frame
-  TLorentzVector fPosOut;      //!  exit position in global frame
-  TLorentzVector fPosInLocal;  //!  entry position in straw frame
-  TLorentzVector fPosOutLocal; //!  exit position in straw frame
-  TLorentzVector fMomIn;       //!  momentum
-  TLorentzVector fMomOut;      //!  momentum
-  Double_t fTime;              //!  time
-  Double_t fLength;            //!  length
-  Double_t fELoss;             //!  energy loss
-  Double_t fMass;              //!  particle mass
+  Int_t fTrackID;               //!  track index
+  Int_t fVolumeID;              //!  volume id
+  TLorentzVector fPos;          //!  wire position in global frame
+  TLorentzVector fPosIn;        //!  entry position in global frame
+  TLorentzVector fPosOut;       //!  exit position in global frame
+  TLorentzVector fPosInLocal;   //!  entry position in straw frame
+  TLorentzVector fPosOutLocal;  //!  exit position in straw frame
+  TLorentzVector fMomIn;        //!  momentum
+  TLorentzVector fMomOut;       //!  momentum
+  Double_t fTime;               //!  time
+  Double_t fLength;             //!  length
+  Double_t fELoss;              //!  energy loss
+  Double_t fMass;               //!  particle mass
   Bool_t fIsInitialized;
 
-  Int_t fPosIndex;             //!
-  TClonesArray *fMustCollection; //! Hit collection
-  TLorentzVector fpostot;      // global frame hit position (in)// da cancellare
-  TLorentzVector fpostotin;    // global frame hit position (in)// da cancellare
-  TLorentzVector fpostotout;   // global frame hit position (in)// da cancellare
+  Int_t fPosIndex;                //!
+  TClonesArray* fMustCollection;  //! Hit collection
+  TLorentzVector fpostot;         // global frame hit position (in)// da cancellare
+  TLorentzVector fpostotin;       // global frame hit position (in)// da cancellare
+  TLorentzVector fpostotout;      // global frame hit position (in)// da cancellare
 
-  TObjArray *fPassNodes; //!
+  TObjArray* fPassNodes;  //!
   // geometry type
   Bool_t valid;
   Int_t fGeoType;
-    bool fGeoSchemeSaved{false};
+  bool fGeoSchemeSaved{false};
 
   /** Private method AddHit
    **
    ** Adds a CbmTrdPoint to the HitCollection
    **/
-  CbmMustPoint *AddHit(Int_t trackID, Int_t detID, Int_t layID, Int_t modID, Int_t strID, TVector3 pos, TVector3 posInLocal, TVector3 posOutLocal, TVector3 momIn,
-                       TVector3 momOut, Double_t time, Double_t length, Double_t eLoss, Double_t mass);
+  CbmMustPoint* AddHit(Int_t trackID, Int_t detID, uint32_t address, TVector3 pos, TVector3 posInLocal,
+                       TVector3 posOutLocal, TVector3 momIn, TVector3 momOut, Double_t time, Double_t length,
+                       Double_t eLoss);
 
   /** Private method ResetParameters
    **
@@ -162,8 +166,8 @@ class CbmMust : public FairDetector {
    **/
   float GetSquaredDistanceFromWire();
 
-  CbmMust(const CbmMust &L);
-  CbmMust &operator=(const CbmMust &) { return *this; }
+  CbmMust(const CbmMust& L);
+  CbmMust& operator=(const CbmMust&) { return *this; }
 
   ClassDef(CbmMust, 1)
 };
@@ -177,15 +181,15 @@ inline void CbmMust::ResetParameters()
   fMomIn.SetXYZM(0.0, 0.0, 0.0, 0.0);
   fMomOut.SetXYZM(0.0, 0.0, 0.0, 0.0);
   fTime = fLength = fELoss = 0;
-  fPosIndex = 0;
-  fpostot.SetXYZM(0.0, 0.0, 0.0, 0.0);    // da cancellare
-  fpostotin.SetXYZM(0.0, 0.0, 0.0, 0.0);  // da cancellare
-  fpostotout.SetXYZM(0.0, 0.0, 0.0, 0.0); // da cancellare
+  fPosIndex                = 0;
+  fpostot.SetXYZM(0.0, 0.0, 0.0, 0.0);     // da cancellare
+  fpostotin.SetXYZM(0.0, 0.0, 0.0, 0.0);   // da cancellare
+  fpostotout.SetXYZM(0.0, 0.0, 0.0, 0.0);  // da cancellare
   fPosIn.SetXYZM(0.0, 0.0, 0.0, 0.0);
   fPosOut.SetXYZM(0.0, 0.0, 0.0, 0.0);
-  fMass = 0;
+  fMass          = 0;
   fIsInitialized = kFALSE;
-  valid = kFALSE;
+  valid          = kFALSE;
 }
 
-#endif // CBMMUST_H
+#endif  // CBMMUST_H
-- 
GitLab


From 984ca0b2cfa39d5a5399def6fd81cc0a5fc8c567 Mon Sep 17 00:00:00 2001
From: Radoslaw Karabowicz <r.karabowicz@gsi.de>
Date: Wed, 26 Feb 2025 18:14:18 +0100
Subject: [PATCH 07/16] fix(must): Fix license header

---
 core/data/must/CbmMustPoint.cxx          | 4 ++--
 core/data/must/CbmMustPoint.h            | 4 ++--
 core/detectors/must/CbmGeoMust.cxx       | 4 ++--
 core/detectors/must/CbmGeoMust.h         | 4 ++--
 core/detectors/must/CbmGeoMustPar.cxx    | 4 ++--
 core/detectors/must/CbmGeoMustPar.h      | 4 ++--
 core/detectors/must/CbmMustContFact.cxx  | 4 ++--
 core/detectors/must/CbmMustContFact.h    | 4 ++--
 core/detectors/must/CbmMustGeoScheme.cxx | 1 +
 macro/must/run_sim.C                     | 4 ++--
 sim/detectors/must/CbmMust.cxx           | 4 ++--
 sim/detectors/must/CbmMust.h             | 4 ++--
 12 files changed, 23 insertions(+), 22 deletions(-)

diff --git a/core/data/must/CbmMustPoint.cxx b/core/data/must/CbmMustPoint.cxx
index 155de2cac..fcd6a26cf 100644
--- a/core/data/must/CbmMustPoint.cxx
+++ b/core/data/must/CbmMustPoint.cxx
@@ -1,6 +1,6 @@
-/* Copyright (C) 2004-2024 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
+/* Copyright (C) 2025 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
    SPDX-License-Identifier: GPL-3.0-only
-   Authors: Radoslaw Karabowicz */
+   Authors: Radosław Karabowicz [committer] */
 
 // -------------------------------------------------------------------------
 // -----                      CbmMustPoint source file                 -----
diff --git a/core/data/must/CbmMustPoint.h b/core/data/must/CbmMustPoint.h
index 8ed3d760d..3586fb471 100644
--- a/core/data/must/CbmMustPoint.h
+++ b/core/data/must/CbmMustPoint.h
@@ -1,6 +1,6 @@
-/* Copyright (C) 2004-2024 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
+/* Copyright (C) 2025 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
    SPDX-License-Identifier: GPL-3.0-only
-   Authors: Radoslaw Karabowicz */
+   Authors: Radosław Karabowicz [committer] */
 
 // -------------------------------------------------------------------------
 // -----                      CbmMustPoint header file                 -----
diff --git a/core/detectors/must/CbmGeoMust.cxx b/core/detectors/must/CbmGeoMust.cxx
index 8916dbf1a..a8215fc9d 100644
--- a/core/detectors/must/CbmGeoMust.cxx
+++ b/core/detectors/must/CbmGeoMust.cxx
@@ -1,6 +1,6 @@
-/* Copyright (C) 2004-2024 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
+/* Copyright (C) 2025 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
    SPDX-License-Identifier: GPL-3.0-only
-   Authors: Radoslaw Karabowicz */
+   Authors: Radosław Karabowicz [committer] */
 
 ////////////////////////////////////////////////////////////////////////////
 // CbmGeoMust source file
diff --git a/core/detectors/must/CbmGeoMust.h b/core/detectors/must/CbmGeoMust.h
index eadd01cca..f18d4ed53 100644
--- a/core/detectors/must/CbmGeoMust.h
+++ b/core/detectors/must/CbmGeoMust.h
@@ -1,6 +1,6 @@
-/* Copyright (C) 2004-2024 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
+/* Copyright (C) 2025 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
    SPDX-License-Identifier: GPL-3.0-only
-   Authors: Radoslaw Karabowicz */
+   Authors: Radosław Karabowicz [committer] */
 
 ////////////////////////////////////////////////////////////////////////////
 // CbmGeoMust header file
diff --git a/core/detectors/must/CbmGeoMustPar.cxx b/core/detectors/must/CbmGeoMustPar.cxx
index 2f6e228e1..bc48bc12f 100644
--- a/core/detectors/must/CbmGeoMustPar.cxx
+++ b/core/detectors/must/CbmGeoMustPar.cxx
@@ -1,6 +1,6 @@
-/* Copyright (C) 2004-2024 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
+/* Copyright (C) 2025 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
    SPDX-License-Identifier: GPL-3.0-only
-   Authors: Radoslaw Karabowicz */
+   Authors: Radosław Karabowicz [committer] */
 
 ////////////////////////////////////////////////////////////////////////////
 // CbmGeoMustPar source file
diff --git a/core/detectors/must/CbmGeoMustPar.h b/core/detectors/must/CbmGeoMustPar.h
index 9c9ddf76c..ce3058005 100644
--- a/core/detectors/must/CbmGeoMustPar.h
+++ b/core/detectors/must/CbmGeoMustPar.h
@@ -1,6 +1,6 @@
-/* Copyright (C) 2004-2024 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
+/* Copyright (C) 2025 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
    SPDX-License-Identifier: GPL-3.0-only
-   Authors: Radoslaw Karabowicz */
+   Authors: Radosław Karabowicz [committer] */
 
 ////////////////////////////////////////////////////////////////////////////
 // CbmGeoMustPar header file
diff --git a/core/detectors/must/CbmMustContFact.cxx b/core/detectors/must/CbmMustContFact.cxx
index cb34a6956..d9631af9c 100644
--- a/core/detectors/must/CbmMustContFact.cxx
+++ b/core/detectors/must/CbmMustContFact.cxx
@@ -1,6 +1,6 @@
-/* Copyright (C) 2004-2024 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
+/* Copyright (C) 2025 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
    SPDX-License-Identifier: GPL-3.0-only
-   Authors: Radoslaw Karabowicz */
+   Authors: Radosław Karabowicz [committer] */
 
 ////////////////////////////////////////////////////////////////////////////
 // CbmMustContFact source file
diff --git a/core/detectors/must/CbmMustContFact.h b/core/detectors/must/CbmMustContFact.h
index 2deaaca9e..5b1537422 100644
--- a/core/detectors/must/CbmMustContFact.h
+++ b/core/detectors/must/CbmMustContFact.h
@@ -1,6 +1,6 @@
-/* Copyright (C) 2004-2024 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
+/* Copyright (C) 2025 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
    SPDX-License-Identifier: GPL-3.0-only
-   Authors: Radoslaw Karabowicz */
+   Authors: Radosław Karabowicz [committer] */
 
 ////////////////////////////////////////////////////////////////////////////
 // CbmMustContFact header file
diff --git a/core/detectors/must/CbmMustGeoScheme.cxx b/core/detectors/must/CbmMustGeoScheme.cxx
index d64e60209..a43ce7a9b 100644
--- a/core/detectors/must/CbmMustGeoScheme.cxx
+++ b/core/detectors/must/CbmMustGeoScheme.cxx
@@ -1,6 +1,7 @@
 /* Copyright (C) 2025 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
    SPDX-License-Identifier: GPL-3.0-only
    Authors: Radosław Karabowicz [committer] */
+
 /** CbmMustGeoScheme
  *@author  R.Karabowicz <r.karabowicz@gsi.de>
  *@version 1.0
diff --git a/macro/must/run_sim.C b/macro/must/run_sim.C
index a0f503fe7..07233784a 100644
--- a/macro/must/run_sim.C
+++ b/macro/must/run_sim.C
@@ -1,6 +1,6 @@
-/* Copyright (C) 2004-2024 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
+/* Copyright (C) 2025 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
    SPDX-License-Identifier: GPL-3.0-only
-   Authors: Radoslaw Karabowicz */
+   Authors: Radosław Karabowicz [committer] */
 
 int run_sim(Int_t nEvents = 10, Int_t pid = 13, Float_t p1 = 10.0, Float_t p2 = 10.0)
 {
diff --git a/sim/detectors/must/CbmMust.cxx b/sim/detectors/must/CbmMust.cxx
index f490a35e8..7c25754a9 100644
--- a/sim/detectors/must/CbmMust.cxx
+++ b/sim/detectors/must/CbmMust.cxx
@@ -1,6 +1,6 @@
-/* Copyright (C) 2004-2024 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
+/* Copyright (C) 2025 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
    SPDX-License-Identifier: GPL-3.0-only
-   Authors: Radoslaw Karabowicz */
+   Authors: Radosław Karabowicz [committer] */
 
 ////////////////////////////////////////////////////////////////////////////
 // CbmMust source file
diff --git a/sim/detectors/must/CbmMust.h b/sim/detectors/must/CbmMust.h
index 781259ffc..122cf29dc 100644
--- a/sim/detectors/must/CbmMust.h
+++ b/sim/detectors/must/CbmMust.h
@@ -1,6 +1,6 @@
-/* Copyright (C) 2004-2024 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
+/* Copyright (C) 2025 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
    SPDX-License-Identifier: GPL-3.0-only
-   Authors: Radoslaw Karabowicz */
+   Authors: Radosław Karabowicz [committer] */
 
 ////////////////////////////////////////////////////////////////////////////
 // CbmMust header file
-- 
GitLab


From 9defc37708eb9a17ac706ea0b1f97b620778d80b Mon Sep 17 00:00:00 2001
From: David Emschermann <d.emschermann@gsi.de>
Date: Tue, 11 Mar 2025 10:12:52 +0100
Subject: [PATCH 08/16] Adapt CbmGeoSetup to allow for usage of MUST / PASTA
 subsystem in mcbm_transport.C

---
 core/data/CbmDefs.h                           | 13 ++-
 core/detectors/must/CbmMustGeoScheme.cxx      |  5 +-
 sim/detectors/must/CbmMust.cxx                |  2 +-
 sim/transport/geosetup/CMakeLists.txt         | 84 +++++--------------
 .../geosetup/CbmGeoSetupProvider.cxx          | 14 ++--
 .../geosetup/CbmGeoSetupRepoProvider.cxx      | 22 +++--
 6 files changed, 58 insertions(+), 82 deletions(-)

diff --git a/core/data/CbmDefs.h b/core/data/CbmDefs.h
index 3b8943078..833005aad 100644
--- a/core/data/CbmDefs.h
+++ b/core/data/CbmDefs.h
@@ -44,19 +44,20 @@ enum class ECbmModuleId
   kMuch       = 4,   ///< Muon detection system
   kTrd        = 5,   ///< Transition Radiation Detector
   kTof        = 6,   ///< Time-of-flight Detector
-  kEcal       = 7,   ///< EM-Calorimeter
+  kMust       = 7,   ///< MuSt detection system
   kPsd        = 8,   ///< Projectile spectator detector
   kHodo       = 9,   ///< Hodoscope (for test beam times)
   kDummyDet   = 10,  ///< Dummy for tutorials or tests
-  kBmon       = 11,  //< Bmon Counter
+  kBmon       = 11,  ///< Bmon Counter
   kTrd2d      = 12,  ///< TRD-FASP Detector  (FIXME)
   kFsd        = 13,  ///< Forward spectator detector
   kNofSystems = 14,  ///< For loops over active systems
+  kEcal       = 15,  ///< EM-Calorimeter
   kMagnet     = 17,  ///< Magnet
   kTarget     = 18,  ///< Target
   kPipe       = 19,  ///< Beam pipe
   kShield     = 20,  ///< Beam pipe shielding in MUCH section
-                     //  kBmon       = 21,  ///< Bmon counter, hallo detector BMON
+                     //  kBmon       = 21,  ///< Bmon counter, halo detector BMON
   kPlatform   = 21,  ///< RICH rail platform
   kCave       = 22,  ///< Cave
   kLastModule = 23,  ///< For loops over all modules
@@ -111,6 +112,12 @@ enum class ECbmDataType
   kMuchPixelHit,
   kMuchStrawHit,
   kMuchTrack,  // MUCH
+  kMustPoint = ToIntegralType(ECbmModuleId::kMust) * 100,
+  kMustDigi,
+  kMustCluster,
+  kMustPixelHit,
+  kMustStrawHit,
+  kMustTrack,  // MUST
   kTrdPoint = ToIntegralType(ECbmModuleId::kTrd) * 100,
   kTrdDigi,
   kTrdCluster,
diff --git a/core/detectors/must/CbmMustGeoScheme.cxx b/core/detectors/must/CbmMustGeoScheme.cxx
index a43ce7a9b..52e8810db 100644
--- a/core/detectors/must/CbmMustGeoScheme.cxx
+++ b/core/detectors/must/CbmMustGeoScheme.cxx
@@ -12,6 +12,7 @@
  **/
 #include "CbmMustGeoScheme.h"
 
+#include "CbmDefs.h"
 #include "CbmMustLayer.h"  // for CbmMustLayer
 #include "CbmMustModule.h"
 #include "CbmMustStation.h"  // for CbmMustStation
@@ -110,7 +111,9 @@ uint32_t CbmMustGeoScheme::GetAddress(int statId, int layId, int modId, int stra
   //  2 bits  6 -  7    layer id (0...3) in module
   //  6 bits  8 - 13    module id (0...63) in layer
   //  7 bits 14 - 20    straw id (0...127) in straw
-  uint32_t address{15};  // replace with kMust
+
+  uint32_t address{static_cast<uint32_t>(ECbmModuleId::kMust)};
+
   address = address << 2;
   address += statId;
   address = address << 2;
diff --git a/sim/detectors/must/CbmMust.cxx b/sim/detectors/must/CbmMust.cxx
index 7c25754a9..f1b58e1c5 100644
--- a/sim/detectors/must/CbmMust.cxx
+++ b/sim/detectors/must/CbmMust.cxx
@@ -407,7 +407,7 @@ void CbmMust::ConstructGeometry()
 
   // --- Only ROOT geometries are supported
   if (fileName.EndsWith(".root")) {
-    LOG(info) << "Constructing Must geometry from ROOT file " << fileName.Data();
+    LOG(info) << "Importing MUST geometry from ROOT file " << fileName.Data();
     TGeoCombiTrans* fCombiTrans = NULL;
     Cbm::GeometryUtils::ImportRootGeometry(fgeoName, this, fCombiTrans);
     return;
diff --git a/sim/transport/geosetup/CMakeLists.txt b/sim/transport/geosetup/CMakeLists.txt
index 92ab662e9..3f758f8ce 100644
--- a/sim/transport/geosetup/CMakeLists.txt
+++ b/sim/transport/geosetup/CMakeLists.txt
@@ -1,62 +1,22 @@
-set(INCLUDE_DIRECTORIES
-  ${CMAKE_CURRENT_SOURCE_DIR}
-  )
-
-set(SRCS
-  CbmGeoSetup.cxx
-  CbmGeoSetupField.cxx
-  CbmGeoSetupModule.cxx
-  CbmGeoSetupMedia.cxx
-  CbmGeoSetupProvider.cxx
-  CbmGeoSetupRepoProvider.cxx
-  CbmGeoSetupDbProvider.cxx
-  )
-
-set(INSTALL_HEADERS
-  CbmGeoSetup.h
-  CbmGeoSetupField.h
-  CbmGeoSetupModule.h
-  CbmGeoSetupMedia.h
-  CbmGeoSetupProvider.h
-  CbmGeoSetupRepoProvider.h
-  CbmGeoSetupDbProvider.h
-  )
-
-set(LIBRARY_NAME CbmGeoSetup)
-set(LINKDEF ${LIBRARY_NAME}LinkDef.h)
-set(PUBLIC_DEPENDENCIES
-  CbmData
-  ROOT::Core
-  )
-
-set(PRIVATE_DEPENDENCIES
-  CbmMuchSim
-  CbmMvdSim
-  CbmPassive
-  CbmPsdSim
-  CbmFsdSim
-  CbmRichSim
-  CbmBmonSim
-  CbmSimBase
-  CbmStsSim
-  CbmTofSim
-  CbmTrdSim
-  FairRoot::Base
-  ROOT::Net
-  ROOT::RSQLite
-  
-  )
-
-set(INTERFACE_DEPENDENCIES
-  ROOT::Geom
-  )
-
-
-
-generate_cbm_library()
-
-
-install(FILES 
-       ${INSTALL_HEADERS} 
-       DESTINATION include/geosetup
-       )
+set(INCLUDE_DIRECTORIES ${CMAKE_CURRENT_SOURCE_DIR})
+
+  set(SRCS CbmGeoSetup.cxx CbmGeoSetupField.cxx CbmGeoSetupModule.cxx CbmGeoSetupMedia.cxx CbmGeoSetupProvider
+        .cxx CbmGeoSetupRepoProvider.cxx CbmGeoSetupDbProvider.cxx)
+
+    set(INSTALL_HEADERS CbmGeoSetup.h CbmGeoSetupField.h CbmGeoSetupModule.h CbmGeoSetupMedia.h CbmGeoSetupProvider
+          .h CbmGeoSetupRepoProvider.h CbmGeoSetupDbProvider.h)
+
+      set(LIBRARY_NAME CbmGeoSetup) set(LINKDEF ${LIBRARY_NAME} LinkDef.h) set(PUBLIC_DEPENDENCIES CbmData ROOT::Core)
+
+        set(PRIVATE_DEPENDENCIES CbmMuchSim CbmMustSim CbmMvdSim CbmPassive CbmPsdSim CbmFsdSim CbmRichSim CbmBmonSim
+              CbmSimBase CbmStsSim CbmTofSim CbmTrdSim FairRoot::Base ROOT::Net ROOT::RSQLite
+
+            )
+
+          set(INTERFACE_DEPENDENCIES ROOT::Geom)
+
+
+            generate_cbm_library()
+
+
+              install(FILES ${INSTALL_HEADERS} DESTINATION include / geosetup)
diff --git a/sim/transport/geosetup/CbmGeoSetupProvider.cxx b/sim/transport/geosetup/CbmGeoSetupProvider.cxx
index d7147faea..826893211 100644
--- a/sim/transport/geosetup/CbmGeoSetupProvider.cxx
+++ b/sim/transport/geosetup/CbmGeoSetupProvider.cxx
@@ -1,4 +1,4 @@
-/* Copyright (C) 2019-2020 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
+/* Copyright (C) 2019-2025 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
    SPDX-License-Identifier: GPL-3.0-only
    Authors: Evgeny Lavrik, Florian Uhlig [committer] */
 
@@ -13,6 +13,7 @@
 #include "CbmDefs.h"
 #include "CbmMagnet.h"
 #include "CbmMuch.h"
+#include "CbmMust.h"
 #include "CbmMvd.h"
 #include "CbmPipe.h"
 #include "CbmRich.h"
@@ -20,9 +21,9 @@
 #include "CbmTarget.h"
 #include "CbmTof.h"
 #include "CbmTrd.h"
-
 #include "FairModule.h"
 #include "FairRunSim.h"
+
 #include <Logger.h>
 //#include "CbmEcal.h"
 #include "CbmFsdMC.h"
@@ -45,8 +46,8 @@ namespace
     return {
       ECbmModuleId::kCave, ECbmModuleId::kMagnet, ECbmModuleId::kPipe, ECbmModuleId::kTarget,
       //      ECbmModuleId::kMvd, ECbmModuleId::kSts, ECbmModuleId::kRich, ECbmModuleId::kMuch, ECbmModuleId::kTrd, ECbmModuleId::kTof, ECbmModuleId::kEcal, ECbmModuleId::kPsd,
-      ECbmModuleId::kMvd, ECbmModuleId::kSts, ECbmModuleId::kRich, ECbmModuleId::kMuch, ECbmModuleId::kTrd,
-      ECbmModuleId::kTof, ECbmModuleId::kPsd, ECbmModuleId::kFsd,
+      ECbmModuleId::kMvd, ECbmModuleId::kSts, ECbmModuleId::kRich, ECbmModuleId::kMuch, ECbmModuleId::kMust,
+      ECbmModuleId::kTrd, ECbmModuleId::kTof, ECbmModuleId::kPsd, ECbmModuleId::kFsd,
       //      ECbmModuleId::kHodo, ECbmModuleId::kShield, ECbmModuleId::kPlatform };
       ECbmModuleId::kBmon, ECbmModuleId::kPlatform};
   }
@@ -104,7 +105,7 @@ void CbmGeoSetupProvider::RegisterSetup()
     std::vector<std::string> _tag;
     boost::split(_geom, fileName, [](char c) { return c == ':'; });
     boost::split(_tag, geoTag, [](char c) { return c == ':'; });
-    int counter {0};
+    int counter{0};
     for (auto& string : _geom) {
 
       LOG(info) << "-I- RegisterSetup: Registering " << modulName << " " << _tag[counter]
@@ -119,7 +120,7 @@ void CbmGeoSetupProvider::RegisterSetup()
         case ECbmModuleId::kMagnet: fairModule = new CbmMagnet("MAGNET"); break;
         case ECbmModuleId::kBmon: fairModule = new CbmBmon("BMON"); break;
         case ECbmModuleId::kPipe: {
-          std::string volname {"PIPE"};
+          std::string volname{"PIPE"};
           volname += std::to_string(counter);
           fairModule = new CbmPipe(volname.c_str());
           break;
@@ -129,6 +130,7 @@ void CbmGeoSetupProvider::RegisterSetup()
         case ECbmModuleId::kSts: fairModule = new CbmStsMC(isActive); break;
         case ECbmModuleId::kRich: fairModule = new CbmRich("RICH", isActive); break;
         case ECbmModuleId::kMuch: fairModule = new CbmMuch("MUCH", isActive); break;
+        case ECbmModuleId::kMust: fairModule = new CbmMuch("MUST", isActive); break;
         case ECbmModuleId::kTrd: fairModule = new CbmTrd("TRD", isActive); break;
         case ECbmModuleId::kTof:
           fairModule = new CbmTof("TOF", isActive);
diff --git a/sim/transport/geosetup/CbmGeoSetupRepoProvider.cxx b/sim/transport/geosetup/CbmGeoSetupRepoProvider.cxx
index b771e4ed1..c388c59ad 100644
--- a/sim/transport/geosetup/CbmGeoSetupRepoProvider.cxx
+++ b/sim/transport/geosetup/CbmGeoSetupRepoProvider.cxx
@@ -1,4 +1,4 @@
-/* Copyright (C) 2019-2021 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
+/* Copyright (C) 2019-2025 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
    SPDX-License-Identifier: GPL-3.0-only
    Authors: Evgeny Lavrik, Florian Uhlig [committer] */
 
@@ -10,12 +10,11 @@
 #include "CbmGeoSetupRepoProvider.h"
 
 #include "CbmDefs.h"
-
-#include <Logger.h>
-
 #include "TSystem.h"
 #include "TSystemDirectory.h"
 
+#include <Logger.h>
+
 #include <boost/algorithm/string.hpp>
 
 #include <fstream>
@@ -54,7 +53,7 @@ namespace
   };
 
   /// lookup map for various module properties
-  std::map<ECbmModuleId, DetInfo> detectorMap {
+  std::map<ECbmModuleId, DetInfo> detectorMap{
     {ECbmModuleId::kCave, {"caveGeoTag", "cave", "cave", "CAVE"}},
     {ECbmModuleId::kMagnet, {"magnetGeoTag", "magnet", "magnet", "MAGNET"}},
     {ECbmModuleId::kPipe, {"pipeGeoTag", "pipe", "pipe", "PIPE"}},
@@ -63,6 +62,7 @@ namespace
     {ECbmModuleId::kSts, {"stsGeoTag", "sts", "sts", "STS"}},
     {ECbmModuleId::kRich, {"richGeoTag", "rich", "rich", "RICH"}},
     {ECbmModuleId::kMuch, {"muchGeoTag", "much", "much", "MUCH"}},
+    {ECbmModuleId::kMust, {"mustGeoTag", "must", "must", "MUST"}},
     {ECbmModuleId::kTrd, {"trdGeoTag", "trd", "trd", "TRD"}},
     {ECbmModuleId::kTof, {"tofGeoTag", "tof", "tof", "TOF"}},
     //    { ECbmModuleId::kEcal, {"ecalGeoTag", "ecal", "ecal", "ECAL"} },
@@ -125,7 +125,7 @@ CbmGeoSetup CbmGeoSetupRepoProvider::GetSetupByTag(std::string setupTag, std::st
     LOG(warn) << "-W- LoadSetup " << setupTag << ": overwriting existing setup " << fSetup.GetTag();
   }
 
-  LOG(info) << "Loading CbmGeoSetup from svn repository.\nSetup tag: " << setupTag
+  LOG(info) << "Loading CbmGeoSetup from repository.\nSetup tag: " << setupTag
             << " Revision: " << (revision.empty() ? "latest" : revision);
 
   std::string base          = gSystem->Getenv("VMCWORKDIR");
@@ -138,7 +138,7 @@ CbmGeoSetup CbmGeoSetupRepoProvider::GetSetupByTag(std::string setupTag, std::st
 
   // remove commented out-lines
   std::regex commentRegex("/[/]+.*");
-  std::string replacementString {""};
+  std::string replacementString{""};
   fileContents = std::regex_replace(fileContents, commentRegex, replacementString);
 
   // setup name
@@ -179,8 +179,12 @@ CbmGeoSetup CbmGeoSetupRepoProvider::GetSetupByTag(std::string setupTag, std::st
     std::regex setModuleRegex(R"(.*SetModule\(.*)" + detector.second.tag + R"(\);)");
     std::string tag;
     bool added = false;
-    if (std::regex_search(fileContents, match, tagRegex)) { tag = match[1]; }
-    if (std::regex_search(fileContents, match, setModuleRegex)) { added = true; }
+    if (std::regex_search(fileContents, match, tagRegex)) {
+      tag = match[1];
+    }
+    if (std::regex_search(fileContents, match, setModuleRegex)) {
+      added = true;
+    }
 
     if (tag.size() && added) {
       ECbmModuleId moduleId = detector.first;
-- 
GitLab


From 0ffffbf0ec54536a92bf5bf79189ba63f86255c4 Mon Sep 17 00:00:00 2001
From: David Emschermann <d.emschermann@gsi.de>
Date: Tue, 11 Mar 2025 10:23:11 +0100
Subject: [PATCH 09/16] Do not run Clangformat on CMakeLists.txt

---
 sim/transport/geosetup/CMakeLists.txt | 85 ++++++++++++++++++++-------
 1 file changed, 63 insertions(+), 22 deletions(-)

diff --git a/sim/transport/geosetup/CMakeLists.txt b/sim/transport/geosetup/CMakeLists.txt
index 3f758f8ce..90b9d7f24 100644
--- a/sim/transport/geosetup/CMakeLists.txt
+++ b/sim/transport/geosetup/CMakeLists.txt
@@ -1,22 +1,63 @@
-set(INCLUDE_DIRECTORIES ${CMAKE_CURRENT_SOURCE_DIR})
-
-  set(SRCS CbmGeoSetup.cxx CbmGeoSetupField.cxx CbmGeoSetupModule.cxx CbmGeoSetupMedia.cxx CbmGeoSetupProvider
-        .cxx CbmGeoSetupRepoProvider.cxx CbmGeoSetupDbProvider.cxx)
-
-    set(INSTALL_HEADERS CbmGeoSetup.h CbmGeoSetupField.h CbmGeoSetupModule.h CbmGeoSetupMedia.h CbmGeoSetupProvider
-          .h CbmGeoSetupRepoProvider.h CbmGeoSetupDbProvider.h)
-
-      set(LIBRARY_NAME CbmGeoSetup) set(LINKDEF ${LIBRARY_NAME} LinkDef.h) set(PUBLIC_DEPENDENCIES CbmData ROOT::Core)
-
-        set(PRIVATE_DEPENDENCIES CbmMuchSim CbmMustSim CbmMvdSim CbmPassive CbmPsdSim CbmFsdSim CbmRichSim CbmBmonSim
-              CbmSimBase CbmStsSim CbmTofSim CbmTrdSim FairRoot::Base ROOT::Net ROOT::RSQLite
-
-            )
-
-          set(INTERFACE_DEPENDENCIES ROOT::Geom)
-
-
-            generate_cbm_library()
-
-
-              install(FILES ${INSTALL_HEADERS} DESTINATION include / geosetup)
+set(INCLUDE_DIRECTORIES
+  ${CMAKE_CURRENT_SOURCE_DIR}
+  )
+
+set(SRCS
+  CbmGeoSetup.cxx
+  CbmGeoSetupField.cxx
+  CbmGeoSetupModule.cxx
+  CbmGeoSetupMedia.cxx
+  CbmGeoSetupProvider.cxx
+  CbmGeoSetupRepoProvider.cxx
+  CbmGeoSetupDbProvider.cxx
+  )
+
+set(INSTALL_HEADERS
+  CbmGeoSetup.h
+  CbmGeoSetupField.h
+  CbmGeoSetupModule.h
+  CbmGeoSetupMedia.h
+  CbmGeoSetupProvider.h
+  CbmGeoSetupRepoProvider.h
+  CbmGeoSetupDbProvider.h
+  )
+
+set(LIBRARY_NAME CbmGeoSetup)
+set(LINKDEF ${LIBRARY_NAME}LinkDef.h)
+set(PUBLIC_DEPENDENCIES
+  CbmData
+  ROOT::Core
+  )
+
+set(PRIVATE_DEPENDENCIES
+  CbmMuchSim
+  CbmMustSim
+  CbmMvdSim
+  CbmPassive
+  CbmPsdSim
+  CbmFsdSim
+  CbmRichSim
+  CbmBmonSim
+  CbmSimBase
+  CbmStsSim
+  CbmTofSim
+  CbmTrdSim
+  FairRoot::Base
+  ROOT::Net
+  ROOT::RSQLite
+  
+  )
+
+set(INTERFACE_DEPENDENCIES
+  ROOT::Geom
+  )
+
+
+
+generate_cbm_library()
+
+
+install(FILES 
+       ${INSTALL_HEADERS} 
+       DESTINATION include/geosetup
+       )
-- 
GitLab


From 399a590c060982029fa29d5251ecb3e8e2dff980 Mon Sep 17 00:00:00 2001
From: David Emschermann <d.emschermann@gsi.de>
Date: Tue, 11 Mar 2025 10:28:58 +0100
Subject: [PATCH 10/16] Fix date in License header

---
 core/data/CbmDefs.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/core/data/CbmDefs.h b/core/data/CbmDefs.h
index 833005aad..34fed8d8a 100644
--- a/core/data/CbmDefs.h
+++ b/core/data/CbmDefs.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 2017-2021 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
+/* Copyright (C) 2017-2025 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
    SPDX-License-Identifier: GPL-3.0-only
    Authors: Florian Uhlig, Volker Friese [committer], Semen Lebedev */
 
-- 
GitLab


From d08c5cc0d86e588a29dd4094973960e10d169ffa Mon Sep 17 00:00:00 2001
From: David Emschermann <d.emschermann@gsi.de>
Date: Tue, 11 Mar 2025 11:04:50 +0100
Subject: [PATCH 11/16] Fix comments by Eoin to merge request

---
 macro/must/run_sim.C | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/macro/must/run_sim.C b/macro/must/run_sim.C
index 07233784a..db5fa14ac 100644
--- a/macro/must/run_sim.C
+++ b/macro/must/run_sim.C
@@ -22,13 +22,13 @@ int run_sim(Int_t nEvents = 10, Int_t pid = 13, Float_t p1 = 10.0, Float_t p2 =
   // Cave geometry
   TString caveGeom = "cave.geo";
   // Target geometry
-  TString targetGeom = "tpassive/targetbox_v22c.gdml";
+  TString targetGeom = "passive/targetbox_v22c.gdml";
   // Beam pipe geometry
   TString pipeGeom = "pipe/pipe_v22d.geo.root";
   // Magnet geometry and field map
-  TString magnetGeom  = "magnet/magnet_v22b.geo.root";
-  TString fieldMap    = "field_v22d";
-  Double_t fieldZ     = 50.;  // z position of field centre
+  TString magnetGeom  = "magnet/magnet_v22a.geo.root";   // "magnet/magnet_v22b.geo.root";
+  TString fieldMap    = "field_v22c";   // "field_v22d";
+  Double_t fieldZ     = 0.;   // z position of field centre
   Double_t fieldScale = 1.;   // field scaling factor
 
   std::string outFile = "points.root";
-- 
GitLab


From 4a11475f21edafc96bd25b4d41071451948b0190 Mon Sep 17 00:00:00 2001
From: David Emschermann <d.emschermann@gsi.de>
Date: Tue, 11 Mar 2025 11:35:48 +0100
Subject: [PATCH 12/16] No clang format on run_sim.C

---
 macro/must/run_sim.C | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/macro/must/run_sim.C b/macro/must/run_sim.C
index db5fa14ac..7f1a8673b 100644
--- a/macro/must/run_sim.C
+++ b/macro/must/run_sim.C
@@ -2,6 +2,8 @@
    SPDX-License-Identifier: GPL-3.0-only
    Authors: Radosław Karabowicz [committer] */
 
+// clang-format off
+
 int run_sim(Int_t nEvents = 10, Int_t pid = 13, Float_t p1 = 10.0, Float_t p2 = 10.0)
 {
   // 2212 proton
-- 
GitLab


From 3ae108a35b75c379d07d470f5b7a46df07a4afde Mon Sep 17 00:00:00 2001
From: David Emschermann <d.emschermann@gsi.de>
Date: Tue, 11 Mar 2025 11:58:41 +0100
Subject: [PATCH 13/16] Fix typo much -> must

---
 sim/transport/geosetup/CbmGeoSetupProvider.cxx | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sim/transport/geosetup/CbmGeoSetupProvider.cxx b/sim/transport/geosetup/CbmGeoSetupProvider.cxx
index 826893211..66e997c08 100644
--- a/sim/transport/geosetup/CbmGeoSetupProvider.cxx
+++ b/sim/transport/geosetup/CbmGeoSetupProvider.cxx
@@ -130,7 +130,7 @@ void CbmGeoSetupProvider::RegisterSetup()
         case ECbmModuleId::kSts: fairModule = new CbmStsMC(isActive); break;
         case ECbmModuleId::kRich: fairModule = new CbmRich("RICH", isActive); break;
         case ECbmModuleId::kMuch: fairModule = new CbmMuch("MUCH", isActive); break;
-        case ECbmModuleId::kMust: fairModule = new CbmMuch("MUST", isActive); break;
+        case ECbmModuleId::kMust: fairModule = new CbmMust("MUST", isActive); break;
         case ECbmModuleId::kTrd: fairModule = new CbmTrd("TRD", isActive); break;
         case ECbmModuleId::kTof:
           fairModule = new CbmTof("TOF", isActive);
-- 
GitLab


From a52ae9aeaf3726e5b95b3d13cf9b6358e6e6ff38 Mon Sep 17 00:00:00 2001
From: David Emschermann <d.emschermann@gsi.de>
Date: Tue, 11 Mar 2025 14:00:04 +0100
Subject: [PATCH 14/16] Switch to silver setup as default

---
 macro/mcbm/mcbm_transport.C | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/macro/mcbm/mcbm_transport.C b/macro/mcbm/mcbm_transport.C
index 598122bc5..c53c6dec6 100644
--- a/macro/mcbm/mcbm_transport.C
+++ b/macro/mcbm/mcbm_transport.C
@@ -21,10 +21,10 @@
 void SetTrack(CbmTransport*, Double_t, Int_t, Double_t, Double_t, Double_t);
 
 void mcbm_transport(Int_t nEvents = 10,
-                    //                  const char* setupName = "mcbm_beam_2025_02_14_silver",
+                    const char* setupName = "mcbm_beam_2025_02_14_silver",
                     //                  const char* setupName = "mcbm_beam_2024_06_20_uranium",
                     //                  const char* setupName = "mcbm_beam_2024_05_08_nickel",
-                    const char* setupName = "mcbm_beam_2024_03_22_gold",
+                    //                  const char* setupName = "mcbm_beam_2024_03_22_gold",
                     //                  const char* setupName = "mcbm_beam_2022_06_16_gold",
                     //                  const char* setupName = "mcbm_beam_2022_05_23_nickel",
                     //                  const char* setupName = "mcbm_beam_2022_03_28_uranium",
-- 
GitLab


From b808460cb7ce29dc1989c1f70803355a0609a93f Mon Sep 17 00:00:00 2001
From: Radoslaw Karabowicz <r.karabowicz@gsi.de>
Date: Wed, 12 Mar 2025 16:05:55 +0100
Subject: [PATCH 15/16] fix(must): Remove special characters
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Replace Radosław with Radoslaw and Ibrišimović with Ibrisimovic
in of multiple files.
---
 core/data/must/CbmMustPoint.cxx          | 2 +-
 core/data/must/CbmMustPoint.h            | 2 +-
 core/detectors/must/CbmGeoMust.cxx       | 4 ++--
 core/detectors/must/CbmGeoMust.h         | 4 ++--
 core/detectors/must/CbmGeoMustPar.cxx    | 4 ++--
 core/detectors/must/CbmGeoMustPar.h      | 4 ++--
 core/detectors/must/CbmMustContFact.cxx  | 4 ++--
 core/detectors/must/CbmMustContFact.h    | 4 ++--
 core/detectors/must/CbmMustGeoScheme.cxx | 2 +-
 core/detectors/must/CbmMustGeoScheme.h   | 2 +-
 core/detectors/must/CbmMustLayer.cxx     | 2 +-
 core/detectors/must/CbmMustLayer.h       | 2 +-
 core/detectors/must/CbmMustModule.cxx    | 2 +-
 core/detectors/must/CbmMustModule.h      | 2 +-
 core/detectors/must/CbmMustStation.cxx   | 2 +-
 core/detectors/must/CbmMustStation.h     | 2 +-
 core/detectors/must/CbmMustTube.cxx      | 2 +-
 core/detectors/must/CbmMustTube.h        | 2 +-
 macro/must/run_sim.C                     | 2 +-
 sim/detectors/must/CbmMust.cxx           | 4 ++--
 sim/detectors/must/CbmMust.h             | 4 ++--
 21 files changed, 29 insertions(+), 29 deletions(-)

diff --git a/core/data/must/CbmMustPoint.cxx b/core/data/must/CbmMustPoint.cxx
index fcd6a26cf..03b9b81ca 100644
--- a/core/data/must/CbmMustPoint.cxx
+++ b/core/data/must/CbmMustPoint.cxx
@@ -1,6 +1,6 @@
 /* Copyright (C) 2025 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
    SPDX-License-Identifier: GPL-3.0-only
-   Authors: Radosław Karabowicz [committer] */
+   Authors: Radoslaw Karabowicz [committer] */
 
 // -------------------------------------------------------------------------
 // -----                      CbmMustPoint source file                 -----
diff --git a/core/data/must/CbmMustPoint.h b/core/data/must/CbmMustPoint.h
index 3586fb471..e4d7a321a 100644
--- a/core/data/must/CbmMustPoint.h
+++ b/core/data/must/CbmMustPoint.h
@@ -1,6 +1,6 @@
 /* Copyright (C) 2025 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
    SPDX-License-Identifier: GPL-3.0-only
-   Authors: Radosław Karabowicz [committer] */
+   Authors: Radoslaw Karabowicz [committer] */
 
 // -------------------------------------------------------------------------
 // -----                      CbmMustPoint header file                 -----
diff --git a/core/detectors/must/CbmGeoMust.cxx b/core/detectors/must/CbmGeoMust.cxx
index a8215fc9d..8780a3fe1 100644
--- a/core/detectors/must/CbmGeoMust.cxx
+++ b/core/detectors/must/CbmGeoMust.cxx
@@ -1,6 +1,6 @@
 /* Copyright (C) 2025 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
    SPDX-License-Identifier: GPL-3.0-only
-   Authors: Radosław Karabowicz [committer] */
+   Authors: Radoslaw Karabowicz [committer] */
 
 ////////////////////////////////////////////////////////////////////////////
 // CbmGeoMust source file
@@ -9,7 +9,7 @@
 //
 // authors: Radoslaw Karabowicz, GSI, 2024
 //
-// modified from CbmGeoFts by Nafija Ibrišimović in 2023
+// modified from CbmGeoFts by Nafija Ibrisimovic in 2023
 ////////////////////////////////////////////////////////////////////////////
 
 #include "CbmGeoMust.h"
diff --git a/core/detectors/must/CbmGeoMust.h b/core/detectors/must/CbmGeoMust.h
index f18d4ed53..fbeca29fb 100644
--- a/core/detectors/must/CbmGeoMust.h
+++ b/core/detectors/must/CbmGeoMust.h
@@ -1,6 +1,6 @@
 /* Copyright (C) 2025 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
    SPDX-License-Identifier: GPL-3.0-only
-   Authors: Radosław Karabowicz [committer] */
+   Authors: Radoslaw Karabowicz [committer] */
 
 ////////////////////////////////////////////////////////////////////////////
 // CbmGeoMust header file
@@ -9,7 +9,7 @@
 //
 // authors: Radoslaw Karabowicz, GSI, 2024
 //
-// modified from CbmGeoFts by Nafija Ibrišimović in 2023
+// modified from CbmGeoFts by Nafija Ibrisimovic in 2023
 ////////////////////////////////////////////////////////////////////////////
 
 #ifndef CBMGEOMUST_H
diff --git a/core/detectors/must/CbmGeoMustPar.cxx b/core/detectors/must/CbmGeoMustPar.cxx
index bc48bc12f..1f79bf4e9 100644
--- a/core/detectors/must/CbmGeoMustPar.cxx
+++ b/core/detectors/must/CbmGeoMustPar.cxx
@@ -1,6 +1,6 @@
 /* Copyright (C) 2025 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
    SPDX-License-Identifier: GPL-3.0-only
-   Authors: Radosław Karabowicz [committer] */
+   Authors: Radoslaw Karabowicz [committer] */
 
 ////////////////////////////////////////////////////////////////////////////
 // CbmGeoMustPar source file
@@ -9,7 +9,7 @@
 //
 // authors: Radoslaw Karabowicz, GSI, 2024
 //
-// modified from CbmGeoFtsPar by Nafija Ibrišimović in 2023
+// modified from CbmGeoFtsPar by Nafija Ibrisimovic in 2023
 ////////////////////////////////////////////////////////////////////////////
 
 #include "CbmGeoMustPar.h"
diff --git a/core/detectors/must/CbmGeoMustPar.h b/core/detectors/must/CbmGeoMustPar.h
index ce3058005..dd6d6c212 100644
--- a/core/detectors/must/CbmGeoMustPar.h
+++ b/core/detectors/must/CbmGeoMustPar.h
@@ -1,6 +1,6 @@
 /* Copyright (C) 2025 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
    SPDX-License-Identifier: GPL-3.0-only
-   Authors: Radosław Karabowicz [committer] */
+   Authors: Radoslaw Karabowicz [committer] */
 
 ////////////////////////////////////////////////////////////////////////////
 // CbmGeoMustPar header file
@@ -9,7 +9,7 @@
 //
 // authors: Radoslaw Karabowicz, GSI, 2024
 //
-// modified from CbmGeoFtsPar by Nafija Ibrišimović in 2023
+// modified from CbmGeoFtsPar by Nafija Ibrisimovic in 2023
 ////////////////////////////////////////////////////////////////////////////
 
 #ifndef CBMGEOMUSTPAR_H
diff --git a/core/detectors/must/CbmMustContFact.cxx b/core/detectors/must/CbmMustContFact.cxx
index d9631af9c..ae816b670 100644
--- a/core/detectors/must/CbmMustContFact.cxx
+++ b/core/detectors/must/CbmMustContFact.cxx
@@ -1,6 +1,6 @@
 /* Copyright (C) 2025 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
    SPDX-License-Identifier: GPL-3.0-only
-   Authors: Radosław Karabowicz [committer] */
+   Authors: Radoslaw Karabowicz [committer] */
 
 ////////////////////////////////////////////////////////////////////////////
 // CbmMustContFact source file
@@ -9,7 +9,7 @@
 //
 // authors: Radoslaw Karabowicz, GSI, 2024
 //
-// modified from CbmMustContFact by Nafija Ibrišimović in 2023
+// modified from CbmMustContFact by Nafija Ibrisimovic in 2023
 ////////////////////////////////////////////////////////////////////////////
 
 #include "CbmMustContFact.h"
diff --git a/core/detectors/must/CbmMustContFact.h b/core/detectors/must/CbmMustContFact.h
index 5b1537422..b8db38e32 100644
--- a/core/detectors/must/CbmMustContFact.h
+++ b/core/detectors/must/CbmMustContFact.h
@@ -1,6 +1,6 @@
 /* Copyright (C) 2025 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
    SPDX-License-Identifier: GPL-3.0-only
-   Authors: Radosław Karabowicz [committer] */
+   Authors: Radoslaw Karabowicz [committer] */
 
 ////////////////////////////////////////////////////////////////////////////
 // CbmMustContFact header file
@@ -9,7 +9,7 @@
 //
 // authors: Radoslaw Karabowicz, GSI, 2024
 //
-// modified from CbmMustContFact by Nafija Ibrišimović in 2023
+// modified from CbmMustContFact by Nafija Ibrisimovic in 2023
 ////////////////////////////////////////////////////////////////////////////
 
 #ifndef CBMMUSTCONTFACT_H
diff --git a/core/detectors/must/CbmMustGeoScheme.cxx b/core/detectors/must/CbmMustGeoScheme.cxx
index 52e8810db..ecd122b13 100644
--- a/core/detectors/must/CbmMustGeoScheme.cxx
+++ b/core/detectors/must/CbmMustGeoScheme.cxx
@@ -1,6 +1,6 @@
 /* Copyright (C) 2025 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
    SPDX-License-Identifier: GPL-3.0-only
-   Authors: Radosław Karabowicz [committer] */
+   Authors: Radoslaw Karabowicz [committer] */
 
 /** CbmMustGeoScheme
  *@author  R.Karabowicz <r.karabowicz@gsi.de>
diff --git a/core/detectors/must/CbmMustGeoScheme.h b/core/detectors/must/CbmMustGeoScheme.h
index ddcd6a7cd..b603bb663 100644
--- a/core/detectors/must/CbmMustGeoScheme.h
+++ b/core/detectors/must/CbmMustGeoScheme.h
@@ -1,6 +1,6 @@
 /* Copyright (C) 2025 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
    SPDX-License-Identifier: GPL-3.0-only
-   Authors: Radosław Karabowicz [committer] */
+   Authors: Radoslaw Karabowicz [committer] */
 
 // -------------------------------------------------------------------------
 // -----                   CbmMustGeoScheme header file                -----
diff --git a/core/detectors/must/CbmMustLayer.cxx b/core/detectors/must/CbmMustLayer.cxx
index 1422079cb..9b77d9411 100644
--- a/core/detectors/must/CbmMustLayer.cxx
+++ b/core/detectors/must/CbmMustLayer.cxx
@@ -1,6 +1,6 @@
 /* Copyright (C) 2025 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
    SPDX-License-Identifier: GPL-3.0-only
-   Authors: Radosław Karabowicz [committer] */
+   Authors: Radoslaw Karabowicz [committer] */
 
 /** CbmMustLayer.cxx
  *@author  R.Karabowicz <r.karabowicz@gsi.de>
diff --git a/core/detectors/must/CbmMustLayer.h b/core/detectors/must/CbmMustLayer.h
index 1c60c30e6..eccc602d1 100644
--- a/core/detectors/must/CbmMustLayer.h
+++ b/core/detectors/must/CbmMustLayer.h
@@ -1,6 +1,6 @@
 /* Copyright (C) 2025 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
    SPDX-License-Identifier: GPL-3.0-only
-   Authors: Radosław Karabowicz [committer] */
+   Authors: Radoslaw Karabowicz [committer] */
 
 /** CbmMustLayer.h
  *@author  R.Karabowicz <r.karabowicz@gsi.de>
diff --git a/core/detectors/must/CbmMustModule.cxx b/core/detectors/must/CbmMustModule.cxx
index 26502ec98..690710fab 100644
--- a/core/detectors/must/CbmMustModule.cxx
+++ b/core/detectors/must/CbmMustModule.cxx
@@ -1,6 +1,6 @@
 /* Copyright (C) 2025 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
    SPDX-License-Identifier: GPL-3.0-only
-   Authors: Radosław Karabowicz [committer] */
+   Authors: Radoslaw Karabowicz [committer] */
 
 /** CbmMustModule.cxx
  *@author  R.Karabowicz <r.karabowicz@gsi.de>
diff --git a/core/detectors/must/CbmMustModule.h b/core/detectors/must/CbmMustModule.h
index 65f96123c..d78a2e919 100644
--- a/core/detectors/must/CbmMustModule.h
+++ b/core/detectors/must/CbmMustModule.h
@@ -1,6 +1,6 @@
 /* Copyright (C) 2025 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
    SPDX-License-Identifier: GPL-3.0-only
-   Authors: Radosław Karabowicz [committer] */
+   Authors: Radoslaw Karabowicz [committer] */
 
 /** CbmMustModule.h
  *@author  R.Karabowicz <r.karabowicz@gsi.de>
diff --git a/core/detectors/must/CbmMustStation.cxx b/core/detectors/must/CbmMustStation.cxx
index b72c53e05..07eca27c0 100644
--- a/core/detectors/must/CbmMustStation.cxx
+++ b/core/detectors/must/CbmMustStation.cxx
@@ -1,6 +1,6 @@
 /* Copyright (C) 2025 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
    SPDX-License-Identifier: GPL-3.0-only
-   Authors: Radosław Karabowicz [committer] */
+   Authors: Radoslaw Karabowicz [committer] */
 
 /** CbmMustStation.cxx
  *@author  R.Karabowicz <r.karabowicz@gsi.de>
diff --git a/core/detectors/must/CbmMustStation.h b/core/detectors/must/CbmMustStation.h
index 9f9ad649b..bbec038eb 100644
--- a/core/detectors/must/CbmMustStation.h
+++ b/core/detectors/must/CbmMustStation.h
@@ -1,6 +1,6 @@
 /* Copyright (C) 2025 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
    SPDX-License-Identifier: GPL-3.0-only
-   Authors: Radosław Karabowicz [committer] */
+   Authors: Radoslaw Karabowicz [committer] */
 
 /** CbmMustStation.h
  *@author  R.Karabowicz <r.karabowicz@gsi.de>
diff --git a/core/detectors/must/CbmMustTube.cxx b/core/detectors/must/CbmMustTube.cxx
index 0481e23cc..224e67476 100644
--- a/core/detectors/must/CbmMustTube.cxx
+++ b/core/detectors/must/CbmMustTube.cxx
@@ -1,6 +1,6 @@
 /* Copyright (C) 2025 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
    SPDX-License-Identifier: GPL-3.0-only
-   Authors: Radosław Karabowicz [committer] */
+   Authors: Radoslaw Karabowicz [committer] */
 
 ////////////////////////////////////////////////////////////////////////////
 // CbmMustTube header file
diff --git a/core/detectors/must/CbmMustTube.h b/core/detectors/must/CbmMustTube.h
index ae5d3bf29..d80923aea 100644
--- a/core/detectors/must/CbmMustTube.h
+++ b/core/detectors/must/CbmMustTube.h
@@ -1,6 +1,6 @@
 /* Copyright (C) 2025 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
    SPDX-License-Identifier: GPL-3.0-only
-   Authors: Radosław Karabowicz [committer] */
+   Authors: Radoslaw Karabowicz [committer] */
 
 ////////////////////////////////////////////////////////////////////////////
 // CbmMustTube header file
diff --git a/macro/must/run_sim.C b/macro/must/run_sim.C
index 7f1a8673b..f10cfd3f1 100644
--- a/macro/must/run_sim.C
+++ b/macro/must/run_sim.C
@@ -1,6 +1,6 @@
 /* Copyright (C) 2025 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
    SPDX-License-Identifier: GPL-3.0-only
-   Authors: Radosław Karabowicz [committer] */
+   Authors: Radoslaw Karabowicz [committer] */
 
 // clang-format off
 
diff --git a/sim/detectors/must/CbmMust.cxx b/sim/detectors/must/CbmMust.cxx
index f1b58e1c5..9558a7fda 100644
--- a/sim/detectors/must/CbmMust.cxx
+++ b/sim/detectors/must/CbmMust.cxx
@@ -1,6 +1,6 @@
 /* Copyright (C) 2025 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
    SPDX-License-Identifier: GPL-3.0-only
-   Authors: Radosław Karabowicz [committer] */
+   Authors: Radoslaw Karabowicz [committer] */
 
 ////////////////////////////////////////////////////////////////////////////
 // CbmMust source file
@@ -9,7 +9,7 @@
 //
 // authors: Radoslaw Karabowicz, GSI, 2024
 //
-// modified from CbmMust by Nafija Ibrišimović in 2023
+// modified from CbmMust by Nafija Ibrisimovic in 2023
 ////////////////////////////////////////////////////////////////////////////
 
 #include "CbmMust.h"
diff --git a/sim/detectors/must/CbmMust.h b/sim/detectors/must/CbmMust.h
index 122cf29dc..84ea7d16e 100644
--- a/sim/detectors/must/CbmMust.h
+++ b/sim/detectors/must/CbmMust.h
@@ -1,6 +1,6 @@
 /* Copyright (C) 2025 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
    SPDX-License-Identifier: GPL-3.0-only
-   Authors: Radosław Karabowicz [committer] */
+   Authors: Radoslaw Karabowicz [committer] */
 
 ////////////////////////////////////////////////////////////////////////////
 // CbmMust header file
@@ -9,7 +9,7 @@
 //
 // authors: Radoslaw Karabowicz, GSI, 2024
 //
-// modified from CbmMust by Nafija Ibrišimović in 2023
+// modified from CbmMust by Nafija Ibrisimovic in 2023
 ////////////////////////////////////////////////////////////////////////////
 
 #ifndef CBMMUST_H
-- 
GitLab


From bdfc2762a1de7746966c8387303f84e7b5247eef Mon Sep 17 00:00:00 2001
From: Radoslaw Karabowicz <r.karabowicz@gsi.de>
Date: Wed, 19 Mar 2025 15:35:54 +0100
Subject: [PATCH 16/16] feat(must): Replace TObjArray with std::vector for
 parameter storage

Changed CbmMustGeoScheme, CbmMustStation, CbmMustLayer,
CbmMustModule, CbmMustTube to store and retrieve geometry
parameters with std::vector.
Changed CbmMust to allow for the creation of the parameter
file with std::vector<CbmMustStation*>.
---
 core/detectors/must/CbmMustGeoScheme.cxx | 43 +++++++++++-------------
 core/detectors/must/CbmMustGeoScheme.h   | 11 +++---
 core/detectors/must/CbmMustLayer.cxx     | 11 +++---
 core/detectors/must/CbmMustLayer.h       | 13 +++----
 core/detectors/must/CbmMustModule.cxx    | 13 ++++---
 core/detectors/must/CbmMustModule.h      | 21 +++++++-----
 core/detectors/must/CbmMustStation.cxx   | 12 +++----
 core/detectors/must/CbmMustStation.h     | 17 +++++-----
 core/detectors/must/CbmMustTube.h        |  2 +-
 sim/detectors/must/CbmMust.cxx           | 10 +++---
 10 files changed, 73 insertions(+), 80 deletions(-)

diff --git a/core/detectors/must/CbmMustGeoScheme.cxx b/core/detectors/must/CbmMustGeoScheme.cxx
index ecd122b13..f312fad63 100644
--- a/core/detectors/must/CbmMustGeoScheme.cxx
+++ b/core/detectors/must/CbmMustGeoScheme.cxx
@@ -29,8 +29,8 @@
 #include <TGeoNode.h>      // for TGeoNode
 #include <TGeoTube.h>      // for TGeoTube
 #include <TGeoVolume.h>    // for TGeoVolume
+#include <TKey.h>          // for TKey
 #include <TMath.h>         // for Cos, Sqrt
-#include <TObjArray.h>     // for TObjArray
 #include <TObject.h>       // for TObject
 #include <TVector3.h>      // for TVector3
 
@@ -69,7 +69,7 @@ CbmMustGeoScheme* CbmMustGeoScheme::Instance()
 // -------------------------------------------------------------------------
 
 // -------------------------------------------------------------------------
-void CbmMustGeoScheme::Init(TObjArray* stations)
+void CbmMustGeoScheme::Init(std::vector<CbmMustStation*> stations)
 {
   if (!fInitialized) {
     fStations    = stations;
@@ -82,23 +82,22 @@ void CbmMustGeoScheme::Init(TObjArray* stations)
 // -------------------------------------------------------------------------
 void CbmMustGeoScheme::Init(TString parFileName)
 {
-
   /// Save old global file and folder pointer to avoid messing with FairRoot
   TFile* oldFile     = gFile;
   TDirectory* oldDir = gDirectory;
 
   TFile* file = new TFile(parFileName);
   LOG_IF(fatal, !file) << "File " << parFileName << " does not exist";
-  TObjArray* stations = file->Get<TObjArray>("stations");
-  LOG_IF(fatal, !stations) << "No TObjArray stations found in file " << parFileName;
+  for (auto&& keyAsObj : *file->GetListOfKeys()) {
+    auto key = (TKey*) keyAsObj;
+    fStations.push_back(static_cast<CbmMustStation*>(key->ReadObj()));
+  }
   file->Close();
   file->Delete();
 
   /// Restore old global file and folder pointer to avoid messing with FairRoot
   gFile      = oldFile;
   gDirectory = oldDir;
-
-  Init(stations);
 }
 // -------------------------------------------------------------------------
 
@@ -133,19 +132,15 @@ uint32_t CbmMustGeoScheme::GetAddress(int statId, int layId, int modId, int stra
 // -------------------------------------------------------------------------
 CbmMustStation* CbmMustGeoScheme::GetStation(int iStation) const
 {
+  Bool_t result = (iStation >= 0) || (iStation < (int) fStations.size());
 
-  if (!fStations) return nullptr;
-  Bool_t result = (iStation >= 0) || (iStation < fStations->GetEntriesFast());
-
-  return result ? (CbmMustStation*) fStations->At(iStation) : nullptr;
+  return result ? (CbmMustStation*) fStations.at(iStation) : nullptr;
 }
 // -------------------------------------------------------------------------
 
 CbmMustStation* CbmMustGeoScheme::FindStation(int detid)
 {
-  if (!fStations) fStations = new TObjArray();
-  for (Int_t iobj = 0; iobj < fStations->GetEntriesFast(); iobj++) {
-    CbmMustStation* tempStation = (CbmMustStation*) (fStations->At(iobj));
+  for (const auto tempStation : fStations) {
     if (tempStation->GetDetectorId() == detid) return tempStation;
   }
   return nullptr;
@@ -161,20 +156,18 @@ CbmMustTube* CbmMustGeoScheme::GetTube(int detid)
 
 bool CbmMustGeoScheme::AddStation(CbmMustStation* station)
 {
-  for (Int_t iobj = 0; iobj < fStations->GetEntriesFast(); iobj++) {
-    CbmMustStation* tempStation = (CbmMustStation*) (fStations->At(iobj));
+  for (const auto tempStation : fStations) {
     if (tempStation->GetDetectorId() == station->GetDetectorId()) return false;
   }
 
-  fStations->Add(station);
+  fStations.push_back(station);
   return true;
 }
 
 void CbmMustGeoScheme::Show()
 {
   LOG(info) << "MustGeoScheme:";
-  for (Int_t iobj = 0; iobj < fStations->GetEntriesFast(); iobj++) {
-    CbmMustStation* tempStation = (CbmMustStation*) (fStations->At(iobj));
+  for (const auto tempStation : fStations) {
     tempStation->Show();
   }
 }
@@ -190,8 +183,13 @@ void CbmMustGeoScheme::StoreGeoScheme()
   std::string geoSchemeFileName("must_geoScheme.root");
   TFile* file = new TFile(geoSchemeFileName.c_str(), "recreate");
   LOG_IF(fatal, !file) << "File " << geoSchemeFileName << " does not exist";
-  file->WriteObject(fStations, "stations");
-  //  fStations->Write();
+  auto istat{1};
+  for (const auto tempStation : fStations) {
+    LOG(info) << "Store station" << istat << " at z=" << tempStation->GetZ() << "cm with " << tempStation->GetNLayers()
+              << " layers";
+    file->WriteObject(tempStation, Form("station%d", istat));
+    istat++;
+  }
   file->Close();
   file->Delete();
 
@@ -202,7 +200,6 @@ void CbmMustGeoScheme::StoreGeoScheme()
 // -------------------------------------------------------------------------
 CbmMustLayer* CbmMustGeoScheme::GetLayer(int iStation, int iLayer) const
 {
-
   CbmMustStation* station = GetStation(iStation);
   return station ? station->GetLayer(iLayer) : nullptr;
 }
@@ -214,7 +211,7 @@ void CbmMustGeoScheme::NavigateTo(const TString& path)
   gGeoManager->cd(path.Data());
   //    fGeoPathHash;
   //  fGeoPathHash      = path.Hash();
-  TGeoVolume* fCurrentVolume = gGeoManager->GetCurrentVolume();
+  //  TGeoVolume* fCurrentVolume = gGeoManager->GetCurrentVolume();
   //  TGeoBBox*   fVolumeBoxShape   = (TGeoBBox*) fCurrentVolume->GetShape();
   Double_t local[3] = {0., 0., 0.};
   gGeoManager->LocalToMaster(local, fGlobal);
diff --git a/core/detectors/must/CbmMustGeoScheme.h b/core/detectors/must/CbmMustGeoScheme.h
index b603bb663..80ac07f42 100644
--- a/core/detectors/must/CbmMustGeoScheme.h
+++ b/core/detectors/must/CbmMustGeoScheme.h
@@ -27,7 +27,6 @@
 #include <TArrayI.h>     // for TArrayI
 #include <TGeoBBox.h>    // for TGeoBBox
 #include <TGeoCone.h>    // for TGeoCone
-#include <TObjArray.h>   // for TObjArray
 #include <TObject.h>     // for TObject
 #include <TString.h>     // for TString
 #include <TVector3.h>    // for TVector3
@@ -55,13 +54,13 @@ class CbmMustGeoScheme : public TObject {
   Bool_t IsInitialized() { return fInitialized; }
 
   // Get geometry objects by indices
-  TObjArray* GetStations() const { return fStations; };
+  std::vector<CbmMustStation*> GetStations() const { return fStations; };
   CbmMustStation* GetStation(int iStation) const;
   CbmMustLayer* GetLayer(int iStation, int iLayer) const;
 
   uint32_t GetAddress(int statId, int layId, int modId, int strawId);
 
-  int GetNStations() const { return fStations->GetEntriesFast(); }
+  int GetNStations() const { return fStations.size(); }
 
   CbmMustTube* GetTube(int detid);
 
@@ -70,7 +69,7 @@ class CbmMustGeoScheme : public TObject {
   void Show();
   void StoreGeoScheme();
 
-  void Init(TObjArray* stations);
+  void Init(std::vector<CbmMustStation*> stations);
   void Init(TString parFileName);
 
   void NavigateTo(const TString& path);
@@ -84,8 +83,8 @@ class CbmMustGeoScheme : public TObject {
 
   CbmMustGeoScheme();
 
-  bool fInitialized{false};
-  TObjArray* fStations{nullptr};  //!
+  bool fInitialized{false};  //!
+  std::vector<CbmMustStation*> fStations;
   double fGlobal[3]{0., 0., 0.};
 
   CbmMustGeoScheme(const CbmMustGeoScheme&);
diff --git a/core/detectors/must/CbmMustLayer.cxx b/core/detectors/must/CbmMustLayer.cxx
index 9b77d9411..66b7e6056 100644
--- a/core/detectors/must/CbmMustLayer.cxx
+++ b/core/detectors/must/CbmMustLayer.cxx
@@ -59,8 +59,7 @@ CbmMustTube* CbmMustLayer::GetTube(int detid)
 
 CbmMustModule* CbmMustLayer::FindModule(int detid)
 {
-  for (Int_t iobj = 0; iobj < fModules.GetEntriesFast(); iobj++) {
-    CbmMustModule* tempModule = (CbmMustModule*) (fModules.At(iobj));
+  for (const auto tempModule : fModules) {
     if (tempModule->GetDetectorId() == detid) return tempModule;
   }
   return nullptr;
@@ -68,20 +67,18 @@ CbmMustModule* CbmMustLayer::FindModule(int detid)
 
 bool CbmMustLayer::AddModule(CbmMustModule* module)
 {
-  for (Int_t iobj = 0; iobj < fModules.GetEntriesFast(); iobj++) {
-    CbmMustModule* tempModule = (CbmMustModule*) (fModules.At(iobj));
+  for (const auto tempModule : fModules) {
     if (tempModule->GetDetectorId() == module->GetDetectorId()) return false;
   }
 
-  fModules.Add(module);
+  fModules.push_back(module);
   return true;
 }
 
 void CbmMustLayer::Show()
 {
   LOG(info) << "    Layer " << fDetectorId << " (@ z = " << fZ << "):";
-  for (Int_t iobj = 0; iobj < fModules.GetEntriesFast(); iobj++) {
-    CbmMustModule* tempModule = (CbmMustModule*) (fModules.At(iobj));
+  for (const auto tempModule : fModules) {
     tempModule->Show();
   }
 }
diff --git a/core/detectors/must/CbmMustLayer.h b/core/detectors/must/CbmMustLayer.h
index eccc602d1..6b2901532 100644
--- a/core/detectors/must/CbmMustLayer.h
+++ b/core/detectors/must/CbmMustLayer.h
@@ -22,9 +22,10 @@
 
 #include <Rtypes.h>      // for THashConsistencyHolder, ClassDef
 #include <RtypesCore.h>  // for Double_t, Int_t, Bool_t, Double32_t
-#include <TObjArray.h>   // for TObjArray
 #include <TObject.h>     // for TObject
 
+#include <vector>  // for vector
+
 class CbmMustLayer : public TObject {
 
  public:
@@ -54,9 +55,9 @@ class CbmMustLayer : public TObject {
   double GetZ() const { return fZ; }
   double GetZtoStationCenter() const { return fZtoStationCenter; }
 
-  int GetNModules() const { return fModules.GetEntriesFast(); }
+  int GetNModules() const { return fModules.size(); }
 
-  CbmMustModule* GetModule(int iModule) const { return (CbmMustModule*) fModules.At(iModule); }
+  CbmMustModule* GetModule(int iModule) const { return fModules.at(iModule); }
 
   CbmMustTube* GetTube(int detid);
 
@@ -67,9 +68,9 @@ class CbmMustLayer : public TObject {
  protected:
   int fDetectorId{0};  // Unique detector ID
   double fZ{0.};
-  double fZtoStationCenter{0.};  // Relative position of the layer center with respect
-                                 // to the station center
-  TObjArray fModules;            // Array of CbmMustModules
+  double fZtoStationCenter{0.};          // Relative position of the layer center with respect
+                                         // to the station center
+  std::vector<CbmMustModule*> fModules;  // Array of CbmMustModules
 
   ClassDef(CbmMustLayer, 1);
 };
diff --git a/core/detectors/must/CbmMustModule.cxx b/core/detectors/must/CbmMustModule.cxx
index 690710fab..696999c2e 100644
--- a/core/detectors/must/CbmMustModule.cxx
+++ b/core/detectors/must/CbmMustModule.cxx
@@ -35,8 +35,7 @@ CbmMustModule::CbmMustModule(int iStation, int iLayer, int iModule, TVector3 pos
 
 CbmMustTube* CbmMustModule::FindTube(int detid)
 {
-  for (Int_t iobj = 0; iobj < fTubes.GetEntriesFast(); iobj++) {
-    CbmMustTube* tempTube = (CbmMustTube*) (fTubes.At(iobj));
+  for (const auto tempTube : fTubes) {
     if (tempTube->GetTubeNumber() == detid) return tempTube;
   }
   return nullptr;
@@ -44,11 +43,10 @@ CbmMustTube* CbmMustModule::FindTube(int detid)
 
 bool CbmMustModule::AddTube(CbmMustTube* tube)
 {
-  for (Int_t iobj = 0; iobj < fTubes.GetEntriesFast(); iobj++) {
-    CbmMustTube* tempTube = (CbmMustTube*) (fTubes.At(iobj));
+  for (const auto tempTube : fTubes) {
     if (tempTube->GetTubeNumber() == tube->GetTubeNumber()) return false;
   }
-  fTubes.Add(tube);
+  fTubes.push_back(tube);
   return true;
 }
 
@@ -59,8 +57,8 @@ void CbmMustModule::Show()
   std::string tubeString(128, '.');
   std::string tubeNumbDec(128, '0');
   std::string tubeNumbOne(128, '0');
-  for (Int_t iobj = 0; iobj < fTubes.GetEntriesFast(); iobj++) {
-    CbmMustTube* tempTube = (CbmMustTube*) (fTubes.At(iobj));
+  int iobj{0};
+  for (const auto tempTube : fTubes) {
     //        if ( iobj == 0 )
     LOG(info) << "        Tube " << tempTube->GetDetectorId() << "  @ " << tempTube->GetPosition().X() << ","
               << tempTube->GetPosition().Y() << "," << tempTube->GetPosition().Z() << " -> "
@@ -69,6 +67,7 @@ void CbmMustModule::Show()
     tubeNumbDec[iobj]                         = char(tempTube->GetTubeNumber() / 10 + 48);
     tubeNumbOne[iobj]                         = char(tempTube->GetTubeNumber() % 10 + 48);
     tubeString[tempTube->GetTubeNumber() - 1] = '*';
+    iobj++;
   }
   LOG(info) << "        Tubes " << tubeString;
   LOG(info) << "            - " << tubeNumbDec;
diff --git a/core/detectors/must/CbmMustModule.h b/core/detectors/must/CbmMustModule.h
index d78a2e919..5c37c8b47 100644
--- a/core/detectors/must/CbmMustModule.h
+++ b/core/detectors/must/CbmMustModule.h
@@ -19,12 +19,12 @@
 
 #include <Rtypes.h>      // for THashConsistencyHolder, ClassDef
 #include <RtypesCore.h>  // for Color_t
-#include <TObjArray.h>   // for TObjArray
 #include <TObject.h>     // for TObject
 #include <TVector3.h>    // for TVector3
 
 #include <map>      // for multimap
 #include <utility>  // for pair
+#include <vector>   // for vector
 
 class CbmMustModule : public TObject {
  public:
@@ -46,23 +46,28 @@ class CbmMustModule : public TObject {
   TVector3 GetPosition() const { return fPosition; }
   TVector3 GetDirection() const { return fDirection; }
 
-  int GetNTubes() const { return fTubes.GetEntriesFast(); }
+  int GetNTubes() const { return fTubes.size(); }
 
-  CbmMustTube* GetTube(int iTube) const { return (CbmMustTube*) fTubes.At(iTube); }
+  CbmMustTube* GetTube(int iTube) const { return fTubes.at(iTube); }
 
   CbmMustTube* FindTube(int detid);
   bool AddTube(CbmMustTube* tube);
-  void SortTubes() { fTubes.Sort(); }
+  void SortTubes()
+  {
+    std::sort(fTubes.begin(), fTubes.end(),
+              [](const CbmMustTube* a, const CbmMustTube* b) { return a->GetTubeNumber() > b->GetTubeNumber(); });
+  }
+
   void Show();
 
   virtual bool InitModule() { return kTRUE; }
   virtual void DrawModule(Color_t) {}
 
  protected:
-  int fDetectorId;      // Unique detector ID
-  TVector3 fPosition;   // Location vector of the module center in global c.s. (all dimensions in [cm])
-  TVector3 fDirection;  // Direction vector of the module
-  TObjArray fTubes;     // Array of CbmMustTubes
+  int fDetectorId;                   // Unique detector ID
+  TVector3 fPosition;                // Location vector of the module center in global c.s. (all dimensions in [cm])
+  TVector3 fDirection;               // Direction vector of the module
+  std::vector<CbmMustTube*> fTubes;  // Array of CbmMustTubes
 
  private:
   CbmMustModule(const CbmMustModule&);
diff --git a/core/detectors/must/CbmMustStation.cxx b/core/detectors/must/CbmMustStation.cxx
index 07eca27c0..73e6b769f 100644
--- a/core/detectors/must/CbmMustStation.cxx
+++ b/core/detectors/must/CbmMustStation.cxx
@@ -18,7 +18,6 @@
 #include <Logger.h>  // for LOG
 
 #include <TMathBase.h>  // for Abs
-#include <TObjArray.h>  // for TObjArray
 
 // -----   Default constructor   -------------------------------------------
 CbmMustStation::CbmMustStation() : TObject(), fDetectorId(0), fZ(0.), fLayers() {}
@@ -43,8 +42,7 @@ CbmMustTube* CbmMustStation::GetTube(int detid)
 // -----   Public method AddSector   ---------------------------------------
 CbmMustLayer* CbmMustStation::FindLayer(int detid)
 {
-  for (Int_t iobj = 0; iobj < fLayers.GetEntriesFast(); iobj++) {
-    CbmMustLayer* tempLayer = (CbmMustLayer*) (fLayers.At(iobj));
+  for (const auto tempLayer : fLayers) {
     if (tempLayer->GetDetectorId() == detid) return tempLayer;
   }
   return nullptr;
@@ -54,12 +52,11 @@ CbmMustLayer* CbmMustStation::FindLayer(int detid)
 // -----   Public method AddSector   ---------------------------------------
 bool CbmMustStation::AddLayer(CbmMustLayer* layer)
 {
-  for (Int_t iobj = 0; iobj < fLayers.GetEntriesFast(); iobj++) {
-    CbmMustLayer* tempLayer = (CbmMustLayer*) (fLayers.At(iobj));
+  for (const auto tempLayer : fLayers) {
     if (tempLayer->GetDetectorId() == layer->GetDetectorId()) return false;
   }
 
-  fLayers.Add(layer);
+  fLayers.push_back(layer);
   return true;
 }
 // -------------------------------------------------------------------------
@@ -67,8 +64,7 @@ bool CbmMustStation::AddLayer(CbmMustLayer* layer)
 void CbmMustStation::Show()
 {
   LOG(info) << "  Station " << fDetectorId << " (@ z = " << fZ << "):";
-  for (Int_t iobj = 0; iobj < fLayers.GetEntriesFast(); iobj++) {
-    CbmMustLayer* tempLayer = (CbmMustLayer*) (fLayers.At(iobj));
+  for (const auto tempLayer : fLayers) {
     tempLayer->Show();
   }
 }
diff --git a/core/detectors/must/CbmMustStation.h b/core/detectors/must/CbmMustStation.h
index bbec038eb..1433b4bbe 100644
--- a/core/detectors/must/CbmMustStation.h
+++ b/core/detectors/must/CbmMustStation.h
@@ -20,9 +20,10 @@
 #include "CbmMustLayer.h"  // for CbmMustLayer
 #include "CbmMustTube.h"
 
-#include <Rtypes.h>     // for THashConsistencyHolder, ClassDef
-#include <TObjArray.h>  // for TObjArray
-#include <TObject.h>    // for TObject
+#include <Rtypes.h>   // for THashConsistencyHolder, ClassDef
+#include <TObject.h>  // for TObject
+
+#include <vector>  // for vector
 
 class CbmMustStation : public TObject {
  public:
@@ -43,11 +44,11 @@ class CbmMustStation : public TObject {
   /** Accessors **/
   int GetDetectorId() const { return fDetectorId; }
   double GetZ() const { return fZ; }
-  int GetNLayers() const { return fLayers.GetEntriesFast(); }
+  int GetNLayers() const { return fLayers.size(); }
 
   CbmMustTube* GetTube(int detid);
 
-  CbmMustLayer* GetLayer(int iLayer) const { return (CbmMustLayer*) fLayers.At(iLayer); }
+  CbmMustLayer* GetLayer(int iLayer) const { return fLayers.at(iLayer); }
 
   /** Add one sector to the array **/
   CbmMustLayer* FindLayer(int detid);
@@ -55,9 +56,9 @@ class CbmMustStation : public TObject {
   void Show();
 
  protected:
-  int fDetectorId;    // Unique detector ID
-  double fZ;          // z position of station center (midplane) [cm] in global cs
-  TObjArray fLayers;  // Array of CbmMustLayers
+  int fDetectorId;                     // Unique detector ID
+  double fZ;                           // z position of station center (midplane) [cm] in global cs
+  std::vector<CbmMustLayer*> fLayers;  // Array of CbmMustLayers
   ClassDef(CbmMustStation, 1);
 };
 #endif
diff --git a/core/detectors/must/CbmMustTube.h b/core/detectors/must/CbmMustTube.h
index d80923aea..5c6ab5330 100644
--- a/core/detectors/must/CbmMustTube.h
+++ b/core/detectors/must/CbmMustTube.h
@@ -51,7 +51,7 @@ class CbmMustTube : public TObject {
   TMatrixT<double> fRotationMatrix;
   Double_t fRadIn, fRadOut, fHalfLength;
 
-  ClassDef(CbmMustTube, 1);
+  ClassDefOverride(CbmMustTube, 1);
 };
 
 #endif
diff --git a/sim/detectors/must/CbmMust.cxx b/sim/detectors/must/CbmMust.cxx
index 9558a7fda..3ee953ac5 100644
--- a/sim/detectors/must/CbmMust.cxx
+++ b/sim/detectors/must/CbmMust.cxx
@@ -255,7 +255,7 @@ Bool_t CbmMust::ProcessHits(FairVolume* vol)
         detId                     = detId + moduleId * 1e3;
         CbmMustModule* mustModule = mustLayer->FindModule(detId);
         TVector3 directionVector(0., 1., 0.);
-        if (layerId == 2 || layerId == 3) {
+        if (layerId == 1 || layerId == 2) {
           double angle = 5. * TMath::DegToRad();
           if (layerId == 3) angle = -angle;
           directionVector[0] = TMath::Sin(angle);
@@ -311,10 +311,9 @@ void CbmMust::EndOfEvent()
   fPosIndex = 0;
 
   if (1 == 0) {
-    int nofTubes        = 0;
-    TObjArray* stations = CbmMustGeoScheme::Instance()->GetStations();
-    for (Int_t iobj = 0; iobj < stations->GetEntriesFast(); iobj++) {
-      CbmMustStation* tempStation = (CbmMustStation*) (stations->At(iobj));
+    int nofTubes                          = 0;
+    std::vector<CbmMustStation*> stations = CbmMustGeoScheme::Instance()->GetStations();
+    for (const auto tempStation : stations) {
       for (int ilay = 0; ilay < tempStation->GetNLayers(); ilay++) {
         CbmMustLayer* tempLayer = tempStation->GetLayer(ilay);
         for (int imod = 0; imod < tempLayer->GetNModules(); imod++) {
@@ -402,7 +401,6 @@ void CbmMust::Initialize()
 // -----   Public method ConstructGeometry   -------------------------------
 void CbmMust::ConstructGeometry()
 {
-
   TString fileName = GetGeometryFileName();
 
   // --- Only ROOT geometries are supported
-- 
GitLab