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
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 {
50public:
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; }
136
142 static int32_t GetSmId(uint32_t address) { return ((address >> fgkSmIdOffset) & ((1 << fgkSmIdBits) - 1)); };
147 static int32_t GetSmType(uint32_t address) { return ((address >> fgkSmTypeOffset) & ((1 << fgkSmTypeBits) - 1)); };
152 static int32_t GetRpcId(uint32_t address) { return ((address >> fgkRpcIdOffset) & ((1 << fgkRpcIdBits) - 1)); };
157 static int32_t GetRpcType(uint32_t address) { return ((address >> fgkRpcTypeOffset) & ((1 << fgkRpcTypeBits) - 1)); };
162 static int32_t GetChannelId(uint32_t address)
163 {
164 return ((address >> fgkChannelIdOffset) & ((1 << fgkChannelIdBits) - 1));
165 };
170 static int32_t GetChannelSide(uint32_t address)
171 {
172 return ((address >> fgkChannelSideOffset) & ((1 << fgkChannelSideBits) - 1));
173 };
178 static int32_t GetModFullId(uint32_t address) { return (address & fgkiModFullIdMask); };
183 static int32_t GetRpcFullId(uint32_t address) { return (address & fgkiRpcFullIdMask); };
188 static int32_t GetStripFullId(uint32_t address) { return (address & fgkiStripFullIdMask); };
189
199 static uint32_t GetUniqueAddress(uint32_t Sm, uint32_t Rpc, uint32_t Channel, uint32_t Side = 0, uint32_t SmType = 0,
200 uint32_t RpcType = 0)
201 {
202 return (uint32_t)(((ToIntegralType(ECbmModuleId::kTof) & ((1 << fgkSystemBits) - 1)))
203 + ((Sm & ((1 << fgkSmIdBits) - 1)) << fgkSmIdOffset)
204 + ((SmType & ((1 << fgkSmTypeBits) - 1)) << fgkSmTypeOffset)
205 + ((Side & ((1 << fgkChannelSideBits) - 1)) << fgkChannelSideOffset)
206 + ((Rpc & ((1 << fgkRpcIdBits) - 1)) << fgkRpcIdOffset)
207 + ((Channel & ((1 << fgkChannelIdBits) - 1)) << fgkChannelIdOffset)
208 + ((RpcType & ((1 << fgkRpcTypeBits) - 1)) << fgkRpcTypeOffset));
209 };
210
211 static bool SameModule(uint32_t addressA, uint32_t addressB)
212 {
213 return (GetModFullId(addressA) == GetModFullId(addressB)) ? true : false;
214 };
219 {
220 // For now assume that the system ID will always be correct
221 // Otherwise would need including CbmDetectorList.h
222 // if( kTof != infoInput.fDetectorSystem)
223 // return 0;
224
225 return GetUniqueAddress(infoInput.fSModule, infoInput.fCounter, infoInput.fCell, 0, infoInput.fSMtype,
226 infoInput.fCounterType);
227 };
228 static uint32_t ConvertCbmTofDetectorId(int32_t detIdInput)
229 {
230 // For now assume that the system ID will always be correct
231 // Otherwise would need including CbmDetectorList.h
232 // if( kTof != CbmTofDetectorId::GetSystemId( detIdInput ) )
233 // return 0;
235 return GetUniqueAddress(detId.GetSModule(detIdInput), detId.GetCounter(detIdInput), detId.GetCell(detIdInput), 0,
236 detId.GetSMType(detIdInput));
237 };
242 static std::string ToString(int32_t address);
243
244 private:
245 // FIXME: SZh 7.2.2025: Make these fields constexpr
253 // v14a
254 /*
255 // Number of bits for Super Module Id in the address field
256 static const int32_t fgkSmIdBits = 8;
257 // Number of bits for Super Module Type in the address field
258 static const int32_t fgkSmTypeBits = 4;
259 // Number of bits for Rpc Id in the address field
260 static const int32_t fgkRpcIdBits = 7;
261 // Number of bits for Channel Side in the address field
262 static const int32_t fgkChannelSideBits = 1;
263 // Number of bits for Channel Id in the address field
264 static const int32_t fgkChannelIdBits = 8;
265 // Number of bits for Rpc Type in the address field
266 static const int32_t fgkRpcTypeBits = 0;
267 */
268 // v21a
269 // Number of bits for Super Module Id in the address field
270 static const int32_t fgkSmIdBits = 7;
271 // Number of bits for Super Module Type in the address field
272 static const int32_t fgkSmTypeBits = 4;
273 // Number of bits for Rpc Id in the address field
274 static const int32_t fgkRpcIdBits = 6;
275 // Number of bits for Channel Side in the address field
276 static const int32_t fgkChannelSideBits = 1;
277 // Number of bits for Channel Id in the address field
278 static const int32_t fgkChannelIdBits = 6;
279 // Number of bits for Rpc Type in the address field
280 static const int32_t fgkRpcTypeBits = 4;
288 static const int32_t fgkSmIdOffset;
290 static const int32_t fgkSmTypeOffset;
292 static const int32_t fgkChannelSideOffset;
294 static const int32_t fgkRpcIdOffset;
296 static const int32_t fgkChannelIdOffset;
298 static const int32_t fgkRpcTypeOffset;
299
303 static const int32_t fgkiModFullIdMask;
304
308 static const int32_t fgkiRpcFullIdMask;
309
313 static const int32_t fgkiStripFullIdMask;
314
315
317 static const int32_t fgkSystemIdBitmask; //< A bitmask for System ID
318 static const int32_t fgkSmIdBitmask; //< A bitmask for SM
319 static const int32_t fgkSmTypeBitmask; //< A bitmask for SM Type
320 static const int32_t fgkRpcIdBitmask; //< A bitmask for RPC ID
321 static const int32_t fgkChannelSideBitmask; //< A bitmask for Channel Side
322 static const int32_t fgkChannelIdBitmask; //< A bitmask for Channel ID
323 static const int32_t fgkRpcTypeBitmask; //< A bitmask for RPC Type
324};
325
326#endif // CBMTOFADDRESS_H
XPU_D constexpr auto ToIntegralType(T enumerator) -> typename std::underlying_type< T >::type
Definition CbmDefs.h:29
@ kTof
Time-of-flight Detector.
Base class for interfaces to the unique address.
Definition CbmAddress.h:27
static const int32_t fgkSystemBits
Definition CbmAddress.h:52
CBM ToF interface class to the unique address.
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 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)