diff --git a/core/base/CbmTrackingDetectorInterfaceBase.cxx b/core/base/CbmTrackingDetectorInterfaceBase.cxx index 8720cf43e9ef4f7242d4cd83831278a5bf33c7f7..03610868e32c2221056394607ccb68b8c50860e5 100644 --- a/core/base/CbmTrackingDetectorInterfaceBase.cxx +++ b/core/base/CbmTrackingDetectorInterfaceBase.cxx @@ -20,6 +20,8 @@ #include <set> #include <vector> +#include <fmt/format.h> + // --------------------------------------------------------------------------------------------------------------------- // bool CbmTrackingDetectorInterfaceBase::Check() const @@ -98,32 +100,22 @@ bool CbmTrackingDetectorInterfaceBase::Check() const // std::string CbmTrackingDetectorInterfaceBase::ToString() const { - using std::setfill; - using std::setw; + // TODO: Add verbosity level, probably distribute properties into several tables + using fmt::format; std::stringstream table; - table << std::boolalpha; - table << "\nTracking detector interface: " << setw(5) << GetDetectorName() << '\n'; - table << setw(5) << "st.No" << ' '; - table << setw(10) << "z_ref[cm]" << ' '; - table << setw(10) << "z_min[cm]" << ' '; - table << setw(10) << "z_max[cm]" << ' '; - table << setw(10) << "x_min[cm]" << ' '; - table << setw(10) << "x_max[cm]" << ' '; - table << setw(10) << "y_min[cm]" << ' '; - table << setw(10) << "y_max[cm]" << ' '; - table << setw(10) << "time info" << ' '; - table << '\n'; + table << format("|{:>5}|{:>9}|{:>17}|{:>17}|{:>17}|{:>17}|{:>17}|{:>17}|{:>9}|{:>9}|{:>9}|{:>9}|{:>9}|{:>9}|{:>9}|\n", + "st.No", "z_ref[cm]", "x_min(active)[cm]", "x_max(active)[cm]", "y_min(active)[cm]", + "y_max(active)[cm]", "z_min(active)[cm]", "z_max(active)[cm]", "x_min[cm]", "x_max[cm]", "y_min[cm]", + "y_max[cm]", "z_min[cm]", "z_max[cm]", "time info"); + table << format("|{0:->5}|{0:->9}|{0:->17}|{0:->17}|{0:->17}|{0:->17}|{0:->17}|{0:->17}|{0:->9}|{0:->9}" + "|{0:->9}|{0:->9}|{0:->9}|{0:->9}|{0:->9}|\n", + ""); for (int iSt = 0; iSt < GetNtrackingStations(); ++iSt) { - table << setw(5) << iSt << ' '; - table << setw(10) << GetZref(iSt) << ' '; - table << setw(10) << GetZmin(iSt) << ' '; - table << setw(10) << GetZmax(iSt) << ' '; - table << setw(10) << GetXmin(iSt) << ' '; - table << setw(10) << GetXmax(iSt) << ' '; - table << setw(10) << GetYmin(iSt) << ' '; - table << setw(10) << GetYmax(iSt) << ' '; - table << setw(10) << IsTimeInfoProvided(iSt) << ' '; - table << '\n'; + table << format("|{:>5d}|{:>9f}|{:>17f}|{:>17f}|{:>17f}|{:>17f}|{:>17f}|{:>17f}|{:>9f}|{:>9f}|{:>9f}|{:>9f}|{:>9f}|" + "{:>9f}|{:>9}|\n", + iSt, GetZref(iSt), GetActiveXmin(iSt), GetActiveXmax(iSt), GetActiveYmin(iSt), GetActiveYmax(iSt), + GetActiveZmin(iSt), GetActiveZmax(iSt), GetXmin(iSt), GetXmax(iSt), GetYmin(iSt), GetYmax(iSt), + GetZmin(iSt), GetZmax(iSt), IsTimeInfoProvided(iSt)); } return table.str(); } @@ -179,6 +171,16 @@ CbmTrackingDetectorInterfaceBase::VolumeInfo CbmTrackingDetectorInterfaceBase::R 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; } + + +// --------------------------------------------------------------------------------------------------------------------- +// +std::string CbmTrackingDetectorInterfaceBase::VolumeInfo::ToString() const +{ + std::stringstream msg; + msg << "zRef = " << 0.5 * (fZmin + fZmax) << "zMin = " << fZmin << ", zMax = " << fZmax << ", xMin = " << fXmin + << ", xMax = " << fXmax << ", yMin = " << fYmin << ", yMax = " << fYmax; + return msg.str(); +} diff --git a/core/base/CbmTrackingDetectorInterfaceBase.h b/core/base/CbmTrackingDetectorInterfaceBase.h index d66f152516774e9b6a080fe518635e8614c0eb62..7b6927118f6c0ab0c532acd35b9ca23f1c416182 100644 --- a/core/base/CbmTrackingDetectorInterfaceBase.h +++ b/core/base/CbmTrackingDetectorInterfaceBase.h @@ -33,27 +33,49 @@ class TString; /// @brief Abstract class, which should be inherited by every detecting subsystem tracking interface class /// class CbmTrackingDetectorInterfaceBase { + public: /// @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) + 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] + 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] + + /// @brief Constructor from parameters + VolumeInfo(double xMin, double xMax, double yMin, double yMax, double zMin, double zMax) + : fXmin(xMin) , fXmax(xMax) , fYmin(yMin) , fYmax(yMax) + , fZmin(zMin) + , fZmax(zMax) + { + } + + /// @brief Rule of five + VolumeInfo() = default; + //VolumeInfo(const VolumeInfo&) = default; + //VolumeInfo(VolumeInfo&&) = default; + //VolumeInfo& operator=(const VolumeInfo&) = default; + //VolumeInfo& operator=(VolumeInfo&&) = default; + + /// @brief Compound assingment of another volume + VolumeInfo& operator+=(const VolumeInfo& other) { + fXmin = std::min(fXmin, other.fXmin); + fXmax = std::max(fXmax, other.fXmax); + fYmin = std::min(fYmin, other.fYmin); + fYmax = std::max(fYmax, other.fYmax); + fZmin = std::min(fZmin, other.fZmin); + fZmax = std::max(fZmax, other.fZmax); + return *this; } - 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] + + /// @brief String representation of the structure + std::string ToString() const; }; public: @@ -67,7 +89,7 @@ public: virtual std::string GetDetectorName() const = 0; /// @brief Gets actual number of stations, provided by the current geometry setup - int GetNtrackingStations() const { return fvStations.size(); } + int GetNtrackingStations() const { return fvStationsFull.size(); } /// @brief Gets stereo angles of the two independent measured coordinates /// @note The tracking does not use this method. It is only used by the QA task. @@ -90,45 +112,75 @@ public: /// @return Local index of the tracking station virtual int GetTrackingStationIndex(int address) const = 0; - /// @brief Gets upper bound of a station along the X-axis + /// @brief Gets upper bound of a station passive volume along the X-axis /// @param stationId Tracking station ID in the setup (NOTE: must be in range [0..GetNstations()-1]) /// @return Size of station along the X-axis [cm] - double GetXmax(int stationId) const { return fvStations[stationId].fXmax; } + double GetXmax(int stationId) const { return fvStationsFull[stationId].fXmax; } - /// @brief Gets lower bound of a station along the X-axis + /// @brief Gets lower bound of a station passive volume along the X-axis /// @param stationId Tracking station ID in the setup (NOTE: must be in range [0..GetNstations()-1]) /// @return Size of station along the X-axis [cm] - double GetXmin(int stationId) const { return fvStations[stationId].fXmin; } + double GetXmin(int stationId) const { return fvStationsFull[stationId].fXmin; } - /// @brief Gets upper bound of a station along the Y-axis + /// @brief Gets upper bound of a station passive volume along the Y-axis /// @param stationId Tracking station ID in the setup (NOTE: must be in range [0..GetNstations()-1]) /// @return Size of station along the Y-axis [cm] - double GetYmax(int stationId) const { return fvStations[stationId].fYmax; } + double GetYmax(int stationId) const { return fvStationsFull[stationId].fYmax; } - /// @brief Gets lower bound of a station along the Y-axis + /// @brief Gets lower bound of a station passive volume along the Y-axis /// @param stationId Tracking station ID in the setup (NOTE: must be in range [0..GetNstations()-1]) /// @return Size of station along the Y-axis [cm] - double GetYmin(int stationId) const { return fvStations[stationId].fYmin; } + double GetYmin(int stationId) const { return fvStationsFull[stationId].fYmin; } - /// @brief Gets reference z of the station + /// @brief Gets reference z of the station passive volume /// @param stationId Tracking station ID in the setup (NOTE: must be in range [0..GetNstations()-1]) /// @return Reference z position of the station [cm] - double GetZref(int stationId) const { return fvStations[stationId].fZref; }; + double GetZref(int stationId) const { return 0.5 * (GetActiveZmin(stationId) + GetActiveZmax(stationId)); } /// @brief Gets reference z of the detector module (e.g., RPC for TOF) /// @param address Address of the module /// @return Reference z of module (if not defined, the ref z of the station will be returned) virtual double GetZrefModule(int address) { return GetZref(GetTrackingStationIndex(address)); } - /// @brief Gets min z of the station + /// @brief Gets min z of the station passive volume /// @param stationId Tracking station ID in the setup (NOTE: must be in range [0..GetNstations()-1]) /// @return min Z of the station [cm] - double GetZmin(int stationId) const { return fvStations[stationId].fZmin; } + double GetZmin(int stationId) const { return fvStationsFull[stationId].fZmin; } - /// @brief Gets max z of the station + /// @brief Gets max z of the station passive volume /// @param stationId Tracking station ID in the setup (NOTE: must be in range [0..GetNstations()-1]) /// @return max Z of the station [cm] - double GetZmax(int stationId) const { return fvStations[stationId].fZmax; } + double GetZmax(int stationId) const { return fvStationsFull[stationId].fZmax; } + + /// @brief Gets lower bound of the station active volume along x-axis + /// @param stationId Tracking station ID in the setup (NOTE: must be in range [0..GetNstations()-1]) + /// @return min X of the station active volume [cm] + double GetActiveXmin(int stationId) const { return fvStationsActive[stationId].fXmin; } + + /// @brief Gets upper bound of the station active volume along x-axis + /// @param stationId Tracking station ID in the setup (NOTE: must be in range [0..GetNstations()-1]) + /// @return max X of the station active volume [cm] + double GetActiveXmax(int stationId) const { return fvStationsActive[stationId].fXmax; } + + /// @brief Gets lower bound of the station active volume along y-axis + /// @param stationId Tracking station ID in the setup (NOTE: must be in range [0..GetNstations()-1]) + /// @return min Y of the station active volume [cm] + double GetActiveYmin(int stationId) const { return fvStationsActive[stationId].fYmin; } + + /// @brief Gets upper bound of the station active volume along y-axis + /// @param stationId Tracking station ID in the setup (NOTE: must be in range [0..GetNstations()-1]) + /// @return max Y of the station active volume [cm] + double GetActiveYmax(int stationId) const { return fvStationsActive[stationId].fYmax; } + + /// @brief Gets lower bound of the station active volume along z-axis + /// @param stationId Tracking station ID in the setup (NOTE: must be in range [0..GetNstations()-1]) + /// @return min Z of the station active volume [cm] + double GetActiveZmin(int stationId) const { return fvStationsActive[stationId].fZmin; } + + /// @brief Gets upper bound of the station active volume along z-axis + /// @param stationId Tracking station ID in the setup (NOTE: must be in range [0..GetNstations()-1]) + /// @return max Z of the station active volume [cm] + double GetActiveZmax(int stationId) const { return fvStationsActive[stationId].fZmax; } /// @brief Check if station provides time measurements /// @param stationId Tracking station ID in the setup @@ -153,9 +205,9 @@ public: std::string ToString() const; protected: - /// \brief TEMPORARY switcher for the det. ifs definition (from digi pars -> from geometry) + /// \brief If use legacy tracking detector interface definition /// FIXME: Remove after testing - static constexpr bool kDebugGeoDefined{false}; + static constexpr bool kLegacy{false}; /// @brief Collects paths of the components /// @param[in] detector Name hint of the detector @@ -171,7 +223,11 @@ public: /// @throw std::runtime_error If node is not found by path VolumeInfo ReadVolume(const TString& path); - std::vector<VolumeInfo> fvStations{}; ///< Geometric properties of stations + // NOTE: SZh 10.09.2024: For now the passive and active volumes destinguish in TRD and TOF only. For STS + // the z-components are active, and the x- and y-components are passive. For + // MVD and MuCh the components are legacy (active? taken from digitizers). + std::vector<VolumeInfo> fvStationsFull{}; ///< Geometric properties of passive station volumes + std::vector<VolumeInfo> fvStationsActive{}; ///< Geometric properties of active station volumes }; #endif // CbmTrackingDetectorInterfaceBase_h diff --git a/core/detectors/much/CbmMuchTrackingInterface.cxx b/core/detectors/much/CbmMuchTrackingInterface.cxx index 0857f5f7b315f25b53b9ae59428d41c79f653c4f..31dcc1216ec3fddd9a157f1bdade45c1c4c27ae6 100644 --- a/core/detectors/much/CbmMuchTrackingInterface.cxx +++ b/core/detectors/much/CbmMuchTrackingInterface.cxx @@ -73,15 +73,17 @@ InitStatus CbmMuchTrackingInterface::Init() for (int iMuchSt = 0; iMuchSt < fGeoScheme->GetNStations(); ++iMuchSt) { nStations += fGeoScheme->GetStation(iMuchSt)->GetNLayers(); } - fvStations.clear(); + fvStationsFull.clear(); // FIXME: Provide - fvStations.reserve(nStations); + fvStationsFull.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.); + fvStationsFull.emplace_back(-100., +100, -100., +100, pLayer->GetZ() - 0.5 * pLayer->GetDz(), + pLayer->GetZ() + 0.5 * pLayer->GetDz()); } + fvStationsActive = fvStationsFull; + // 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 94687e635a4fc838c61b18286e9139d50ccd9c0f..2b3c72497ded25ce59a4d40c7c1b10f7f6758c80 100644 --- a/core/detectors/mvd/CbmMvdTrackingInterface.cxx +++ b/core/detectors/mvd/CbmMvdTrackingInterface.cxx @@ -42,18 +42,17 @@ InitStatus CbmMvdTrackingInterface::Init() if (!fMvdStationPar) { return kFATAL; } - - fvStations.clear(); + fvStationsFull.clear(); // FIXME: Provide station parameters from geometry definition (seems to be unavailable) int nStations{fMvdStationPar->GetStationCount()}; - fvStations.reserve(nStations); + fvStationsFull.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)); + fvStationsFull.emplace_back(-fMvdStationPar->GetWidth(iSt), +fMvdStationPar->GetWidth(iSt), + -fMvdStationPar->GetHeight(iSt), +fMvdStationPar->GetHeight(iSt), + fMvdStationPar->GetZPosition(iSt) - 0.5 * fMvdStationPar->GetZThickness(iSt), + fMvdStationPar->GetZPosition(iSt) + 0.5 * fMvdStationPar->GetZThickness(iSt)); } - + fvStationsActive = fvStationsFull; // Check the validity of the parameters if (!this->Check()) { diff --git a/core/detectors/sts/CbmStsTrackingInterface.cxx b/core/detectors/sts/CbmStsTrackingInterface.cxx index e9c063c81e157a41d5a205497c12394d6e0cfb43..9b44a74f5e5985d176b963446affb1c2a0e8f154 100644 --- a/core/detectors/sts/CbmStsTrackingInterface.cxx +++ b/core/detectors/sts/CbmStsTrackingInterface.cxx @@ -91,23 +91,20 @@ InitStatus CbmStsTrackingInterface::Init() if (!stsSetup->IsSensorCondInit()) { stsSetup->SetSensorConditions(fStsParSetSensorCond); } int nStations = CbmStsSetup::Instance()->GetNofStations(); - fvStations.clear(); - fvStations.reserve(nStations); + fvStationsFull.clear(); + fvStationsFull.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->GetZmin(), pStsStation->GetZmax(), - pStsStation->GetXmin(), pStsStation->GetXmax(), pStsStation->GetYmin(), - pStsStation->GetYmax()); + if constexpr (!kLegacy) { + fvStationsFull.emplace_back(pStsStation->GetXmin(), pStsStation->GetXmax(), pStsStation->GetYmin(), + pStsStation->GetYmax(), pStsStation->GetZmin(), pStsStation->GetZmax()); } 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()); + fvStationsFull.emplace_back(pStsStation->GetXmin(), pStsStation->GetXmax(), pStsStation->GetYmin(), + pStsStation->GetYmax(), pStsStation->GetZ() - 2., pStsStation->GetZ() + 2.); } } + fvStationsActive = fvStationsFull; // Check the validity of the parameters diff --git a/core/detectors/tof/CbmTofTrackingInterface.cxx b/core/detectors/tof/CbmTofTrackingInterface.cxx index b0d05509735e8dfe9e055e754174bf21dd7cffda..26444747d0f7121df8a45ed564894650dd6a9f75 100644 --- a/core/detectors/tof/CbmTofTrackingInterface.cxx +++ b/core/detectors/tof/CbmTofTrackingInterface.cxx @@ -45,6 +45,8 @@ CbmTofTrackingInterface::~CbmTofTrackingInterface() // InitStatus CbmTofTrackingInterface::Init() { + static_assert(std::is_trivially_copyable_v<VolumeInfo> == true); + // create digitization parameters from geometry file auto tofDigiPar = new CbmTofCreateDigiPar("TOF Digi Producer", "TOF task"); LOG(info) << "Create DigiPar"; @@ -58,39 +60,37 @@ InitStatus CbmTofTrackingInterface::Init() // Number of ToF RPCs for a given tracking station: std::vector<int> nTofStationModules(nStations, 0); - - fvStations.clear(); - fvStations.resize(nStations); - if constexpr (kDebugGeoDefined) { + fvStationsFull.clear(); + fvStationsFull.resize(nStations); + fvStationsActive.clear(); + fvStationsActive.resize(nStations); + if constexpr (!kLegacy) { // 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) { + auto vRpcPaths{CollectNodes("tof", "counter", "", gGeoManager->GetTopNode())}; + std::regex rpcPattern{"module_(\\d+)_(\\d+)/gas_box_(\\d+)/counter_(\\d+)"}; + for (const auto& rpcPath : vRpcPaths) { std::smatch match; - std::string line{path.Data()}; - if (std::regex_search(line, match, pattern)) { + std::string line{rpcPath.Data()}; + if (std::regex_search(line, match, rpcPattern)) { 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 + + if (5 == iSmType || iStation < 0) { // NOTE: Check for BeamOn modules or other inactive RPCs continue; } - 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); + + fvStationsFull[iStation] += ReadVolume(rpcPath); // Adding RPC as a passive volume + gGeoManager->cd(rpcPath); + auto vCellPaths{CollectNodes("tof", "cell", rpcPath(0, rpcPath.Last('/')), gGeoManager->GetCurrentNode())}; + for (const auto& cellPath : vCellPaths) { + fvStationsActive[iStation] += ReadVolume(cellPath); + } } } - for (auto& station : fvStations) { - station.fZref = 0.5 * (station.fZmin + station.fZmax); - } } - else { // old tracing station definition + else { // old tracking station definition fTofStationZ.clear(); fTofStationZ.resize(nStations); fTofStationZMin.clear(); @@ -137,15 +137,15 @@ InitStatus CbmTofTrackingInterface::Init() /// 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; + auto& station{fvStationsActive[iSt]}; station.fXmin = -100.; station.fXmax = +100.; station.fYmin = -100.; station.fYmax = +100.; + station.fZmin = fTofStationZMin[iSt] - .5; + station.fZmax = fTofStationZMax[iSt] + .5; } + fvStationsFull = fvStationsActive; } // Check the validity of the parameters diff --git a/core/detectors/trd/CbmTrdTrackingInterface.cxx b/core/detectors/trd/CbmTrdTrackingInterface.cxx index 59b36523238f10a172a89c7ef74c9b5bb97e3094..98d27fe2b3268626ce9c07006cbaf6c82b69c4f5 100644 --- a/core/detectors/trd/CbmTrdTrackingInterface.cxx +++ b/core/detectors/trd/CbmTrdTrackingInterface.cxx @@ -88,26 +88,25 @@ 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) { + if constexpr (!kLegacy) { + auto vLayerPaths{CollectNodes("trd", "layer", "", gGeoManager->GetTopNode())}; + fvStationsFull.clear(); + fvStationsFull.resize(vLayerPaths.size()); + fvStationsActive.clear(); + fvStationsActive.resize(vLayerPaths.size()); + std::regex stationPattern{"layer(\\d+)_(\\d+)"}; + for (const auto& layerPath : vLayerPaths) { 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); + std::string line{layerPath.Data()}; + if (std::regex_search(line, match, stationPattern)) { + int iStation{std::stoi(match[1]) - 1}; // the tracking station is a TRD layer + fvStationsFull[iStation] = ReadVolume(layerPath); + gGeoManager->cd(layerPath); + auto vGasPaths{CollectNodes("trd", "gas", layerPath(0, layerPath.Last('/')), gGeoManager->GetCurrentNode())}; + for (const auto& gasPath : vGasPaths) { + fvStationsActive[iStation] += ReadVolume(gasPath); + } } } } @@ -128,15 +127,16 @@ InitStatus CbmTrdTrackingInterface::Init() } } } - fvStations.clear(); - fvStations.reserve(nStations); + fvStationsFull.clear(); + fvStationsFull.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()); + fvStationsFull.emplace_back( + pModulePar->GetX() - pModulePar->GetSizeX(), pModulePar->GetX() + pModulePar->GetSizeX(), + pModulePar->GetY() - pModulePar->GetSizeY(), pModulePar->GetY() + pModulePar->GetSizeY(), + pModulePar->GetZ() - pModulePar->GetSizeZ(), pModulePar->GetZ() + pModulePar->GetSizeZ()); } + fvStationsActive = fvStationsFull; } // Check access to TRD modules