diff --git a/core/base/CbmTrackingDetectorInterfaceBase.cxx b/core/base/CbmTrackingDetectorInterfaceBase.cxx index 017d17256d754f5cea28d0859daad82d2ab80cbd..e8a69dbbd0595ceda1bda2903342add1c68d7f76 100644 --- a/core/base/CbmTrackingDetectorInterfaceBase.cxx +++ b/core/base/CbmTrackingDetectorInterfaceBase.cxx @@ -11,6 +11,10 @@ #include <Logger.h> +#include <TGeoManager.h> +#include <TGeoNode.h> +#include <TString.h> + #include <iomanip> #include <limits> #include <set> @@ -121,5 +125,73 @@ std::string CbmTrackingDetectorInterfaceBase::ToString() const table << setw(10) << IsTimeInfoProvided(iSt) << ' '; table << '\n'; } + table << "--------------\n"; + for (int iSt = 0; iSt < GetNtrackingStations(); ++iSt) { + table << setw(5) << iSt << ' '; + table << setw(10) << fvStations[iSt].fZref << ' '; + table << setw(10) << fvStations[iSt].fZmin << ' '; + table << setw(10) << fvStations[iSt].fZmax << ' '; + table << setw(10) << fvStations[iSt].fXmin << ' '; + table << setw(10) << fvStations[iSt].fXmax << ' '; + table << setw(10) << fvStations[iSt].fYmin << ' '; + table << setw(10) << fvStations[iSt].fYmax << ' '; + table << setw(10) << IsTimeInfoProvided(iSt) << ' '; + table << '\n'; + } return table.str(); } + +// --------------------------------------------------------------------------------------------------------------------- +// +std::vector<TString> CbmTrackingDetectorInterfaceBase::CollectNodes(const TString& detector, const TString& component, + const TString& path, TGeoNode* pNode) +{ + std::vector<TString> vPaths; + + if (!pNode) { + return vPaths; + } + + TString nodePath = path + (path.IsNull() ? "" : "/") + pNode->GetName(); + + if (TString(pNode->GetName()).Contains(component, TString::kIgnoreCase)) { + if (nodePath.Contains(detector, TString::kIgnoreCase)) { + vPaths.push_back(nodePath); + } + } + + for (int iNode = 0; iNode < pNode->GetNdaughters(); ++iNode) { + TGeoNode* pDaughter = pNode->GetDaughter(iNode); + auto daughterPaths = CollectNodes(detector, component, nodePath, pDaughter); + vPaths.insert(vPaths.end(), daughterPaths.begin(), daughterPaths.end()); + } + return vPaths; +} + +// --------------------------------------------------------------------------------------------------------------------- +// +CbmTrackingDetectorInterfaceBase::VolumeInfo CbmTrackingDetectorInterfaceBase::ReadVolume(const TString& path) +{ + VolumeInfo res; + if (!gGeoManager->cd(path)) { + std::stringstream msg; + msg << "Node with path " << path << " is not found in the geo manager"; + throw std::runtime_error(msg.str()); + } + + auto* matrix{gGeoManager->GetCurrentMatrix()}; + const double* translation{matrix->GetTranslation()}; + auto* volume{gGeoManager->GetCurrentVolume()}; + auto* shape{volume->GetShape()}; + auto GetDimension = [&](int iD) { + double min; + double max; + shape->GetAxisRange(iD + 1, min, max); + return std::make_pair<double, double>(min + translation[iD], max + translation[iD]); + }; + std::tie(res.fXmin, res.fXmax) = GetDimension(0); + std::tie(res.fYmin, res.fYmax) = GetDimension(1); + std::tie(res.fZmin, res.fZmax) = GetDimension(2); + res.fZref = 0.5 * (res.fZmin + res.fZmax); + return res; +} diff --git a/core/base/CbmTrackingDetectorInterfaceBase.h b/core/base/CbmTrackingDetectorInterfaceBase.h index c08a6498fb2384a6aacb963c1f97539e0fd4dbbd..0271756774a0e9463dbf82b4d7e21d5186ed2872 100644 --- a/core/base/CbmTrackingDetectorInterfaceBase.h +++ b/core/base/CbmTrackingDetectorInterfaceBase.h @@ -26,10 +26,36 @@ #include <cmath> +class TGeoNode; +class TString; + /// @class CbmTrackingDetectorInterfaceBase /// @brief Abstract class, which should be inherited by every detecting subsystem tracking interface class /// class CbmTrackingDetectorInterfaceBase { + /// @struct VolumeInfo + /// @brief Structure to store geometry information of each station + struct VolumeInfo { + VolumeInfo() = default; + VolumeInfo(double zRef, double zMin, double zMax, double xMin, double xMax, double yMin, double yMax) + : fZref(zRef) + , fZmin(zMin) + , fZmax(zMax) + , fXmin(xMin) + , fXmax(xMax) + , fYmin(yMin) + , fYmax(yMax) + { + } + double fZref{std::numeric_limits<double>::signaling_NaN()}; ///< Reference z-position of active volume [cm] + double fZmin{+std::numeric_limits<double>::max()}; ///< Lower bound in z-direction [cm] + double fZmax{-std::numeric_limits<double>::max()}; ///< Upper bound in z-direction [cm] + double fXmin{+std::numeric_limits<double>::max()}; ///< Lower bound in x-direction [cm] + double fXmax{-std::numeric_limits<double>::max()}; ///< Upper bound in x-direction [cm] + double fYmin{+std::numeric_limits<double>::max()}; ///< Lower bound in y-direction [cm] + double fYmax{-std::numeric_limits<double>::max()}; ///< Upper bound in y-direction [cm] + }; + public: /// @brief Virtual destructor virtual ~CbmTrackingDetectorInterfaceBase() {} @@ -109,10 +135,6 @@ public: /// @return Flag: true - station provides time measurements, false - station does not provide time measurements virtual bool IsTimeInfoProvided(int stationId) const = 0; - /// @brief Returns the map of address to station index - /// @return std::unordered_map<int32_t - address, int - station index> - const std::unordered_map<int32_t, int>& GetAddressToStationMap() const { return fmAddressToStation; } - /// @brief Gets x,y,t ranges of a CbmPixelHit /// @param hit A hit /// @return range X, Y, T @@ -130,8 +152,25 @@ public: /// @brief Prints all the parameters into table and saves the table as a string std::string ToString() const; - /// @brief Map of the address to station index - std::unordered_map<int32_t, int> fmAddressToStation {}; + protected: + /// \brief TEMPORARY switcher for the det. ifs definition (from digi pars -> from geometry) + /// FIXME: Remove after testing + static constexpr bool kDebugGeoDefined{false}; + + /// @brief Collects paths of the components + /// @param[in] detector Name hint of the detector + /// @param[in] component Name of the active node component + /// @param[inout] path Path to the node + /// @param[inout] pNode Pointer to the node + /// @return Vector of paths to the matched components + std::vector<TString> CollectNodes(const TString& detector, const TString& component, const TString& path, + TGeoNode* pNode); + + /// @brief Creates volume info from a geo node provided by path + /// @param path Path to volume in TGeoManager + VolumeInfo ReadVolume(const TString& path); + + std::vector<VolumeInfo> fvStations{}; ///< Geometric properties of stations }; #endif // CbmTrackingDetectorInterfaceBase_h diff --git a/core/detectors/much/CbmMuchTrackingInterface.cxx b/core/detectors/much/CbmMuchTrackingInterface.cxx index 0c29a6cd81684f1d25f97e3eeb51c4e8b81b1a05..341172164904bc13c6255e029529a42cfbe60efd 100644 --- a/core/detectors/much/CbmMuchTrackingInterface.cxx +++ b/core/detectors/much/CbmMuchTrackingInterface.cxx @@ -83,6 +83,19 @@ InitStatus CbmMuchTrackingInterface::Init() iFirstLayer += fGeoScheme->GetStation(iMuchSt)->GetNLayers(); } + int nStations{0}; + for (int iMuchSt = 0; iMuchSt < fGeoScheme->GetNStations(); ++iMuchSt) { + nStations += fGeoScheme->GetStation(iMuchSt)->GetNLayers(); + } + fvStations.clear(); + // FIXME: Provide + fvStations.reserve(nStations); + for (int iSt = 0; iSt < nStations; ++iSt) { + auto* pLayer{GetMuchLayer(iSt)}; + fvStations.emplace_back(pLayer->GetZ(), pLayer->GetZ() - 0.5 * pLayer->GetDz(), + pLayer->GetZ() + 0.5 * pLayer->GetDz(), -100., +100., -100., +100.); + } + // Check the validity of the parameters if (!this->Check()) { LOG(error) diff --git a/core/detectors/mvd/CbmMvdTrackingInterface.cxx b/core/detectors/mvd/CbmMvdTrackingInterface.cxx index 0dfd769c5eb9618838da6122bda7dd3324963876..eaadd4eeaf492ea9bf287334020570d2bd75ac62 100644 --- a/core/detectors/mvd/CbmMvdTrackingInterface.cxx +++ b/core/detectors/mvd/CbmMvdTrackingInterface.cxx @@ -43,6 +43,19 @@ InitStatus CbmMvdTrackingInterface::Init() if (!fMvdStationPar) { return kFATAL; } + + fvStations.clear(); + // FIXME: Provide station parameters from geometry definition (seems to be unavailable) + int nStations{fMvdStationPar->GetStationCount()}; + fvStations.reserve(nStations); + for (int iSt = 0; iSt < nStations; ++iSt) { + fvStations.emplace_back( + fMvdStationPar->GetZPosition(iSt), fMvdStationPar->GetZPosition(iSt) - 0.5 * fMvdStationPar->GetZThickness(iSt), + fMvdStationPar->GetZPosition(iSt) + 0.5 * fMvdStationPar->GetZThickness(iSt), -fMvdStationPar->GetWidth(iSt), + +fMvdStationPar->GetWidth(iSt), -fMvdStationPar->GetHeight(iSt), +fMvdStationPar->GetHeight(iSt)); + } + + // Check the validity of the parameters if (!this->Check()) { LOG(error) diff --git a/core/detectors/mvd/CbmMvdTrackingInterface.h b/core/detectors/mvd/CbmMvdTrackingInterface.h index 6160a8dcdeaeb299b3e41d2bc7e241df77d1e670..eed072bf09995f05ec12fa1dd27253e3113d3de5 100644 --- a/core/detectors/mvd/CbmMvdTrackingInterface.h +++ b/core/detectors/mvd/CbmMvdTrackingInterface.h @@ -65,7 +65,7 @@ public: /// @param stationId Tracking station ID in the setup (NOTE: must be in range [0..GetNstations()-1]) /// @return Radiation length [cm] // TODO: remove this method - double GetRadLength(int stationId) const + [[deprecated]] double GetRadLength(int stationId) const { return fMvdStationPar->GetZThickness(stationId) / (10. * fMvdStationPar->GetZRadThickness(stationId)); } @@ -80,7 +80,7 @@ public: /// @param stationId Tracking station ID in the setup (NOTE: must be in range [0..GetNstations()-1]) /// @return Station thickness [cm] // TODO: remove this method - double GetSensorThickness(int stationId) const { return fMvdStationPar->GetZThickness(stationId); } + [[deprecated]] double GetSensorThickness(int stationId) const { return fMvdStationPar->GetZThickness(stationId); } /// @brief Gets a tracking station of a CbmHit /// @param hit A pointer to CbmHit diff --git a/core/detectors/sts/CbmStsTrackingInterface.cxx b/core/detectors/sts/CbmStsTrackingInterface.cxx index f80ee34dcba3e48e1c934361adbac837544e0bf7..5e45e6492651fe3827817ae1580a28980b0e7bab 100644 --- a/core/detectors/sts/CbmStsTrackingInterface.cxx +++ b/core/detectors/sts/CbmStsTrackingInterface.cxx @@ -91,6 +91,26 @@ InitStatus CbmStsTrackingInterface::Init() if (!stsSetup->IsSensorParsInit()) { stsSetup->SetSensorParameters(fStsParSetSensor); } if (!stsSetup->IsSensorCondInit()) { stsSetup->SetSensorConditions(fStsParSetSensorCond); } + int nStations = CbmStsSetup::Instance()->GetNofStations(); + fvStations.clear(); + fvStations.reserve(nStations); + for (int iSt = 0; iSt < nStations; ++iSt) { + const auto* pStsStation{CbmStsSetup::Instance()->GetStation(iSt)}; + if constexpr (kDebugGeoDefined) { + fvStations.emplace_back(pStsStation->GetZ(), pStsStation->GetZ() - pStsStation->GetSensorD(), + pStsStation->GetZ() + pStsStation->GetSensorD(), pStsStation->GetXmin(), + pStsStation->GetXmax(), pStsStation->GetYmin(), pStsStation->GetYmax()); + } + else { + fvStations.emplace_back(pStsStation->GetZ(), + pStsStation->GetZ() - 2., // NOTE: old thickness definition + pStsStation->GetZ() + 2., // NOTE: old thickness definition + pStsStation->GetXmin(), pStsStation->GetXmax(), pStsStation->GetYmin(), + pStsStation->GetYmax()); + } + } + + // Check the validity of the parameters if (!this->Check()) { LOG(error) diff --git a/core/detectors/sts/CbmStsTrackingInterface.h b/core/detectors/sts/CbmStsTrackingInterface.h index 4ee55056e6d47ca02c9042fbb0edad75fae4b25a..b81307ae3935b8fa31a758399e2b473ee8e4c434 100644 --- a/core/detectors/sts/CbmStsTrackingInterface.h +++ b/core/detectors/sts/CbmStsTrackingInterface.h @@ -137,13 +137,13 @@ public: /// \param stationId Tracking station ID in the setup (NOTE: must be in range [0..GetNstations()-1]) /// \return Radiation length [cm] // TODO: remove this method - double GetRadLength(int stationId) const { return GetStsStation(stationId)->GetRadLength(); } + [[deprecated]] double GetRadLength(int stationId) const { return GetStsStation(stationId)->GetRadLength(); } /// -- to be removed -- Gets station thickness along the Z-axis /// \param stationId Tracking station ID in the setup (NOTE: must be in range [0..GetNstations()-1]) /// \return Station thickness [cm] // TODO: remove this method - double GetSensorThickness(int stationId) const { return GetStsStation(stationId)->GetSensorD(); } + [[deprecated]] double GetSensorThickness(int stationId) const { return GetStsStation(stationId)->GetSensorD(); } /// @brief FairTask: sets parameter containers up void SetParContainers(); diff --git a/core/detectors/tof/CbmTofTrackingInterface.cxx b/core/detectors/tof/CbmTofTrackingInterface.cxx index a8e4daee0d1cf0ae588aa691aecd45e3b79c6451..f233c523facba6398f3baf6f87b56d38b7c8bf85 100644 --- a/core/detectors/tof/CbmTofTrackingInterface.cxx +++ b/core/detectors/tof/CbmTofTrackingInterface.cxx @@ -18,6 +18,7 @@ #include <Logger.h> #include <limits> +#include <regex> ClassImp(CbmTofTrackingInterface) @@ -52,97 +53,100 @@ InitStatus CbmTofTrackingInterface::Init() // ** ToF tracking station geometrical information initialization ** + auto nStations = fDigiBdfPar->GetNbTrackingStations(); // Init ToF stations position z-components. For each ToF tracking station the position z-component is calculated // as an average of the components for each ToF module inside the tracking station. - std::vector<int> nTofStationModules(this->GetNtrackingStations(), - 0); // Number of ToF modules for a given tracking station - - auto nStations = this->GetNtrackingStations(); - fTofStationXMin.clear(); - fTofStationXMax.clear(); - fTofStationYMin.clear(); - fTofStationYMax.clear(); - fTofStationZ.clear(); - fTofStationZMin.clear(); - fTofStationZMax.clear(); - fTofStationXMin.resize(nStations, std::numeric_limits<double>::max()); - fTofStationXMax.resize(nStations, std::numeric_limits<double>::lowest()); - fTofStationYMin.resize(nStations, std::numeric_limits<double>::max()); - fTofStationYMax.resize(nStations, std::numeric_limits<double>::lowest()); - fTofStationZ.resize(nStations, 0); - fTofStationZMin.resize(nStations, std::numeric_limits<double>::max()); - fTofStationZMax.resize(nStations, std::numeric_limits<double>::lowest()); - - std::vector<std::set<double>> mRpcZ; - mRpcZ.resize(nStations, std::set<double>{}); - - fmAddressToStation.clear(); - for (int iSmType = 0; iSmType < fDigiBdfPar->GetNbSmTypes(); ++iSmType) { - for (int iSm = 0; iSm < fDigiBdfPar->GetNbSm(iSmType); ++iSm) { - for (int iRpc = 0; iRpc < fDigiBdfPar->GetNbRpc(iSmType); ++iRpc) { - auto address = CbmTofAddress::GetUniqueAddress(iSm, iRpc, 0, 0, iSmType); - int iStation = fDigiBdfPar->GetTrackingStation(iSmType, iSm, iRpc); // Local index of tracking station - fmAddressToStation[address] = iStation; - - auto* pChannelInfo = dynamic_cast<CbmTofCell*>(fDigiPar->GetCell(address)); - if (nullptr == pChannelInfo) { - LOG(warn) << fName << ": CbmTofCell object is not defined for iSmType = " << iSmType << ", iSm = " << iSm - << ", iRpc = " << iRpc; + // Number of ToF RPCs for a given tracking station: + std::vector<int> nTofStationModules(nStations, 0); + + + fvStations.clear(); + fvStations.resize(nStations); + if constexpr (kDebugGeoDefined) { + // loop over all RPCs; assign a tracking station ID using DigiBdfPar; combine the RPCs for each station ID + auto nodePaths{CollectNodes("tof", "counter", "", gGeoManager->GetTopNode())}; + std::regex pattern{"module_(\\d+)_(\\d+)/gas_box_(\\d+)/counter_(\\d+)"}; + for (const auto& path : nodePaths) { + std::smatch match; + std::string line{path.Data()}; + if (std::regex_search(line, match, pattern)) { + int iSmType{std::stoi(match[1])}; + int iSm{std::stoi(match[2])}; + int iRpc{std::stoi(match[4])}; + int iStation{fDigiBdfPar->GetTrackingStation(iSmType, iSm, iRpc)}; + if (5 == iSm || iStation < 0) { // NOTE: Check for BeamOn modules or other inactive RPCs continue; } - - // Tracking station sizes - auto chPosX = pChannelInfo->GetX(); - auto chPosY = pChannelInfo->GetY(); - auto chPosZ = pChannelInfo->GetZ(); - auto chSizeX = pChannelInfo->GetSizex(); - auto chSizeY = pChannelInfo->GetSizey(); - auto chLoBoarderX = chPosX - chSizeX; - auto chUpBoarderX = chPosX + chSizeX; - auto chLoBoarderY = chPosY - chSizeY; - auto chUpBoarderY = chPosY + chSizeY; - - LOG(debug) << "iSmType=" << iSmType << ", iSm=" << iSm << ", iRpc=" << iRpc << ": trSta=" << iStation - << ", x=" << chPosX << ", y=" << chPosY << ", z=" << chPosZ; - - // Cuts on Bmon and undefined station ID - if (5 == iSmType) { - continue; - } // Skip Bmon - if (iStation < 0) { - continue; - } - - mRpcZ[iStation].insert(chPosZ); - fTofStationZ[iStation] += chPosZ; - // FIXME: Sizes of stations are incorrect - if (chPosZ > fTofStationZMax[iStation]) { - fTofStationZMax[iStation] = chPosZ; - } - if (chPosZ < fTofStationZMin[iStation]) { - fTofStationZMin[iStation] = chPosZ; - } - if (chUpBoarderX > fTofStationXMax[iStation]) { - fTofStationXMax[iStation] = chUpBoarderX; - } - if (chUpBoarderY > fTofStationYMax[iStation]) { - fTofStationYMax[iStation] = chUpBoarderY; - } - if (chLoBoarderX < fTofStationXMin[iStation]) { - fTofStationXMin[iStation] = chLoBoarderX; - } - if (chLoBoarderY < fTofStationYMin[iStation]) { - fTofStationYMin[iStation] = chLoBoarderY; - } - - nTofStationModules[iStation] += 1; + auto& station = fvStations[iStation]; + auto rpc{ReadVolume(path)}; + station.fXmin = std::min(station.fXmin, rpc.fXmin); + station.fXmax = std::max(station.fXmax, rpc.fXmax); + station.fYmin = std::min(station.fYmin, rpc.fYmin); + station.fYmax = std::max(station.fYmax, rpc.fYmax); + station.fZmin = std::min(station.fZmin, rpc.fZmin); + station.fZmax = std::max(station.fZmax, rpc.fZmax); } } + for (auto& station : fvStations) { + station.fZref = 0.5 * (station.fZmin + station.fZmax); + } } + else { // old tracing station definition + fTofStationZ.clear(); + fTofStationZ.resize(nStations); + fTofStationZMin.clear(); + fTofStationZMin.resize(nStations, std::numeric_limits<double>::max()); + fTofStationZMax.clear(); + fTofStationZMax.resize(nStations, std::numeric_limits<double>::lowest()); + + for (int iSmType{0}; iSmType < fDigiBdfPar->GetNbSmTypes(); ++iSmType) { + for (int iSm{0}; iSm < fDigiBdfPar->GetNbSm(iSmType); ++iSm) { + for (int iRpc{0}; iRpc < fDigiBdfPar->GetNbRpc(iSmType); ++iRpc) { + auto address{CbmTofAddress::GetUniqueAddress(iSm, iRpc, 0, 0, iSmType)}; + int iStation{fDigiBdfPar->GetTrackingStation(iSmType, iSm, iRpc)}; // Local index of tracking station + auto* pChannelInfo{dynamic_cast<CbmTofCell*>(fDigiPar->GetCell(address))}; + if (nullptr == pChannelInfo) { + LOG(warn) << fName << ": CbmTofCell object is not defined for iSmType = " << iSmType << ", iSm = " << iSm + << ", iRpc = " << iRpc; + continue; + } + + // Tracking station sizes + auto chPosZ{pChannelInfo->GetZ()}; + + // Cuts on Bmon and undefined station ID + if (5 == iSmType) { + continue; + } // Skip Bmon + if (iStation < 0) { + continue; + } + + fTofStationZ[iStation] += chPosZ; + if (chPosZ > fTofStationZMax[iStation]) { + fTofStationZMax[iStation] = chPosZ; + } + if (chPosZ < fTofStationZMin[iStation]) { + fTofStationZMin[iStation] = chPosZ; + } + + nTofStationModules[iStation] += 1; + } + } + } - /// Get the average values - for (int iSt = 0; iSt < nStations; ++iSt) { - fTofStationZ[iSt] = fTofStationZ[iSt] / nTofStationModules[iSt]; + /// Get the average values and define final arrays + for (int iSt{0}; iSt < nStations; ++iSt) { + fTofStationZ[iSt] = fTofStationZ[iSt] / nTofStationModules[iSt]; + auto& station{fvStations[iSt]}; + station.fZref = fTofStationZ[iSt]; + station.fZmin = fTofStationZMin[iSt] - .5; + station.fZmax = fTofStationZMax[iSt] + .5; + station.fXmin = -100.; + station.fXmax = +100.; + station.fYmin = -100.; + station.fYmax = +100.; + } } // Check the validity of the parameters diff --git a/core/detectors/tof/CbmTofTrackingInterface.h b/core/detectors/tof/CbmTofTrackingInterface.h index a1b7aa1bb90806843f6a420162f154990207b8bf..365db1e32135e9c3e7eece9826419acfe18e53a3 100644 --- a/core/detectors/tof/CbmTofTrackingInterface.h +++ b/core/detectors/tof/CbmTofTrackingInterface.h @@ -161,10 +161,6 @@ class CbmTofTrackingInterface : public FairTask, public CbmTrackingDetectorInter CbmTofDigiPar* fDigiPar{nullptr}; CbmTofDigiBdfPar* fDigiBdfPar{nullptr}; - std::vector<double> fTofStationXMin{}; ///< Lower bounds of TOF stations along x-axis [cm] - std::vector<double> fTofStationXMax{}; ///< Upper bounds of TOF stations along x-axis [cm] - std::vector<double> fTofStationYMin{}; ///< Lower bounds of TOF stations along y-axis [cm] - std::vector<double> fTofStationYMax{}; ///< Upper bounds of TOF stations along y-axis [cm] std::vector<double> fTofStationZ{}; ///< Centers of TOF stations along z-axis [cm] 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] diff --git a/core/detectors/trd/CbmTrdTrackingInterface.cxx b/core/detectors/trd/CbmTrdTrackingInterface.cxx index 1d5ff0d3820d85f4bc075edc32ae3c0879bc1b10..4477b9d0242aa00d56a7122b2bcde236673b201b 100644 --- a/core/detectors/trd/CbmTrdTrackingInterface.cxx +++ b/core/detectors/trd/CbmTrdTrackingInterface.cxx @@ -12,14 +12,15 @@ #include "CbmTrdTrackingInterface.h" #include "CbmTrdHit.h" - #include "FairDetector.h" #include "FairRunAna.h" -#include <Logger.h> - #include "TGeoManager.h" #include "TString.h" +#include <Logger.h> + +#include <regex> + ClassImp(CbmTrdTrackingInterface) CbmTrdTrackingInterface* CbmTrdTrackingInterface::fpInstance = nullptr; @@ -105,6 +106,57 @@ std::tuple<double, double, double> CbmTrdTrackingInterface::GetHitRanges(const C // InitStatus CbmTrdTrackingInterface::Init() { + + // Collect nodes + if constexpr (kDebugGeoDefined) { + auto nodePaths = CollectNodes("trd", "layer", "", gGeoManager->GetTopNode()); + //for (const auto& path: nodePaths) { + // LOG(info) << ">>>>>>>> NODE: " << path; + //} + + //std::regex pattern{"layer(\\d+)_(\\d+)/module(\\d+)_(\\d+)"}; + std::regex pattern{"layer(\\d+)_(\\d+)"}; + + fvStations.clear(); + fvStations.resize(nodePaths.size()); + for (const auto& path : nodePaths) { + std::smatch match; + std::string line{path.Data()}; + if (std::regex_search(line, match, pattern)) { + int iStation{std::stoi(match[1]) - 1}; + auto& station{fvStations[iStation]}; + station = ReadVolume(path); + } + } + } + else { + int nStations = 0; + { + auto topNodes = gGeoManager->GetTopNode()->GetNodes(); + for (int iTopNode = 0; iTopNode < topNodes->GetEntriesFast(); ++iTopNode) { + auto topNode = static_cast<TGeoNode*>(topNodes->At(iTopNode)); + if (TString(topNode->GetName()).Contains("trd")) { + auto layers = topNode->GetNodes(); + for (int iLayer = 0; iLayer < layers->GetEntriesFast(); ++iLayer) { + auto layer = static_cast<TGeoNode*>(layers->At(iLayer)); + if (TString(layer->GetName()).Contains("layer")) { + ++nStations; + } + } + } + } + } + fvStations.clear(); + fvStations.reserve(nStations); + for (int iSt = 0; iSt < nStations; ++iSt) { + const auto* pModulePar = GetTrdModulePar(iSt); + fvStations.emplace_back(pModulePar->GetZ(), pModulePar->GetZ() - pModulePar->GetSizeZ(), + pModulePar->GetZ() + pModulePar->GetSizeZ(), pModulePar->GetX() - pModulePar->GetSizeX(), + pModulePar->GetX() + pModulePar->GetSizeX(), pModulePar->GetY() - pModulePar->GetSizeY(), + pModulePar->GetY() + pModulePar->GetSizeY()); + } + } + // Check access to TRD modules for (int iSt = 0; iSt < this->GetNtrackingStations(); ++iSt) { if (!dynamic_cast<CbmTrdParModDigi*>(fTrdDigiPar->GetModulePar(fTrdDigiPar->GetModuleId(iSt)))) { diff --git a/reco/L1/CbmL1.cxx b/reco/L1/CbmL1.cxx index b4e4f5e34b49fe4fe90dbd2b755cf7ae6c373ea3..d8e95834592e437f43167b4676b04ee25200e423 100644 --- a/reco/L1/CbmL1.cxx +++ b/reco/L1/CbmL1.cxx @@ -282,18 +282,6 @@ try { auto trdInterface = CbmTrdTrackingInterface::Instance(); auto tofInterface = CbmTofTrackingInterface::Instance(); - if (fUseTOF) { - LOG(debug) << "TOF module map"; - std::stringstream ssAddr; - std::stringstream ssStation; - for (auto [addr, iSt] : tofInterface->GetAddressToStationMap()) { - ssAddr << Form("%#010x ", addr); - ssStation << Form("%10d ", iSt); - } - LOG(debug) << ssAddr.str(); - LOG(debug) << ssStation.str(); - } - int nMvdStationsGeom = (fUseMVD) ? mvdInterface->GetNtrackingStations() : 0; int nStsStationsGeom = (fUseSTS) ? stsInterface->GetNtrackingStations() : 0; int nMuchStationsGeom = (fUseMUCH) ? muchInterface->GetNtrackingStations() : 0;