diff --git a/algo/detectors/trd2d/Trd2dReadoutConfig.cxx b/algo/detectors/trd2d/Trd2dReadoutConfig.cxx index 3a7d04e7feca0203fa8e193f13faa25e217d5523..e5ffe41d97c26496092b0d1b3dbdc139ad22ba39 100644 --- a/algo/detectors/trd2d/Trd2dReadoutConfig.cxx +++ b/algo/detectors/trd2d/Trd2dReadoutConfig.cxx @@ -62,11 +62,27 @@ namespace cbm::algo } // ------------------------------------------------------------------------------------ + // --- Initialise the component mapping structure ---------------------------------- + void Trd2dReadoutConfig::InitComponentMap(const std::map<uint32_t, uint16_t[NCROBMOD]>& map) + { + // Receive map (moduleId, crobId) -> (equipId) + // Invert to obtain component map (equipId) -> (module iq, crob id) + for (auto& entry : map) { + uint16_t mod_id = entry.first; + for (uint8_t crob_id = 0; crob_id < NCROBMOD; crob_id++) { + uint16_t eq_id = entry.second[crob_id]; + if (!eq_id) continue; + fReadoutMap[eq_id] = std::make_pair(mod_id, crob_id); + } + } + } + // ------------------------------------------------------------------------------------ + // --- Initialise the mapping structure -------------------------------------------- void Trd2dReadoutConfig::InitChannelMap( const std::map<size_t, std::map<size_t, std::map<size_t, std::tuple<int32_t, bool, uint64_t>>>>& channelMap) { - // Constructing the map (equipId, asicId, chanId) -> (pad address, R pairing flag, daq offset) + // Constructing the map (equipId, asicId, chanId) -> (pad address, mask flag, daq offset) for (auto compMap : channelMap) { uint16_t equipmentId = compMap.first; uint16_t numAsics = compMap.second.size(); @@ -76,7 +92,6 @@ namespace cbm::algo uint16_t asicId = asicMap.first; uint16_t numChans = asicMap.second.size(); fChannelMap[equipmentId][asicId].resize(numChans); - for (auto chanMap : asicMap.second) { uint16_t chanId = chanMap.first; std::tuple<int32_t, bool, uint64_t> chanPars = chanMap.second; @@ -88,7 +103,7 @@ namespace cbm::algo // ------------------------------------------------------------------------------------ - // --- Mapping (equimentId, asicId, channel) -> (pad address, R pairing flag, daq offset) ----- + // --- Mapping (equimentId, asicId, channel) -> (pad address, mask flag, daq offset) ----- std::tuple<int32_t, bool, uint64_t> Trd2dReadoutConfig::ChanMap(uint16_t equipId, uint16_t asic, uint16_t chan) { std::tuple<int32_t, bool, uint64_t> result = std::make_tuple(-1, false, 0); @@ -138,10 +153,10 @@ namespace cbm::algo for (size_t chanId = 0; chanId < numChans; chanId++) { auto entry = asicMap.second.at(asicId).at(chanId); int32_t address = std::get<0>(entry); - bool hasPairingR = std::get<1>(entry); + bool isMasked = std::get<1>(entry); uint64_t daqOffset = std::get<2>(entry); ss << "\n Equipment " << equipmentId << " AsicId " << asicId << " chanID " << chanId << " pad address " - << address << " pairingR " << hasPairingR << " daq offset " << daqOffset; + << address << " mask " << isMasked << " daq offset " << daqOffset; } } } diff --git a/algo/detectors/trd2d/Trd2dReadoutConfig.h b/algo/detectors/trd2d/Trd2dReadoutConfig.h index e449fabb5816edbb8f8e9631bef454a7a05ac223..4330bc3a9bd2fca665f2b007cacacefcc1c5fc96 100644 --- a/algo/detectors/trd2d/Trd2dReadoutConfig.h +++ b/algo/detectors/trd2d/Trd2dReadoutConfig.h @@ -80,6 +80,9 @@ namespace cbm::algo /** @brief Debug output of readout map **/ std::string PrintReadoutMap(); + /** @brief Initialisation of readout map **/ + void InitComponentMap(const std::map<uint32_t, uint16_t[NCROBMOD]>& crob_map); + /** @brief Initialisation of channel map **/ void InitChannelMap( const std::map<size_t, std::map<size_t, std::map<size_t, std::tuple<int32_t, bool, uint64_t>>>>& channelMap); @@ -90,7 +93,7 @@ namespace cbm::algo std::map<uint16_t, std::pair<uint16_t, uint8_t>> fReadoutMap = {}; //! // --- TRD2D channel map - // --- Map index: (equipment, asic, chan), map value: (pad address, R pairing flag, daq offset) + // --- Map index: (equipment, asic, chan), map value: (pad address, mask flag, daq offset) std::map<uint16_t, std::vector<std::vector<std::tuple<int32_t, bool, uint64_t>>>> fChannelMap = {}; //! }; diff --git a/algo/detectors/trd2d/UnpackTrd2d.cxx b/algo/detectors/trd2d/UnpackTrd2d.cxx index a1eb4ec42726799d524c2196ea3da7e8ff5c5562..c23e1bc565e0feeccd6ec8d3c16349ae92ed807c 100644 --- a/algo/detectors/trd2d/UnpackTrd2d.cxx +++ b/algo/detectors/trd2d/UnpackTrd2d.cxx @@ -100,8 +100,8 @@ namespace cbm::algo const uint64_t tdaqOffset = asicPar.fChanParams[messes[0].ch].fDaqOffset; for (auto imess : messes) { - const int32_t pad = asicPar.fChanParams[imess.ch].fPadAddress; - const bool hasPairingR = asicPar.fChanParams[imess.ch].fHasPairingR; + const int32_t pad = std::abs(asicPar.fChanParams[imess.ch].fPadAddress); + const bool hasPairingR = bool(asicPar.fChanParams[imess.ch].fPadAddress > 0); const uint64_t lTime = time + tdaqOffset + imess.tlab; const uint16_t lchR = hasPairingR ? imess.data : 0; const uint16_t lchT = hasPairingR ? 0 : imess.data; diff --git a/algo/detectors/trd2d/UnpackTrd2d.h b/algo/detectors/trd2d/UnpackTrd2d.h index 9cb8a3580fe236bbae0418fa7bb8e6d5963de94e..5381e067ac7c60742a4fc9538da5e2f4c73fcbfe 100644 --- a/algo/detectors/trd2d/UnpackTrd2d.h +++ b/algo/detectors/trd2d/UnpackTrd2d.h @@ -54,7 +54,7 @@ namespace cbm::algo **/ struct UnpackTrd2dChannelPar { int32_t fPadAddress; ///< Pad address for channel - bool fHasPairingR; ///< Flag for R or T compoment + bool fMask; ///< Flag for channel masking uint64_t fDaqOffset = 0; ///< Time calibration parameter };