CbmRoot
Loading...
Searching...
No Matches
CbmTofAddress.h
Go to the documentation of this file.
1/* Copyright (C) 2013-2020 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Pierre-Alain Loizeau, Florian Uhlig [committer], Norbert Herrmann */
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
48class CbmTofAddress : public CbmAddress {
49public:
52
54 virtual ~CbmTofAddress() {};
55
60 static int32_t GetNofSmIdBits() { return fgkSmIdBits; };
64 static int32_t GetNofSmTypeBits() { return fgkSmTypeBits; };
68 static int32_t GetNofRpcIdBits() { return fgkRpcIdBits; };
72 static int32_t GetNofChannelIdBits() { return fgkChannelIdBits; };
76 static int32_t GetNofChSideBits() { return fgkChannelSideBits; };
77
83 static int32_t GetSmId(uint32_t address) { return ((address >> fgkSmIdOffset) & ((1 << fgkSmIdBits) - 1)); };
88 static int32_t GetSmType(uint32_t address) { return ((address >> fgkSmTypeOffset) & ((1 << fgkSmTypeBits) - 1)); };
93 static int32_t GetRpcId(uint32_t address) { return ((address >> fgkRpcIdOffset) & ((1 << fgkRpcIdBits) - 1)); };
98 static int32_t GetChannelId(uint32_t address)
99 {
100 return ((address >> fgkChannelIdOffset) & ((1 << fgkChannelIdBits) - 1));
101 };
106 static int32_t GetChannelSide(uint32_t address)
107 {
108 return ((address >> fgkChannelSideOffset) & ((1 << fgkChannelSideBits) - 1));
109 };
114 static int32_t GetModFullId(uint32_t address) { return (address & fgkiModFullIdMask); };
119 static int32_t GetRpcFullId(uint32_t address) { return (address & fgkiRpcFullIdMask); };
124 static int32_t GetStripFullId(uint32_t address) { return (address & fgkiStripFullIdMask); };
125
135 static uint32_t GetUniqueAddress(uint32_t Sm, uint32_t Rpc, uint32_t Channel, uint32_t Side = 0, uint32_t SmType = 0,
136 uint32_t RpcType = 0)
137 {
138 return (uint32_t)(((ToIntegralType(ECbmModuleId::kTof) & ((1 << fgkSystemBits) - 1)))
139 + ((Sm & ((1 << fgkSmIdBits) - 1)) << fgkSmIdOffset)
140 + ((SmType & ((1 << fgkSmTypeBits) - 1)) << fgkSmTypeOffset)
141 + ((Side & ((1 << fgkChannelSideBits) - 1)) << fgkChannelSideOffset)
142 + ((Rpc & ((1 << fgkRpcIdBits) - 1)) << fgkRpcIdOffset)
143 + ((Channel & ((1 << fgkChannelIdBits) - 1)) << fgkChannelIdOffset)
144 + ((RpcType & ((1 << fgkRpcTypeBits) - 1)) << fgkRpcTypeOffset));
145 };
146
147 static bool SameModule(uint32_t addressA, uint32_t addressB)
148 {
149 return (GetModFullId(addressA) == GetModFullId(addressB)) ? true : false;
150 };
151
153 {
154 // For now assume that the system ID will always be correct
155 // Otherwise would need including CbmDetectorList.h
156 // if( kTof != infoInput.fDetectorSystem)
157 // return 0;
158
159 return GetUniqueAddress(infoInput.fSModule, infoInput.fCounter, infoInput.fCell, 0, infoInput.fSMtype,
160 infoInput.fCounterType);
161 };
162 static uint32_t ConvertCbmTofDetectorId(int32_t detIdInput)
163 {
164 // For now assume that the system ID will always be correct
165 // Otherwise would need including CbmDetectorList.h
166 // if( kTof != CbmTofDetectorId::GetSystemId( detIdInput ) )
167 // return 0;
169 return GetUniqueAddress(detId.GetSModule(detIdInput), detId.GetCounter(detIdInput), detId.GetCell(detIdInput), 0,
170 detId.GetSMType(detIdInput));
171 };
172
173private:
181 // v14a
182 /*
183 // Number of bits for Super Module Id in the address field
184 static const int32_t fgkSmIdBits = 8;
185 // Number of bits for Super Module Type in the address field
186 static const int32_t fgkSmTypeBits = 4;
187 // Number of bits for Rpc Id in the address field
188 static const int32_t fgkRpcIdBits = 7;
189 // Number of bits for Channel Side in the address field
190 static const int32_t fgkChannelSideBits = 1;
191 // Number of bits for Channel Id in the address field
192 static const int32_t fgkChannelIdBits = 8;
193 // Number of bits for Rpc Type in the address field
194 static const int32_t fgkRpcTypeBits = 0;
195 */
196 // v21a
197 // Number of bits for Super Module Id in the address field
198 static const int32_t fgkSmIdBits = 7;
199 // Number of bits for Super Module Type in the address field
200 static const int32_t fgkSmTypeBits = 4;
201 // Number of bits for Rpc Id in the address field
202 static const int32_t fgkRpcIdBits = 6;
203 // Number of bits for Channel Side in the address field
204 static const int32_t fgkChannelSideBits = 1;
205 // Number of bits for Channel Id in the address field
206 static const int32_t fgkChannelIdBits = 6;
207 // Number of bits for Rpc Type in the address field
208 static const int32_t fgkRpcTypeBits = 4;
216 static const int32_t fgkSmIdOffset;
218 static const int32_t fgkSmTypeOffset;
220 static const int32_t fgkChannelSideOffset;
222 static const int32_t fgkRpcIdOffset;
224 static const int32_t fgkChannelIdOffset;
226 static const int32_t fgkRpcTypeOffset;
227
231 static const int32_t fgkiModFullIdMask;
232
236 static const int32_t fgkiRpcFullIdMask;
237
241 static const int32_t fgkiStripFullIdMask;
242};
243
244#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 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 uint32_t ConvertCbmTofDetectorInfo(CbmTofDetectorInfo infoInput)
static const int32_t fgkSmIdOffset
static uint32_t ConvertCbmTofDetectorId(int32_t detIdInput)
static int32_t GetSmId(uint32_t address)
static int32_t GetModFullId(uint32_t address)
static const int32_t fgkChannelIdBits
static const int32_t fgkSmTypeOffset
static const int32_t fgkRpcIdBits
static int32_t GetRpcId(uint32_t address)
static int32_t GetNofSmIdBits()
static bool SameModule(uint32_t addressA, uint32_t addressB)
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 int32_t GetNofChSideBits()
static int32_t GetNofRpcIdBits()
static int32_t GetChannelId(uint32_t address)
static const int32_t fgkChannelSideOffset
virtual ~CbmTofAddress()
static const int32_t fgkSmTypeBits
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)