CbmRoot
Loading...
Searching...
No Matches
CbmTofAddress.h
Go to the documentation of this file.
1/* Copyright (C) 2013-2025 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Pierre-Alain Loizeau, Florian Uhlig [committer], Norbert Herrmann, Sergei Zharko */
4
9
37
38#ifndef CBMTOFADDRESS_H
39#define CBMTOFADDRESS_H 1
40
41#include "CbmAddress.h" // for CbmAddress, CbmAddress::fgkSystem...
42#include "CbmDefs.h" // for kTof
43#include "CbmTofDetectorId.h" // for CbmTofDetectorInfo
44#include "CbmTofDetectorId_v12b.h" // for CbmTofDetectorId_v12b
45
46#include <cstdint>
47#include <string>
48
49class CbmTofAddress : public CbmAddress {
50 public:
53
55 virtual ~CbmTofAddress(){};
56
61 static int32_t GetSystemIdBitmask() { return fgkSystemIdBitmask; }
65 static int32_t GetSmIdBitmask() { return fgkSmIdBitmask; }
69 static int32_t GetSmTypeBitmask() { return fgkSmTypeBitmask; }
73 static int32_t GetRpcIdBitmask() { return fgkRpcIdBitmask; }
77 static int32_t GetChannelSideBitmask() { return fgkChannelSideBitmask; }
81 static int32_t GetChannelIdBitmask() { return fgkChannelIdBitmask; }
85 static int32_t GetRpcTypeBitmask() { return fgkRpcTypeBitmask; }
86
87
92 static int32_t GetNofSmIdBits() { return fgkSmIdBits; };
96 static int32_t GetNofSmTypeBits() { return fgkSmTypeBits; };
100 static int32_t GetNofRpcIdBits() { return fgkRpcIdBits; };
104 static int32_t GetNofChannelIdBits() { return fgkChannelIdBits; };
108 static int32_t GetNofChSideBits() { return fgkChannelSideBits; };
109
110
115 static int32_t GetSmIdOffset() { return fgkSmIdOffset; }
119 static int32_t GetSmTypeOffset() { return fgkSmTypeOffset; }
123 static int32_t GetRpcIdOffset() { return fgkRpcIdOffset; }
127 static int32_t GetChannelSideOffset() { return fgkChannelSideOffset; }
131 static int32_t GetChannelIdOffset() { return fgkChannelIdOffset; }
135 static int32_t GetRpcTypeOffset() { return fgkRpcTypeOffset; }
139 static uint32_t GetDetectorId(uint32_t address) { return GetRpcFullId(address); }
140
141
147 static int32_t GetSmId(uint32_t address) { return ((address >> fgkSmIdOffset) & ((1 << fgkSmIdBits) - 1)); };
152 static int32_t GetSmType(uint32_t address) { return ((address >> fgkSmTypeOffset) & ((1 << fgkSmTypeBits) - 1)); };
157 static int32_t GetRpcId(uint32_t address) { return ((address >> fgkRpcIdOffset) & ((1 << fgkRpcIdBits) - 1)); };
162 static int32_t GetRpcType(uint32_t address) { return ((address >> fgkRpcTypeOffset) & ((1 << fgkRpcTypeBits) - 1)); };
167 static int32_t GetChannelId(uint32_t address)
168 {
169 return ((address >> fgkChannelIdOffset) & ((1 << fgkChannelIdBits) - 1));
170 };
171
175 static int32_t GetChannelSide(uint32_t address)
176 {
177 return ((address >> fgkChannelSideOffset) & ((1 << fgkChannelSideBits) - 1));
178 };
179
183 static int32_t GetModFullId(uint32_t address) { return (address & fgkiModFullIdMask); };
188 static int32_t GetRpcFullId(uint32_t address) { return (address & fgkiRpcFullIdMask); };
193 static int32_t GetStripFullId(uint32_t address) { return (address & fgkiStripFullIdMask); };
194
204 static uint32_t GetUniqueAddress(uint32_t Sm, uint32_t Rpc, uint32_t Channel, uint32_t Side = 0, uint32_t SmType = 0,
205 uint32_t RpcType = 0)
206 {
207 return (uint32_t)(((ToIntegralType(ECbmModuleId::kTof) & ((1 << fgkSystemBits) - 1)))
208 + ((Sm & ((1 << fgkSmIdBits) - 1)) << fgkSmIdOffset)
209 + ((SmType & ((1 << fgkSmTypeBits) - 1)) << fgkSmTypeOffset)
210 + ((Side & ((1 << fgkChannelSideBits) - 1)) << fgkChannelSideOffset)
211 + ((Rpc & ((1 << fgkRpcIdBits) - 1)) << fgkRpcIdOffset)
212 + ((Channel & ((1 << fgkChannelIdBits) - 1)) << fgkChannelIdOffset)
213 + ((RpcType & ((1 << fgkRpcTypeBits) - 1)) << fgkRpcTypeOffset));
214 };
215
216 static bool SameModule(uint32_t addressA, uint32_t addressB)
217 {
218 return (GetModFullId(addressA) == GetModFullId(addressB)) ? true : false;
219 };
220
224 {
225 // For now assume that the system ID will always be correct
226 // Otherwise would need including CbmDetectorList.h
227 // if( kTof != infoInput.fDetectorSystem)
228 // return 0;
229
230 return GetUniqueAddress(infoInput.fSModule, infoInput.fCounter, infoInput.fCell, 0, infoInput.fSMtype,
231 infoInput.fCounterType);
232 };
233 static uint32_t ConvertCbmTofDetectorId(int32_t detIdInput)
234 {
235 // For now assume that the system ID will always be correct
236 // Otherwise would need including CbmDetectorList.h
237 // if( kTof != CbmTofDetectorId::GetSystemId( detIdInput ) )
238 // return 0;
240 return GetUniqueAddress(detId.GetSModule(detIdInput), detId.GetCounter(detIdInput), detId.GetCell(detIdInput), 0,
241 detId.GetSMType(detIdInput));
242 };
243
247 static std::string ToString(int32_t address);
248
249 private:
250 // FIXME: SZh 7.2.2025: Make these fields constexpr
255
257
258 // v14a
259 /*
260 // Number of bits for Super Module Id in the address field
261 static const int32_t fgkSmIdBits = 8;
262 // Number of bits for Super Module Type in the address field
263 static const int32_t fgkSmTypeBits = 4;
264 // Number of bits for Rpc Id in the address field
265 static const int32_t fgkRpcIdBits = 7;
266 // Number of bits for Channel Side in the address field
267 static const int32_t fgkChannelSideBits = 1;
268 // Number of bits for Channel Id in the address field
269 static const int32_t fgkChannelIdBits = 8;
270 // Number of bits for Rpc Type in the address field
271 static const int32_t fgkRpcTypeBits = 0;
272 */
273 // v21a
274 // Number of bits for Super Module Id in the address field
275 static const int32_t fgkSmIdBits = 7;
276 // Number of bits for Super Module Type in the address field
277 static const int32_t fgkSmTypeBits = 4;
278 // Number of bits for Rpc Id in the address field
279 static const int32_t fgkRpcIdBits = 6;
280 // Number of bits for Channel Side in the address field
281 static const int32_t fgkChannelSideBits = 1;
282 // Number of bits for Channel Id in the address field
283 static const int32_t fgkChannelIdBits = 6;
284 // Number of bits for Rpc Type in the address field
285 static const int32_t fgkRpcTypeBits = 4;
290
293 static const int32_t fgkSmIdOffset;
295 static const int32_t fgkSmTypeOffset;
297 static const int32_t fgkChannelSideOffset;
299 static const int32_t fgkRpcIdOffset;
301 static const int32_t fgkChannelIdOffset;
303 static const int32_t fgkRpcTypeOffset;
304
308 static const int32_t fgkiModFullIdMask;
309
313 static const int32_t fgkiRpcFullIdMask;
314
318 static const int32_t fgkiStripFullIdMask;
319
320
322 static const int32_t fgkSystemIdBitmask; //< A bitmask for System ID
323 static const int32_t fgkSmIdBitmask; //< A bitmask for SM
324 static const int32_t fgkSmTypeBitmask; //< A bitmask for SM Type
325 static const int32_t fgkRpcIdBitmask; //< A bitmask for RPC ID
326 static const int32_t fgkChannelSideBitmask; //< A bitmask for Channel Side
327 static const int32_t fgkChannelIdBitmask; //< A bitmask for Channel ID
328 static const int32_t fgkRpcTypeBitmask; //< A bitmask for RPC Type
329};
330
331#endif // CBMTOFADDRESS_H
XPU_D constexpr auto ToIntegralType(T enumerator) -> typename std::underlying_type< T >::type
Converts an element of enum class to its underlying integral type.
Definition CbmDefs.h:33
@ kTof
Time-of-flight Detector.
Definition CbmDefs.h:52
static const int32_t fgkSystemBits
Definition CbmAddress.h:52
static int32_t GetSmIdOffset()
static const int32_t fgkSmIdBits
static int32_t GetNofChannelIdBits()
static const int32_t fgkRpcTypeBits
static const int32_t fgkChannelIdOffset
static const int32_t fgkiRpcFullIdMask
static const int32_t fgkRpcIdOffset
static uint32_t GetUniqueAddress(uint32_t Sm, uint32_t Rpc, uint32_t Channel, uint32_t Side=0, uint32_t SmType=0, uint32_t RpcType=0)
static const int32_t fgkChannelSideBits
static const int32_t fgkiModFullIdMask
static const int32_t fgkSmTypeBitmask
static int32_t GetSystemIdBitmask()
static const int32_t fgkChannelSideBitmask
static int32_t GetChannelIdOffset()
static uint32_t ConvertCbmTofDetectorInfo(CbmTofDetectorInfo infoInput)
Sets the channel ID to the address.
static int32_t GetSmIdBitmask()
static const int32_t fgkSmIdOffset
static int32_t GetRpcType(uint32_t address)
static uint32_t ConvertCbmTofDetectorId(int32_t detIdInput)
static int32_t GetSmId(uint32_t address)
static int32_t GetSmTypeBitmask()
static int32_t GetModFullId(uint32_t address)
static const int32_t fgkChannelIdBits
static const int32_t fgkSmTypeOffset
static const int32_t fgkRpcTypeBitmask
static const int32_t fgkRpcIdBits
static int32_t GetRpcId(uint32_t address)
static const int32_t fgkSmIdBitmask
static const int32_t fgkRpcIdBitmask
static int32_t GetNofSmIdBits()
static uint32_t GetDetectorId(uint32_t address)
Gets detectorId - address of minimal alignable volume.
static bool SameModule(uint32_t addressA, uint32_t addressB)
static const int32_t fgkChannelIdBitmask
static int32_t GetRpcTypeOffset()
static int32_t GetRpcIdOffset()
static const int32_t fgkSystemIdBitmask
static int32_t GetStripFullId(uint32_t address)
static int32_t GetNofSmTypeBits()
static int32_t GetSmType(uint32_t address)
static int32_t GetRpcFullId(uint32_t address)
static int32_t GetChannelSide(uint32_t address)
static const int32_t fgkiStripFullIdMask
static std::string ToString(int32_t address)
static int32_t GetNofChSideBits()
static int32_t GetNofRpcIdBits()
static int32_t GetChannelSideBitmask()
static int32_t GetChannelId(uint32_t address)
static const int32_t fgkChannelSideOffset
virtual ~CbmTofAddress()
static int32_t GetChannelIdBitmask()
static int32_t GetChannelSideOffset()
static int32_t GetRpcTypeBitmask()
static int32_t GetSmTypeOffset()
static const int32_t fgkSmTypeBits
static int32_t GetRpcIdBitmask()
static const int32_t fgkRpcTypeOffset
int32_t GetCounter(const int32_t detectorId)
int32_t GetSModule(const int32_t detectorId)
int32_t GetSMType(const int32_t detectorId)
int32_t GetCell(const int32_t detectorId)