Skip to content

Commit 7431594

Browse files
bovulpesshahor02
authored andcommitted
MFT: fix lanes mapping for decoding commissionning data and for working also with MC, both MFT and ITS
1 parent 04738cb commit 7431594

File tree

5 files changed

+27
-14
lines changed

5 files changed

+27
-14
lines changed

Detectors/ITSMFT/MFT/simulation/src/digi2raw.cxx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,6 @@ void setupLinks(o2::itsmft::MC2RawEncoder<MAP>& m2r, std::string_view outDir, st
228228

229229
int ruID = nRUtot++;
230230
bool accept = !(ruSW < m2r.getRUSWMin() || ruSW > m2r.getRUSWMax()); // ignored RUs ?
231-
int accL = 0;
232231
if (accept) {
233232
m2r.getCreateRUDecode(ruSW); // create RU container
234233
nRU++;
@@ -237,12 +236,11 @@ void setupLinks(o2::itsmft::MC2RawEncoder<MAP>& m2r, std::string_view outDir, st
237236
uint32_t lanes = mp.getCablesOnRUType(ru.ruInfo->ruType); // lanes patter of this RU
238237
ru.links[0] = m2r.addGBTLink();
239238
auto link = m2r.getGBTLink(ru.links[0]);
240-
link->lanes = lanes & ((0x1 << lnkAs) - 1) << (accL);
239+
link->lanes = lanes;
241240
link->idInCRU = linkID;
242241
link->cruID = cruIDtmp * 100 + o2::detectors::DetID::MFT;
243242
link->feeID = mp.RUSW2FEEId(ruSW);
244243
link->endPointID = 0; // 0 or 1
245-
accL += lnkAs;
246244
// register the link in the writer, if not done here, its data will be dumped to common default file
247245
//printf("Register link: FeeID 0x%02x , CRU ID 0x%x , link ID %2d \n", link->feeID, link->cruID, link->idInCRU);
248246
//printf("RU SW: %2d HW: 0x%02x Type: %2d %s \n", ruSW, ruHW, ruType, outFileLink.data());

Detectors/ITSMFT/common/reconstruction/include/ITSMFTReconstruction/ChipMappingITS.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,9 @@ class ChipMappingITS
172172
///< convert HW cable ID to SW ID for given RU type (see ChipOnRUInfo.cableSW explanation)
173173
uint8_t cableHW2SW(uint8_t ruType, uint8_t hwid) const { return mCableHW2SW[ruType][hwid]; }
174174

175+
///< convert cable iterator ID to the position on the ActiveLanes word in the GBT.header for given RU type; MFT lanes position compatible
176+
uint8_t cablePos(uint8_t ruType, uint8_t id) const { return id; }
177+
175178
///< get number of chips served by single cable on given RU type
176179
int getNChipsPerCable(int ruType) { return NChipsPerCableSB[ruType]; }
177180

Detectors/ITSMFT/common/reconstruction/include/ITSMFTReconstruction/ChipMappingMFT.h

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,9 @@ class ChipMappingMFT
108108
///< convert HW cable ID to SW ID for give RU type
109109
uint8_t cableHW2SW(uint8_t ruType, uint8_t hwid) const { return mCableHW2SW[ruType][hwid]; }
110110

111+
///< convert cable iterator ID to its position on the ActiveLanes word in the GBT.header for given RU type
112+
uint8_t cablePos(uint8_t ruType, uint8_t id) const { return mCablePos[ruType][id]; }
113+
111114
///< get chip global SW ID from chipID on module, cable SW ID and stave (RU) info
112115
uint16_t getGlobalChipID(uint16_t chOnModuleHW, int cableHW, const RUInfo& ruInfo) const
113116
{
@@ -198,8 +201,14 @@ class ChipMappingMFT
198201

199202
static constexpr std::int16_t getRUDetectorField() { return 0x0; }
200203

201-
///< get pattern of lanes on the RU served by a given RU type
202-
Int_t getCablesOnRUType(Int_t ruType) const { return (0x1 << NChipsOnRUType[ruType]) - 1; }
204+
uint32_t getCablesOnRUType(Int_t ruType) const
205+
{
206+
uint32_t pattern = 0;
207+
for (Int_t i = 0; i < NRUCables; i++) {
208+
pattern |= (0x1 << mCableHW2Pos[ruType][i]);
209+
}
210+
return pattern;
211+
}
203212

204213
///< get info on sw RU
205214
const RUInfo* getRUInfoSW(int ruSW) const { return &mRUInfo[ruSW]; }
@@ -277,6 +286,7 @@ class ChipMappingMFT
277286

278287
std::vector<uint8_t> mCableHW2SW[NRUs]; ///< table of cables HW to SW conversion for each RU type
279288
std::vector<uint8_t> mCableHW2Pos[NRUs]; ///< table of cables positions in the ActiveLanes mask for each RU type
289+
std::vector<uint8_t> mCablePos[NRUs]; ///< reverse table of cables positions in the ActiveLanes mask for each RU type
280290
std::vector<uint8_t> mCableHWFirstChip[NRUs]; ///< 1st chip of module (relative to the 1st chip of the stave) served by each cable
281291

282292
std::array<std::vector<uint16_t>, NRUs> mRUGlobalChipID;

Detectors/ITSMFT/common/reconstruction/src/ChipMappingMFT.cxx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1652,6 +1652,7 @@ ChipMappingMFT::ChipMappingMFT()
16521652
mChipInfoEntryRU[iRU] = ctrChip;
16531653
mCableHW2SW[iRU].resize(NRUCables, 0xff);
16541654
mCableHW2Pos[iRU].resize(NRUCables, 0xff);
1655+
mCablePos[iRU].resize(NRUCables, 0xff);
16551656
mCableHWFirstChip[iRU].resize(NRUCables, 0xff);
16561657
} else {
16571658
if ((layer != curLayer) || (zone != curZone) || (half != curHalf)) {
@@ -1676,10 +1677,11 @@ ChipMappingMFT::ChipMappingMFT()
16761677

16771678
chInfo.cableHW = ChipConnectorCable[chInfo.moduleHW][chInfo.chipOnModuleSW];
16781679
chInfo.cableSW = chipOnRU;
1679-
chInfo.cableHWPos = chipOnRU;
1680+
chInfo.cableHWPos = chInfo.cableHW;
16801681

16811682
chInfo.chipOnCable = 0;
16821683

1684+
mCablePos[iRU][chInfo.id] = chInfo.cableHWPos;
16831685
mCableHW2Pos[iRU][chInfo.cableHW] = chInfo.cableHWPos;
16841686
mCableHW2SW[iRU][chInfo.cableHW] = chInfo.cableSW;
16851687
mCableHWFirstChip[iRU][chInfo.cableHW] = 0;

Detectors/ITSMFT/common/simulation/src/MC2RawEncoder.cxx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -180,8 +180,8 @@ void MC2RawEncoder<Mapping>::fillGBTLinks(RUDecodeData& ru)
180180
// estimate real payload size in GBT words
181181
int nPayLoadWordsNeeded = 0; // number of payload words filled to link buffer (RDH not included) for current IR
182182
for (int icab = ru.nCables; icab--;) { // calculate number of GBT words per link
183-
if ((link->lanes & (0x1 << icab))) {
184-
int nb = ru.cableData[icab].getSize();
183+
if ((link->lanes & (0x1 << mMAP.cablePos(ru.ruInfo->ruType, icab)))) {
184+
int nb = ru.cableData[mMAP.cablePos(ru.ruInfo->ruType, icab)].getSize();
185185
nPayLoadWordsNeeded += nb ? 1 + (nb - 1) / 9 : 0; // single GBT word carries at most 9 payload bytes
186186
}
187187
}
@@ -195,19 +195,19 @@ void MC2RawEncoder<Mapping>::fillGBTLinks(RUDecodeData& ru)
195195
while (hasData) {
196196
hasData = false;
197197
for (int icab = 0; icab < ru.nCables; icab++) {
198-
if ((link->lanes & (0x1 << icab))) {
199-
auto& cableData = ru.cableData[icab];
198+
if ((link->lanes & (0x1 << mMAP.cablePos(ru.ruInfo->ruType, icab)))) {
199+
auto& cableData = ru.cableData[mMAP.cablePos(ru.ruInfo->ruType, icab)];
200200
int nb = cableData.getUnusedSize();
201201
if (!nb) {
202202
continue; // write 80b word only if there is something to write
203203
}
204204
if (nb > 9) {
205205
nb = 9;
206206
}
207-
int gbtWordStart = link->data.getSize(); // beginning of the current GBT word in the link
208-
link->data.addFast(cableData.getPtr(), nb); // fill payload of cable
209-
link->data.addFast(zero16, GBTPaddedWordLength - nb); // fill the rest of the GBT word by 0
210-
link->data[gbtWordStart + 9] = mMAP.getGBTHeaderRUType(ru.ruInfo->ruType, ru.cableHWID[icab]); // set cable flag
207+
int gbtWordStart = link->data.getSize(); // beginning of the current GBT word in the link
208+
link->data.addFast(cableData.getPtr(), nb); // fill payload of cable
209+
link->data.addFast(zero16, GBTPaddedWordLength - nb); // fill the rest of the GBT word by 0
210+
link->data[gbtWordStart + 9] = mMAP.getGBTHeaderRUType(ru.ruInfo->ruType, ru.cableHWID[mMAP.cablePos(ru.ruInfo->ruType, icab)]); // set cable flag
211211
cableData.setPtr(cableData.getPtr() + nb);
212212
hasData = true;
213213
} // storing data of single cable

0 commit comments

Comments
 (0)