diff --git a/algo/detectors/much/MuchReadoutConfig.cxx b/algo/detectors/much/MuchReadoutConfig.cxx index 5e661112b432d2b6b47e0ab2c44bb261633bf58f..5d06b3295049d8ed0b7cf85f1ee4f6e2ea1544bd 100644 --- a/algo/detectors/much/MuchReadoutConfig.cxx +++ b/algo/detectors/much/MuchReadoutConfig.cxx @@ -6,31 +6,17 @@ #include "CbmMuchAddress.h" -//#include "FairDetParIo.h" -//#include "FairParIo.h" -//#include "FairParamList.h" #include <Logger.h> -#include <bitset> -//#include "TMath.h" -//#include "TString.h" +#include <bitset> using namespace std; namespace cbm::algo { + // ------------------------------------------------------------------------- /* -// ----- Public method clear ------------------------------------------- -void MuchReadoutConfig::clear() -{ - status = false; - resetInputVersions(); -} -// ------------------------------------------------------------------------- - -// ------------------------------------------------------------------------- - void MuchReadoutConfig::putParams(FairParamList* l) { if (!l) return; @@ -53,63 +39,6 @@ void MuchReadoutConfig::putParams(FairParamList* l) l->add("RealX", fRealX); l->add("PadSize", fRealPadSize); } - -// ------------------------------------------------------------------------- - -bool MuchReadoutConfig::getParams(FairParamList* l) -{ - - if (!l) return false; - - if (!l->fill("NrOfDpbs", &numComp)) return false; - - eqId.Set(numComp); - if (!l->fill("DbpIdArray", &eqId)) return false; - - fiCrobActiveFlag.Set(numComp * kuNbCrobsPerDpb); - if (!l->fill("CrobActiveFlag", &fiCrobActiveFlag)) return false; - - if (!l->fill("NrOfFebsInGemA", &fuFebsInGemA)) return false; - - fnFebsIdsArrayGemA.Set(GetNrOfFebsInGemA()); - if (!l->fill("nFebsIdsArrayA", &fnFebsIdsArrayGemA)) return false; - - if (!l->fill("NrOfFebsInGemB", &fuFebsInGemB)) return false; - - fnFebsIdsArrayGemB.Set(GetNrOfFebsInGemB()); - if (!l->fill("nFebsIdsArrayB", &fnFebsIdsArrayGemB)) return false; - - if (!l->fill("NrOfFebsInRpc", &fuFebsInRpc)) return false; - - fnFebsIdsArrayRpc.Set(GetNrOfFebsInRpc()); - if (!l->fill("nFebsIdsArrayRpc", &fnFebsIdsArrayRpc)) return false; - - fChannelsToPadXA.Set(GetNrOfFebs() * kuNbChanPerAsic); - if (!l->fill("ChannelsToPadXA", &fChannelsToPadXA)) return false; - - fChannelsToPadYA.Set(GetNrOfFebs() * kuNbChanPerAsic); - if (!l->fill("ChannelsToPadYA", &fChannelsToPadYA)) return false; - - fChannelsToPadXB.Set(GetNrOfFebs() * kuNbChanPerAsic); - if (!l->fill("ChannelsToPadXB", &fChannelsToPadXB)) return false; - - fChannelsToPadYB.Set(GetNrOfFebs() * kuNbChanPerAsic); - if (!l->fill("ChannelsToPadYB", &fChannelsToPadYB)) return false; - - fChannelsToPadXRpc.Set(GetNrOfFebsInRpc() * kuNbChanPerAsic); - if (!l->fill("ChannelsToPadXRpc", &fChannelsToPadXRpc)) return false; - - fChannelsToPadYRpc.Set(GetNrOfFebsInRpc() * kuNbChanPerAsic); - if (!l->fill("ChannelsToPadYRpc", &fChannelsToPadYRpc)) return false; - - fRealX.Set(2232); // Number of Sectors in one GEM Module - if (!l->fill("RealX", &fRealX)) return false; - - fRealPadSize.Set(2232); // Number of Sectors in one GEM Module - if (!l->fill("PadSize", &fRealPadSize)) return false; - - return true; -} */ void MuchReadoutConfig::Init() @@ -119,6 +48,28 @@ bool MuchReadoutConfig::getParams(FairParamList* l) // Array to hold the unique IDs (equipment ID) for all MUCH DPBs uint16_t eqId[numComp] = {0x18e3, 0x18ef, 0x1861, 0x6601, 0x4f19, 0x5b7b}; + + // Mapping of eLink to FEB number within CROB. If -1, elink not used. + // This mapping is the same for each component. + const int16_t elink2Feb[numElinksPerCrob] = {0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, + 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 8, 8, 8, 8}; + + // Constructing the map (equipmentId, eLink, channel) -> (MUCH address) + uint16_t numElinksPerComp = numCrobPerComp * numElinksPerCrob; + for (uint16_t comp = 0; comp < numComp; comp++) { + uint16_t equipment = eqId[comp]; + fReadoutMap[equipment].resize(numElinksPerComp); + for (uint16_t crob = 0; crob < numCrobPerComp; crob++) { + for (uint16_t elink = 0; elink < numElinksPerCrob; elink++) { + fReadoutMap[equipment][elink].resize(numChanPerAsic); + for (uint16_t channel = 0; channel < numChanPerAsic; channel++) { + + + fReadoutMap[equipment][elink][channel] = 0; + } //# channel + } //# elink + } //# CROB + } //# component } //To do address need to be checked carefully @@ -238,20 +189,22 @@ bool MuchReadoutConfig::getParams(FairParamList* l) // ------------------------------------------------------------------------- + /* int16_t MuchReadoutConfig::ElinkIdxToFebIdx(uint16_t uElink) { - if (uElink < kuNbElinksPerCrob) return kiCrobMapElinkFebIdx[uElink]; + if (uElink < numElinksPerCrob) return kiCrobMapElinkFebIdx[uElink]; else { LOG(warning) << "MuchReadoutConfig::ElinkIdxToFebIdx => Index out of bound, " << "Elink is " << uElink << " returning crazy value!"; return -1; } } + */ bool MuchReadoutConfig::IsCrobActive(uint16_t uDpbIdx, uint16_t uCrobIdx) { if (uDpbIdx < numComp) { - if (uCrobIdx < kuNbCrobsPerDpb) return 0 < fiCrobActiveFlag[uDpbIdx * kuNbCrobsPerDpb + uCrobIdx] ? true : false; + if (uCrobIdx < numCrobPerComp) return 0 < fiCrobActiveFlag[uDpbIdx * numCrobPerComp + uCrobIdx] ? true : false; else { LOG(warning) << "MuchReadoutConfig::IsCrobActive => Crob Index out of bound, " << "returning default inactive!"; @@ -282,9 +235,9 @@ bool MuchReadoutConfig::getParams(FairParamList* l) bool MuchReadoutConfig::IsFebActive(uint16_t uDpbIdx, uint16_t uCrobIdx, uint16_t uFebIdx) { if (uDpbIdx < numComp) { - if (uCrobIdx < kuNbCrobsPerDpb) { + if (uCrobIdx < numCrobPerComp) { if (uFebIdx < kuNbFebsPerCrob) { - uint16_t uIdx = (uDpbIdx * kuNbCrobsPerDpb + uCrobIdx) * kuNbFebsPerCrob + uFebIdx; + uint16_t uIdx = (uDpbIdx * numCrobPerComp + uCrobIdx) * kuNbFebsPerCrob + uFebIdx; return IsFebActive(uIdx); } else { @@ -308,62 +261,62 @@ bool MuchReadoutConfig::getParams(FairParamList* l) int8_t MuchReadoutConfig::GetPadXA(uint8_t febid, uint8_t channelid) { - if (fChannelsToPadXA.size() <= static_cast<int16_t>((febid * kuNbChanPerAsic) + channelid)) { - LOG(debug) << "MuchReadoutConfig::GetPadXA => Index out of bounds: " << ((febid * kuNbChanPerAsic) + channelid) + if (fChannelsToPadXA.size() <= static_cast<int16_t>((febid * numChanPerAsic) + channelid)) { + LOG(debug) << "MuchReadoutConfig::GetPadXA => Index out of bounds: " << ((febid * numChanPerAsic) + channelid) << " VS " << fChannelsToPadXA.size() << " (" << febid << " and " << channelid << ")"; return -2; } - return fChannelsToPadXA[(febid * kuNbChanPerAsic) + channelid]; + return fChannelsToPadXA[(febid * numChanPerAsic) + channelid]; } int8_t MuchReadoutConfig::GetPadYA(uint8_t febid, uint8_t channelid) { - if (fChannelsToPadYA.size() <= static_cast<int16_t>((febid * kuNbChanPerAsic) + channelid)) { - LOG(debug) << "MuchReadoutConfig::GetPadYA => Index out of bounds: " << ((febid * kuNbChanPerAsic) + channelid) + if (fChannelsToPadYA.size() <= static_cast<int16_t>((febid * numChanPerAsic) + channelid)) { + LOG(debug) << "MuchReadoutConfig::GetPadYA => Index out of bounds: " << ((febid * numChanPerAsic) + channelid) << " VS " << fChannelsToPadYA.size() << " (" << febid << " and " << channelid << ")"; return -2; } - return fChannelsToPadYA[(febid * kuNbChanPerAsic) + channelid]; + return fChannelsToPadYA[(febid * numChanPerAsic) + channelid]; } int8_t MuchReadoutConfig::GetPadXB(uint8_t febid, uint8_t channelid) { - if (fChannelsToPadXB.size() <= static_cast<int16_t>((febid * kuNbChanPerAsic) + channelid)) { - LOG(debug) << "MuchReadoutConfig::GetPadXB => Index out of bounds: " << ((febid * kuNbChanPerAsic) + channelid) + if (fChannelsToPadXB.size() <= static_cast<int16_t>((febid * numChanPerAsic) + channelid)) { + LOG(debug) << "MuchReadoutConfig::GetPadXB => Index out of bounds: " << ((febid * numChanPerAsic) + channelid) << " VS " << fChannelsToPadXB.size() << " (" << febid << " and " << channelid << ")"; return -2; } - return fChannelsToPadXB[(febid * kuNbChanPerAsic) + channelid]; + return fChannelsToPadXB[(febid * numChanPerAsic) + channelid]; } int8_t MuchReadoutConfig::GetPadYB(uint8_t febid, uint8_t channelid) { - if (fChannelsToPadYB.size() <= static_cast<int16_t>((febid * kuNbChanPerAsic) + channelid)) { - LOG(debug) << "MuchReadoutConfig::GetPadYB => Index out of bounds: " << ((febid * kuNbChanPerAsic) + channelid) + if (fChannelsToPadYB.size() <= static_cast<int16_t>((febid * numChanPerAsic) + channelid)) { + LOG(debug) << "MuchReadoutConfig::GetPadYB => Index out of bounds: " << ((febid * numChanPerAsic) + channelid) << " VS " << fChannelsToPadYB.size() << " (" << febid << " and " << channelid << ")"; return -2; } - return fChannelsToPadYB[(febid * kuNbChanPerAsic) + channelid]; + return fChannelsToPadYB[(febid * numChanPerAsic) + channelid]; } int8_t MuchReadoutConfig::GetPadXRpc(uint8_t febid, uint8_t channelid) { - if (fChannelsToPadXRpc.size() <= static_cast<int16_t>((febid * kuNbChanPerAsic) + channelid)) { - LOG(debug) << "CbmMcbm2018MuchPar::GetPadXRpc => Index out of bounds: " << ((febid * kuNbChanPerAsic) + channelid) + if (fChannelsToPadXRpc.size() <= static_cast<int16_t>((febid * numChanPerAsic) + channelid)) { + LOG(debug) << "CbmMcbm2018MuchPar::GetPadXRpc => Index out of bounds: " << ((febid * numChanPerAsic) + channelid) << " VS " << fChannelsToPadXRpc.size() << " (" << febid << " and " << channelid << ")"; return -2; } - return fChannelsToPadXRpc[(febid * kuNbChanPerAsic) + channelid]; + return fChannelsToPadXRpc[(febid * numChanPerAsic) + channelid]; } int8_t MuchReadoutConfig::GetPadYRpc(uint8_t febid, uint8_t channelid) { - if (fChannelsToPadYRpc.size() <= static_cast<int16_t>((febid * kuNbChanPerAsic) + channelid)) { - LOG(debug) << "CbmMcbm2018MuchPar::GetPadYRpc => Index out of bounds: " << ((febid * kuNbChanPerAsic) + channelid) + if (fChannelsToPadYRpc.size() <= static_cast<int16_t>((febid * numChanPerAsic) + channelid)) { + LOG(debug) << "CbmMcbm2018MuchPar::GetPadYRpc => Index out of bounds: " << ((febid * numChanPerAsic) + channelid) << " VS " << fChannelsToPadYRpc.size() << " (" << febid << " and " << channelid << ")"; return -2; } - return fChannelsToPadYRpc[(febid * kuNbChanPerAsic) + channelid]; + return fChannelsToPadYRpc[(febid * numChanPerAsic) + channelid]; } int32_t MuchReadoutConfig::GetFebId(uint16_t uAsicIdx) @@ -383,18 +336,6 @@ bool MuchReadoutConfig::getParams(FairParamList* l) } } - //GetModule() is not used in unpacker - uint16_t MuchReadoutConfig::GetModule(uint16_t uAsicIdx) - { - if (uAsicIdx >= GetNrOfFebsInGemA()) { - if ((uAsicIdx % GetNrOfFebsInGemA()) < GetNrOfFebsInRpc()) return 1; - else - return 2; - } - else - return 0; - } - double MuchReadoutConfig::GetRealX(int16_t SectorIndex) { if (SectorIndex < 0 || SectorIndex <= 97) { diff --git a/algo/detectors/much/MuchReadoutConfig.h b/algo/detectors/much/MuchReadoutConfig.h index b66a47cbd235961006f8d80330d6a74dc321244f..debbabbe805dd0c71a1413443d0f1bbf0d370c3f 100644 --- a/algo/detectors/much/MuchReadoutConfig.h +++ b/algo/detectors/much/MuchReadoutConfig.h @@ -11,21 +11,12 @@ #ifndef ALGO_DETECTORS_MUCH_MUCHREADOUTCONFIG_H #define ALGO_DETECTORS_MUCH_MUCHREADOUTCONFIG_H -//#include "FairParGenericSet.h" - #include <cstdint> +#include <map> #include <vector> -//#include "TArrayD.h" -//#include "TArrayI.h" - -//class FairParIo; -//class FairParamList; - namespace cbm::algo { - - //class MuchReadoutConfig : public FairParGenericSet { class MuchReadoutConfig { public: @@ -35,37 +26,12 @@ namespace cbm::algo /** Destructor **/ ~MuchReadoutConfig() {}; - /** Reset all parameters **/ - virtual void clear(); - - /* - void putParams(FairParamList*); - bool getParams(FairParamList*); -*/ - static constexpr uint16_t GetNbCrobsPerDpb() { return kuNbCrobsPerDpb; } - static constexpr uint16_t GetNbElinkPerCrob() { return kuNbElinksPerCrob; } - static constexpr uint16_t GetNbElinkPerDpb() { return kuNbCrobsPerDpb * kuNbElinksPerCrob; } - static constexpr uint16_t GetNbFebsPerCrob() { return kuNbFebsPerCrob; } - static constexpr uint16_t GetNbFebsPerDpb() { return kuNbCrobsPerDpb * kuNbFebsPerCrob; } - static constexpr uint16_t GetNbAsicsPerFeb() { return kuNbAsicsPerFeb; } - static constexpr uint16_t GetNbAsicsPerCrob() { return kuNbFebsPerCrob * kuNbAsicsPerFeb; } - static constexpr uint16_t GetNbAsicsPerDpb() { return kuNbCrobsPerDpb * GetNbAsicsPerCrob(); } - static constexpr uint16_t GetNbChanPerAsic() { return kuNbChanPerAsic; } - static constexpr uint16_t GetNbChanPerFeb() { return kuNbAsicsPerFeb * kuNbChanPerAsic; } - - //! Convert from eLink index to FEB Connection ( 0 to kuNbFebsPerCrob) - int16_t ElinkIdxToFebIdx(uint16_t uElink); - - uint16_t GetNrOfDpbs() { return numComp; } - uint16_t GetNrOfCrobs() { return numComp * kuNbCrobsPerDpb; } + uint16_t GetNrOfCrobs() { return numComp * numCrobPerComp; } uint16_t GetNrOfFebs() { return GetNrOfCrobs() * kuNbFebsPerCrob; } - uint16_t GetNrOfAsics() { return GetNrOfFebs() * kuNbAsicsPerFeb; } uint16_t GetNrOfFebsInGemA() { return fuFebsInGemA; } uint16_t GetNrOfFebsInGemB() { return fuFebsInGemB; } - int16_t GetNrOfChannels() { return kuNbChanPerAsic; } int32_t GetFebId(uint16_t); - uint16_t GetModule(uint16_t); int8_t GetPadXA(uint8_t febid, uint8_t channelid); int8_t GetPadYA(uint8_t febid, uint8_t channelid); @@ -91,6 +57,10 @@ namespace cbm::algo double GetFebAdcOffset(uint16_t uDpbIdx, uint16_t uCrobIdx, uint16_t uFebIdx); private: + // --- MUCH readout map + // --- Map index: (equipment, elink, channel), map value: (MUCH address) + std::map<uint16_t, std::vector<std::vector<uint32_t>>> fReadoutMap = {}; + /** @brief Initialisation of readout map **/ void Init(); @@ -98,20 +68,15 @@ namespace cbm::algo uint32_t CreateMuchAddress(uint32_t dpbidx, int32_t iFebId, uint32_t usChan); /// Constants - static const uint16_t kuNbCrobsPerDpb = 1; // Number of CROBs possible per DPB - static const uint16_t kuNbElinksPerCrob = 42; // Number of elinks in each CROB ? - static const uint16_t kuNbFebsPerCrob = 9; // Number of FEBs connected to each CROB for mMuch 2019 - static const uint16_t kuNbAsicsPerFeb = 1; // Number of ASICs connected in each FEB for MUCH - static const uint16_t kuNbChanPerAsic = 128; // Number of channels in each ASIC - // static constexpr uint16_t kuCrobMapElinkFebIdx[ kuNbElinksPerCrob ] = { - const int16_t kiCrobMapElinkFebIdx[kuNbElinksPerCrob] = {0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, - 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, - 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 8, 8, 8, 8}; - //! Map from eLink index to ASIC index within CROB ( 0 to kuNbFebsPerCrob * kuNbAsicPerFeb ) + static const uint16_t numCrobPerComp = 1; // Number of CROBs possible per DPB + static const uint16_t numElinksPerCrob = 42; // Number of elinks in each CROB ? + static const uint16_t kuNbFebsPerCrob = 9; // Number of FEBs connected to each CROB for mMuch 2019 + static const uint16_t kuNbAsicsPerFeb = 1; // Number of ASICs connected in each FEB for MUCH + static const uint16_t numChanPerAsic = 128; // Number of channels in each ASIC /// Variables - uint16_t numComp = 6; // Total number of MUCH DPBs in system - + uint16_t numComp = 6; // Total number of MUCH DPBs in system + std::vector<int16_t> fiCrobActiveFlag; // Array to hold the active flag for all CROBs, [ NbDpb * kuNbCrobPerDpb ] uint16_t fuFebsInGemA = 0; // Number of FEBs connected in GEM Module A uint16_t fuFebsInGemB = 0; // Number of FEBs connected in GEM Module B