BmnRoot 26.10.0-18-g4e3414f9
Software framework of the BM@N experiment
Loading...
Searching...
No Matches
BmnFHCalAddress.h
Go to the documentation of this file.
1/** \class BmnFHCalAddress
2 ** \brief BmnFHCal interface class to the unique address
3 ** \author Nikolay Karpushkin <karpushkin@inr.ru>
4 ** \version 1.0
5 **
6 ** BmnFHCalAddress is the class for the concrete interfaces to the unique address,
7 ** which is encoded in a 32-bit field (uint32_t), for the FHCal detector elements.
8 **
9 ** 3 2 1 0 Shift Bits Values
10 ** Current definition: 10987654321098765432109876543210
11 ** System id on bits 0- 4 00000000000000000000000000011111 << 0 5 31
12 ** ModType on bits 5- 6 00000000000000000000000001100000 << 5 2 3
13 ** ModIdx on bits 7-13 00000000000000000011111110000000 << 7 7 127
14 ** SecIdx on bits 14-17 00000000000000111100000000000000 <<14 4 15
15 ** ScintIdx on bits 18-20 00000000000111000000000000000000 <<18 3 7
16 **
17 **/
18
19#ifndef BmnFHCalAddress_H
20#define BmnFHCalAddress_H 1
21
22#include "BmnDetectorList.h" // for kFHCAL
23
24#include <cassert> // for assert
25#include <sstream> // for std::ostringstream
26
28{
29 public:
30 virtual ~BmnFHCalAddress() {}
31 /**
32 * \brief Return address from system ID, Module type, Module ID, Section ID, Scintillator ID (optional).
33 * \param[in] ModuleType Module type.
34 * \param[in] ModuleId Module id.
35 * \param[in] SectionId Section id.
36 * \param[in] ScintillatorId Scintillator id.
37 * \return Address from system ID, Module type, Module ID, Section ID, Scintillator id (optional).
38 **/
39 static uint32_t GetAddress(uint32_t ModuleType, uint32_t ModuleId, uint32_t SectionId, uint32_t ScintillatorId = 0)
40 {
41 assert((uint32_t)kFHCAL <= fgkSystemIdLength);
42 assert(ModuleType <= fgkModTypeLength);
43 assert(ModuleId <= fgkModIdxLength);
44 assert(SectionId <= fgkSecIdxLength);
45 assert(ScintillatorId <= fgkScintIdxLength);
46 return ((((uint32_t)kFHCAL) << fgkSystemIdShift) | (ModuleType << fgkModTypeShift)
47 | (ModuleId << fgkModIdxShift) | (SectionId << fgkSecIdxShift) | (ScintillatorId << fgkScintIdxShift));
48 }
49
50 /**
51 * \brief Return a formatted string with all address components.
52 * \param[in] address Unique channel address.
53 * \return Formatted string with address components
54 **/
55 static std::string GetInfoString(uint32_t address)
56 {
57 std::ostringstream oss;
58 oss << "Address: " << address << ", SystemId: " << GetSystemId(address)
59 << ", ModuleType: " << GetModuleType(address) << ", ModuleId: " << GetModuleId(address)
60 << ", SectionId: " << GetSectionId(address) << ", ScintillatorId: " << GetScintillatorId(address);
61 return oss.str();
62 }
63
64 /**
65 * \brief Return System identifier from address.
66 * \param[in] address Unique channel address.
67 * \return System identifier from address.
68 **/
69 static uint32_t GetSystemId(uint32_t address)
70 {
71 return (address & (fgkSystemIdLength << fgkSystemIdShift)) >> fgkSystemIdShift;
72 }
73
74 /**
75 * \brief Return Module id from address.
76 * \param[in] address Unique channel address.
77 * \return Module id from address.
78 **/
79 static uint32_t GetModuleType(uint32_t address)
80 {
81 return (address & (fgkModTypeLength << fgkModTypeShift)) >> fgkModTypeShift;
82 }
83
84 /**
85 * \brief Return Module id from address.
86 * \param[in] address Unique channel address.
87 * \return Module id from address.
88 **/
89 static uint32_t GetModuleId(uint32_t address)
90 {
91 return (address & (fgkModIdxLength << fgkModIdxShift)) >> fgkModIdxShift;
92 }
93
94 /**
95 * \brief Return Section id from address.
96 * \param[in] address Unique channel address.
97 * \return Section id from address.
98 **/
99 static uint32_t GetSectionId(uint32_t address)
100 {
101 return (address & (fgkSecIdxLength << fgkSecIdxShift)) >> fgkSecIdxShift;
102 }
103
104 /**
105 * \brief Return Scintillator id from address.
106 * \param[in] address Unique channel address.
107 * \return Scintillator id from address.
108 **/
109 static uint32_t GetScintillatorId(uint32_t address)
110 {
111 return (address & (fgkScintIdxLength << fgkScintIdxShift)) >> fgkScintIdxShift;
112 }
113
114 /**
115 * \brief Return Physical address (w/o scintillator id) from address.
116 * \param[in] address Unique channel address.
117 * \return Physical address (w/o scintillator id)
118 **/
119 static uint32_t GetPhysicalAddress(uint32_t address) { return address & ((1 << fgkScintIdxShift) - 1); }
120
121 private:
122 // Length of the index of the corresponding volume
123 static const uint32_t fgkSystemIdLength = 31; // 2^5 - 1
124 static const uint32_t fgkModTypeLength = 3; // 2^2 - 1
125 static const uint32_t fgkModIdxLength = 127; // 2^7 - 1
126 static const uint32_t fgkSecIdxLength = 15; // 2^4 - 1
127 static const uint32_t fgkScintIdxLength = 7; // 2^3 - 1
128
129 // Number of a start bit for each volume
130 static const uint32_t fgkSystemIdShift = 0;
131 static const uint32_t fgkModTypeShift = 5;
132 static const uint32_t fgkModIdxShift = 7;
133 static const uint32_t fgkSecIdxShift = 14;
134 static const uint32_t fgkScintIdxShift = 18;
135
137};
138
139#endif
#define ClassDef(name, id)
@ kFHCAL
BmnFHCal interface class to the unique address.
static const uint32_t fgkSecIdxLength
static const uint32_t fgkModIdxShift
static uint32_t GetModuleId(uint32_t address)
Return Module id from address.
static const uint32_t fgkScintIdxShift
static const uint32_t fgkModTypeLength
static uint32_t GetModuleType(uint32_t address)
Return Module id from address.
static std::string GetInfoString(uint32_t address)
Return a formatted string with all address components.
static uint32_t GetSectionId(uint32_t address)
Return Section id from address.
static uint32_t GetSystemId(uint32_t address)
Return System identifier from address.
static const uint32_t fgkModIdxLength
static const uint32_t fgkModTypeShift
static const uint32_t fgkScintIdxLength
static const uint32_t fgkSecIdxShift
static const uint32_t fgkSystemIdLength
static uint32_t GetPhysicalAddress(uint32_t address)
Return Physical address (w/o scintillator id) from address.
virtual ~BmnFHCalAddress()
static const uint32_t fgkSystemIdShift
static uint32_t GetAddress(uint32_t ModuleType, uint32_t ModuleId, uint32_t SectionId, uint32_t ScintillatorId=0)
Return address from system ID, Module type, Module ID, Section ID, Scintillator ID (optional).
static uint32_t GetScintillatorId(uint32_t address)
Return Scintillator id from address.