diff --git a/core/data/trd/CbmTrdRawMessageSpadic.cxx b/core/data/trd/CbmTrdRawMessageSpadic.cxx index dfe783ee6c14e91795214735aa46cbae2496f077..66bf8e03b53e6e4caa80e8a69569605cfa67357b 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 4ff1080b962c31a0a25674b8bfd035fa33ae8c51..63be72efb1087aaf506e3af38cb4f93ef6139232 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 f34896075ef014983b36f116ced5599f1686a0f5..542470c67f42dda6f6664286261556072db51d8f 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);