CbmRoot
Loading...
Searching...
No Matches
CbmTrdAddress.h
Go to the documentation of this file.
1/* Copyright (C) 2009-2020 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Andrey Lebedev, Florian Uhlig [committer] */
4
24#ifndef CBMTRDDETECTORID_H
25#define CBMTRDDETECTORID_H 1
26
27#include "CbmDefs.h" // for kTrd
28
29#include <cassert> // for assert
30#include <cstdint>
31
32
34public:
44 static uint32_t GetAddress(int32_t layerId, int32_t moduleId, int32_t sectorId, int32_t rowId, int32_t columnId)
45 {
46 assert(!(layerId < 0 || layerId > fgkLayerIdLength || moduleId < 0 || moduleId > fgkModuleIdLength || sectorId < 0
47 || sectorId > fgkSectorIdLength || rowId < 0 || rowId > fgkRowIdLength || columnId < 0
48 || columnId > fgkColumnIdLength));
50 | (moduleId << fgkModuleIdShift) | (sectorId << fgkSectorIdShift) | (rowId << fgkRowIdShift)
51 | (columnId << fgkColumnIdShift);
52 }
53
59 static uint32_t GetSystemId(uint32_t address)
60 {
61 return (address & (fgkSystemIdLength << fgkSystemIdShift)) >> fgkSystemIdShift;
62 }
63
69 static uint32_t GetLayerId(uint32_t address)
70 {
71 return (address & (fgkLayerIdLength << fgkLayerIdShift)) >> fgkLayerIdShift;
72 }
73
79 static uint32_t GetModuleId(uint32_t address)
80 {
81 return (address & (fgkModuleIdLength << fgkModuleIdShift)) >> fgkModuleIdShift;
82 }
83
89 static uint32_t GetSectorId(uint32_t address)
90 {
91 return (address & (fgkSectorIdLength << fgkSectorIdShift)) >> fgkSectorIdShift;
92 }
93
99 static uint32_t GetRowId(uint32_t address) { return (address & (fgkRowIdLength << fgkRowIdShift)) >> fgkRowIdShift; }
100
106 static uint32_t GetColumnId(uint32_t address)
107 {
108 return (address & (fgkColumnIdLength << fgkColumnIdShift)) >> fgkColumnIdShift;
109 }
110
116 static uint32_t GetModuleAddress(uint32_t address)
117 {
119 }
120
126 static uint32_t GetSectorAddress(uint32_t address)
127 {
129 }
130
137 static uint32_t SetLayerId(uint32_t address, int32_t newLayerId)
138 {
139 assert(!(newLayerId < 0 || newLayerId > fgkLayerIdLength));
140 return GetAddress(newLayerId, GetModuleId(address), GetSectorId(address), GetRowId(address), GetColumnId(address));
141 }
142
149 static uint32_t SetModuleId(uint32_t address, int32_t newModuleId)
150 {
151 assert(!(newModuleId < 0 || newModuleId > fgkModuleIdLength));
152 return GetAddress(GetLayerId(address), newModuleId, GetSectorId(address), GetRowId(address), GetColumnId(address));
153 }
154
161 static uint32_t SetSectorId(uint32_t address, int32_t newSectorId)
162 {
163 assert(!(newSectorId < 0 || newSectorId > fgkSectorIdLength));
164 return GetAddress(GetLayerId(address), GetModuleId(address), newSectorId, GetRowId(address), GetColumnId(address));
165 }
166
173 static uint32_t SetRowId(uint32_t address, int32_t newRowId)
174 {
175 assert(!(newRowId < 0 || newRowId > fgkRowIdLength));
176 return GetAddress(GetLayerId(address), GetModuleId(address), GetSectorId(address), newRowId, GetColumnId(address));
177 }
178
185 static uint32_t SetColumnId(uint32_t address, int32_t newColumnId)
186 {
187 assert(!(newColumnId < 0 || newColumnId > fgkColumnIdLength));
188 return GetAddress(GetLayerId(address), GetModuleId(address), GetSectorId(address), GetRowId(address), newColumnId);
189 }
190
191private:
192 // Length of the index of the corresponding volume
193 static const int32_t fgkSystemIdLength = 15; // 2^4 - 1
194 static const int32_t fgkLayerIdLength = 15; // 2^4 - 1
195 static const int32_t fgkModuleIdLength = 127; // 2^7 - 1
196 static const int32_t fgkSectorIdLength = 3; // 2^2 - 1
197 static const int32_t fgkRowIdLength = 127; // 2^7 - 1
198 static const int32_t fgkColumnIdLength = 255; // 2^8 - 1
199 // Number of a start bit for each volume
200 static const int32_t fgkSystemIdShift = 0;
201 static const int32_t fgkLayerIdShift = 4;
202 static const int32_t fgkModuleIdShift = 8;
203 static const int32_t fgkSectorIdShift = 15;
204 static const int32_t fgkRowIdShift = 17;
205 static const int32_t fgkColumnIdShift = 24;
206 // Start bit and length for unique module address.
207 // For unique module address use all bits up to sector ID.
208 static const int32_t fgkModuleAddressStart = 0;
209 static const int32_t fgkModuleAddressLength = 32767; // 2^15 - 1
210 // Start bit and length for unique sector address.
211 // For unique sector address use all bits up to column ID.
212 static const int32_t fgkSectorAddressStart = 0;
213 static const int32_t fgkSectorAddressLength = 131071; // 2^17 - 1
214};
215
216#endif
XPU_D constexpr auto ToIntegralType(T enumerator) -> typename std::underlying_type< T >::type
Definition CbmDefs.h:29
@ kTrd
Transition Radiation Detector.
static uint32_t SetRowId(uint32_t address, int32_t newRowId)
Set new row ID for address.
static uint32_t GetModuleId(uint32_t address)
Return module ID from address.
static uint32_t GetSectorId(uint32_t address)
Return sector ID from address.
static uint32_t SetColumnId(uint32_t address, int32_t newColumnId)
Set new column ID for address.
static uint32_t SetModuleId(uint32_t address, int32_t newModuleId)
Set new module ID for address.
static uint32_t GetColumnId(uint32_t address)
Return column ID from address.
static const int32_t fgkSystemIdLength
static const int32_t fgkModuleAddressStart
static const int32_t fgkColumnIdShift
static const int32_t fgkRowIdLength
static uint32_t GetLayerId(uint32_t address)
Return layer ID from address.
static const int32_t fgkSystemIdShift
static const int32_t fgkColumnIdLength
static uint32_t SetSectorId(uint32_t address, int32_t newSectorId)
Set new sector ID for address.
static uint32_t SetLayerId(uint32_t address, int32_t newLayerId)
Set new layer ID for address.
static const int32_t fgkModuleIdShift
static const int32_t fgkRowIdShift
static uint32_t GetModuleAddress(uint32_t address)
Return unique module ID from address.
static const int32_t fgkSectorAddressLength
static const int32_t fgkModuleIdLength
static const int32_t fgkModuleAddressLength
static const int32_t fgkSectorIdLength
static uint32_t GetAddress(int32_t layerId, int32_t moduleId, int32_t sectorId, int32_t rowId, int32_t columnId)
Return address from system ID, layer, module, sector, column and row IDs.
static const int32_t fgkLayerIdShift
static const int32_t fgkSectorAddressStart
static const int32_t fgkLayerIdLength
static uint32_t GetSectorAddress(uint32_t address)
Return unique sector ID from address.
static uint32_t GetRowId(uint32_t address)
Return row ID from address.
static uint32_t GetSystemId(uint32_t address)
Return System identifier from address.
static const int32_t fgkSectorIdShift