Skip to content

Commit c073298

Browse files
committed
added orbit consistency check with timestamp
1 parent 5f80cab commit c073298

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

src/DataBlock.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ struct DataBlockHeader {
6262
uint32_t timeframeOrbitLast; ///< from timeframe
6363
uint8_t flagEndOfTimeframe; ///< flag to signal this is the last TF block
6464
uint8_t isRdhFormat; ///< flag set when payload is RDH-formatted
65+
uint32_t orbitFirstInBlock; ///< the first orbit in this block
6566
uint32_t orbitOffset; ///< set when RDH orbits should be added given offset to match TFid
6667
uint32_t memorySize; ///< size in memory of current block
6768

@@ -70,10 +71,10 @@ struct DataBlockHeader {
7071

7172
// Version of this header
7273
// with DB marker for DataBlock start, 1st byte in header little-endian
73-
const uint32_t DataBlockVersion = 0x0004DBDB;
74+
const uint32_t DataBlockVersion = 0x0005DBDB;
7475

7576
// DataBlockHeader instance with all default fields
76-
const DataBlockHeader defaultDataBlockHeader = { .headerVersion = DataBlockVersion, .headerSize = sizeof(DataBlockHeader), .dataSize = 0, .blockId = undefinedBlockId, .pipelineId = undefinedBlockId, .timeframeId = undefinedTimeframeId, .runNumber = undefinedRunNumber, .systemId = undefinedSystemId, .feeId = undefinedFeeId, .equipmentId = undefinedEquipmentId, .linkId = undefinedLinkId, .timeframeOrbitFirst = undefinedOrbit, .timeframeOrbitLast = undefinedOrbit, .flagEndOfTimeframe = 0, .isRdhFormat = 1, .orbitOffset = undefinedOrbit, .memorySize = 0, .userSpace = { 0 } };
77+
const DataBlockHeader defaultDataBlockHeader = { .headerVersion = DataBlockVersion, .headerSize = sizeof(DataBlockHeader), .dataSize = 0, .blockId = undefinedBlockId, .pipelineId = undefinedBlockId, .timeframeId = undefinedTimeframeId, .runNumber = undefinedRunNumber, .systemId = undefinedSystemId, .feeId = undefinedFeeId, .equipmentId = undefinedEquipmentId, .linkId = undefinedLinkId, .timeframeOrbitFirst = undefinedOrbit, .timeframeOrbitLast = undefinedOrbit, .flagEndOfTimeframe = 0, .isRdhFormat = 1, .orbitFirstInBlock = undefinedOrbit, .orbitOffset = undefinedOrbit, .memorySize = 0, .userSpace = { 0 } };
7778

7879
// DataBlock
7980
// Pair of header + payload data

src/ReadoutEquipment.cxx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -487,12 +487,20 @@ Thread::CallbackResult ReadoutEquipment::threadCallback(void* arg)
487487
}
488488

489489
static InfoLogger::AutoMuteToken logTFdiscontinuityToken(LogWarningSupport_(3004), 10, 60);
490+
static InfoLogger::AutoMuteToken logTFdiscontinuityTokenError(LogErrorSupport_(3004), 10, 60);
490491

491492
ptr->statsNumberOfTimeframes++;
492493
// detect gaps in TF id continuity
493494
if (tfId != ptr->lastTimeframe + 1) {
494495
if (ptr->cfgRdhDumpWarningEnabled) {
495496
theLog.log(logTFdiscontinuityToken, "Non-contiguous timeframe IDs %llu ... %llu", (unsigned long long)ptr->lastTimeframe, (unsigned long long)tfId);
497+
// check if difference is large and orbit consistant with timestamp
498+
double now = ptr->firstTimeframeTimestamp.getTime();
499+
double dt = (nextBlock->getData()->header.orbitFirstInBlock - ptr->firstTimeframeHbOrbitBegin) * 1.0 / ptr->LHCOrbitRate; // diff in orbit / orbit rate = should be close to current timestamp
500+
uint32_t expected = ptr->firstTimeframeHbOrbitBegin + (uint32_t)(now * ptr->LHCOrbitRate);
501+
if (fabs(dt - now) > 10) {
502+
theLog.log(logTFdiscontinuityTokenError, "Orbit 0x%X seems inconsistent from expected ~0x%X (orbit rate %u, elapsed time %.1fs)", (int)nextBlock->getData()->header.orbitFirstInBlock, expected, ptr->LHCOrbitRate, now);
503+
}
496504
}
497505
}
498506
ptr->lastTimeframe = tfId;
@@ -640,6 +648,7 @@ uint64_t ReadoutEquipment::getTimeframeFromOrbit(uint32_t hbOrbit)
640648
{
641649
if (!isDefinedFirstTimeframeHbOrbitBegin) {
642650
firstTimeframeHbOrbitBegin = hbOrbit;
651+
firstTimeframeTimestamp.reset();
643652
isDefinedFirstTimeframeHbOrbitBegin = 1;
644653
bool isOk = true;
645654
gReadoutStats.mutex.lock();
@@ -730,6 +739,7 @@ int ReadoutEquipment::tagDatablockFromRdh(RdhHandle& h, DataBlockHeader& bh)
730739
}
731740
}
732741
getTimeframeOrbitRange(tfId, bh.timeframeOrbitFirst, bh.timeframeOrbitLast);
742+
bh.orbitFirstInBlock = hbOrbit;
733743
bh.timeframeOrbitFirst -= bh.orbitOffset;
734744
bh.timeframeOrbitLast -= bh.orbitOffset;
735745
// printf("TF %d eq %d link %d : orbits %X - %X\n", (int)bh.timeframeId, (int)bh.equipmentId, (int)bh.linkId, (int)bh.timeframeOrbitFirst, (int)bh.timeframeOrbitLast);

src/ReadoutEquipment.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ class ReadoutEquipment
156156
unsigned long long statsNumberOfTimeframes = 0; // number of timeframes read out
157157
uint32_t firstTimeframeHbOrbitBegin = 0; // HbOrbit of beginning of first timeframe
158158
bool isDefinedFirstTimeframeHbOrbitBegin = 0;
159+
AliceO2::Common::Timer firstTimeframeTimestamp; // timestamp of first timeframe/orbit received, for consistency checks
159160

160161
AliceO2::Common::Timer timeframeClock; // timeframe id should be increased at each clock cycle
161162
uint64_t currentTimeframe = 0; // id of current timeframe

0 commit comments

Comments
 (0)