CbmRoot
Loading...
Searching...
No Matches
much/ReadoutConfig.h
Go to the documentation of this file.
1/* Copyright (C) 2021 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Dominik Smith [committer] */
4
5#ifndef ALGO_DETECTORS_MUCH_READOUTCONFIG_H
6#define ALGO_DETECTORS_MUCH_READOUTCONFIG_H
7
8#include "CbmYaml.h"
9
10#include <cstddef>
11#include <cstdint>
12#include <map>
13#include <vector>
14
15namespace cbm::algo::much
16{
21 struct ReadoutSetup {
22 struct Component {
23 uint16_t equipmentId;
24 bool active;
25
27 yaml::Property(&Component::equipmentId, "equipmentId",
28 "Equipment ID of component. Written to the data stream (MicrosliceDescriptor).", YAML::Hex),
29 yaml::Property(&Component::active, "active", "Active/Inactive flag per component (Unused for now)"));
30 };
31
32 struct FebsIds {
33 std::vector<int16_t> febsGemA;
34 std::vector<int16_t> febsGemB;
35 std::vector<int16_t> febsRpc;
36
38 yaml::Property(&FebsIds::febsGemA, "febsGemA", "Mapping of FEBs IDs for GEM A"),
39 yaml::Property(&FebsIds::febsGemB, "febsGemB", "Mapping of FEBs IDs for GEM B"),
40 yaml::Property(&FebsIds::febsRpc, "febsRpc", "Mapping of FEBs IDs forRPC"));
41 };
42
43 struct PadsConfig {
44 std::vector<int16_t> channelToPadX;
45 std::vector<int16_t> channelToPadY;
46
47 // PadX means CHANNEL for CbmMuchAddress
48 // PadY means SECTOR for CbmMuchAddress
50 yaml::Property(&PadsConfig::channelToPadX, "channelToPadX", "X means CHANNEL for CbmMuchAddressA"),
51 yaml::Property(&PadsConfig::channelToPadY, "channelToPadY", "Y means SECTOR for CbmMuchAddress"));
52 };
53
54 int32_t timeOffset;
56 std::vector<Component> components;
61
62 CBM_YAML_PROPERTIES(yaml::Property(&ReadoutSetup::timeOffset, "timeOffset", "Time offset in ns of the MVD data relative to the reference/trigger"),
63 yaml::Property(&ReadoutSetup::numAsicsPerFeb, "numAsicsPerFeb", "Number of ASICs per FEB"),
64 yaml::Property(&ReadoutSetup::components, "components", "Components", {}, YAML::Flow),
65 yaml::Property(&ReadoutSetup::febsMapping, "febsMapping",
66 "FEBs mapping per detector", {}, YAML::Flow),
67 yaml::Property(&ReadoutSetup::padsConfigGemA, "padsConfigGemA",
68 "Mapping of channel to PAD for GEM A", {}, YAML::Flow),
69 yaml::Property(&ReadoutSetup::padsConfigGemB, "padsConfigGemB",
70 "Mapping of channel to PAD for GEM B", {}, YAML::Flow),
71 yaml::Property(&ReadoutSetup::padsConfigRpc, "padsConfigRpc",
72 "Mapping of channel to PAD for RPC", {}, YAML::Flow));
73 };
74
76
77 public:
80
83
85 virtual ~ReadoutConfig();
86
90 int32_t GetSystemTimeOffset() const { return fTimeOffset; }
91
95 std::vector<uint16_t> GetEquipmentIds();
96
101 size_t GetNumElinks(uint16_t equipmentId);
102
108 std::vector<uint32_t> Map(uint16_t equipId, uint16_t elink);
109
115 std::vector<bool> MaskMap(uint16_t equipId, uint16_t elink);
116
120 std::map<uint16_t, std::vector<std::vector<uint32_t>>> GetFullMap() { return fReadoutMap; }
121
122 private:
123 // --- MUCH system time offset
124 int32_t fTimeOffset = 0;
125
126 // --- MUCH readout map
127 // --- Map index: (equipment, elink, channel), map value: (MUCH address)
128 std::map<uint16_t, std::vector<std::vector<uint32_t>>> fReadoutMap = {};
129
130 // --- MUCH channel mask map
131 // --- Map index: (equipment, elink), map value: (vector of mask flags for channels per asic)
132 std::map<uint16_t, std::map<size_t, std::vector<bool>>> fMaskMap = {};
133
135 void Init();
136
138 void Init(const ReadoutSetup&);
139
141 void InitHardcoded();
142
144 uint32_t CreateMuchAddress(uint32_t dpbidx, int32_t iFebId, uint32_t usChan);
145
147 static const uint16_t numCrobPerComp = 1;
148 static const uint16_t numElinksPerCrob = 42;
149 static const uint16_t numFebsPerCrob = 9;
150 static const uint16_t numAsicsPerFeb = 1;
151 const uint16_t numChanPerAsic = 128;
152
153 // Mapping of eLink to FEB number within CROB. If -1, elink not used.
154 // This mapping is the same for each component.
155 // => Valid only starting from 2024 data, so incoherent results with 2022 data (even though not crashing)
156 static constexpr int16_t elink2Feb[numElinksPerCrob] = {0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2,
157 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5,
158 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8};
159
161 uint16_t numFebsInGemA = 27;
162 uint16_t numFebsInGemB = 27;
163 uint16_t numFebsInRpc = 9;
164 std::vector<int16_t> fnFebsIdsArrayGemA;
165 std::vector<int16_t> fnFebsIdsArrayGemB;
166 std::vector<int16_t> fnFebsIdsArrayRpc;
167 std::vector<int16_t>
169 std::vector<int16_t>
171 std::vector<int16_t>
173 std::vector<int16_t>
175 std::vector<int16_t> fChannelsToPadXRpc;
176 std::vector<int16_t> fChannelsToPadYRpc;
177
178 void InitChannelToPadMaps();
179
180 int32_t GetFebId(uint16_t);
181 int8_t GetPadXA(uint8_t febid, uint8_t channelid);
182 int8_t GetPadYA(uint8_t febid, uint8_t channelid);
183 int8_t GetPadXB(uint8_t febid, uint8_t channelid);
184 int8_t GetPadYB(uint8_t febid, uint8_t channelid);
185
186 //RPC Module Related Functions
187 int8_t GetPadXRpc(uint8_t febid, uint8_t channelid);
188 int8_t GetPadYRpc(uint8_t febid, uint8_t channelid);
189 };
190
191} // namespace cbm::algo::much
192
193#endif // ALGO_DETECTORS_MUCH_READOUTCONFIG_H
std::vector< bool > MaskMap(uint16_t equipId, uint16_t elink)
API: Mapping from component and elink to channel mask flags.
void InitChannelToPadMaps()
Init arrays which store positions of PADs.
static const uint16_t numAsicsPerFeb
Number of ASICs connected in each FEB for MUCH.
void InitHardcoded()
Initialisation of readout map from hardcoded valus, backup if YAML missing.
int8_t GetPadYA(uint8_t febid, uint8_t channelid)
std::vector< int16_t > fChannelsToPadXA
Array which stores the corresponding x position of PAD of entire module A.
ReadoutConfig()
Default Constructor if no valid YAMl file available.
std::vector< int16_t > fChannelsToPadXB
Array which stores the corresponding x position of PAD of entire module B.
uint16_t numFebsInGemB
Number of FEBs connected in GEM Module B.
static const uint16_t numCrobPerComp
Constants.
std::vector< uint16_t > GetEquipmentIds()
Equipment in the configuration.
static const uint16_t numFebsPerCrob
Number of FEBs connected to each CROB for mMuch 2019.
std::map< uint16_t, std::vector< std::vector< uint32_t > > > fReadoutMap
std::vector< uint32_t > Map(uint16_t equipId, uint16_t elink)
API: Mapping from component and elink to addresses per channel.
void Init()
Initialisation of readout map with hardcoded values.
int32_t GetSystemTimeOffset() const
System time offset for MUCH.
size_t GetNumElinks(uint16_t equipmentId)
Number of elinks of a component.
std::vector< int16_t > fnFebsIdsArrayRpc
Array to hold FEB IDs connected to RPC Module.
std::vector< int16_t > fChannelsToPadYRpc
Array which stores the corresponding y position of PAD of RPC module.
std::vector< int16_t > fnFebsIdsArrayGemA
Array to hold FEB IDs connected to GEM Module A.
std::vector< int16_t > fChannelsToPadYB
Array which stores the corresponding y position of PAD of entire module B.
int8_t GetPadXB(uint8_t febid, uint8_t channelid)
int8_t GetPadXRpc(uint8_t febid, uint8_t channelid)
std::vector< int16_t > fChannelsToPadYA
Array which stores the corresponding y position of PAD of entire module A.
std::vector< int16_t > fChannelsToPadXRpc
Array which stores the corresponding x position of PAD of RPC module.
static constexpr int16_t elink2Feb[numElinksPerCrob]
static const uint16_t numElinksPerCrob
Number of elinks in each CROB ?
int8_t GetPadYB(uint8_t febid, uint8_t channelid)
const uint16_t numChanPerAsic
Number of channels in each ASIC.
std::map< uint16_t, std::vector< std::vector< uint32_t > > > GetFullMap()
API: Get fullMapping from component and elink to addresses per channel.
uint32_t CreateMuchAddress(uint32_t dpbidx, int32_t iFebId, uint32_t usChan)
Maps component index, Fed Id and channel number to Much Address.
int8_t GetPadYRpc(uint8_t febid, uint8_t channelid)
int8_t GetPadXA(uint8_t febid, uint8_t channelid)
uint16_t numFebsInRpc
Number of FEBs connected in RPC Module.
std::vector< int16_t > fnFebsIdsArrayGemB
Array to hold FEB IDs connected to GEM Module B.
std::map< uint16_t, std::map< size_t, std::vector< bool > > > fMaskMap
CBM_YAML_PROPERTIES(yaml::Property(&Component::equipmentId, "equipmentId", "Equipment ID of component. Written to the data stream (MicrosliceDescriptor).", YAML::Hex), yaml::Property(&Component::active, "active", "Active/Inactive flag per component (Unused for now)"))
CBM_YAML_PROPERTIES(yaml::Property(&FebsIds::febsGemA, "febsGemA", "Mapping of FEBs IDs for GEM A"), yaml::Property(&FebsIds::febsGemB, "febsGemB", "Mapping of FEBs IDs for GEM B"), yaml::Property(&FebsIds::febsRpc, "febsRpc", "Mapping of FEBs IDs forRPC"))
CBM_YAML_PROPERTIES(yaml::Property(&PadsConfig::channelToPadX, "channelToPadX", "X means CHANNEL for CbmMuchAddressA"), yaml::Property(&PadsConfig::channelToPadY, "channelToPadY", "Y means SECTOR for CbmMuchAddress"))
Readout setup / Hardware cabling for MUCH Used to create the hardware mapping for the MUCH unpacker.
std::vector< Component > components
CBM_YAML_PROPERTIES(yaml::Property(&ReadoutSetup::timeOffset, "timeOffset", "Time offset in ns of the MVD data relative to the reference/trigger"), yaml::Property(&ReadoutSetup::numAsicsPerFeb, "numAsicsPerFeb", "Number of ASICs per FEB"), yaml::Property(&ReadoutSetup::components, "components", "Components", {}, YAML::Flow), yaml::Property(&ReadoutSetup::febsMapping, "febsMapping", "FEBs mapping per detector", {}, YAML::Flow), yaml::Property(&ReadoutSetup::padsConfigGemA, "padsConfigGemA", "Mapping of channel to PAD for GEM A", {}, YAML::Flow), yaml::Property(&ReadoutSetup::padsConfigGemB, "padsConfigGemB", "Mapping of channel to PAD for GEM B", {}, YAML::Flow), yaml::Property(&ReadoutSetup::padsConfigRpc, "padsConfigRpc", "Mapping of channel to PAD for RPC", {}, YAML::Flow))