CbmRoot
CbmMuchAddress.cxx
Go to the documentation of this file.
1
#include "
CbmMuchAddress.h
"
2
3
#include "
CbmDefs.h
"
// for kMuch
4
5
#include <iomanip>
// for setw, __iom_t6
6
#include <ios>
// for right
7
8
9
// ----- Definition of the address field -------------------------------
10
const
Int_t
CbmMuchAddress::fgkBits
[] = {fgkSystemBits,
// system = kMUCH
11
3,
// station
12
2,
// layer
13
1,
// layerside
14
5,
// module
15
8,
// sector
16
9};
// channel
17
// -------------------------------------------------------------------------
18
19
// ----- Initialisation of bit shifts -----------------------------------
20
const
Int_t
CbmMuchAddress::fgkShift
[] = {
21
0,
22
CbmMuchAddress::fgkShift
[0] +
CbmMuchAddress::fgkBits
[0],
23
CbmMuchAddress::fgkShift
[1] +
CbmMuchAddress::fgkBits
[1],
24
CbmMuchAddress::fgkShift
[2] +
CbmMuchAddress::fgkBits
[2],
25
CbmMuchAddress::fgkShift
[3] +
CbmMuchAddress::fgkBits
[3],
26
CbmMuchAddress::fgkShift
[4] +
CbmMuchAddress::fgkBits
[4],
27
CbmMuchAddress::fgkShift
[5] +
CbmMuchAddress::fgkBits
[5]};
28
// -------------------------------------------------------------------------
29
30
31
// ----- Initialisation of bit masks -----------------------------------
32
const
Int_t
CbmMuchAddress::fgkMask
[] = {(1 << fgkBits[0]) - 1,
33
(1 << fgkBits[1]) - 1,
34
(1 << fgkBits[2]) - 1,
35
(1 << fgkBits[3]) - 1,
36
(1 << fgkBits[4]) - 1,
37
(1 << fgkBits[5]) - 1,
38
(1 << fgkBits[6]) - 1};
39
// -------------------------------------------------------------------------
40
41
42
// ----- Unique element address -----------------------------------------
43
UInt_t
CbmMuchAddress::GetAddress
(Int_t station,
44
Int_t layer,
45
Int_t layerside,
46
Int_t module,
47
Int_t sector,
48
Int_t channel) {
49
50
// Catch overrunning of allowed ranges
51
if
(station >= (1 <<
fgkBits
[
kMuchStation
])) {
52
LOG(error) <<
"Station Id "
<< station <<
" exceeds maximum ("
53
<< (1 <<
fgkBits
[
kMuchStation
]) - 1 <<
")"
;
54
return
0;
55
}
56
if
(layer >= (1 <<
fgkBits
[
kMuchLayer
])) {
57
LOG(error) <<
"Layer Id "
<< layer <<
" exceeds maximum ("
58
<< (1 <<
fgkBits
[
kMuchLayer
]) - 1 <<
")"
;
59
return
0;
60
}
61
if
(layerside >= (1 <<
fgkBits
[
kMuchLayerSide
])) {
62
LOG(error) <<
"LayerSide Id "
<< layerside <<
" exceeds maximum ("
63
<< (1 <<
fgkBits
[
kMuchLayerSide
]) - 1 <<
")"
;
64
return
0;
65
}
66
if
(module >= (1 <<
fgkBits
[
kMuchModule
])) {
67
LOG(error) <<
"Module Id "
<< module <<
" exceeds maximum ("
68
<< (1 <<
fgkBits
[
kMuchModule
]) - 1 <<
")"
;
69
return
0;
70
}
71
if
(sector >= (1 <<
fgkBits
[
kMuchSector
])) {
72
LOG(error) <<
"Sector Id "
<< sector <<
" exceeds maximum ("
73
<< (1 <<
fgkBits
[
kMuchSector
]) - 1 <<
")"
;
74
return
0;
75
}
76
if
(channel >= (1 <<
fgkBits
[
kMuchChannel
])) {
77
LOG(error) <<
"Channel Id "
<< channel <<
" exceeds maximum ("
78
<< (1 <<
fgkBits
[
kMuchChannel
]) - 1 <<
")"
;
79
return
0;
80
}
81
82
return
ToIntegralType
(
ECbmModuleId::kMuch
) <<
fgkShift
[
kMuchSystem
]
83
| station <<
fgkShift
[
kMuchStation
] | layer <<
fgkShift
[
kMuchLayer
]
84
| layerside <<
fgkShift
[
kMuchLayerSide
]
85
| module <<
fgkShift
[
kMuchModule
] | sector <<
fgkShift
[
kMuchSector
]
86
| channel <<
fgkShift
[
kMuchChannel
];
87
}
88
// -------------------------------------------------------------------------
89
90
91
// ----- Unique element address -----------------------------------------
92
UInt_t
CbmMuchAddress::GetAddress
(Int_t* elementId) {
93
94
UInt_t address =
ToIntegralType
(
ECbmModuleId::kMuch
) <<
fgkShift
[
kMuchSystem
];
95
for
(Int_t level = 1; level <
kMuchNofLevels
; level++) {
96
if
(elementId[level] >= (1 <<
fgkBits
[level])) {
97
LOG(error) <<
"Id "
<< elementId[level] <<
" for MUCH level "
<< level
98
<<
" exceeds maximum ("
<< (1 <<
fgkBits
[level]) - 1 <<
")"
;
99
return
0;
100
}
101
address = address | (elementId[level] <<
fgkShift
[level]);
102
}
103
104
return
address;
105
}
106
// -------------------------------------------------------------------------
107
108
109
// ----- Print info ----------------------------------------------------
110
void
CbmMuchAddress::Print
() {
111
LOG(info) <<
"Number of MUCH levels is "
<<
kMuchNofLevels
;
112
for
(Int_t level = 0; level <
kMuchNofLevels
; level++)
113
LOG(info) <<
"Level "
<< std::setw(2) << std::right << level <<
": bits "
114
<< std::setw(2) <<
fgkBits
[level] <<
", max. range "
115
<< std::setw(6) <<
fgkMask
[level];
116
}
117
// -------------------------------------------------------------------------
118
119
120
ClassImp
(
CbmMuchAddress
)
CbmMuchAddress
Interface class to unique address for the MUCH.
Definition:
CbmMuchAddress.h:49
kMuchSystem
@ kMuchSystem
System = MUCH.
Definition:
CbmMuchAddress.h:16
kMuchChannel
@ kMuchChannel
Channel.
Definition:
CbmMuchAddress.h:22
kMuchStation
@ kMuchStation
Station.
Definition:
CbmMuchAddress.h:17
kMuchSector
@ kMuchSector
Sector.
Definition:
CbmMuchAddress.h:21
kMuchNofLevels
@ kMuchNofLevels
Number of MUCH levels.
Definition:
CbmMuchAddress.h:23
kMuchLayerSide
@ kMuchLayerSide
LayerSide.
Definition:
CbmMuchAddress.h:19
CbmMuchAddress::fgkShift
static const Int_t fgkShift[kMuchNofLevels]
Definition:
CbmMuchAddress.h:156
kMuchLayer
@ kMuchLayer
Layer.
Definition:
CbmMuchAddress.h:18
CbmMuchAddress::fgkBits
static const Int_t fgkBits[kMuchNofLevels]
Definition:
CbmMuchAddress.h:153
CbmMuchAddress::fgkMask
static const Int_t fgkMask[kMuchNofLevels]
Definition:
CbmMuchAddress.h:159
ClassImp
ClassImp(CbmConverterManager) InitStatus CbmConverterManager
Definition:
CbmConverterManager.cxx:12
CbmMuchAddress::Print
static void Print()
Definition:
CbmMuchAddress.cxx:110
CbmMuchAddress.h
ToIntegralType
constexpr auto ToIntegralType(T enumerator) -> typename std::underlying_type< T >::type
Definition:
CbmDefs.h:24
ECbmModuleId::kMuch
@ kMuch
Muon detection system.
kMuchModule
@ kMuchModule
Module.
Definition:
CbmMuchAddress.h:20
CbmMuchAddress::GetAddress
static UInt_t GetAddress(Int_t station=0, Int_t layer=0, Int_t side=0, Int_t module=0, Int_t sector=0, Int_t channel=0)
Definition:
CbmMuchAddress.cxx:43
CbmDefs.h
core
data
much
CbmMuchAddress.cxx
Generated on Wed Oct 28 2020 15:11:42 for CbmRoot by
1.8.18