Skip to content

Commit b89e443

Browse files
committed
[MCH] added pad remapping function for ST1
The remapping function corrects the pads mapping for seven DS boards on the edge of the bending cathodes, all corresponding to the motif type "1BG".
1 parent 6e7b6ee commit b89e443

File tree

1 file changed

+186
-1
lines changed

1 file changed

+186
-1
lines changed

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

Lines changed: 186 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,198 @@
2121
#include <stdexcept>
2222
#include <limits>
2323

24+
namespace
25+
{
26+
using PadRemappingTable = std::unordered_map<int, int>;
27+
using PadRemappingTableWithLimits = std::pair<PadRemappingTable, std::pair<int, int>>;
28+
using PadRemappingTablesForDE = std::vector<PadRemappingTableWithLimits>;
29+
using PadRemappingTables = std::unordered_map<int, PadRemappingTablesForDE>;
30+
31+
// utility function that updates a digit with a given pad remapping table
32+
bool updateDigitMapping(o2::mch::Digit& digit, const PadRemappingTables& padsRemapping)
33+
{
34+
int deId = digit.getDetID();
35+
// check if the current DE is included in the pad remapping table
36+
auto padsRemappingForDE = padsRemapping.find(deId);
37+
if (padsRemappingForDE == padsRemapping.end()) {
38+
return false;
39+
}
40+
41+
// find the remapping table that contains this padId, if existing
42+
int padId = digit.getPadID();
43+
for (auto& padsRemappingForDS : padsRemappingForDE->second) {
44+
if (padId < padsRemappingForDS.second.first || padId > padsRemappingForDS.second.second) {
45+
continue;
46+
}
47+
48+
auto padIDRemapped = padsRemappingForDS.first.find(digit.getPadID());
49+
if (padIDRemapped == padsRemappingForDS.first.end()) {
50+
continue;
51+
}
52+
53+
// update the digit
54+
digit.setPadID(padIDRemapped->second);
55+
return true;
56+
}
57+
return false;
58+
}
59+
60+
/** Initialization of the pad remapping table for Station 1 DEs
61+
* See https://its.cern.ch/jira/browse/MCH-4 for detals
62+
*/
63+
void initST1PadsRemappingTable(PadRemappingTables& fullTable)
64+
{
65+
std::array<int, 8> deToRemap{100, 101, 102, 103, 200, 201, 202, 203};
66+
std::array<int, 7> dsToRemap{1, 27, 53, 79, 105, 131, 157};
67+
68+
std::vector<int> newToOld(64);
69+
newToOld[0] = 55;
70+
newToOld[1] = 1;
71+
newToOld[2] = 11;
72+
newToOld[3] = 48;
73+
newToOld[4] = 4;
74+
newToOld[5] = 52;
75+
newToOld[6] = 12;
76+
newToOld[7] = 61;
77+
newToOld[8] = 59;
78+
newToOld[9] = 9;
79+
newToOld[10] = 10;
80+
newToOld[11] = 17;
81+
newToOld[12] = 5;
82+
newToOld[13] = 36;
83+
newToOld[14] = 57;
84+
newToOld[15] = 13;
85+
newToOld[16] = 21;
86+
newToOld[17] = 23;
87+
newToOld[18] = 34;
88+
newToOld[19] = 58;
89+
newToOld[20] = 20;
90+
newToOld[21] = 62;
91+
newToOld[22] = 43;
92+
newToOld[23] = 24;
93+
newToOld[24] = 38;
94+
newToOld[25] = 49;
95+
newToOld[26] = 26;
96+
newToOld[27] = 47;
97+
newToOld[28] = 50;
98+
newToOld[29] = 41;
99+
newToOld[30] = 31;
100+
newToOld[31] = 53;
101+
newToOld[32] = 32;
102+
newToOld[33] = 15;
103+
newToOld[34] = 33;
104+
newToOld[35] = 42;
105+
newToOld[36] = 3;
106+
newToOld[37] = 18;
107+
newToOld[38] = 37;
108+
newToOld[39] = 40;
109+
newToOld[40] = 30;
110+
newToOld[41] = 39;
111+
newToOld[42] = 46;
112+
newToOld[43] = 22;
113+
newToOld[44] = 35;
114+
newToOld[45] = 45;
115+
newToOld[46] = 0;
116+
newToOld[47] = 25;
117+
newToOld[48] = 51;
118+
newToOld[49] = 27;
119+
newToOld[50] = 28;
120+
newToOld[51] = 44;
121+
newToOld[52] = 6;
122+
newToOld[53] = 29;
123+
newToOld[54] = 2;
124+
newToOld[55] = 56;
125+
newToOld[56] = 19;
126+
newToOld[57] = 60;
127+
newToOld[58] = 54;
128+
newToOld[59] = 16;
129+
newToOld[60] = 8;
130+
newToOld[61] = 14;
131+
newToOld[62] = 7;
132+
newToOld[63] = 63;
133+
134+
for (auto deId : deToRemap) {
135+
136+
// create an empty table, or reset the existing one
137+
fullTable[deId] = PadRemappingTablesForDE();
138+
// get a reference to the table for the current DE
139+
auto& tableForDE = fullTable[deId];
140+
141+
const o2::mch::mapping::Segmentation& segment = o2::mch::mapping::segmentation(deId);
142+
for (auto dsId : dsToRemap) {
143+
// add an empty table for the currend DS board
144+
auto& tableForDSWithLimits = tableForDE.emplace_back();
145+
auto& tableForDS = tableForDSWithLimits.first;
146+
147+
int padIdMin = std::numeric_limits<int>::max();
148+
int padIdMax = -1;
149+
for (int channel = 0; channel < 64; channel++) {
150+
// get the pad ID associated to the channel in the new mapping
151+
// this IS NOT the pad that originally fired
152+
int padId = segment.findPadByFEE(dsId, channel);
153+
// get the corresponding channel number in the old mapping
154+
// this IS the electronic channel that originally fired
155+
int channelInOldMapping = newToOld[channel];
156+
// get the pad ID associated to the fired channel in the new mapping
157+
int padIdRemapped = segment.findPadByFEE(dsId, channelInOldMapping);
158+
// update the pad remapping table
159+
tableForDS[padId] = padIdRemapped;
160+
161+
padIdMin = std::min(padIdMin, padId);
162+
padIdMax = std::max(padIdMax, padId);
163+
}
164+
165+
tableForDSWithLimits.second.first = padIdMin;
166+
tableForDSWithLimits.second.second = padIdMax;
167+
}
168+
}
169+
}
170+
171+
o2::mch::DigitModifier createST1MappingCorrector(int runNumber)
172+
{
173+
static PadRemappingTables padsRemapping;
174+
175+
constexpr int lastRunToBeFixed = 560402;
176+
// ST2 mapping needs to be corrected only for data collected up to the end of 2024 Pb-Pb
177+
if (runNumber > lastRunToBeFixed) {
178+
// do not modify digits collected after 2024 Pb-Pb
179+
return {};
180+
}
181+
182+
if (padsRemapping.empty()) {
183+
initST1PadsRemappingTable(padsRemapping);
184+
}
185+
186+
return [](o2::mch::Digit& digit) {
187+
updateDigitMapping(digit, padsRemapping);
188+
};
189+
}
190+
} // namespace
191+
24192
namespace o2::mch
25193
{
26194
DigitModifier createDigitModifier(int runNumber,
27195
bool updateST1,
28196
bool updateST2)
29197
{
30-
return {};
198+
DigitModifier modifierST1 = updateST1 ? createST1MappingCorrector(runNumber) : DigitModifier{};
199+
DigitModifier modifierST2{};
200+
201+
if (modifierST1 || modifierST2) {
202+
return [modifierST1, modifierST2](Digit& digit) {
203+
// the ST1/ST2 modifiers are mutually exclusive, depending on the DeID associated to the digit
204+
auto detID = digit.getDetID();
205+
if (modifierST1 && detID >= 100 && detID < 300) {
206+
modifierST1(digit);
207+
}
208+
if (modifierST2 && detID >= 300 && detID < 500) {
209+
modifierST2(digit);
210+
}
211+
};
212+
} else {
213+
// return an empty function if none of the modifiers is set
214+
return {};
215+
}
31216
}
32217

33218
} // namespace o2::mch

0 commit comments

Comments
 (0)