From 6a48ab325d41e1b08a1075711b87abfb81117e3e Mon Sep 17 00:00:00 2001 From: Dominik Smith <smith@th.physik.uni-frankfurt.de> Date: Mon, 26 Jun 2023 12:39:57 +0200 Subject: [PATCH] Implemented system time offsets for all unpackers in cbm::algo. --- algo/detectors/rich/UnpackRich.cxx | 2 +- algo/detectors/rich/UnpackRich.h | 7 +------ algo/detectors/trd/UnpackTrd.cxx | 2 +- algo/detectors/trd/UnpackTrd.h | 6 ------ algo/detectors/trd2d/UnpackTrd2d.cxx | 2 +- algo/detectors/trd2d/UnpackTrd2d.h | 7 +------ algo/unpack/Unpack.cxx | 21 ++++++++++++--------- algo/unpack/Unpack.h | 7 +++++++ 8 files changed, 24 insertions(+), 30 deletions(-) diff --git a/algo/detectors/rich/UnpackRich.cxx b/algo/detectors/rich/UnpackRich.cxx index 471504f5f9..7958be3dc6 100644 --- a/algo/detectors/rich/UnpackRich.cxx +++ b/algo/detectors/rich/UnpackRich.cxx @@ -258,7 +258,7 @@ namespace cbm::algo double ToTcorr = fbDoToTCorr ? fParams.fElinkParams[fpgaID].fToTshift[channel] : 0.; int32_t pixelUID = GetPixelUID(fpgaID, channel); //check ordering - double finalTime = time + (double) fMsRefTime - fSystemTimeOffset; + double finalTime = time + (double) fMsRefTime - fParams.fElinkParams[fpgaID].fTimeOffset; // Do not accept digis, where the MS und TS differs by more than 6 sec (mainly TS0) if (6e9 < finalTime) return; diff --git a/algo/detectors/rich/UnpackRich.h b/algo/detectors/rich/UnpackRich.h index 8987e926f3..944660d687 100644 --- a/algo/detectors/rich/UnpackRich.h +++ b/algo/detectors/rich/UnpackRich.h @@ -46,6 +46,7 @@ namespace cbm::algo **/ struct UnpackRichElinkPar { std::vector<double> fToTshift; ///< TOT shift for different channels + uint64_t fTimeOffset = 0.; ///< Time calibration parameter }; @@ -178,12 +179,6 @@ namespace cbm::algo /** @brief Storage of monitoring data. */ UnpackRichMonitorData fMonitor; - - /** - * @brief Time offset for the system - * @todo This should be module and channel dependent and included into the asic parameters - */ - std::int32_t fSystemTimeOffset = 0; }; diff --git a/algo/detectors/trd/UnpackTrd.cxx b/algo/detectors/trd/UnpackTrd.cxx index 854cb8e202..ed9fe1ee0a 100644 --- a/algo/detectors/trd/UnpackTrd.cxx +++ b/algo/detectors/trd/UnpackTrd.cxx @@ -404,7 +404,7 @@ namespace cbm::algo fLastFulltime = raw.GetFullTime(); // Get the time information and apply the necessary correction - uint64_t time = raw.GetTime() - fSystemTimeOffset; + uint64_t time = raw.GetTime() - elinkPar.fTimeOffset; // Get the timeshift and set the member, which is required for some of the rtd methods uint64_t currentTimeshift = GetBinTimeShift(raw.GetSamples()); diff --git a/algo/detectors/trd/UnpackTrd.h b/algo/detectors/trd/UnpackTrd.h index 1afc4ed23a..915535c1f2 100644 --- a/algo/detectors/trd/UnpackTrd.h +++ b/algo/detectors/trd/UnpackTrd.h @@ -250,12 +250,6 @@ namespace cbm::algo /** @brief Number of streams per word **/ static const std::uint8_t fStreamsPerWord = 2; - /** - ** @brief Time offset for the system - ** @todo This should be module and channel dependent and included into the asic parameters - **/ - std::int32_t fSystemTimeOffset = 0; - /** @brief Start time of the current µSlice relative to the Timeslice start time in Spadic CC. */ size_t fMsStartTimeRelCC = 0; diff --git a/algo/detectors/trd2d/UnpackTrd2d.cxx b/algo/detectors/trd2d/UnpackTrd2d.cxx index e6709b4a00..a1eb4ec427 100644 --- a/algo/detectors/trd2d/UnpackTrd2d.cxx +++ b/algo/detectors/trd2d/UnpackTrd2d.cxx @@ -39,7 +39,7 @@ namespace cbm::algo // - relative offset of the MS wrt the TS // - FASP epoch offset for current CROB // - TRD2D system offset wrt to experiment time (e.g. T0) - uint64_t time = uint64_t((msDescr.idx - tTimeslice - fSystemTimeOffset) / 12.5); + uint64_t time = uint64_t((msDescr.idx - tTimeslice - fParams.fSystemTimeOffset) / 12.5); // Get parameters for current eq id. const uint8_t crob_id = fParams.fCrobId; diff --git a/algo/detectors/trd2d/UnpackTrd2d.h b/algo/detectors/trd2d/UnpackTrd2d.h index 25cc2886c2..9cb8a3580f 100644 --- a/algo/detectors/trd2d/UnpackTrd2d.h +++ b/algo/detectors/trd2d/UnpackTrd2d.h @@ -73,6 +73,7 @@ namespace cbm::algo ** @brief Parameters required for the TRD unpacking (specific to one component) **/ struct UnpackTrd2dPar { + int32_t fSystemTimeOffset = 0; ///< Time calibration parameter uint16_t fModId = 0; ///< Module ID of component uint8_t fCrobId = 0; ///< CROB ID of component std::vector<UnpackTrd2dAsicPar> fAsicParams = {}; ///< Parameters for each ASIC @@ -141,12 +142,6 @@ namespace cbm::algo UnpackTrd2dMonitorData fMonitor; ///< Container for monitoring data - /** - ** @brief Time offset for the system - ** @todo This should be module and channel dependent and included into the asic parameters - **/ - std::int32_t fSystemTimeOffset = 0; - bool pushDigis(std::vector<CbmTrdFaspMessage> messages, const uint64_t time); /** @brief Finalize component (e.g. copy from temp buffers) */ diff --git a/algo/unpack/Unpack.cxx b/algo/unpack/Unpack.cxx index 6c8eb331db..32cf018102 100644 --- a/algo/unpack/Unpack.cxx +++ b/algo/unpack/Unpack.cxx @@ -146,7 +146,7 @@ namespace cbm::algo auto mapEntry = fStsConfig.Map(equip, elink); elinkPar.fAddress = mapEntry.first; // Module address for this elink elinkPar.fAsicNr = mapEntry.second; // ASIC number within module - elinkPar.fTimeOffset = 0.; + elinkPar.fTimeOffset = fSystemTimeOffset[fles::SubsystemIdentifier::STS]; elinkPar.fAdcOffset = 1.; elinkPar.fAdcGain = 1.; elinkPar.fWalk = fStsConfig.WalkMap(elinkPar.fAddress, elinkPar.fAsicNr); @@ -165,7 +165,7 @@ namespace cbm::algo for (size_t elink = 0; elink < numElinks; elink++) { UnpackMuchElinkPar elinkPar; elinkPar.fAddress = fMuchConfig.Map(equip, elink); // Vector of MUCH addresses for this elink - elinkPar.fTimeOffset = 0.; + elinkPar.fTimeOffset = fSystemTimeOffset[fles::SubsystemIdentifier::MUCH]; par->fElinkParams.push_back(elinkPar); } fAlgoMuch[equip].SetParams(std::move(par)); @@ -180,7 +180,7 @@ namespace cbm::algo for (size_t elink = 0; elink < numElinks; elink++) { UnpackTofElinkPar elinkPar; elinkPar.fChannelUId = fTofConfig.Map(equip, elink); // Vector of TOF addresses for this elink - elinkPar.fTimeOffset = 0.; + elinkPar.fTimeOffset = fSystemTimeOffset[fles::SubsystemIdentifier::RPC]; par->fElinkParams.push_back(elinkPar); } fAlgoTof[equip].SetParams(std::move(par)); @@ -195,7 +195,7 @@ namespace cbm::algo for (size_t elink = 0; elink < numElinks; elink++) { UnpackBmonElinkPar elinkPar; elinkPar.fChannelUId = fBmonConfig.Map(equip, elink); // Vector of T0 addresses for this elink - elinkPar.fTimeOffset = 0.; + elinkPar.fTimeOffset = fSystemTimeOffset[fles::SubsystemIdentifier::T0]; par->fElinkParams.push_back(elinkPar); } fAlgoBmon[equip].SetParams(std::move(par)); @@ -208,8 +208,9 @@ namespace cbm::algo std::unique_ptr<UnpackRichPar> par(new UnpackRichPar()); std::map<uint32_t, std::vector<double>> compMap = fRichConfig.Map(equip); for (auto const& val : compMap) { - uint32_t address = val.first; - par->fElinkParams[address].fToTshift = val.second; + uint32_t address = val.first; + par->fElinkParams[address].fToTshift = val.second; + par->fElinkParams[address].fTimeOffset = fSystemTimeOffset[fles::SubsystemIdentifier::RICH]; } fAlgoRich[equip].SetParams(std::move(par)); L_(info) << "--- Configured equipment " << equip << " with " << fRichConfig.GetNumElinks(equip) << " elinks"; @@ -231,6 +232,7 @@ namespace cbm::algo auto addresses = fTrdConfig.Map(equip, crob, elink); elinkPar.fAddress = addresses.first; // Asic address for this elink elinkPar.fChanAddress = addresses.second; // Channel addresses for this elink + elinkPar.fTimeOffset = fSystemTimeOffset[fles::SubsystemIdentifier::TRD]; crobPar.fElinkParams.push_back(elinkPar); } par->fCrobParams.push_back(crobPar); @@ -258,9 +260,10 @@ namespace cbm::algo chanPar.fDaqOffset = std::get<2>(pars); // Time calibration parameter asicPar.fChanParams.push_back(chanPar); } - auto comppars = fTrd2dConfig.CompMap(equip); - par->fModId = comppars.first; - par->fCrobId = comppars.second; + auto comppars = fTrd2dConfig.CompMap(equip); + par->fSystemTimeOffset = fSystemTimeOffset[fles::SubsystemIdentifier::TRD2D]; + par->fModId = comppars.first; + par->fCrobId = comppars.second; par->fAsicParams.push_back(asicPar); } fAlgoTrd2d[equip].SetParams(std::move(par)); diff --git a/algo/unpack/Unpack.h b/algo/unpack/Unpack.h index 57d72cb8d2..3071986f54 100644 --- a/algo/unpack/Unpack.h +++ b/algo/unpack/Unpack.h @@ -132,6 +132,13 @@ namespace cbm::algo /** @brief RICH unpackers **/ std::map<uint16_t, UnpackRich> fAlgoRich = {}; + + /** @brief System time offsets **/ + std::map<fles::SubsystemIdentifier, int32_t> fSystemTimeOffset = { + {fles::SubsystemIdentifier::STS, -970}, {fles::SubsystemIdentifier::MUCH, -980}, + {fles::SubsystemIdentifier::RICH, 100}, {fles::SubsystemIdentifier::RPC, 40}, + {fles::SubsystemIdentifier::T0, 0}, {fles::SubsystemIdentifier::TRD, 1300}, + {fles::SubsystemIdentifier::TRD2D, -510}}; }; } // namespace cbm::algo -- GitLab