diff --git a/core/detectors/sts/CbmStsTrackingInterface.cxx b/core/detectors/sts/CbmStsTrackingInterface.cxx index e64f18bdd00fa8f21a1af6717d67cbf14bdbb346..5000a2ab09412ee9a38a9f9ca9b2026372fd0f48 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 f24f188193ecc6861e990192050f2adaf9720e66..35219dd36cc15433f325b227ed65f322e352ff26 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 aa02e04cc6f4984b9b72eb9390b0dd81d1fae9d1..12031a158f8ff7db15cd58b1191d65b815b6a66f 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 bb2ba3e3494d026ac647f7e94ceaa9586bff6223..e5768c0d904660d48a3c53b1381fef04ee62b8a7 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 c39cbfbf2fd6cbfe8bc4a2f12896e16280189394..54d19effdea3bacd4d87e1bd99cf8929c8840561 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 2d0e600c37d62ae643229b9aaee0184014c52fc7..0320443576003dd8cbbb515b461de249e2f54925 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};