Skip to content

Commit 4d45475

Browse files
committed
[MCH] added pad remapping function for ST2
The remapping function corrects the pads mapping for five consecutive motif types on the bending side of ST2 quadrants (types "2Bv1" to "2Bv5").
1 parent b89e443 commit 4d45475

File tree

1 file changed

+108
-1
lines changed

1 file changed

+108
-1
lines changed

Detectors/MUON/MCH/DigitFiltering/src/DigitModifier.cxx

Lines changed: 108 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,113 @@ o2::mch::DigitModifier createST1MappingCorrector(int runNumber)
187187
updateDigitMapping(digit, padsRemapping);
188188
};
189189
}
190+
191+
/** Initialization of the pad remapping table for Station 2 DEs
192+
* See https://its.cern.ch/jira/browse/MCH-5 for details
193+
*/
194+
void initST2PadsRemappingTable(PadRemappingTables& fullTable)
195+
{
196+
// Remapping of ST2 DS boards near the rounded part
197+
std::array<int, 8> deToRemap{300, 301, 302, 303, 400, 401, 402, 403};
198+
std::array<int, 5> dsToRemap{99, 100, 101, 102, 103};
199+
200+
for (auto deId : deToRemap) {
201+
202+
// create an empty table, or reset the existing one
203+
fullTable[deId] = PadRemappingTablesForDE();
204+
// get a reference to the table for the current DE
205+
auto& tableForDE = fullTable[deId];
206+
207+
const o2::mch::mapping::Segmentation& segment = o2::mch::mapping::segmentation(deId);
208+
for (auto dsId : dsToRemap) {
209+
210+
auto& tableForDSWithLimits = tableForDE.emplace_back();
211+
auto& tableForDS = tableForDSWithLimits.first;
212+
213+
// double loop on DS channels
214+
// 1. find the minimum pad index of the DS board
215+
int padIdMin = -1;
216+
int channelForPadIdMin = -1;
217+
for (int channel = 0; channel < 64; channel++) {
218+
auto padId = segment.findPadByFEE(dsId, int(channel));
219+
if (padId < 0) {
220+
// this should never occur in this specific case, as all channels of this group of boards
221+
// is connected to pads, hence we rise an exception
222+
throw std::out_of_range(fmt::format("Unknown padId for DE{} DS{} channel {}", deId, dsId, channel));
223+
}
224+
if (padIdMin < 0 || padId < padIdMin) {
225+
padIdMin = padId;
226+
channelForPadIdMin = channel;
227+
}
228+
}
229+
230+
int padIdMax = -1;
231+
// 2. build the re-mapping table
232+
for (int channel = 0; channel < 64; channel++) {
233+
auto padId = segment.findPadByFEE(dsId, int(channel));
234+
if (padId < padIdMin) {
235+
// something is wrong here...
236+
continue;
237+
}
238+
239+
// update maximum padId value
240+
padIdMax = std::max(padIdMax, padId);
241+
242+
int padIdInDS = padId - padIdMin;
243+
int padColumn = padIdInDS / 16;
244+
int padRow = padIdInDS % 16;
245+
246+
int padIdRemapped = -1;
247+
248+
switch (padColumn) {
249+
case 0:
250+
// shift right by 3 columns
251+
padIdRemapped = padId + 16 * 3;
252+
break;
253+
case 1:
254+
// shift right by 1 column
255+
padIdRemapped = padId + 16;
256+
break;
257+
case 2:
258+
// shift left by 1 column
259+
padIdRemapped = padId - 16;
260+
break;
261+
case 3:
262+
// shift left by 3 columns
263+
padIdRemapped = padId - 16 * 3;
264+
break;
265+
}
266+
267+
// padsRemapping[deId][padId] = padIdRemapped;
268+
tableForDS[padId] = padIdRemapped;
269+
}
270+
271+
tableForDSWithLimits.second.first = padIdMin;
272+
tableForDSWithLimits.second.second = padIdMax;
273+
}
274+
}
275+
}
276+
277+
o2::mch::DigitModifier createST2MappingCorrector(int runNumber)
278+
{
279+
// static std::unordered_map<int, std::unordered_map<int, int>> padsRemapping;
280+
static PadRemappingTables padsRemapping;
281+
282+
constexpr int lastRunToBeFixed = 560402;
283+
// ST2 mapping needs to be corrected only for data collected up to the end of 2024 Pb-Pb
284+
if (runNumber > lastRunToBeFixed) {
285+
// do not modify digits collected after 2024 Pb-Pb
286+
return {};
287+
}
288+
289+
if (padsRemapping.empty()) {
290+
initST2PadsRemappingTable(padsRemapping);
291+
}
292+
293+
return [](o2::mch::Digit& digit) {
294+
updateDigitMapping(digit, padsRemapping);
295+
};
296+
}
190297
} // namespace
191298

192299
namespace o2::mch
@@ -196,7 +303,7 @@ DigitModifier createDigitModifier(int runNumber,
196303
bool updateST2)
197304
{
198305
DigitModifier modifierST1 = updateST1 ? createST1MappingCorrector(runNumber) : DigitModifier{};
199-
DigitModifier modifierST2{};
306+
DigitModifier modifierST2 = updateST2 ? createST2MappingCorrector(runNumber) : DigitModifier{};
200307

201308
if (modifierST1 || modifierST2) {
202309
return [modifierST1, modifierST2](Digit& digit) {

0 commit comments

Comments
 (0)