Skip to content

Commit 761f62e

Browse files
authored
[FOCAL-8] Accept payload also on trigger pages (#1766)
- Check for payload on each page, before evaluation of trigger and stop bit - Allow end of HBF to contain payload (memory size > header size) Needed as pixels might send an additional diagnositc word on the last page.
1 parent 97524cf commit 761f62e

1 file changed

Lines changed: 48 additions & 47 deletions

File tree

Modules/FOCAL/src/TestbeamRawTask.cxx

Lines changed: 48 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -372,63 +372,64 @@ void TestbeamRawTask::monitorData(o2::framework::ProcessingContext& ctx)
372372
ILOG(Debug, Support) << "Channel " << header->dataOrigin.str << "/" << header->dataDescription.str << "/" << header->subSpecification << ENDM;
373373

374374
gsl::span<const char> databuffer(rawData.payload, payloadSize);
375+
ILOG(Debug, Support) << "Payload buffer has size " << databuffer.size() << ENDM;
375376
int currentpos = 0;
376377
while (currentpos < databuffer.size()) {
377378
auto rdh = reinterpret_cast<const o2::header::RDHAny*>(databuffer.data() + currentpos);
378379
if (mDebugMode) {
379380
o2::raw::RDHUtils::printRDH(rdh);
380381
}
381-
if (o2::raw::RDHUtils::getMemorySize(rdh) == o2::raw::RDHUtils::getHeaderSize(rdh)) {
382-
auto trigger = o2::raw::RDHUtils::getTriggerType(rdh);
383-
if (trigger & o2::trigger::SOT || trigger & o2::trigger::HB) {
384-
if (o2::raw::RDHUtils::getStop(rdh)) {
385-
ILOG(Debug, Support) << "Stop bit received - processing payload" << ENDM;
386-
// Data ready
387-
if (currentfee == 0xcafe) { // Use FEE ID 0xcafe for PAD data
388-
// Pad data
389-
if (!mDisablePads) {
390-
ILOG(Debug, Support) << "Processing PAD data" << ENDM;
391-
auto payloadsizeGBT = rawbuffer.size() * sizeof(char) / sizeof(o2::focal::PadGBTWord);
392-
processPadPayload(gsl::span<const o2::focal::PadGBTWord>(reinterpret_cast<const o2::focal::PadGBTWord*>(rawbuffer.data()), payloadsizeGBT));
393-
}
394-
} else { // All other FEEs are pixel FEEs
395-
// Pixel data
396-
if (!mDisablePixels) {
397-
auto feeID = o2::raw::RDHUtils::getFEEID(rdh);
398-
ILOG(Debug, Support) << "Processing Pixel data from FEE " << feeID << ENDM;
399-
auto payloadsizeGBT = rawbuffer.size() * sizeof(char) / sizeof(o2::itsmft::GBTWord);
400-
processPixelPayload(gsl::span<const o2::itsmft::GBTWord>(reinterpret_cast<const o2::itsmft::GBTWord*>(rawbuffer.data()), payloadsizeGBT), feeID);
401-
}
382+
383+
if (o2::raw::RDHUtils::getMemorySize(rdh) > o2::raw::RDHUtils::getHeaderSize(rdh)) {
384+
// non-0 payload size:
385+
auto payloadsize = o2::raw::RDHUtils::getMemorySize(rdh) - o2::raw::RDHUtils::getHeaderSize(rdh);
386+
auto fee = static_cast<int>(o2::raw::RDHUtils::getFEEID(rdh));
387+
ILOG(Debug, Support) << "Next RDH: " << ENDM;
388+
stringstream ss;
389+
ss << "Found fee 0x" << std::hex << fee << std::dec << " (System " << (fee == 0xcafe ? "Pads" : "Pixels") << ")";
390+
ILOG(Debug, Support) << ss.str() << ENDM;
391+
ILOG(Debug, Support) << "Found trigger BC: " << o2::raw::RDHUtils::getTriggerBC(rdh) << ENDM;
392+
ILOG(Debug, Support) << "Found trigger Oribt: " << o2::raw::RDHUtils::getTriggerOrbit(rdh) << ENDM;
393+
ILOG(Debug, Support) << "Found payload size: " << payloadsize << ENDM;
394+
ILOG(Debug, Support) << "Found offset to next: " << o2::raw::RDHUtils::getOffsetToNext(rdh) << ENDM;
395+
ILOG(Debug, Support) << "Stop bit: " << (o2::raw::RDHUtils::getStop(rdh) ? "yes" : "no") << ENDM;
396+
ILOG(Debug, Support) << "Number of GBT words: " << (payloadsize * sizeof(char) / (fee == 0xcafe ? sizeof(o2::focal::PadGBTWord) : sizeof(o2::itsmft::GBTWord))) << ENDM;
397+
auto page_payload = databuffer.subspan(currentpos + o2::raw::RDHUtils::getHeaderSize(rdh), payloadsize);
398+
std::copy(page_payload.begin(), page_payload.end(), std::back_inserter(rawbuffer));
399+
}
400+
401+
auto trigger = o2::raw::RDHUtils::getTriggerType(rdh);
402+
if (trigger & o2::trigger::SOT || trigger & o2::trigger::HB) {
403+
if (o2::raw::RDHUtils::getStop(rdh)) {
404+
ILOG(Debug, Support) << "Stop bit received - processing payload" << ENDM;
405+
// Data ready
406+
if (currentfee == 0xcafe) { // Use FEE ID 0xcafe for PAD data
407+
// Pad data
408+
if (!mDisablePads) {
409+
ILOG(Debug, Support) << "Processing PAD data" << ENDM;
410+
auto payloadsizeGBT = rawbuffer.size() * sizeof(char) / sizeof(o2::focal::PadGBTWord);
411+
ILOG(Debug) << "Found pixel payload of size " << rawbuffer.size() << " (" << payloadsizeGBT << " GBT words)" << ENDM;
412+
processPadPayload(gsl::span<const o2::focal::PadGBTWord>(reinterpret_cast<const o2::focal::PadGBTWord*>(rawbuffer.data()), payloadsizeGBT));
413+
}
414+
} else { // All other FEEs are pixel FEEs
415+
// Pixel data
416+
if (!mDisablePixels) {
417+
auto feeID = o2::raw::RDHUtils::getFEEID(rdh);
418+
ILOG(Debug, Support) << "Processing Pixel data from FEE " << feeID << ENDM;
419+
auto payloadsizeGBT = rawbuffer.size() * sizeof(char) / sizeof(o2::itsmft::GBTWord);
420+
ILOG(Debug, Support) << "Found pixel payload of size " << rawbuffer.size() << " (" << payloadsizeGBT << " GBT words)" << ENDM;
421+
processPixelPayload(gsl::span<const o2::itsmft::GBTWord>(reinterpret_cast<const o2::itsmft::GBTWord*>(rawbuffer.data()), payloadsizeGBT), feeID);
402422
}
403-
rawbuffer.clear();
404-
} else {
405-
ILOG(Debug, Support) << "New HBF or Timeframe" << ENDM;
406-
currentfee = o2::raw::RDHUtils::getFEEID(rdh);
407-
stringstream ss;
408-
ss << "Using FEE ID: 0x" << std::hex << currentfee << std::dec;
409-
ILOG(Debug, Support) << ss.str() << ENDM;
410-
rawbuffer.clear();
411423
}
424+
rawbuffer.clear();
425+
} else {
426+
ILOG(Debug, Support) << "New HBF or Timeframe" << ENDM;
427+
currentfee = o2::raw::RDHUtils::getFEEID(rdh);
428+
stringstream ss;
429+
ss << "Using FEE ID: 0x" << std::hex << currentfee << std::dec;
430+
ILOG(Debug, Support) << ss.str() << ENDM;
412431
}
413-
currentpos += o2::raw::RDHUtils::getOffsetToNext(rdh);
414-
continue;
415432
}
416-
417-
// non-0 payload size:
418-
auto payloadsize = o2::raw::RDHUtils::getMemorySize(rdh) - o2::raw::RDHUtils::getHeaderSize(rdh);
419-
auto fee = static_cast<int>(o2::raw::RDHUtils::getFEEID(rdh));
420-
ILOG(Debug, Support) << "Next RDH: " << ENDM;
421-
stringstream ss;
422-
ss << "Found fee 0x" << std::hex << fee << std::dec << " (System " << (fee == 0xcafe ? "Pads" : "Pixels") << ")";
423-
ILOG(Debug, Support) << ss.str() << ENDM;
424-
ILOG(Debug, Support) << "Found trigger BC: " << o2::raw::RDHUtils::getTriggerBC(rdh) << ENDM;
425-
ILOG(Debug, Support) << "Found trigger Oribt: " << o2::raw::RDHUtils::getTriggerOrbit(rdh) << ENDM;
426-
ILOG(Debug, Support) << "Found payload size: " << payloadsize << ENDM;
427-
ILOG(Debug, Support) << "Found offset to next: " << o2::raw::RDHUtils::getOffsetToNext(rdh) << ENDM;
428-
ILOG(Debug, Support) << "Stop bit: " << (o2::raw::RDHUtils::getStop(rdh) ? "yes" : "no") << ENDM;
429-
ILOG(Debug, Support) << "Number of GBT words: " << (payloadsize * sizeof(char) / (fee == 0xcafe ? sizeof(o2::focal::PadGBTWord) : sizeof(o2::itsmft::GBTWord))) << ENDM;
430-
auto page_payload = databuffer.subspan(currentpos + o2::raw::RDHUtils::getHeaderSize(rdh), payloadsize);
431-
std::copy(page_payload.begin(), page_payload.end(), std::back_inserter(rawbuffer));
432433
currentpos += o2::raw::RDHUtils::getOffsetToNext(rdh);
433434
}
434435
} else {

0 commit comments

Comments
 (0)