BmnRoot
Loading...
Searching...
No Matches
BmnFHCalAddress.h
Go to the documentation of this file.
1
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() {}
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
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
69 static uint32_t GetSystemId(uint32_t address)
70 {
71 return (address & (fgkSystemIdLength << fgkSystemIdShift)) >> fgkSystemIdShift;
72 }
73
79 static uint32_t GetModuleType(uint32_t address)
80 {
81 return (address & (fgkModTypeLength << fgkModTypeShift)) >> fgkModTypeShift;
82 }
83
89 static uint32_t GetModuleId(uint32_t address)
90 {
91 return (address & (fgkModIdxLength << fgkModIdxShift)) >> fgkModIdxShift;
92 }
93
99 static uint32_t GetSectionId(uint32_t address)
100 {
101 return (address & (fgkSecIdxLength << fgkSecIdxShift)) >> fgkSecIdxShift;
102 }
103
109 static uint32_t GetScintillatorId(uint32_t address)
110 {
111 return (address & (fgkScintIdxLength << fgkScintIdxShift)) >> fgkScintIdxShift;
112 }
113
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
136 ClassDef(BmnFHCalAddress, 2)
137};
138
139#endif
@ kFHCAL
BmnFHCal interface class to the unique address.
static uint32_t GetModuleId(uint32_t address)
Return Module id from address.
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 uint32_t GetPhysicalAddress(uint32_t address)
Return Physical address (w/o scintillator id) from address.
virtual ~BmnFHCalAddress()
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.
Defines unique identifiers (enum) for all BM@N detector systems.