From ab0f53f55ce0876d3b83d0880440a2d7559e6288 Mon Sep 17 00:00:00 2001 From: Pascal Raisig <praisig@ikf.uni-frankfurt.de> Date: Tue, 30 Nov 2021 10:52:09 +0100 Subject: [PATCH] Fix TRD digi time resolution of real data. Due to some missed casting to double values, the UTC time stored in the CbmTrdRawMessageSpadic lost precision. Now we also only store the time relative to the Timeslice in the 2021+ unpacker, such that a double is large enough to store the full information. --- core/data/trd/CbmTrdRawMessageSpadic.cxx | 3 ++- core/data/trd/CbmTrdRawMessageSpadic.h | 10 +++++----- reco/detectors/trd/unpack/CbmTrdUnpackAlgoR.cxx | 13 +++++++------ 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/core/data/trd/CbmTrdRawMessageSpadic.cxx b/core/data/trd/CbmTrdRawMessageSpadic.cxx index dfe783ee6c..66bf8e03b5 100644 --- a/core/data/trd/CbmTrdRawMessageSpadic.cxx +++ b/core/data/trd/CbmTrdRawMessageSpadic.cxx @@ -7,6 +7,7 @@ #include <Logger.h> // for LOG #include <algorithm> // for max_element +#include <cstdint> #include <stdexcept> // for range_error // ------- Default Constructor ---------------- @@ -26,7 +27,7 @@ CbmTrdRawMessageSpadic::CbmTrdRawMessageSpadic() // ------- Constructor ---------------- CbmTrdRawMessageSpadic::CbmTrdRawMessageSpadic(std::uint8_t channelId, std::uint8_t elinkId, std::uint8_t crobId, std::uint16_t criId, std::uint8_t hitType, std::uint8_t nrSamples, - bool multiHit, size_t fullTime, std::vector<std::int16_t> samples) + bool multiHit, std::uint64_t fullTime, std::vector<std::int16_t> samples) : fChannelID {channelId} , fElinkID {elinkId} , fCrobId(crobId) diff --git a/core/data/trd/CbmTrdRawMessageSpadic.h b/core/data/trd/CbmTrdRawMessageSpadic.h index 4ff1080b96..63be72efb1 100644 --- a/core/data/trd/CbmTrdRawMessageSpadic.h +++ b/core/data/trd/CbmTrdRawMessageSpadic.h @@ -84,7 +84,7 @@ private: std::uint8_t fHitType; std::uint8_t fNrSamples; bool fMultiHit; - size_t fFullTime; /**< Fulltime in units of Clockcycles. */ + std::uint64_t fFullTime; /**< Fulltime in units of Clockcycles. */ std::vector<std::int16_t> fSamples; /**< Holds up to 32 Samples from a Spadic Message. Valid values [-256,255] */ public: @@ -93,7 +93,7 @@ public: /** Constructor **/ CbmTrdRawMessageSpadic(std::uint8_t channelId, std::uint8_t elinkId, std::uint8_t crobId, std::uint16_t criId, - std::uint8_t hitType, std::uint8_t nrSamples, bool multiHi, size_t fullTime, + std::uint8_t hitType, std::uint8_t nrSamples, bool multiHi, std::uint64_t fullTime, std::vector<std::int16_t> samples); /** Copy Constructor **/ @@ -116,17 +116,17 @@ public: std::uint8_t GetHitType() const { return fHitType; } std::uint8_t GetNrSamples() const { return fNrSamples; } bool GetMultiHit() const { return fMultiHit; } - size_t GetFullTime() const { return fFullTime; } + std::uint64_t GetFullTime() const { return fFullTime; } const std::vector<std::int16_t>* GetSamples() const { return &fSamples; } /** Returns the full time in nanoseconds */ - Double_t GetTime() const { return fFullTime * 62.5; } + double GetTime() const { return (fFullTime * 62.5); } /** @brief increase the number of samples stored in this raw message by one */ void IncNrSamples() { fNrSamples++; } /** Set the full time in nanoseconds */ - void SetTime(Double_t setvalue) { fFullTime = (size_t)(setvalue / 62.5); } + void SetTime(Double_t setvalue) { fFullTime = static_cast<std::uint64_t>(setvalue / 62.5); } /** Returns the value of the sample with the highest value. */ int16_t GetMaxAdc(); diff --git a/reco/detectors/trd/unpack/CbmTrdUnpackAlgoR.cxx b/reco/detectors/trd/unpack/CbmTrdUnpackAlgoR.cxx index f34896075e..542470c67f 100644 --- a/reco/detectors/trd/unpack/CbmTrdUnpackAlgoR.cxx +++ b/reco/detectors/trd/unpack/CbmTrdUnpackAlgoR.cxx @@ -7,6 +7,7 @@ #include "CbmTrdParManager.h" #include "CbmTrdParSetAsic.h" #include "CbmTrdRawMessageSpadic.h" +#include "CbmTrdSpadic.h" #include <FairTask.h> #include <Logger.h> @@ -289,10 +290,8 @@ void CbmTrdUnpackAlgoR::makeDigi(CbmTrdRawMessageSpadic raw) // Get the time information and apply the necessary correction ULong64_t time = raw.GetTime(); - time -= fSystemTimeOffset; - // Set the time relative to the TS start - time -= fTsStartTime; + time -= fSystemTimeOffset; auto digi = fRTDMethod->MakeDigi(raw.GetSamples(), padChNr, uniqueModuleId, time, triggerType, errClass); @@ -309,15 +308,17 @@ CbmTrdRawMessageSpadic CbmTrdUnpackAlgoR::makeRaw(const std::uint32_t frame, std { auto chId = static_cast<std::uint8_t>(((frame >> 17) & 0xf)); - auto timestamp = static_cast<std::uint16_t>((frame >> 9) & 0xff); + auto timestamp = static_cast<std::uint8_t>((frame >> 9) & 0xff); bool multihit = ((frame >> 8) & 0x1); auto hitType = static_cast<std::uint8_t>((frame >> 6) & 0x3); std::uint8_t nsamples = 0; // We directly start with the largest possible samples vector to only init it once std::vector<std::int16_t> samples = std::vector<std::int16_t>(0); - // get the correct fulltime in units of clock cycles - size_t fulltime = fMsStartTimeCC + (fNrTsMsbVec.at(istream) * fTsMsbLengthCC) + timestamp; + // Get the µSlice starttime relative to the timeslice starttime. Otherwise the UTC will already here be to large due to a cast, caused by the multiplication with a double used in the raw message + auto relMsStartTimeCC = fMsStartTimeCC - (fTsStartTime / CbmTrdSpadic::GetClockCycle()); + uint64_t fulltime = relMsStartTimeCC + (fNrTsMsbVec.at(istream) * fTsMsbLengthCC) + timestamp; + // Create message CbmTrdRawMessageSpadic retval(chId, elinkId, crobId, criId, hitType, nsamples, multihit, fulltime, samples); -- GitLab