5 #ifndef TRIGT1MUCTPIBITS_HELPERSPHASE1_H
6 #define TRIGT1MUCTPIBITS_HELPERSPHASE1_H
11 #include <string_view>
23 static constexpr std::array<std::string_view,16> DataStatusWordErrors = {
24 "Event number mismatch between MSPA and TRP in the central time slice",
25 "Event number mismatch between MSPC and TRP in the central time slice",
26 "Event number mismatch between MSPA and MSPC in any time slice",
27 "BCID mismatch between TRP and MSPA in the central time slice",
28 "BCID mismatch between TRP and MSPC in the central time slice",
29 "BCID mismatch between MSPA and MSPC in any time slice",
30 "MSPA multiplicity LVDS link CRC error in any time slice",
31 "MSPC multiplicity LVDS link CRC error in any time slice",
32 "Sector logic error flag set on any of the 104 MSPA sectors",
33 "Sector logic error flag set on any of the 104 MSPC sectors",
34 "Error flag set in any of the muon candidates in the event after zero-supression",
35 "CRC error on the MSPA DAQ link (in any time slice)",
36 "CRC error on the MSPC DAQ link (in any time slice)",
37 "TriggerType reception timeout error",
38 "MSPA DAQ link input FIFO full flag (cleared at EOF)",
39 "MSPC DAQ link input FIFO full flag (cleared at EOF)"
45 return ((word >> shift) &
mask);
50 return ((word >> shift) &
mask);
65 if (
wordEquals(word, RUN3_TIMESLICE_MULT_WORD_ID_SHIFT, RUN3_TIMESLICE_MULT_WORD_ID_MASK, RUN3_TIMESLICE_MULT_WORD_ID_VAL)) {
66 if (
wordEquals(word, RUN3_TIMESLICE_MULT_WORD_NUM_SHIFT, RUN3_TIMESLICE_MULT_WORD_NUM_MASK, RUN3_TIMESLICE_WORD_NUM_VAL)) {
70 }
else if (
wordEquals(word, RUN3_CAND_WORD_ID_SHIFT, RUN3_CAND_WORD_ID_MASK, RUN3_CAND_WORD_ID_VAL)) {
72 }
else if (
wordEquals(word, RUN3_TOPO_WORD_ID_SHIFT, RUN3_TOPO_WORD_ID_MASK, RUN3_TOPO_WORD_ID_VAL)) {
74 }
else if (
wordEquals(word, RUN3_STATUS_WORD_ID_SHIFT, RUN3_STATUS_WORD_ID_MASK, RUN3_STATUS_WORD_ID_VAL)) {
87 header.bcid =
maskedWord(word, RUN3_TIMESLICE_BCID_SHIFT, RUN3_TIMESLICE_BCID_MASK);
88 header.tobCount =
maskedWord(word, RUN3_TIMESLICE_NTOB_SHIFT, RUN3_TIMESLICE_NTOB_MASK);
89 header.candCount =
maskedWord(word, RUN3_TIMESLICE_NCAND_SHIFT, RUN3_TIMESLICE_NCAND_MASK);
96 word |=
buildWord(RUN3_TIMESLICE_MULT_WORD_ID_VAL, RUN3_TIMESLICE_MULT_WORD_ID_SHIFT, RUN3_TIMESLICE_MULT_WORD_ID_MASK);
97 word |=
buildWord(RUN3_TIMESLICE_WORD_NUM_VAL, RUN3_TIMESLICE_MULT_WORD_NUM_SHIFT, RUN3_TIMESLICE_MULT_WORD_NUM_MASK);
98 word |=
buildWord(
bcid, RUN3_TIMESLICE_BCID_SHIFT, RUN3_TIMESLICE_BCID_MASK);
99 word |=
buildWord(tobCount, RUN3_TIMESLICE_NTOB_SHIFT, RUN3_TIMESLICE_NTOB_MASK);
100 word |=
buildWord(candCount, RUN3_TIMESLICE_NCAND_SHIFT, RUN3_TIMESLICE_NCAND_MASK);
125 header.pt =
maskedWord(word, RUN3_TOPO_WORD_PT_SHIFT, RUN3_TOPO_WORD_PT_MASK);
126 header.etacode =
maskedWord(word, RUN3_TOPO_WORD_ETA_SHIFT, RUN3_TOPO_WORD_ETA_MASK);
127 header.phicode =
maskedWord(word, RUN3_TOPO_WORD_PHI_SHIFT, RUN3_TOPO_WORD_PHI_MASK);
129 header.hemi =
maskedWord(word, RUN3_TOPO_WORD_HEMI_SHIFT, RUN3_TOPO_WORD_HEMI_MASK);
131 header.det =
maskedWord(word, RUN3_TOPO_WORD_DET_SHIFT, RUN3_TOPO_WORD_DET_MASK);
141 else if (
header.det == 1){
146 else if (
header.det == 2){
155 return maskedWord(word, RUN3_TIMESLICE_MULT_WORD_NUM_SHIFT, RUN3_TIMESLICE_MULT_WORD_NUM_MASK);
160 std::array<uint32_t,3>
words{};
162 words[iWord] |=
buildWord(RUN3_TIMESLICE_MULT_WORD_ID_VAL, RUN3_TIMESLICE_MULT_WORD_ID_SHIFT, RUN3_TIMESLICE_MULT_WORD_ID_MASK);
163 words[iWord] |=
buildWord(iWord+1, RUN3_TIMESLICE_MULT_WORD_NUM_SHIFT, RUN3_TIMESLICE_MULT_WORD_NUM_MASK);
165 words[0] |=
maskedWord(multiplicity, RUN3_MULTIPLICITY_PART1_SHIFT, RUN3_MULTIPLICITY_PART1_MASK);
166 words[1] |=
maskedWord(multiplicity, RUN3_MULTIPLICITY_PART2_SHIFT, RUN3_MULTIPLICITY_PART2_MASK);
167 words[2] |=
maskedWord(multiplicity, RUN3_MULTIPLICITY_PART3_SHIFT, RUN3_MULTIPLICITY_PART3_MASK);
168 words[2] |=
maskedWord(triggerBits, RUN3_MULTIPLICITY_TRIGBITS_SHIFT, RUN3_MULTIPLICITY_TRIGBITS_MASK);
169 words[2] |=
maskedWord(
static_cast<uint32_t>(overflow), RUN3_MULTIPLICITY_OVERFLOW_SHIFT, RUN3_MULTIPLICITY_OVERFLOW_MASK);
175 if (
wordEquals(word, RUN3_SUBSYS_ADDRESS_EC_SHIFT, RUN3_SUBSYS_ADDRESS_EC_MASK, RUN3_SUBSYS_ADDRESS_EC_VAL)) {
177 }
else if (
wordEquals(word, RUN3_SUBSYS_ADDRESS_BAFW_SHIFT, RUN3_SUBSYS_ADDRESS_BAFW_MASK, RUN3_SUBSYS_ADDRESS_FW_VAL)) {
179 }
else if (
wordEquals(word, RUN3_SUBSYS_ADDRESS_BAFW_SHIFT, RUN3_SUBSYS_ADDRESS_BAFW_MASK, RUN3_SUBSYS_ADDRESS_BA_VAL)) {
189 std::vector<size_t>
errors;
190 for (
size_t bit=0; bit<DataStatusWordErrors.size(); ++bit) {
200 uint32_t word =
buildWord(RUN3_STATUS_WORD_ID_VAL, RUN3_STATUS_WORD_ID_SHIFT, RUN3_STATUS_WORD_ID_MASK);
212 std::vector<uint32_t>
cnt = {};
238 errorFlag =
maskedWord(word, RUN3_CAND_WORD_SECTORERRORFLAG_SHIFT, RUN3_CAND_WORD_SECTORERRORFLAG_MASK);
240 side =
maskedWord(word, RUN3_SUBSYS_HEMISPHERE_SHIFT, RUN3_SUBSYS_HEMISPHERE_MASK);
243 pt =
maskedWord(word, RUN3_CAND_WORD_PT_SHIFT, RUN3_CAND_WORD_PT_MASK);
245 roi =
maskedWord(word, RUN3_CAND_WORD_ROI_SHIFT, RUN3_CAND_WORD_ROI_MASK);
248 candFlag_GoodMF =
maskedWord(word, RUN3_CAND_WORD_CANDFLAGS_ECFW_GOODMF_SHIFT, RUN3_CAND_WORD_CANDFLAGS_ECFW_GOODMF_MASK);
250 candFlag_BW23 =
maskedWord(word, RUN3_CAND_WORD_CANDFLAGS_ECFW_BW23_SHIFT, RUN3_CAND_WORD_CANDFLAGS_ECFW_BW23_MASK);
251 candFlag_Charge =
maskedWord(word, RUN3_CAND_WORD_CANDFLAGS_ECFW_CHARGE_SHIFT, RUN3_CAND_WORD_CANDFLAGS_ECFW_CHARGE_MASK);
252 num =
maskedWord(word, RUN3_CAND_SECTORID_SHIFT, ENDCAP_SECTORID_MASK);
260 num =
maskedWord(word, RUN3_CAND_SECTORID_SHIFT, BARREL_SECTORID_MASK);
264 candFlag_GoodMF =
maskedWord(word, RUN3_CAND_WORD_CANDFLAGS_ECFW_GOODMF_SHIFT, RUN3_CAND_WORD_CANDFLAGS_ECFW_GOODMF_MASK);
266 candFlag_BW23 =
maskedWord(word, RUN3_CAND_WORD_CANDFLAGS_ECFW_BW23_SHIFT, RUN3_CAND_WORD_CANDFLAGS_ECFW_BW23_MASK);
267 candFlag_Charge =
maskedWord(word, RUN3_CAND_WORD_CANDFLAGS_ECFW_CHARGE_SHIFT, RUN3_CAND_WORD_CANDFLAGS_ECFW_CHARGE_MASK);
268 num =
maskedWord(word, RUN3_CAND_SECTORID_SHIFT, BARREL_SECTORID_MASK);
274 std::cout <<
"Muon word content (cand): ";
275 std::cout << (
side?
"Side A, ":
"Side C, ");
277 std::cout <<
"BA" <<
num <<
" ";
280 std::cout <<
"Eta = " <<
eta <<
" ";
281 std::cout <<
"Phi = " <<
phi <<
" ";
282 std::cout <<
"pT = " <<
pt <<
" ";
283 std::cout <<
"mappedPt = " <<
mappedPt <<
" ";
295 std::cout <<
" SF: " << std::endl;
303 std::cout <<
" Veto = " << (
vetoFlag?
"1":
"0") <<
" ";
304 std::cout << std::endl;
345 side =
maskedWord(word, RUN3_TOPO_WORD_HEMI_SHIFT, RUN3_TOPO_WORD_HEMI_MASK);
346 det =
maskedWord(word, RUN3_TOPO_WORD_DET_SHIFT, RUN3_TOPO_WORD_DET_MASK);
347 pt =
maskedWord(word, RUN3_TOPO_WORD_PT_SHIFT, RUN3_TOPO_WORD_PT_MASK);
354 candFlag_GoodMF =
maskedWord(word, RUN3_TOPO_WORD_CANDFLAGS_ECFW_GOODMF_SHIFT, RUN3_TOPO_WORD_CANDFLAGS_ECFW_GOODMF_MASK);
356 candFlag_BW23 =
maskedWord(word, RUN3_TOPO_WORD_CANDFLAGS_ECFW_BW23_SHIFT, RUN3_TOPO_WORD_CANDFLAGS_ECFW_BW23_MASK);
357 candFlag_Charge =
maskedWord(word, RUN3_TOPO_WORD_CANDFLAGS_ECFW_CHARGE_SHIFT, RUN3_TOPO_WORD_CANDFLAGS_ECFW_CHARGE_MASK);
358 etaRaw =
maskedWord(word, RUN3_TOPO_WORD_ETA_SHIFT, RUN3_TOPO_WORD_ETA_MASK);
359 phiRaw =
maskedWord(word, RUN3_TOPO_WORD_PHI_SHIFT, RUN3_TOPO_WORD_PHI_MASK);
364 std::cout <<
"Muon word content (TOB) : ";
365 std::cout << (
side?
"Side A, ":
"Side C, ");
367 std::cout <<
"BA" <<
sec <<
" ";
369 std::cout << (
det==1?
"FW":
"EC") <<
sec <<
" ";
372 std::cout <<
"pT = " <<
pt << std::endl;
374 if(
det == 1 ||
det == 2) {
380 std::cout << std::endl;
387 std::vector<Candidate>
cand = {};
388 std::vector<TopoTOB>
tob = {};
393 #endif // TRIGT1MUCTPIBITS_HELPERSPHASE1_H