From ab23dabf6e18ba168f9b2d25353d0ca65162403d Mon Sep 17 00:00:00 2001 From: "se.gorbunov" <se.gorbunov@gsi.de> Date: Fri, 25 Apr 2025 14:50:48 +0200 Subject: [PATCH] extract path to the geo node from the detector ID --- .../detectors/sts/CbmStsTrackingInterface.cxx | 17 ++++++++ core/detectors/sts/CbmStsTrackingInterface.h | 3 ++ .../detectors/tof/CbmTofTrackingInterface.cxx | 43 +++++++++++++++++++ core/detectors/tof/CbmTofTrackingInterface.h | 8 ++++ .../detectors/trd/CbmTrdTrackingInterface.cxx | 34 ++++++++++++++- core/detectors/trd/CbmTrdTrackingInterface.h | 19 ++++---- 6 files changed, 111 insertions(+), 13 deletions(-) diff --git a/core/detectors/sts/CbmStsTrackingInterface.cxx b/core/detectors/sts/CbmStsTrackingInterface.cxx index e64f18bdd..5000a2ab0 100644 --- a/core/detectors/sts/CbmStsTrackingInterface.cxx +++ b/core/detectors/sts/CbmStsTrackingInterface.cxx @@ -78,6 +78,23 @@ std::tuple<double, double> CbmStsTrackingInterface::GetStereoAnglesSensor(int ad return std::tuple(angleF, angleB); } +std::string CbmStsTrackingInterface::GetGeoNodeSensor(int address) const +{ + /// Gets path to the geometry node of the sensor + + const CbmStsElement* element = CbmStsSetup::Instance()->GetElement(address, EStsElementLevel::kStsSensor); + if (!element) { + return ""; + } + + const TGeoPhysicalNode* node = element->GetPnode(); + if (!node) { + return ""; + } + + return node->GetName(); +} + // --------------------------------------------------------------------------------------------------------------------- // InitStatus CbmStsTrackingInterface::Init() diff --git a/core/detectors/sts/CbmStsTrackingInterface.h b/core/detectors/sts/CbmStsTrackingInterface.h index f24f18819..35219dd36 100644 --- a/core/detectors/sts/CbmStsTrackingInterface.h +++ b/core/detectors/sts/CbmStsTrackingInterface.h @@ -102,6 +102,9 @@ class CbmStsTrackingInterface : public FairTask, public CbmTrackingDetectorInter // TODO: remove this method [[deprecated]] double GetSensorThickness(int stationId) const { return GetStsStation(stationId)->GetSensorD(); } + /// @brief Gets path to the geometry node of the sensor + std::string GetGeoNodeSensor(int address) const; + /// @brief FairTask: sets parameter containers up void SetParContainers() override; diff --git a/core/detectors/tof/CbmTofTrackingInterface.cxx b/core/detectors/tof/CbmTofTrackingInterface.cxx index aa02e04cc..12031a158 100644 --- a/core/detectors/tof/CbmTofTrackingInterface.cxx +++ b/core/detectors/tof/CbmTofTrackingInterface.cxx @@ -50,8 +50,28 @@ InitStatus CbmTofTrackingInterface::Init() // create digitization parameters from geometry file auto tofDigiPar = new CbmTofCreateDigiPar("TOF Digi Producer", "TOF task"); LOG(info) << "Create DigiPar"; + tofDigiPar->SetParContainers(); tofDigiPar->Init(); + fCellNodeMap.clear(); + fModuleNodeMap.clear(); + for (Int_t iCell = 0; iCell < fDigiPar->GetNrOfModules(); iCell++) { + Int_t iAddr = fDigiPar->GetCellId(iCell); + CbmTofCell* fChannelInfo = fDigiPar->GetCell(iAddr); + gGeoManager->FindNode(fChannelInfo->GetX(), fChannelInfo->GetY(), fChannelInfo->GetZ()); + fCellNodeMap.insert({iAddr, gGeoManager->GetPath()}); + + // search for the module node + while (gGeoManager->GetCurrentNode() != gGeoManager->GetTopNode() + && !TString(gGeoManager->GetCurrentNode()->GetName()).Contains("module")) { + gGeoManager->CdUp(); + } + + if (TString(gGeoManager->GetCurrentNode()->GetName()).Contains("module")) { + fModuleNodeMap.insert({iAddr, gGeoManager->GetPath()}); + } + } + // ** ToF tracking station geometrical information initialization ** auto nStations = fDigiBdfPar->GetNbTrackingStations(); @@ -182,3 +202,26 @@ void CbmTofTrackingInterface::SetParContainers() } runtimeDb->initContainers(FairRunAna::Instance()->GetRunId()); } + + +std::string CbmTofTrackingInterface::GetGeoNodeCell(int address) const +{ + /// Gets path to the geometry node of the cell + + auto it = fCellNodeMap.find(address); + if (it == fCellNodeMap.end()) { + LOG(fatal) << "Failed to find cell geometry node for TOF address " << address; + } + return it->second; +} + +std::string CbmTofTrackingInterface::GetGeoNodeModule(int address) const +{ + /// Gets path to the geometry node of the cell + + auto it = fModuleNodeMap.find(address); + if (it == fModuleNodeMap.end()) { + LOG(fatal) << "Failed to find module geometry node for TOF address " << address; + } + return it->second; +} diff --git a/core/detectors/tof/CbmTofTrackingInterface.h b/core/detectors/tof/CbmTofTrackingInterface.h index bb2ba3e34..e5768c0d9 100644 --- a/core/detectors/tof/CbmTofTrackingInterface.h +++ b/core/detectors/tof/CbmTofTrackingInterface.h @@ -26,6 +26,7 @@ #include <vector> class CbmTofDigiPar; +class CbmTofGeoHandler; /// Class CbmTofTrackingInterface is a CbmTrackingDetetorInterfaceInit subtask, which provides necessary methods for L1 tracker /// to access the geometry and dataflow settings. @@ -100,6 +101,10 @@ class CbmTofTrackingInterface : public FairTask, public CbmTrackingDetectorInter /// @return Flag: true - station provides time measurements, false - station does not provide time measurements bool IsTimeInfoProvided(int /*stationId*/) const override { return true; } + + std::string GetGeoNodeCell(int address) const; + std::string GetGeoNodeModule(int address) const; + /// @brief FairTask: Init method InitStatus Init() override; @@ -122,6 +127,9 @@ class CbmTofTrackingInterface : public FairTask, public CbmTrackingDetectorInter std::vector<double> fTofStationZMin{}; ///< Lower bounds of TOF stations along z-axis [cm] std::vector<double> fTofStationZMax{}; ///< Upper bounds of TOF stations along z-axis [cm] + std::map<Int_t, std::string> fCellNodeMap; // Map TOF addresses to the geometry node of the cell + std::map<Int_t, std::string> fModuleNodeMap; // Map TOF addresses to the geometry node of the module + ClassDefOverride(CbmTofTrackingInterface, 0); }; diff --git a/core/detectors/trd/CbmTrdTrackingInterface.cxx b/core/detectors/trd/CbmTrdTrackingInterface.cxx index c39cbfbf2..54d19effd 100644 --- a/core/detectors/trd/CbmTrdTrackingInterface.cxx +++ b/core/detectors/trd/CbmTrdTrackingInterface.cxx @@ -12,9 +12,15 @@ #include "CbmTrdTrackingInterface.h" #include "CbmTrdHit.h" +#include "CbmTrdParModDigi.h" +#include "CbmTrdParModGeo.h" +#include "CbmTrdParSetDigi.h" +#include "CbmTrdParSetGeo.h" #include "FairDetector.h" #include "FairRunAna.h" #include "TGeoManager.h" +#include "TGeoPhysicalNode.h" +#include "TMath.h" #include "TString.h" #include <Logger.h> @@ -90,6 +96,22 @@ std::tuple<double, double, double> CbmTrdTrackingInterface::GetHitRanges(const C return std::tuple(rangeX, rangeY, rangeT); } +std::string CbmTrdTrackingInterface::GetGeoNodeModule(int address) const +{ + /// Gets path to the geometry node of the module + CbmTrdParModGeo* par = dynamic_cast<CbmTrdParModGeo*>(fTrdGeoPar->GetModulePar(address)); + if (!par) { + LOG(fatal) << "CbmTrdTrackingInterface::Init: error accessing the TRD module for address " << address + << " (failed dynamic cast to CbmTrdParModGeo)"; + } + std::string path = par->GetPath(); + if (path.empty()) { + LOG(fatal) << "Failed to find path to TRD module with address " << address; + } + return path; +} + + // --------------------------------------------------------------------------------------------------------------------- // InitStatus CbmTrdTrackingInterface::Init() @@ -136,7 +158,9 @@ InitStatus CbmTrdTrackingInterface::Init() fvStationFullVolume.clear(); fvStationFullVolume.reserve(nStations); for (int iSt = 0; iSt < nStations; ++iSt) { - const auto* pModulePar = GetTrdModulePar(iSt); + const CbmTrdParModDigi* pModulePar = + static_cast<CbmTrdParModDigi*>(fTrdDigiPar->GetModulePar(fTrdDigiPar->GetModuleId(iSt))); + fvStationFullVolume.emplace_back( pModulePar->GetX() - pModulePar->GetSizeX(), pModulePar->GetX() + pModulePar->GetSizeX(), pModulePar->GetY() - pModulePar->GetSizeY(), pModulePar->GetY() + pModulePar->GetSizeY(), @@ -176,7 +200,13 @@ InitStatus CbmTrdTrackingInterface::ReInit() void CbmTrdTrackingInterface::SetParContainers() { auto runtimeDb = FairRunAna::Instance()->GetRuntimeDb(); - fTrdDigiPar = dynamic_cast<CbmTrdParSetDigi*>(runtimeDb->getContainer("CbmTrdParSetDigi")); + + fTrdGeoPar = dynamic_cast<CbmTrdParSetGeo*>(runtimeDb->getContainer("CbmTrdParSetGeo")); + if (!fTrdGeoPar) { + LOG(fatal) << "CbmTrdTrackingInterface::SetParContainers: error accessing to CbmTrdParSetGeo container"; + } + + fTrdDigiPar = dynamic_cast<CbmTrdParSetDigi*>(runtimeDb->getContainer("CbmTrdParSetDigi")); if (!fTrdDigiPar) { LOG(fatal) << "CbmTrdTrackingInterface::SetParContainers: error accessing to CbmTrdParSetDigi container"; } diff --git a/core/detectors/trd/CbmTrdTrackingInterface.h b/core/detectors/trd/CbmTrdTrackingInterface.h index 2d0e600c3..032044357 100644 --- a/core/detectors/trd/CbmTrdTrackingInterface.h +++ b/core/detectors/trd/CbmTrdTrackingInterface.h @@ -15,14 +15,16 @@ #include "CbmHit.h" #include "CbmTrackingDetectorInterfaceBase.h" #include "CbmTrdAddress.h" -#include "CbmTrdParModDigi.h" -#include "CbmTrdParSetDigi.h" #include "FairTask.h" -#include "TMath.h" #include <iostream> #include <vector> + +class CbmTrdParSetDigi; +class CbmTrdParSetGeo; +class CbmTrdParModDigi; + /// @class CbmTrdTrackingInterface /// @brief A CbmL1 subtask, which provides necessary methods for CA tracker to access the geometry and dataflow s /// ettings. @@ -86,6 +88,8 @@ class CbmTrdTrackingInterface : public FairTask, public CbmTrackingDetectorInter /// @return range X, Y, T std::tuple<double, double, double> GetHitRanges(const CbmPixelHit& hit) const override; + std::string GetGeoNodeModule(int address) const; + /// @brief FairTask: Init method InitStatus Init() override; @@ -99,16 +103,9 @@ class CbmTrdTrackingInterface : public FairTask, public CbmTrackingDetectorInter void SetParContainers() override; private: - /// @brief Gets pointer to the TRD module - /// @param moduleId Id of the Trd module - /// @return Pointer to the particular CbmTrdParModDigi object - __attribute__((always_inline)) CbmTrdParModDigi* GetTrdModulePar(int moduleId) const - { - return static_cast<CbmTrdParModDigi*>(fTrdDigiPar->GetModulePar(fTrdDigiPar->GetModuleId(moduleId))); - } - inline static CbmTrdTrackingInterface* fpInstance{nullptr}; ///< Instance of the class + CbmTrdParSetGeo* fTrdGeoPar{nullptr}; CbmTrdParSetDigi* fTrdDigiPar{nullptr}; //CbmTrdParModDigi* fTrdModuleInfo {nullptr}; -- GitLab