diff --git a/algo/detectors/trd2d/Trd2dReadoutConfig.cxx b/algo/detectors/trd2d/Trd2dReadoutConfig.cxx index 115f4bc699c4116a6d6fabc502bb1752ce8c2768..e6ca18b123c367078412b83e886421db7b4aa2be 100644 --- a/algo/detectors/trd2d/Trd2dReadoutConfig.cxx +++ b/algo/detectors/trd2d/Trd2dReadoutConfig.cxx @@ -1,6 +1,6 @@ -/* Copyright (C) 2022 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt +/* Copyright (C) 2023 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt SPDX-License-Identifier: GPL-3.0-only - Authors: Volker Friese [committer] */ + Authors: Volker Friese, Dominik Smith [committer] */ #include "Trd2dReadoutConfig.h" diff --git a/algo/detectors/trd2d/Trd2dReadoutConfig.h b/algo/detectors/trd2d/Trd2dReadoutConfig.h index 2737a0b7cc467f29f7eb3d2041dce4ad75dd9b1f..7de76995318938c359ee61e0525536303034bc35 100644 --- a/algo/detectors/trd2d/Trd2dReadoutConfig.h +++ b/algo/detectors/trd2d/Trd2dReadoutConfig.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2022 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt +/* Copyright (C) 2023 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt SPDX-License-Identifier: GPL-3.0-only Authors: Volker Friese, Dominik Smith [committer] */ diff --git a/algo/detectors/trd2d/UnpackTrd2d.cxx b/algo/detectors/trd2d/UnpackTrd2d.cxx index 087f4a0b2cbbd3db48b424b75105aa0523ea2924..c067198fa5c925a216a7d5f8349fd1d29c0910fc 100644 --- a/algo/detectors/trd2d/UnpackTrd2d.cxx +++ b/algo/detectors/trd2d/UnpackTrd2d.cxx @@ -1,6 +1,6 @@ /* Copyright (C) 2023 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt SPDX-License-Identifier: GPL-3.0-only - Authors: Pascal Raisig, Dominik Smith [committer] */ + Authors: Pascal Raisig, Alexandru Bercuci, Dominik Smith [committer] */ #include "UnpackTrd2d.h" @@ -39,7 +39,6 @@ namespace cbm::algo uint64_t time = uint64_t((msDescr.idx - tTimeslice - fSystemTimeOffset) / 12.5); // Get parameters for current eq id. - const uint16_t mod_id = fParams.fModId; const uint8_t crob_id = fParams.fCrobId; // Get the number of complete words in the input MS buffer. @@ -51,12 +50,11 @@ namespace cbm::algo unsigned char lFaspOld(0xff); std::vector<CbmTrdFaspMessage> vMess; for (uint64_t j = 0; j < nwords; j++, wd++) { - uint32_t w = *wd; - uint8_t ch_id = w & 0xf; - uint8_t isaux = (w >> 4) & 0x1; - uint8_t slice = (w >> 5) & 0x7f; - uint16_t data = (w >> 12) & 0x3fff; - // uint8_t fasp_id = ((w >> 26) & 0x3f) + crob_id * NFASPCROB; + uint32_t w = *wd; + uint8_t ch_id = w & 0xf; + uint8_t isaux = (w >> 4) & 0x1; + uint8_t slice = (w >> 5) & 0x7f; + uint16_t data = (w >> 12) & 0x3fff; uint8_t fasp_id = ((w >> 26) & 0x3f); if (isaux) { @@ -70,8 +68,6 @@ namespace cbm::algo } continue; } - //if (fFaspMap) fasp_id = ((*fFaspMap)[mod_id])[fasp_id]; - if (lFaspOld != fasp_id) { if (vMess.size()) { pushDigis(vMess, time); } vMess.clear(); diff --git a/algo/detectors/trd2d/UnpackTrd2d.h b/algo/detectors/trd2d/UnpackTrd2d.h index c1f179cc2ec60831a3c9e2a46a53f7c7a6be9856..d3ba008916f3fcdeed16090a5edb419edc40657c 100644 --- a/algo/detectors/trd2d/UnpackTrd2d.h +++ b/algo/detectors/trd2d/UnpackTrd2d.h @@ -1,6 +1,6 @@ /* Copyright (C) 2023 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt SPDX-License-Identifier: GPL-3.0-only - Authors: Pascal Raisig, Dominik Smith [committer] */ + Authors: Pascal Raisig, Alexandru Bercuci, Dominik Smith [committer] */ #ifndef CBM_ALGO_UNPACKTRD2D_H #define CBM_ALGO_UNPACKTRD2D_H 1 @@ -12,6 +12,7 @@ #include "MicrosliceDescriptor.hpp" #include "Timeslice.hpp" +#include <array> #include <memory> #include <cmath> @@ -163,8 +164,6 @@ namespace cbm::algo std::array<std::vector<CbmTrdDigi>, NFASPMOD* NFASPCH> fDigiBuffer = { {}}; ///> Buffered digi for each pad in CROB component - - std::map<uint32_t, uint8_t[NFASPMOD]>* fFaspMap = nullptr; ///> FASP mapping update wrt the default setting }; diff --git a/reco/tasks/CbmTaskUnpack.cxx b/reco/tasks/CbmTaskUnpack.cxx index f709797d6df7e415630beb9fcae56ad401cf2e62..f1e06438ab13c4f78a8ea751089dc9ea4abbead4 100644 --- a/reco/tasks/CbmTaskUnpack.cxx +++ b/reco/tasks/CbmTaskUnpack.cxx @@ -506,6 +506,31 @@ void CbmTaskUnpack::InitTrd2dReadoutConfig() // Then pass to Trd2dReadoutConfig, will invert to obain map (equipId) -> (module iq, crob id) fTrd2dConfig.InitComponentMap(crob_map); + // FASP mapping update wrt the default setting (optional) + std::map<uint32_t, uint8_t[NFASPMOD]> fasp_map; + + { // Initialize the "fasp remapping" + // Hard coded for run Id >= 2335 (only module Id 5). + uint8_t map[NFASPMOD]; + for (uint32_t i(0); i < NFASPMOD; i++) { + map[i] = i; + } + const size_t nfasp0 = 72; + const size_t nfasps = 36; + uint8_t map22[] = { + 84, 85, 86, 87, 88, 89, // FEB14/0xffc1 + 90, 91, 92, 93, 94, 95, // FEB17/0xffc1 + 96, 97, 98, 99, 100, 101, // FEB18/0xffc1 + 102, 103, 104, 105, 106, 107, // FEB16/0xffc1 + 72, 73, 74, 75, 76, 77, // FEB9/0xffc1 + 78, 79, 80, 81, 82, 83 // FEB8/0xffc1 + }; + for (uint32_t i(0); i < nfasps; i++) { + map[i + nfasp0] = map22[i]; + } + memcpy(fasp_map[5], map, NFASPMOD * sizeof(uint8_t)); + } + // Map (equipId, asicId, chanId) -> (pad address, R pairing flag, daq offset) std::map<size_t, std::map<size_t, std::map<size_t, std::tuple<int32_t, bool, uint64_t>>>> channelMap; @@ -526,10 +551,15 @@ void CbmTaskUnpack::InitTrd2dReadoutConfig() for (auto add : addresses) { //Get local IDs for this component / equipment. - const int32_t fasp_in_eq = ((int) add - 1000 * (int) moduleId) % (NFASPCROB); - const int32_t crob_in_mod = ((int) add - 1000 * (int) moduleId) / (NFASPCROB); + const int32_t fasp_in_mod = add - 1000 * moduleId; + const int32_t fasp_in_eq = fasp_in_mod % (NFASPCROB); + const int32_t crob_in_mod = fasp_in_mod / (NFASPCROB); const uint16_t eq_id = crob_map[moduleId][crob_in_mod]; + // Apply FASP remapping (optional) + const int32_t add_remap = fasp_map[moduleId][fasp_in_mod]; + add = add_remap + 1000 * moduleId; + // ASIC parameter set CbmTrdParFasp* fasppar = (CbmTrdParFasp*) setDet->GetModulePar(add); @@ -539,11 +569,12 @@ void CbmTaskUnpack::InitTrd2dReadoutConfig() const bool hasPairingR = fasppar->GetChannel(chan)->HasPairingR(); const CbmTrdParModDigi* modpar = (CbmTrdParModDigi*) digiparset.GetModulePar(moduleId); uint64_t daq_offset = 0; - if (modpar->GetPadRow(fasppar->GetPadAddress(chan)) % 2 == 0) daq_offset = 3; + if (modpar->GetPadRow(pad) % 2 == 0) daq_offset = 3; channelMap[eq_id][fasp_in_eq][chan] = std::make_tuple(pad, hasPairingR, daq_offset); } } } + fTrd2dConfig.InitChannelMap(channelMap); }