CbmRoot
Loading...
Searching...
No Matches
CbmMuchAddress.h
Go to the documentation of this file.
1/* Copyright (C) 2013-2020 Petersburg Nuclear Physics Institute named by B.P.Konstantinov of National Research Centre "Kurchatov Institute", Gatchina
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Evgeny Kryshen [committer] */
4
5#ifndef CBMMUCHADDRESS_H
6#define CBMMUCHADDRESS_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>
15
21{
55class CbmMuchAddress : public CbmAddress {
56
57public:
67 static uint32_t GetAddress(int32_t station = 0, int32_t layer = 0, int32_t side = 0, int32_t module = 0,
68 int32_t sector = 0, int32_t channel = 0);
69
70
71 static uint32_t GetAddress(int32_t* elementIds);
72
73
78 static int32_t GetNofLevels() { return kMuchNofLevels; }
79
80
85 static int32_t GetNofBits(int32_t level)
86 {
87 if (level < 0 || level >= kMuchNofLevels) return 0;
88 return fgkBits[level];
89 }
90
91
97 static int32_t GetElementId(uint32_t address, int32_t level)
98 {
99 if (level < 0 || level >= kMuchNofLevels) return -1;
100 return (address & (fgkMask[level] << fgkShift[level])) >> fgkShift[level];
101 }
102
104 static int32_t GetSystemIndex(int32_t address) { return GetElementId(address, kMuchSystem); }
105 static int32_t GetStationIndex(int32_t address) { return GetElementId(address, kMuchStation); }
106 static int32_t GetLayerIndex(int32_t address) { return GetElementId(address, kMuchLayer); }
107 static int32_t GetLayerSideIndex(int32_t address) { return GetElementId(address, kMuchLayerSide); }
108 static int32_t GetModuleIndex(int32_t address) { return GetElementId(address, kMuchModule); }
109 static int32_t GetSectorIndex(int32_t address) { return GetElementId(address, kMuchSector); }
110 static int32_t GetChannelIndex(int32_t address) { return GetElementId(address, kMuchChannel); }
111
112 static int32_t GetElementAddress(int32_t address, int32_t level)
113 {
114 int32_t mask = (1 << (CbmMuchAddress::fgkShift[level] + CbmMuchAddress::fgkBits[level])) - 1;
115 return address & mask;
116 }
117
119 static void Print();
120
121
129 static uint32_t SetElementId(uint32_t address, int32_t level, int32_t newId);
130
131private:
133 static const int32_t fgkBits[kMuchNofLevels];
134
136 static const int32_t fgkShift[kMuchNofLevels];
137
139 static const int32_t fgkMask[kMuchNofLevels];
140
141
142#ifndef NO_ROOT
144#endif
145};
146
147
148#endif /* CBMMUCHADDRESS_H */
MuchElementLevel
@ kMuchNofLevels
Number of MUCH levels.
@ kMuchLayerSide
LayerSide.
@ kMuchStation
Station.
@ kMuchSector
Sector.
@ kMuchChannel
Channel.
@ kMuchSystem
System = MUCH.
@ kMuchModule
Module.
@ kMuchLayer
Layer.
Base class for interfaces to the unique address.
Definition CbmAddress.h:27
Interface class to unique address for the MUCH.
static const int32_t fgkBits[kMuchNofLevels]
ClassDef(CbmMuchAddress, 1)
static int32_t GetModuleIndex(int32_t address)
static void Print()
static int32_t GetSectorIndex(int32_t address)
static uint32_t SetElementId(uint32_t address, int32_t level, int32_t newId)
static const int32_t fgkMask[kMuchNofLevels]
static const int32_t fgkShift[kMuchNofLevels]
static int32_t GetChannelIndex(int32_t address)
static int32_t GetLayerIndex(int32_t address)
static int32_t GetLayerSideIndex(int32_t address)
static int32_t GetNofBits(int32_t level)
static int32_t GetNofLevels()
static int32_t GetElementAddress(int32_t address, int32_t level)
static int32_t GetSystemIndex(int32_t address)
static uint32_t GetAddress(int32_t station=0, int32_t layer=0, int32_t side=0, int32_t module=0, int32_t sector=0, int32_t channel=0)
static int32_t GetStationIndex(int32_t address)
static int32_t GetElementId(uint32_t address, int32_t level)