CbmRoot
CbmTrdAddress.h
Go to the documentation of this file.
1 
20 #ifndef CBMTRDDETECTORID_H
21 #define CBMTRDDETECTORID_H 1
22 
23 #include "CbmDefs.h" // for kTrd
24 #include <RtypesCore.h> // for UInt_t, Int_t
25 #include <cassert> // for assert
26 
28 public:
38  static UInt_t GetAddress(Int_t layerId,
39  Int_t moduleId,
40  Int_t sectorId,
41  Int_t rowId,
42  Int_t columnId) {
43  assert(!(layerId < 0 || layerId > fgkLayerIdLength || moduleId < 0
44  || moduleId > fgkModuleIdLength || sectorId < 0
45  || sectorId > fgkSectorIdLength || rowId < 0
46  || rowId > fgkRowIdLength || columnId < 0
47  || columnId > fgkColumnIdLength));
49  | (layerId << fgkLayerIdShift) | (moduleId << fgkModuleIdShift)
50  | (sectorId << fgkSectorIdShift) | (rowId << fgkRowIdShift)
51  | (columnId << fgkColumnIdShift);
52  }
53 
59  static UInt_t GetSystemId(UInt_t address) {
60  return (address & (fgkSystemIdLength << fgkSystemIdShift))
62  }
63 
69  static UInt_t GetLayerId(UInt_t address) {
70  return (address & (fgkLayerIdLength << fgkLayerIdShift)) >> fgkLayerIdShift;
71  }
72 
78  static UInt_t GetModuleId(UInt_t address) {
79  return (address & (fgkModuleIdLength << fgkModuleIdShift))
81  }
82 
88  static UInt_t GetSectorId(UInt_t address) {
89  return (address & (fgkSectorIdLength << fgkSectorIdShift))
91  }
92 
98  static UInt_t GetRowId(UInt_t address) {
99  return (address & (fgkRowIdLength << fgkRowIdShift)) >> fgkRowIdShift;
100  }
101 
107  static UInt_t GetColumnId(UInt_t address) {
108  return (address & (fgkColumnIdLength << fgkColumnIdShift))
109  >> fgkColumnIdShift;
110  }
111 
117  static UInt_t GetModuleAddress(UInt_t address) {
118  return (address & (fgkModuleAddressLength << fgkModuleAddressStart))
120  }
121 
127  static UInt_t GetSectorAddress(UInt_t address) {
128  return (address & (fgkSectorAddressLength << fgkSectorAddressStart))
130  }
131 
138  static UInt_t SetLayerId(UInt_t address, Int_t newLayerId) {
139  assert(!(newLayerId < 0 || newLayerId > fgkLayerIdLength));
140  return GetAddress(newLayerId,
141  GetModuleId(address),
142  GetSectorId(address),
143  GetRowId(address),
144  GetColumnId(address));
145  }
146 
153  static UInt_t SetModuleId(UInt_t address, Int_t newModuleId) {
154  assert(!(newModuleId < 0 || newModuleId > fgkModuleIdLength));
155  return GetAddress(GetLayerId(address),
156  newModuleId,
157  GetSectorId(address),
158  GetRowId(address),
159  GetColumnId(address));
160  }
161 
168  static UInt_t SetSectorId(UInt_t address, Int_t newSectorId) {
169  assert(!(newSectorId < 0 || newSectorId > fgkSectorIdLength));
170  return GetAddress(GetLayerId(address),
171  GetModuleId(address),
172  newSectorId,
173  GetRowId(address),
174  GetColumnId(address));
175  }
176 
183  static UInt_t SetRowId(UInt_t address, Int_t newRowId) {
184  assert(!(newRowId < 0 || newRowId > fgkRowIdLength));
185  return GetAddress(GetLayerId(address),
186  GetModuleId(address),
187  GetSectorId(address),
188  newRowId,
189  GetColumnId(address));
190  }
191 
198  static UInt_t SetColumnId(UInt_t address, Int_t newColumnId) {
199  assert(!(newColumnId < 0 || newColumnId > fgkColumnIdLength));
200  return GetAddress(GetLayerId(address),
201  GetModuleId(address),
202  GetSectorId(address),
203  GetRowId(address),
204  newColumnId);
205  }
206 
207 private:
208  // Length of the index of the corresponding volume
209  static const Int_t fgkSystemIdLength = 15; // 2^4 - 1
210  static const Int_t fgkLayerIdLength = 15; // 2^4 - 1
211  static const Int_t fgkModuleIdLength = 127; // 2^7 - 1
212  static const Int_t fgkSectorIdLength = 3; // 2^2 - 1
213  static const Int_t fgkRowIdLength = 127; // 2^7 - 1
214  static const Int_t fgkColumnIdLength = 255; // 2^8 - 1
215  // Number of a start bit for each volume
216  static const Int_t fgkSystemIdShift = 0;
217  static const Int_t fgkLayerIdShift = 4;
218  static const Int_t fgkModuleIdShift = 8;
219  static const Int_t fgkSectorIdShift = 15;
220  static const Int_t fgkRowIdShift = 17;
221  static const Int_t fgkColumnIdShift = 24;
222  // Start bit and length for unique module address.
223  // For unique module address use all bits up to sector ID.
224  static const Int_t fgkModuleAddressStart = 0;
225  static const Int_t fgkModuleAddressLength = 32767; // 2^15 - 1
226  // Start bit and length for unique sector address.
227  // For unique sector address use all bits up to column ID.
228  static const Int_t fgkSectorAddressStart = 0;
229  static const Int_t fgkSectorAddressLength = 131071; // 2^17 - 1
230 };
231 
232 #endif
CbmTrdAddress::fgkRowIdShift
static const Int_t fgkRowIdShift
Definition: CbmTrdAddress.h:220
CbmTrdAddress::GetModuleAddress
static UInt_t GetModuleAddress(UInt_t address)
Return unique module ID from address.
Definition: CbmTrdAddress.h:117
CbmTrdAddress::fgkLayerIdShift
static const Int_t fgkLayerIdShift
Definition: CbmTrdAddress.h:217
CbmTrdAddress::GetAddress
static UInt_t GetAddress(Int_t layerId, Int_t moduleId, Int_t sectorId, Int_t rowId, Int_t columnId)
Return address from system ID, layer, module, sector, column and row IDs.
Definition: CbmTrdAddress.h:38
CbmTrdAddress::fgkColumnIdShift
static const Int_t fgkColumnIdShift
Definition: CbmTrdAddress.h:221
CbmTrdAddress::GetSystemId
static UInt_t GetSystemId(UInt_t address)
Return System identifier from address.
Definition: CbmTrdAddress.h:59
CbmTrdAddress::GetSectorId
static UInt_t GetSectorId(UInt_t address)
Return sector ID from address.
Definition: CbmTrdAddress.h:88
CbmTrdAddress::SetLayerId
static UInt_t SetLayerId(UInt_t address, Int_t newLayerId)
Set new layer ID for address.
Definition: CbmTrdAddress.h:138
CbmTrdAddress::GetLayerId
static UInt_t GetLayerId(UInt_t address)
Return layer ID from address.
Definition: CbmTrdAddress.h:69
CbmTrdAddress::fgkModuleAddressStart
static const Int_t fgkModuleAddressStart
Definition: CbmTrdAddress.h:224
CbmTrdAddress::GetModuleId
static UInt_t GetModuleId(UInt_t address)
Return module ID from address.
Definition: CbmTrdAddress.h:78
CbmTrdAddress::SetSectorId
static UInt_t SetSectorId(UInt_t address, Int_t newSectorId)
Set new sector ID for address.
Definition: CbmTrdAddress.h:168
CbmTrdAddress::fgkModuleAddressLength
static const Int_t fgkModuleAddressLength
Definition: CbmTrdAddress.h:225
CbmTrdAddress::SetColumnId
static UInt_t SetColumnId(UInt_t address, Int_t newColumnId)
Set new column ID for address.
Definition: CbmTrdAddress.h:198
CbmTrdAddress::fgkSystemIdShift
static const Int_t fgkSystemIdShift
Definition: CbmTrdAddress.h:216
CbmTrdAddress::fgkSectorAddressStart
static const Int_t fgkSectorAddressStart
Definition: CbmTrdAddress.h:228
CbmTrdAddress
Definition: CbmTrdAddress.h:27
CbmTrdAddress::GetSectorAddress
static UInt_t GetSectorAddress(UInt_t address)
Return unique sector ID from address.
Definition: CbmTrdAddress.h:127
CbmTrdAddress::fgkRowIdLength
static const Int_t fgkRowIdLength
Definition: CbmTrdAddress.h:213
ECbmModuleId::kTrd
@ kTrd
Transition Radiation Detector.
CbmTrdAddress::fgkModuleIdShift
static const Int_t fgkModuleIdShift
Definition: CbmTrdAddress.h:218
CbmTrdAddress::fgkSectorAddressLength
static const Int_t fgkSectorAddressLength
Definition: CbmTrdAddress.h:229
CbmTrdAddress::fgkSectorIdLength
static const Int_t fgkSectorIdLength
Definition: CbmTrdAddress.h:212
ToIntegralType
constexpr auto ToIntegralType(T enumerator) -> typename std::underlying_type< T >::type
Definition: CbmDefs.h:24
CbmTrdAddress::fgkLayerIdLength
static const Int_t fgkLayerIdLength
Definition: CbmTrdAddress.h:210
CbmTrdAddress::fgkSectorIdShift
static const Int_t fgkSectorIdShift
Definition: CbmTrdAddress.h:219
CbmTrdAddress::SetRowId
static UInt_t SetRowId(UInt_t address, Int_t newRowId)
Set new row ID for address.
Definition: CbmTrdAddress.h:183
CbmTrdAddress::fgkModuleIdLength
static const Int_t fgkModuleIdLength
Definition: CbmTrdAddress.h:211
CbmTrdAddress::SetModuleId
static UInt_t SetModuleId(UInt_t address, Int_t newModuleId)
Set new module ID for address.
Definition: CbmTrdAddress.h:153
CbmTrdAddress::fgkSystemIdLength
static const Int_t fgkSystemIdLength
Definition: CbmTrdAddress.h:209
CbmTrdAddress::fgkColumnIdLength
static const Int_t fgkColumnIdLength
Definition: CbmTrdAddress.h:214
CbmTrdAddress::GetRowId
static UInt_t GetRowId(UInt_t address)
Return row ID from address.
Definition: CbmTrdAddress.h:98
CbmTrdAddress::GetColumnId
static UInt_t GetColumnId(UInt_t address)
Return column ID from address.
Definition: CbmTrdAddress.h:107
CbmDefs.h