CbmRoot
Loading...
Searching...
No Matches
CbmMvdAddress.h
Go to the documentation of this file.
1/* Copyright (C) 2025 IKF Frankfurt University, Frankfurt am Main
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Ajit Kumar [committer], Jan Michel*/
4
9
10
11#ifndef CBMMVDADDRESS_H
12#define CBMMVDADDRESS_H 1
13
14#include "CbmAddress.h" // for CbmAddress
15
16#ifndef NO_ROOT
17#include <Rtypes.h> // for ClassDef
18#endif
19
20#include <cstdint>
21
24{
39
64
68class CbmMvdAddress : public CbmAddress {
69
70 public:
72 static uint32_t GetAddress(int32_t station = 0, int32_t sideUD = 0, int32_t sideLR = 0, int32_t sideTB = 0,
73 int32_t ladder = 0, int32_t sensor = 0, int32_t sensorY = 0, int32_t sensorX = 0);
74
75 static uint32_t GetAddress(int32_t* elementIds);
76
77 static int32_t GetNofLevels() { return kMvdNofLevels; }
78
79 static int32_t GetNofBits(int32_t level)
80 {
81 if (level < 0 || level >= kMvdNofLevels) return 0;
82 return fgkBits[level];
83 }
84
85 static int32_t GetElementId(uint32_t address, int32_t level)
86 {
87 if (level < 0 || level >= kMvdNofLevels) return -1;
88 return (address & (fgkMask[level] << fgkShift[level])) >> fgkShift[level];
89 }
90
91 // Derivatives for convenience
92 static int32_t GetSystemIndex(uint32_t address) { return GetElementId(address, kMvdSystem); }
93 static int32_t GetStationIndex(uint32_t address) { return GetElementId(address, kMvdStation); }
94 static int32_t GetSideUDIndex(uint32_t address) { return GetElementId(address, kMvdSideUD); }
95 static int32_t GetSideLRIndex(uint32_t address) { return GetElementId(address, kMvdSideLR); }
96 static int32_t GetSideTBIndex(uint32_t address) { return GetElementId(address, kMvdSideTB); }
97 static int32_t GetLadderIndex(uint32_t address) { return GetElementId(address, kMvdLadder); }
98 static int32_t GetSensorIndex(uint32_t address) { return GetElementId(address, kMvdSensor); }
99 static int32_t GetSensorYIndex(uint32_t address) { return GetElementId(address, kMvdSensorY); }
100 static int32_t GetSensorXIndex(uint32_t address) { return GetElementId(address, kMvdSensorX); }
101
105 // TODO: Unify the name of the function: it may be also defined for other detector subsystems to
106 // mask individual channels and leave an address of the whole sensor/module.
107 static uint32_t GetDetectorId(uint32_t address)
108 {
109 return ((1 << (fgkBitsSensorNr + fgkBits[kMvdSystem])) - 1) & address;
110 }
111
112 // FIXME: 07/2025 Compatibility layer for Vertical Test and simulations
113 static uint32_t GetAddressFromSensorNrAndPixelXY(int32_t sensorNr, int32_t sensorY, int32_t sensorX);
114 static int32_t GetSensorNrFromAddress(uint32_t address)
115 {
116 return (address & (fgkMaskSensorNr << fgkShiftSensorNr)) >> fgkShiftSensorNr;
117 }
118
119
121 static int32_t GetElementAddress(int32_t address, int32_t level)
122 {
123 int32_t mask = (1 << (CbmMvdAddress::fgkShift[level] + CbmMvdAddress::fgkBits[level])) - 1;
124 return address & mask;
125 }
126
127 static void Print();
128
129 static uint32_t SetElementId(uint32_t address, int32_t level, int32_t newId);
130
131 private:
132 static constexpr int32_t fgkBits[kMvdNofLevels] = {
133 4, // System (kMVD)
134 2, // Station
135 1, // SideUD (Upstream/Downstream)
136 1, // SideLR (Left/Right)
137 1, // SideTB (Top/Bottom)
138 2, // Ladder
139 2, // Sensor
140 9, // SensorY
141 10, // SensorX
142 };
143
144 static const int32_t fgkShift[kMvdNofLevels];
145 static const int32_t fgkMask[kMvdNofLevels];
146
147 // FIXME: 07/2025 Compatibility layer for Vertical Test and simulations
148 // => To be cleaned up once the CbmMvdDigi class has been updated/reviewed/rewritten
151 static const int32_t fgkShiftSensorNr;
152 static const int32_t fgkMaskSensorNr;
153
154#ifndef NO_ROOT
156#endif
157};
158
159#endif /* CBMMVDADDRESS_H */
MvdElementLevel
@ kMvdSensor
Sensor.
@ kMvdSensorX
Sensor X (row)
@ kMvdSideLR
Left/Right.
@ kMvdStation
Station.
@ kMvdSideTB
Top/Bottom.
@ kMvdSideUD
Upstream/Downstream.
@ kMvdLadder
Ladder.
@ kMvdSensorY
Sensor Y (column)
@ kMvdSystem
System = MVD.
@ kMvdNofLevels
Number of MVD levels.
Functions to encode or decode the address field of MVD data.
static int32_t GetSideUDIndex(uint32_t address)
static uint32_t GetDetectorId(uint32_t address)
Provides a unit sensor address, masking information on the pixels (bits 13-31)
static uint32_t GetAddressFromSensorNrAndPixelXY(int32_t sensorNr, int32_t sensorY, int32_t sensorX)
static int32_t GetElementId(uint32_t address, int32_t level)
static const int32_t fgkMask[kMvdNofLevels]
static int32_t GetNofBits(int32_t level)
static constexpr int32_t fgkBits[kMvdNofLevels]
static int32_t GetStationIndex(uint32_t address)
static uint32_t SetElementId(uint32_t address, int32_t level, int32_t newId)
static const int32_t fgkShiftSensorNr
static const int32_t fgkShift[kMvdNofLevels]
static void Print()
static int32_t GetSideLRIndex(uint32_t address)
ClassDef(CbmMvdAddress, 1)
static int32_t GetNofLevels()
static int32_t GetSystemIndex(uint32_t address)
static int32_t GetSensorXIndex(uint32_t address)
static int32_t GetLadderIndex(uint32_t address)
static int32_t GetElementAddress(int32_t address, int32_t level)
static int32_t GetSensorNrFromAddress(uint32_t address)
static const int32_t fgkMaskSensorNr
static int32_t GetSideTBIndex(uint32_t address)
static constexpr int32_t fgkBitsSensorNr
static uint32_t GetAddress(int32_t station=0, int32_t sideUD=0, int32_t sideLR=0, int32_t sideTB=0, int32_t ladder=0, int32_t sensor=0, int32_t sensorY=0, int32_t sensorX=0)
static int32_t GetSensorYIndex(uint32_t address)
static int32_t GetSensorIndex(uint32_t address)