BmnRoot
26.10.0-18-g4e3414f9
Software framework of the BM@N experiment
Toggle main menu visibility
Loading...
Searching...
No Matches
BmnNdetAddress.h
Go to the documentation of this file.
1
/** \class BmnNdetAddress
2
** \brief BmnNdet interface class to the unique address
3
** \author Nikolay Karpushkin <karpushkin@inr.ru>
4
** \version 1.0
5
**
6
** BmnNdetAddress is the class for the concrete interfaces to the unique address,
7
** which is encoded in a 32-bit field (uint32_t), for the Ndet 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
** ArmId on bits 5- 6 00000000000000000000000001100000 << 5 2 3
13
** RowId on bits 7-10 00000000000000000000011110000000 << 7 4 15
14
** ColumnId on bits 11-14 00000000000000000111100000000000 << 11 4 15
15
** LayerId on bits 15-19 00000000000011111000000000000000 <<15 5 31
16
**
17
**/
18
19
#ifndef BmnNdetAddress_H
20
#define BmnNdetAddress_H 1
21
22
#include "
BmnDetectorList.h
"
// for kNDET
23
24
#include <cassert>
// for assert
25
#include <sstream>
// for std::ostringstream
26
27
class
BmnNdetAddress
28
{
29
public
:
30
virtual
~BmnNdetAddress
() {}
31
/**
32
* \brief Return address
33
* \param[in] ArmId arm id.
34
* \param[in] RowId row id.
35
* \param[in] ColumnId column id.
36
* \param[in] LayerId layer id.
37
* \return Address from system ID, ArmId, RowId, ColumnId, LayerId.
38
**/
39
static
uint32_t
GetAddress
(uint32_t ArmId, uint32_t RowId, uint32_t ColumnId, uint32_t LayerId)
40
{
41
assert((uint32_t)
kNDET
<=
fgkSystemIdLength
);
42
assert(ArmId <=
fgkArmIdLength
);
43
assert(RowId <=
fgkRowIdLength
);
44
assert(ColumnId <=
fgkColumnIdLength
);
45
assert(LayerId <=
fgkLayerIdLength
);
46
return
((((uint32_t)
kNDET
) <<
fgkSystemIdShift
) | (ArmId <<
fgkArmIdShift
) | (RowId <<
fgkRowIdShift
)
47
| (ColumnId <<
fgkColumnIdShift
) | (LayerId <<
fgkLayerIdShift
));
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) <<
", ArmId: "
<<
GetArmId
(address)
59
<<
", RowId: "
<<
GetRowId
(address) <<
", ColumnId: "
<<
GetColumnId
(address)
60
<<
", LayerId: "
<<
GetLayerId
(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 Arm id from address.
76
* \param[in] address Unique channel address.
77
* \return Arm id from address.
78
**/
79
static
uint32_t
GetArmId
(uint32_t address)
80
{
81
return
(address & (
fgkArmIdLength
<<
fgkArmIdShift
)) >>
fgkArmIdShift
;
82
}
83
84
/**
85
* \brief Return Row id from address.
86
* \param[in] address Unique channel address.
87
* \return Row id from address.
88
**/
89
static
uint32_t
GetRowId
(uint32_t address)
90
{
91
return
(address & (
fgkRowIdLength
<<
fgkRowIdShift
)) >>
fgkRowIdShift
;
92
}
93
94
/**
95
* \brief Return Column id from address.
96
* \param[in] address Unique channel address.
97
* \return Column id from address.
98
**/
99
static
uint32_t
GetColumnId
(uint32_t address)
100
{
101
return
(address & (
fgkColumnIdLength
<<
fgkColumnIdShift
)) >>
fgkColumnIdShift
;
102
}
103
104
/**
105
* \brief Return Layer id from address.
106
* \param[in] address Unique channel address.
107
* \return Layer id from address.
108
**/
109
static
uint32_t
GetLayerId
(uint32_t address)
110
{
111
return
(address & (
fgkLayerIdLength
<<
fgkLayerIdShift
)) >>
fgkLayerIdShift
;
112
}
113
114
private
:
115
// Length of the index of the corresponding volume
116
static
const
uint32_t
fgkSystemIdLength
= 31;
// 2^5 - 1
117
static
const
uint32_t
fgkArmIdLength
= 3;
// 2^2 - 1
118
static
const
uint32_t
fgkRowIdLength
= 15;
// 2^4 - 1
119
static
const
uint32_t
fgkColumnIdLength
= 15;
// 2^4 - 1
120
static
const
uint32_t
fgkLayerIdLength
= 31;
// 2^5 - 1
121
122
// Number of a start bit for each volume
123
static
const
uint32_t
fgkSystemIdShift
= 0;
124
static
const
uint32_t
fgkArmIdShift
= 5;
125
static
const
uint32_t
fgkRowIdShift
= 7;
126
static
const
uint32_t
fgkColumnIdShift
= 11;
127
static
const
uint32_t
fgkLayerIdShift
= 15;
128
129
ClassDef
(
BmnNdetAddress
, 1)
130
};
131
132
#endif
ClassDef
#define ClassDef(name, id)
kNDET
@ kNDET
Definition
BmnDetectorList.h:35
BmnNdetAddress
BmnNdet interface class to the unique address.
Definition
BmnNdetAddress.h:28
BmnNdetAddress::GetInfoString
static std::string GetInfoString(uint32_t address)
Return a formatted string with all address components.
Definition
BmnNdetAddress.h:55
BmnNdetAddress::fgkColumnIdShift
static const uint32_t fgkColumnIdShift
Definition
BmnNdetAddress.h:126
BmnNdetAddress::GetRowId
static uint32_t GetRowId(uint32_t address)
Return Row id from address.
Definition
BmnNdetAddress.h:89
BmnNdetAddress::fgkLayerIdShift
static const uint32_t fgkLayerIdShift
Definition
BmnNdetAddress.h:127
BmnNdetAddress::fgkArmIdLength
static const uint32_t fgkArmIdLength
Definition
BmnNdetAddress.h:117
BmnNdetAddress::~BmnNdetAddress
virtual ~BmnNdetAddress()
Definition
BmnNdetAddress.h:30
BmnNdetAddress::GetSystemId
static uint32_t GetSystemId(uint32_t address)
Return System identifier from address.
Definition
BmnNdetAddress.h:69
BmnNdetAddress::fgkRowIdShift
static const uint32_t fgkRowIdShift
Definition
BmnNdetAddress.h:125
BmnNdetAddress::fgkSystemIdShift
static const uint32_t fgkSystemIdShift
Definition
BmnNdetAddress.h:123
BmnNdetAddress::fgkArmIdShift
static const uint32_t fgkArmIdShift
Definition
BmnNdetAddress.h:124
BmnNdetAddress::GetAddress
static uint32_t GetAddress(uint32_t ArmId, uint32_t RowId, uint32_t ColumnId, uint32_t LayerId)
Return address.
Definition
BmnNdetAddress.h:39
BmnNdetAddress::fgkSystemIdLength
static const uint32_t fgkSystemIdLength
Definition
BmnNdetAddress.h:116
BmnNdetAddress::fgkRowIdLength
static const uint32_t fgkRowIdLength
Definition
BmnNdetAddress.h:118
BmnNdetAddress::fgkColumnIdLength
static const uint32_t fgkColumnIdLength
Definition
BmnNdetAddress.h:119
BmnNdetAddress::GetColumnId
static uint32_t GetColumnId(uint32_t address)
Return Column id from address.
Definition
BmnNdetAddress.h:99
BmnNdetAddress::GetArmId
static uint32_t GetArmId(uint32_t address)
Return Arm id from address.
Definition
BmnNdetAddress.h:79
BmnNdetAddress::fgkLayerIdLength
static const uint32_t fgkLayerIdLength
Definition
BmnNdetAddress.h:120
BmnNdetAddress::GetLayerId
static uint32_t GetLayerId(uint32_t address)
Return Layer id from address.
Definition
BmnNdetAddress.h:109
BmnDetectorList.h
Defines unique identifiers (enum) for all BM@N detector systems.
install
include
BmnNdetAddress.h
Generated on
for BmnRoot by
1.17.0