BmnRoot 26.10.0-210-gc52d34b0
Software framework of the BM@N experiment
Loading...
Searching...
No Matches
CbmStsAddress.h
Go to the documentation of this file.
1/** @file CbmStsAddress.h
2 ** @author Volker Friese <v.friese@gsi.de>
3 ** @date 17.05.2013
4 **/
5
6#ifndef CBMSTSADDRESS_H
7#define CBMSTSADDRESS_H 1
8
9#include "CbmAddress.h"
10#include "FairLogger.h"
11#include "Rtypes.h"
12
13#include <iomanip>
14
15/** Enumerator for STS element levels
16 ** If this is changed, the initialisation of the static members
17 ** of CbmStsAddress must be changed accordingly!
18 **/
20{
21 kStsSystem, //!< System = STS
22 kStsStation, //!< Station
23 kStsLadder, //!< Ladder
24 kStsHalfLadder, //!< Halfladder
25 kStsModule, //!< Module
26 kStsSensor, //!< Sensor
27 kStsSide, //!< Side
28 kStsChannel, //!< Channel
29 kStsNofLevels //!< Number of STS levels
30};
31
32/** @class CbmStsAddress
33 ** @brief Interface class to unique address for the STS
34 ** @author V.Friese <v.friese@gsi.de>
35 ** @version 1.0
36 **
37 ** The CbmStsAddress interprets and modifies the unique address
38 ** for the STS by the proper bit operation on the address bit field.
39 **
40 ** The current definition of the bit field for the STS is:
41 **
42 ** 3 2 1
43 ** Level Bits Max. Elements Shift 10987654321098765432109876543210 \n
44 ** System (kSTS) 4 16 0 0000000000000000000000000000xxxx \n
45 ** Station 4 16 4 000000000000000000000000xxxx0000 \n
46 ** Ladder 4 16 8 00000000000000000000xxxx00000000 \n
47 ** HalfLadder 1 2 12 0000000000000000000x000000000000 \n
48 ** Module 3 8 13 0000000000000000xxx0000000000000 \n
49 ** Sensor 2 4 16 00000000000000xx0000000000000000 \n
50 ** Side 1 2 18 0000000000000x000000000000000000 \n
51 ** Channel 13 8192 19 xxxxxxxxxxxxx0000000000000000000 \n
52 **/
54{
55
56 public:
57 /** Construct address
58 ** @param station Station index
59 ** @param ladder Ladder index in station
60 ** @param halfladder Halfladder index in ladder
61 ** @param module Module index within halfladder
62 ** @param sensor Sensor index within module
63 ** @param side Side (0=front, 1=back) of sensor
64 ** @param channel Channel number
65 ** @return Unique element address
66 **/
67 static UInt_t GetAddress(Int_t station = 0,
68 Int_t ladder = 0,
69 Int_t halfladder = 0,
70 Int_t module = 0,
71 Int_t sensor = 0,
72 Int_t side = 0,
73 Int_t channel = 0);
74
75 static UInt_t GetAddress(Int_t* elementIds);
76
77 /** Get the number of hierarchy levels
78 ** For use in macros which do not include this header file.
79 ** @return Number of hierarchy levels
80 **/
81 static Int_t GetNofLevels() { return kStsNofLevels; }
82
83 /** Get the number of bits for a given hierarchy level
84 ** @param level Requested element level
85 ** @return Number of bits in address field
86 **/
87 static Int_t GetNofBits(Int_t level)
88 {
89 if (level < 0 || level >= kStsNofLevels)
90 return 0;
91 return fgkBits[level];
92 }
93
94 /** Get the index of an element
95 ** @param address Unique element address
96 ** @param level Hierarchy level
97 ** @return Element index
98 **/
99 static Int_t GetElementId(UInt_t address, Int_t level)
100 {
101 if (level < 0 || level >= kStsNofLevels)
102 return -1;
103 return (address & (fgkMask[level] << fgkShift[level])) >> fgkShift[level];
104 }
105
106 /** Print information on the bit field **/
107 static void Print();
108
109 /** Set the index of an element
110 ** leaving the other element levels untouched
111 ** @param address Unique element address
112 ** @param level Hierarchy level
113 ** @param newId New element index
114 ** @return New address
115 **/
116 static UInt_t SetElementId(UInt_t address, Int_t level, Int_t newId)
117 {
118 if (level < 0 || level >= kStsNofLevels)
119 return address;
120 if (newId >= (1 << fgkBits[level])) {
121 LOG(error) << "Id " << newId << " for STS level " << level << " exceeds maximum ("
122 << (1 << fgkBits[level]) - 1 << ")";
123 return 0;
124 }
125 return (address & (~(fgkMask[level] << fgkShift[level]))) | (newId << fgkShift[level]);
126 }
127
128 private:
129 /** Number of bits for the different levels **/
130 static const Int_t fgkBits[kStsNofLevels];
131
132 /** Bit shifts for the different levels **/
133 static const Int_t fgkShift[kStsNofLevels];
134
135 /** Bit masks for the different levels **/
136 static const Int_t fgkMask[kStsNofLevels];
137
139};
140
141#endif /* CBMSTSADDRESS_H */
StsElementLevel
Enumerator for STS element levels If this is changed, the initialisation of the static members of Cbm...
@ kStsModule
Module.
@ kStsStation
Station.
@ kStsLadder
Ladder.
@ kStsSystem
System = STS.
@ kStsSide
Side.
@ kStsNofLevels
Number of STS levels.
@ kStsHalfLadder
Halfladder.
@ kStsSensor
Sensor.
@ kStsChannel
Channel.
int Int_t
unsigned int UInt_t
#define ClassDef(name, id)
Interface class to unique address for the STS.
static UInt_t GetAddress(Int_t station=0, Int_t ladder=0, Int_t halfladder=0, Int_t module=0, Int_t sensor=0, Int_t side=0, Int_t channel=0)
Construct address.
static const Int_t fgkMask[kStsNofLevels]
Bit masks for the different levels.
static void Print()
Print information on the bit field.
static const Int_t fgkShift[kStsNofLevels]
Bit shifts for the different levels.
static Int_t GetElementId(UInt_t address, Int_t level)
Get the index of an element.
static const Int_t fgkBits[kStsNofLevels]
Number of bits for the different levels.
static Int_t GetNofBits(Int_t level)
Get the number of bits for a given hierarchy level.
static UInt_t SetElementId(UInt_t address, Int_t level, Int_t newId)
Set the index of an element leaving the other element levels untouched.
static Int_t GetNofLevels()
Get the number of hierarchy levels For use in macros which do not include this header file.