Skip to content
Snippets Groups Projects
Commit 148e7a7d authored by Alexandru Bercuci's avatar Alexandru Bercuci
Browse files

re-introduce the equipment map, add channel mask info to internal parameters

Update from MR 1198
parent 90170205
No related branches found
No related tags found
1 merge request!1228Rebasing MR1179
......@@ -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;
}
}
}
......
......@@ -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 = {}; //!
};
......
......@@ -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;
......
......@@ -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
};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment