diff --git a/core/detectors/much/CbmMuchTrackingInterface.cxx b/core/detectors/much/CbmMuchTrackingInterface.cxx index 33446c0ffe93aebefc9708a5684cc6dcc83b4db7..3f58aadf976d672e5c7e628897bb25b9f2a8c9aa 100644 --- a/core/detectors/much/CbmMuchTrackingInterface.cxx +++ b/core/detectors/much/CbmMuchTrackingInterface.cxx @@ -80,6 +80,11 @@ InitStatus CbmMuchTrackingInterface::Init() // Init conversion matrices InitConversionMatrices(); + // Keep Track of how many layers are present in each station (may be heterogenous) + for (int iMuchSt = 0; iMuchSt < fGeoScheme->GetNStations(); ++iMuchSt) { + fNbLayersPerStation.push_back(fGeoScheme->GetStation(iMuchSt)->GetNLayers()); + } + // Check the validity of the parameters if (!this->Check()) { LOG(error) diff --git a/core/detectors/much/CbmMuchTrackingInterface.h b/core/detectors/much/CbmMuchTrackingInterface.h index aa9a5440a5766c5c5f01c6518e821a93ba907c13..5ba7677dba529eaf0de04b4a55303222a0f86ac5 100644 --- a/core/detectors/much/CbmMuchTrackingInterface.h +++ b/core/detectors/much/CbmMuchTrackingInterface.h @@ -139,16 +139,37 @@ private: } /// Calculates MuCh layer ID from tracker station ID - __attribute__((always_inline)) int GetMuchLayerId(int stationId) const { return stationId % 3; } + __attribute__((always_inline)) int GetMuchLayerId(int stationId) const + { + int layersCount = 0; + auto itStatNbLay = fNbLayersPerStation.cbegin(); + while ((layersCount + *itStatNbLay) <= stationId) { + layersCount += *itStatNbLay; + itStatNbLay++; + } + return stationId - layersCount; + } /// Calculates MuCh station ID from tracker station ID - __attribute__((always_inline)) int GetMuchStationId(int stationId) const { return stationId / 3; } + __attribute__((always_inline)) int GetMuchStationId(int stationId) const + { + int layersCount = 0; + int stationsCount = 0; + // Assume that never station ID as input bigger than total number of stations + while ((layersCount + fNbLayersPerStation[stationsCount]) <= stationId) { + layersCount += fNbLayersPerStation[stationsCount]; + stationsCount++; + } + return stationsCount; + } static CbmMuchTrackingInterface* fpInstance; ///< Instance of the class CbmMuchGeoScheme* fGeoScheme {nullptr}; ///< MuCh geometry scheme instance + std::vector<uint16_t> fNbLayersPerStation = {}; + ClassDef(CbmMuchTrackingInterface, 0); };