Skip to content

Commit de3d43e

Browse files
committed
TPC: handle exceptions in calib_processing_helper::processRawData
RawParser used by processRawData throws on corrupted TPC raw data, eventually killing workflows on all EPNs. This PR catches those exceptions, logs an error and skips the FMQ part, i.e. 1 HBF for single link with current packaging. If an optional pointer on the counter is provided, it will be incremented for each throw.
1 parent c0333a9 commit de3d43e

2 files changed

Lines changed: 40 additions & 29 deletions

File tree

Detectors/TPC/workflow/include/TPCWorkflow/CalibProcessingHelper.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class RawReaderCRU;
2929
namespace calib_processing_helper
3030
{
3131

32-
uint64_t processRawData(o2::framework::InputRecord& inputs, std::unique_ptr<RawReaderCRU>& reader, bool useOldSubspec = false, const std::vector<int>& sectors = {});
32+
uint64_t processRawData(o2::framework::InputRecord& inputs, std::unique_ptr<RawReaderCRU>& reader, bool useOldSubspec = false, const std::vector<int>& sectors = {}, size_t* nerrors = nullptr);
3333
} // namespace calib_processing_helper
3434
} // namespace tpc
3535
} // namespace o2

Detectors/TPC/workflow/src/CalibProcessingHelper.cxx

Lines changed: 39 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ void processGBT(o2::framework::RawParser<>& parser, std::unique_ptr<RawReaderCRU
3434
void processLinkZS(o2::framework::RawParser<>& parser, std::unique_ptr<RawReaderCRU>& reader, uint32_t firstOrbit, uint32_t syncOffsetReference);
3535
uint32_t getBCsyncOffsetReference(InputRecord& inputs, const std::vector<InputSpec>& filter);
3636

37-
uint64_t calib_processing_helper::processRawData(o2::framework::InputRecord& inputs, std::unique_ptr<RawReaderCRU>& reader, bool useOldSubspec, const std::vector<int>& sectors)
37+
uint64_t calib_processing_helper::processRawData(o2::framework::InputRecord& inputs, std::unique_ptr<RawReaderCRU>& reader, bool useOldSubspec, const std::vector<int>& sectors, size_t* nerrors)
3838
{
3939
std::vector<InputSpec> filter = {{"check", ConcreteDataTypeMatcher{o2::header::gDataOriginTPC, "RAWDATA"}, Lifetime::Timeframe}};
40-
40+
size_t errorCount = 0;
4141
// TODO: check if presence of data sampling can be checked in another way
4242
bool sampledData = true;
4343
for ([[maybe_unused]] auto const& ref : InputRecordWalker(inputs, filter)) {
@@ -98,44 +98,55 @@ uint64_t calib_processing_helper::processRawData(o2::framework::InputRecord& inp
9898
rdh_utils::FEEIDType cruID, linkID, endPoint;
9999
rdh_utils::getMapping(feeID, cruID, endPoint, linkID);
100100
const auto globalLinkID = linkID + endPoint * 12;
101-
LOGP(debug, "Specifier: {}/{}/{}", dh->dataOrigin, dh->dataDescription, subSpecification);
101+
LOGP(debug, "Specifier: {}/{}/{} Part {} of {}", dh->dataOrigin, dh->dataDescription, subSpecification, dh->splitPayloadIndex, dh->splitPayloadParts);
102102
LOGP(debug, "Payload size: {}", dh->payloadSize);
103103
LOGP(debug, "CRU: {}; linkID: {}; endPoint: {}; globalLinkID: {}", cruID, linkID, endPoint, globalLinkID);
104104
// ^^^^^^
105105

106106
// TODO: exception handling needed?
107107
const gsl::span<const char> raw = inputs.get<gsl::span<char>>(ref);
108-
o2::framework::RawParser parser(raw.data(), raw.size());
109-
110-
// detect decoder type by analysing first RDH
111-
if (!readFirst) {
112-
auto it = parser.begin();
113-
auto* rdhPtr = it.get_if<o2::header::RAWDataHeaderV6>();
114-
if (!rdhPtr) {
115-
LOGP(fatal, "could not get RDH from packet");
116-
}
117-
const auto link = RDHUtils::getLinkID(*rdhPtr);
118-
const auto detField = RDHUtils::getDetectorField(*rdhPtr);
119-
if ((link == rdh_utils::UserLogicLinkID) || (detField == 1)) {
120-
LOGP(info, "Detected Link-based zero suppression");
121-
isLinkZS = true;
122-
if (!reader->getManager() || !reader->getManager()->getLinkZSCallback()) {
123-
LOGP(fatal, "LinkZSCallback must be set in RawReaderCRUManager");
108+
std::unique_ptr<o2::framework::RawParser<8192>> rawparserPtr;
109+
try {
110+
111+
o2::framework::RawParser parser(raw.data(), raw.size());
112+
// detect decoder type by analysing first RDH
113+
if (!readFirst) {
114+
auto it = parser.begin();
115+
auto* rdhPtr = it.get_if<o2::header::RAWDataHeaderV6>();
116+
if (!rdhPtr) {
117+
LOGP(fatal, "could not get RDH from packet");
118+
}
119+
const auto link = RDHUtils::getLinkID(*rdhPtr);
120+
const auto detField = RDHUtils::getDetectorField(*rdhPtr);
121+
if ((link == rdh_utils::UserLogicLinkID) || (detField == 1)) {
122+
LOGP(info, "Detected Link-based zero suppression");
123+
isLinkZS = true;
124+
if (!reader->getManager() || !reader->getManager()->getLinkZSCallback()) {
125+
LOGP(fatal, "LinkZSCallback must be set in RawReaderCRUManager");
126+
}
124127
}
128+
129+
//firstOrbit = RDHUtils::getHeartBeatOrbit(*rdhPtr);
130+
LOGP(info, "First orbit in present TF: {}", firstOrbit);
131+
readFirst = true;
125132
}
126133

127-
//firstOrbit = RDHUtils::getHeartBeatOrbit(*rdhPtr);
128-
LOGP(info, "First orbit in present TF: {}", firstOrbit);
129-
readFirst = true;
130-
}
134+
if (isLinkZS) {
135+
processLinkZS(parser, reader, firstOrbit, syncOffsetReference);
136+
} else {
137+
processGBT(parser, reader, feeID);
138+
}
131139

132-
if (isLinkZS) {
133-
processLinkZS(parser, reader, firstOrbit, syncOffsetReference);
134-
} else {
135-
processGBT(parser, reader, feeID);
140+
} catch (const std::exception& e) {
141+
LOGP(ERROR, "EXCEPTIION in processRawData: {} -> skipping part:{}/{} of spec:{}/{}/{}, size:{}", e.what(), dh->splitPayloadIndex, dh->splitPayloadParts,
142+
dh->dataOrigin, dh->dataDescription, subSpecification, dh->payloadSize);
143+
errorCount++;
144+
continue;
136145
}
137146
}
138-
147+
if (nerrors) {
148+
*nerrors += errorCount;
149+
}
139150
return activeSectors;
140151
}
141152

0 commit comments

Comments
 (0)