forked from AliceO2Group/AliceO2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRUDecodeData.cxx
More file actions
144 lines (133 loc) · 5.49 KB
/
RUDecodeData.cxx
File metadata and controls
144 lines (133 loc) · 5.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
// All rights not expressly granted are reserved.
//
// This software is distributed under the terms of the GNU General Public
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
//
// In applying this license CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.
/// \file RUDecodeData.cxx
/// \brief Definition of the Readout Unite decoder class
///======================================================================
/// REDOUT UNIT data decoding class
///======================================================================
#include "Framework/Logger.h"
#include "ITSMFTReconstruction/GBTWord.h"
#include "ITSMFTReconstruction/GBTLink.h"
#include "ITSMFTReconstruction/DecodingStat.h"
#include "ITSMFTReconstruction/RUDecodeData.h"
namespace o2
{
namespace itsmft
{
///_________________________________________________________________
/// reset RU and its links
void RUDecodeData::clear()
{
for (int i = ruInfo->nCables; i--;) {
if (cableLinkPtr[i] && !cableLinkPtr[i]->rofJumpWasSeen) {
cableData[i].clear();
}
}
nChipsFired = 0;
nNonEmptyLinks = 0;
calibData.clear();
}
///_________________________________________________________________
/// attach ROF-related info to fired chip. This method has to be in the cxx to avoid explicit
/// dependence of the RUDecodData on GBTLink class
void RUDecodeData::setROFInfo(ChipPixelData* chipData, const GBTLink* lnk)
{
chipData->setTrigger(lnk->trigger);
chipData->setInteractionRecord(lnk->ir);
}
///_________________________________________________________________
/// fill chip decoding statistics
void RUDecodeData::fillChipStatistics(int icab, const ChipPixelData* chipData)
{
cableLinkPtr[icab]->chipStat.nHits += chipData->getData().size();
uint32_t action = 0;
if (chipData->getErrorFlags()) {
action = cableLinkPtr[icab]->chipStat.addErrors(*chipData, verbosity);
auto compid = ChipError::composeID(cableLinkPtr[icab]->feeID, chipData->getChipID());
auto& chErr = chipErrorsTF[compid];
chErr.first++;
chErr.second |= chipData->getErrorFlags();
if (chipData->isErrorSet(ChipStat::RepeatingPixel)) {
auto& errMsg = errMsgVecTF.emplace_back();
errMsg.id = chipData->getChipID();
errMsg.errType = ChipStat::RepeatingPixel;
errMsg.errInfo0 = chipData->getErrorInfo() & 0xffff; // row
errMsg.errInfo1 = (chipData->getErrorInfo() >> 16) & 0xffff; // row
}
}
if (action & ChipStat::ErrActDump) {
linkHBFToDump[(uint64_t(cableLinkPtr[icab]->subSpec) << 32) + cableLinkPtr[icab]->hbfEntry] = cableLinkPtr[icab]->irHBF.orbit;
}
}
///_________________________________________________________________
/// dump cable data for debugging
void RUDecodeData::dumpcabledata(int icab)
{
const auto* cdat = cableData[icab].data();
size_t cdats = cableData[icab].getUnusedSize(), cdi = 0;
const auto lll = cableLinkPtr[icab];
LOGP(info, "RU#{} Cab{} Nbytes: {} IR: {} | {}", ruSWID, icab, cdats, lll->ir.asString(), lll->describe());
std::string dmp = "";
while (cdi < cdats) {
dmp += fmt::format(" {:#04x}", cdat[cdi++]);
if (cdi && (cdi % 9) == 0) {
LOGP(info, "wrd#{}: {}", cdi / 9 - 1, dmp);
dmp = "";
}
}
if (!dmp.empty()) {
LOGP(info, "wrd#{}: {}", cdi / 9 - 1, dmp);
}
}
///_________________________________________________________________
/// check if the link data is in sync with majority
bool RUDecodeData::checkLinkInSync(int icab, const o2::InteractionRecord ir)
{
auto* link = cableLinkPtr[icab];
if (link->ir == ir) {
link->rofJumpWasSeen = false;
return true;
}
if (link->statusInTF == GBTLink::CollectedDataStatus::None || link->statusInTF == GBTLink::CollectedDataStatus::StoppedOnEndOfData) { // link was not seen in this TF or data was over
return true;
}
// apparently there was desynchronization
if (link->ir > ir) {
link->rofJumpWasSeen = true;
#ifdef _RAW_READER_ERROR_CHECKS_
link->statistics.errorCounts[GBTLinkDecodingStat::ErrMissingROF]++;
linkHBFToDump[(uint64_t(link->subSpec) << 32) + link->hbfEntry] = link->irHBF.orbit;
if (link->needToPrintError(link->statistics.errorCounts[GBTLinkDecodingStat::ErrMissingROF])) {
LOGP(info, "{} (cable {}) has IR={} > current majority IR={} -> {}", link->describe(),
cableHWID[icab], link->ir.asString(), ir.asString(), link->statistics.ErrNames[GBTLinkDecodingStat::ErrMissingROF]);
}
#endif
} else { // link IR is behind the majority IR? In principle, this should never happen
#ifdef _RAW_READER_ERROR_CHECKS_
link->statistics.errorCounts[GBTLinkDecodingStat::ErrOldROF]++;
linkHBFToDump[(uint64_t(link->subSpec) << 32) + link->hbfEntry] = link->irHBF.orbit;
if (link->needToPrintError(link->statistics.errorCounts[GBTLinkDecodingStat::ErrOldROF]) && !ROFRampUpStage) {
LOGP(critical, "{} (cable {}) has IR={} for current majority IR={} -> {}", link->describe(),
cableHWID[icab], link->ir.asString(), ir.asString(), link->statistics.ErrNames[GBTLinkDecodingStat::ErrOldROF]);
}
#endif
// clean data of cables of this link
for (int i = 0; i < ruInfo->nCables; i++) {
if (cableLinkPtr[i] == link) {
cableData[i].clear();
}
}
link->rofJumpWasSeen = false;
}
return false;
}
} // namespace itsmft
} // namespace o2