From 9d1d753e3f0133f0d0a0826d90654eed165a1d1d Mon Sep 17 00:00:00 2001 From: David Schledt <schledt@iri.uni-frankfurt.de> Date: Wed, 29 Jun 2022 14:54:19 +0000 Subject: [PATCH] Fix for overflow counting issue in trd1d timing --- reco/detectors/trd/unpack/CbmTrdUnpackAlgoR.cxx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/reco/detectors/trd/unpack/CbmTrdUnpackAlgoR.cxx b/reco/detectors/trd/unpack/CbmTrdUnpackAlgoR.cxx index 6ef532fba2..9292be3990 100644 --- a/reco/detectors/trd/unpack/CbmTrdUnpackAlgoR.cxx +++ b/reco/detectors/trd/unpack/CbmTrdUnpackAlgoR.cxx @@ -246,6 +246,8 @@ Spadic::MsMessageType CbmTrdUnpackAlgoR::getMessageType(const std::uint32_t fram // ---- getTsMsb ---- std::uint8_t CbmTrdUnpackAlgoR::getTsMsb(const std::uint32_t frame) { + if ((frame & 0xf) > 0) + return -2; // if a 'error' ts_msb is received the tsmsb value is not correct. To not mess up the counting -2 is returned. // The epoch in form of the TS_MSBs is written 3 times into the frame to allow to check for bit flips and catch errors. It has the length of 6 bits and an offset of 4 std::uint8_t tsmsb[3]; for (uint iepoch = 0; iepoch < 3; ++iepoch) { @@ -381,7 +383,7 @@ bool CbmTrdUnpackAlgoR::unpack(const fles::Timeslice* ts, std::uint16_t icomp, U switch (kWordtype) { case Spadic::MsMessageType::kEPO: { auto tsmsb = getTsMsb(frame); - if (tsmsb > currTsMsb) fNrTsMsbVec.at(istream)++; + if (((tsmsb - currTsMsb) & 0x3f) == 1 || currTsMsb == -1) fNrTsMsbVec.at(istream)++; currTsMsb = tsmsb; fNrEpochMsgs++; break; -- GitLab