CbmRoot
Loading...
Searching...
No Matches
CbmMustAddress.h
Go to the documentation of this file.
1/* Copyright (C) 2025 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Radoslaw Karabowicz [committer] */
4
5#ifndef CBMMUSTADDRESS_H
6#define CBMMUSTADDRESS_H 1
7
8#include "CbmAddress.h" // for CbmAddress
9
10#ifndef NO_ROOT
11#include <Rtypes.h> // for ClassDef
12#endif
13
14#include <cstdint>
20
31
32
52class CbmMustAddress : public CbmAddress {
53
54 public:
62 static uint32_t GetAddress(int32_t station = 0, int32_t layer = 0, int32_t module = 0, int32_t tube = 0);
63
64
65 static uint32_t GetAddress(int32_t* elementIds);
66
67
72 static int32_t GetNofLevels() { return kMustNofLevels; }
73
74
79 static int32_t GetNofBits(int32_t level) { return (level >= 0 && level < kMustNofLevels) ? fgkBits[level] : 0; }
80
81
87 static int32_t GetElementId(uint32_t address, int32_t level)
88 {
89 return (level >= 0 && level < kMustNofLevels) ? ((address & (fgkMask[level] << fgkShift[level])) >> fgkShift[level])
90 : -1;
91 }
92
94 static int32_t GetSystemIndex(int32_t address) { return GetElementId(address, kMustSystem); }
95 static int32_t GetStationIndex(int32_t address) { return GetElementId(address, kMustStation); }
96 static int32_t GetLayerIndex(int32_t address) { return GetElementId(address, kMustLayer); }
97 static int32_t GetModuleIndex(int32_t address) { return GetElementId(address, kMustModule); }
98 static int32_t GetTubeIndex(int32_t address) { return GetElementId(address, kMustTube); }
99
100 static int32_t GetElementAddress(int32_t address, int32_t level)
101 {
102 int32_t mask = (1 << (CbmMustAddress::fgkShift[level] + CbmMustAddress::fgkBits[level])) - 1;
103 return address & mask;
104 }
105
107 static void Print();
108
109
117 static uint32_t SetElementId(uint32_t address, int32_t level, int32_t newId);
118
119 private:
121 static const int32_t fgkBits[kMustNofLevels];
122
124 static const int32_t fgkShift[kMustNofLevels];
125
127 static const int32_t fgkMask[kMustNofLevels];
128
129
130#ifndef NO_ROOT
132#endif
133};
134
135
136#endif /* CBMMUSTADDRESS_H */
MustElementLevel
@ kMustStation
Station.
@ kMustSystem
System = MuST.
@ kMustModule
Module.
@ kMustTube
Tube.
@ kMustLayer
Layer.
@ kMustNofLevels
Number of MuST levels.
Interface class to unique address for the MuST.
static uint32_t SetElementId(uint32_t address, int32_t level, int32_t newId)
static uint32_t GetAddress(int32_t station=0, int32_t layer=0, int32_t module=0, int32_t tube=0)
static int32_t GetSystemIndex(int32_t address)
static int32_t GetElementId(uint32_t address, int32_t level)
static int32_t GetTubeIndex(int32_t address)
static const int32_t fgkMask[kMustNofLevels]
static int32_t GetNofLevels()
static int32_t GetStationIndex(int32_t address)
static int32_t GetLayerIndex(int32_t address)
static int32_t GetModuleIndex(int32_t address)
ClassDef(CbmMustAddress, 1)
static int32_t GetNofBits(int32_t level)
static const int32_t fgkBits[kMustNofLevels]
static const int32_t fgkShift[kMustNofLevels]
static void Print()
static int32_t GetElementAddress(int32_t address, int32_t level)