From f8a1df48ed19de419a9bc528e58847783733cfb2 Mon Sep 17 00:00:00 2001 From: Pascal Raisig <praisig@ikf.uni-frankfurt.de> Date: Tue, 1 Dec 2020 14:09:27 +0100 Subject: [PATCH] Add some helper functions to retrieve mapping info A helper function was added to retrieve the elink number of a given channel number in the module coordinate system --- core/detectors/trd/CbmTrdParSpadic.cxx | 41 ++++++++++++++++++++++++++ core/detectors/trd/CbmTrdParSpadic.h | 16 ++++++++-- 2 files changed, 54 insertions(+), 3 deletions(-) diff --git a/core/detectors/trd/CbmTrdParSpadic.cxx b/core/detectors/trd/CbmTrdParSpadic.cxx index a3edb4c628..b05f20606d 100644 --- a/core/detectors/trd/CbmTrdParSpadic.cxx +++ b/core/detectors/trd/CbmTrdParSpadic.cxx @@ -23,6 +23,7 @@ CbmTrdParSpadic::CbmTrdParSpadic(Int_t address, std::uint64_t compId) : CbmTrdParAsic(address, FebGrouping, x, y, z, compId) { fChannelAddresses.resize(NSPADICCH); + FillAsicChannelToElinkMap(&fMapAsicChannelToElink); } // ---- LoadParams ---------------------------------------------------- @@ -194,4 +195,44 @@ Int_t CbmTrdParSpadic::GetAsicChAddress(const Int_t asicChannel) { return address; } +// ---- FillAsicChannelToElinkMap ---- +void CbmTrdParSpadic::FillAsicChannelToElinkMap(std::map<UInt_t, UInt_t>* map) { + + // Only emplace pairs in an empty map. + if (map->size() > 0) return; + + // This assumes that we have 2 elinks per SPADIC and that positions 00..15 in fVecSpadicChannels corresponds to the first elink while 16..31 corresponds to the second + UInt_t nthAsicElink = 0; + UInt_t rawchannel = 0; + for (size_t ichannel = 0; ichannel < fVecSpadicChannels.size(); ichannel++) { + rawchannel = fVecSpadicChannels[ichannel]; + if (rawchannel >= NSPADICCH / 2) + nthAsicElink = 1; + else + nthAsicElink = 0; + auto channelpair = std::pair<UInt_t, UInt_t>(ichannel, nthAsicElink); + map->emplace(channelpair); + } +} + +// ---- GetElinkNr ---- +UInt_t CbmTrdParSpadic::GetElinkNr(Int_t moduleChannel, + UInt_t nChannelsPerRow) { + ///< Return the number of the elink (counting started in channel order from bottom left to right) correlated to module wide channel number passed as argument, e.g. 000...767 for the mcbm module type + UInt_t row = moduleChannel / nChannelsPerRow; + UInt_t column = moduleChannel % nChannelsPerRow; + UInt_t nelinksPerRow = nChannelsPerRow / (NSPADICCH / 2); + + // each SPADIC has its channels distributed over 2 rows. Hence, we have (nspadics per row) * 2 elinks per row + // row 0 and 1, 2 and 3, ... use the same elinks + UInt_t nthelink = (column / (NSPADICCH / 2)) * 2 + (row / 2) * nelinksPerRow; + + // up to now we do not know if we have the first or second elink on the asic. Hence, we get the channel number in the asic coordinates and check the asicChannel to elink map, wether it is on the first (0) or second (1) elink. And add the result. + UInt_t asicRow = row % 2; + UInt_t asicChannel = column % (NSPADICCH / 2) + (NSPADICCH / 2) * asicRow; + nthelink += fMapAsicChannelToElink.find(asicChannel)->second; + + return nthelink; +} + ClassImp(CbmTrdParSpadic) diff --git a/core/detectors/trd/CbmTrdParSpadic.h b/core/detectors/trd/CbmTrdParSpadic.h index c99f97e3e1..79d1cf2e5f 100644 --- a/core/detectors/trd/CbmTrdParSpadic.h +++ b/core/detectors/trd/CbmTrdParSpadic.h @@ -6,7 +6,9 @@ #include <Rtypes.h> // for THashConsistencyHolder, ClassDef #include <RtypesCore.h> // for Int_t, Double_t, UInt_t +#include <map> // fMapAsicChannelToElink #include <stdint.h> // for uint64_t, uint8_t, uint16_t +#include <vector> // fVecSpadicChannels #include "CbmTrdParAsic.h" // for CbmTrdParAsic @@ -40,6 +42,9 @@ public: Int_t eLinkId); ///< Create the componentId from a given criId, crobId, eLinkId and the nThCrobOnModule count, according to the scheme, defined by ECbmTrdComponentIdDecoding. + std::vector<UInt_t> GetSpadicChannelVec() { return fVecSpadicChannels; } + ///< Return the vector with the corresponding spadic channel numbers sorted from channel 00..31 in pad plane coordinates + static Int_t GetNasicsOnModule( Int_t moduleType); ///< Returns the number of asics on a given moduleType defined in eCbmTrdModuleTypes @@ -66,6 +71,8 @@ public: std::uint8_t GetElinkId( Int_t channelId); ///< eLinkId for the current asic par set and the given channelId (in the asic coordinates, i.e. 00..31). + UInt_t GetElinkNr(Int_t moduleChannel, UInt_t nChannelsPerRow); + ///< Return the number of the elink (counting started in channel order from bottom left to right) correlated to module wide channel number passed as argument, e.g. 000...767 for the mcbm module type UInt_t GetAddressOnModule() const { return fAddress % 1000; } ///< Returns the number of the asic on the module counted from top left @@ -78,12 +85,15 @@ private: static Double_t fgSizeY; ///< SPADIC half size in y [cm] static Double_t fgSizeZ; ///< SPADIC half size in z [cm] - const std::vector<Int_t> fVecSpadicChannels = { + const std::vector<UInt_t> fVecSpadicChannels = { 23, 7, 22, 6, 21, 19, 5, 20, 18, 4, 3, 17, 16, 2, 1, 0, 31, 30, 29, 15, 14, 28, 27, 13, 11, 26, 12, 10, 25, 9, 24, 8}; + std::map<UInt_t, UInt_t> fMapAsicChannelToElink = {}; + void FillAsicChannelToElinkMap( + std::map<UInt_t, UInt_t>* + map); ///< Write the eLink to asicChannel mapping to the passed map - - ClassDef(CbmTrdParSpadic, 2) // Definition of SPADIC ASIC parameters + ClassDef(CbmTrdParSpadic, 3) // Definition of SPADIC ASIC parameters }; #endif -- GitLab