ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
MuonSpectrometer
MuonCnv
MuonByteStreamCnvTest
src
RpcByteStreamDecoder.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include "
RpcByteStreamDecoder.h
"
6
7
namespace
{
8
constexpr
unsigned
int
const
rpcRawHitWordLength = 7;
9
}
10
11
RpcByteStreamDecoder::RpcByteStreamDecoder
(
const
RPCbytestream
* p_bytestream,
const
RpcCablingCondData
* readCdo,
const
RpcIdHelper
* rpcId,
12
MsgStream* log) :
13
m_bytestream
(p_bytestream),
m_cabling
(readCdo),
m_rpcIdHelper
(rpcId) {
14
m_rpcpads
=
new
std::vector<RpcPad*>;
15
m_log
= log;
16
if
(
m_log
) {
17
m_debug
=
m_log
->level() <= MSG::DEBUG;
18
m_verbose
=
m_log
->level() <= MSG::VERBOSE;
19
}
else
{
20
m_debug
=
false
;
21
m_verbose
=
false
;
22
}
23
}
24
25
RpcByteStreamDecoder::~RpcByteStreamDecoder
() {
26
if
(
m_rpcpads
!=
nullptr
) {
27
delete
m_rpcpads
;
28
m_rpcpads
=
nullptr
;
29
}
30
}
31
32
StatusCode
RpcByteStreamDecoder::decodeByteStream
() {
33
if
(
m_debug
&&
m_log
) *
m_log
<< MSG::DEBUG <<
"Start decoding"
<<
endmsg
;
34
35
PAD_Readout
padReadout =
m_bytestream
->pad_readout();
36
37
// Iterate on the readout PADS and decode them
38
for
(PAD_Readout::iterator it = padReadout.begin(); it != padReadout.end(); ++it) {
39
PADreadout
pad = (*it).second;
40
RpcPad
* newpad =
decodePad
(pad);
41
42
// Push back the decoded pad in the vector
43
m_rpcpads
->push_back(newpad);
44
}
45
46
if
(
m_debug
&&
m_log
) *
m_log
<< MSG::DEBUG <<
"Number of decoded Pads : "
<<
m_rpcpads
->size() <<
endmsg
;
47
48
return
StatusCode::SUCCESS;
49
}
50
51
// Decode a pad and return a pointer to a RpcPad RDO
52
RpcPad
*
RpcByteStreamDecoder::decodePad
(
PADreadout
& pad) {
53
if
(
m_debug
&&
m_log
) *
m_log
<< MSG::DEBUG <<
"Decoding a new RpcPad"
<<
endmsg
;
54
55
// Identifier elements
56
int
name = 0;
57
int
eta
= 0;
58
int
phi
= 0;
59
int
doublet_r = 0;
60
int
doublet_z = 0;
61
int
doublet_phi = 0;
62
int
gas_gap = 0;
63
int
measures_phi = 0;
64
int
strip
= 0;
65
66
PadReadOut
* readout = pad.
give_pad_readout
();
67
68
// Retrieve PAD sector and PAD ID
69
int
sector = pad.
sector
();
70
int
pad_id = pad.
PAD
();
71
// Compute side and logic sector
72
int
side = (sector < 32) ? 0 : 1;
73
int
logic_sector = sector % 32;
74
// Compute the key to retrieve the offline id from the map (as from LVL1 sim.)
75
int
key = side * 10000 + logic_sector * 100 + pad_id;
76
77
if
(
m_debug
&&
m_log
) *
m_log
<< MSG::DEBUG <<
"Pad: Side "
<< side <<
" Sector logic"
<< logic_sector <<
" Id "
<< pad_id <<
endmsg
;
78
79
// Retrieve the identifier elements from the map
80
const
RpcCablingCondData::RDOmap
& pad_map =
m_cabling
->give_RDOs();
81
auto
foundPair = pad_map.find(key);
82
if
(foundPair == pad_map.end())
return
nullptr
;
83
RDOindex
index
= foundPair->second;
84
85
index
.offline_indexes(name,
eta
,
phi
, doublet_r, doublet_z, doublet_phi, gas_gap, measures_phi,
strip
);
86
87
// Build the pad offline identifier
88
bool
valid{
false
};
89
Identifier
id
=
m_rpcIdHelper
->padID(name,
eta
,
phi
, doublet_r, doublet_z, doublet_phi, valid);
90
91
if
(
m_log
&& !valid) {
92
*
m_log
<< MSG::ERROR <<
"Invalid pad offline indices "
<<
endmsg
;
93
*
m_log
<< MSG::ERROR <<
"Name : "
<< name <<
endmsg
;
94
*
m_log
<< MSG::ERROR <<
"Eta "
<<
eta
<<
" Phi "
<<
phi
<<
endmsg
;
95
*
m_log
<< MSG::ERROR <<
"Doublet r "
<< doublet_r <<
" Doublet_z "
<< doublet_z <<
" Doublet_phi "
<< doublet_phi <<
endmsg
;
96
*
m_log
<< MSG::ERROR <<
"Gas gap "
<< gas_gap <<
" Measures_phi "
<< measures_phi <<
" Strip "
<<
strip
<<
endmsg
;
97
}
98
99
// Retrieve Pad status and error code from Pad header and footer
100
PadReadOutStructure
pad_header = readout->
getHeader
();
101
PadReadOutStructure
pad_footer = readout->
getFooter
();
102
// Check the data format
103
// cppcheck-suppress assertWithSideEffect
104
assert(pad_header.
isHeader
());
105
// cppcheck-suppress assertWithSideEffect
106
assert(pad_footer.
isFooter
());
107
108
unsigned
int
hashId =
index
.hash();
109
unsigned
int
onlineId = pad_id;
110
// unsigned int status = pad_header.status();
111
unsigned
int
status = 0;
112
unsigned
int
errorCode = pad_footer.
errorCode
();
113
114
// Construct the new Pad
115
RpcPad
* rpc_pad =
new
RpcPad
(
id
, hashId, onlineId, status, errorCode, sector);
116
117
// Iterate on the matrices and decode them
118
for
(
int
i = 0; i < readout->
numberOfCMROFragments
(); ++i) {
119
MatrixReadOut
* matrix = pad.
matrices_readout
(i);
120
RpcCoinMatrix
* coinMatrix =
decodeMatrix
(matrix,
id
);
121
// Add the matrix to the pad
122
rpc_pad->
push_back
(coinMatrix);
123
}
124
125
if
(
m_debug
&&
m_log
) *
m_log
<< MSG::DEBUG <<
"Number of matrices in Pad : "
<< rpc_pad->
size
() <<
endmsg
;
126
127
return
rpc_pad;
128
}
129
130
// Function decoding a coincidence matrix
131
RpcCoinMatrix
*
RpcByteStreamDecoder::decodeMatrix
(
MatrixReadOut
* matrix,
Identifier
&
id
) {
132
if
(
m_debug
&&
m_log
) *
m_log
<< MSG::DEBUG <<
"Decoding a new RpcCoinMatrix"
<<
endmsg
;
133
134
// Matrix Header and SubHeader
135
MatrixReadOutStructure
matrix_header = matrix->getHeader();
136
MatrixReadOutStructure
matrix_subheader = matrix->getSubHeader();
137
MatrixReadOutStructure
matrix_footer = matrix->getFooter();
138
// Check the data structure
139
// cppcheck-suppress assertWithSideEffect
140
assert(matrix_header.
isHeader
());
141
// cppcheck-suppress assertWithSideEffect
142
assert(matrix_subheader.
isSubHeader
());
143
// cppcheck-suppress assertWithSideEffect
144
assert(matrix_footer.
isFooter
());
145
146
// Create the coincidence matrix
147
RpcCoinMatrix
* coinMatrix =
148
new
RpcCoinMatrix
(
id
, matrix_header.
cmid
(), matrix_footer.
crc
(), matrix_header.
fel1id
(), matrix_subheader.
febcid
());
149
150
// Iterate on fired channels and decode them
151
MatrixReadOutStructure
cm_hit;
152
for
(
int
j = 0; j < matrix->numberOfBodyWords(); ++j) {
153
cm_hit = matrix->getCMAHit(j);
154
// cppcheck-suppress assertWithSideEffect
155
assert(cm_hit.
isBody
());
156
RpcFiredChannel
* firedChannel =
nullptr
;
157
158
if
(cm_hit.
ijk
() < rpcRawHitWordLength) {
159
firedChannel =
new
RpcFiredChannel
(cm_hit.
bcid
(), cm_hit.
time
(), cm_hit.
ijk
(), cm_hit.
channel
());
160
}
else
if
(cm_hit.
ijk
() == rpcRawHitWordLength) {
161
firedChannel =
new
RpcFiredChannel
(cm_hit.
bcid
(), cm_hit.
time
(), cm_hit.
ijk
(), cm_hit.
threshold
(), cm_hit.
overlap
());
162
}
163
164
coinMatrix->
push_back
(firedChannel);
165
}
166
167
if
(
m_debug
&&
m_log
) *
m_log
<< MSG::DEBUG <<
"Number of Fired Channels in Matrix : "
<< coinMatrix->
size
() <<
endmsg
;
168
return
coinMatrix;
169
}
170
171
// Printout the RDOs for testing
172
void
RpcByteStreamDecoder::print
() {
173
std::cout <<
"Printing out RPC RDO's : "
<< std::endl;
174
std::cout <<
"Number of Pads in event : "
<<
m_rpcpads
->size() << std::endl;
175
std::vector<RpcPad*>::const_iterator pad_it;
176
int
ipad = 1;
177
// Iterate on pads
178
for
(pad_it =
m_rpcpads
->begin(); pad_it !=
m_rpcpads
->end(); ++pad_it, ++ipad) {
179
std::cout <<
"Pad number "
<< ipad <<
" Identifier : \n"
<< (*pad_it)->identify();
180
std::cout <<
"\nNumber of Matrices in Pad : "
<< (*pad_it)->size() <<
"\n"
;
181
// Iterate on the pad's coincidence matrices
182
RpcPad::const_iterator
mat_it;
183
int
imat = 1;
184
for
(mat_it = (*pad_it)->begin(); mat_it != (*pad_it)->end(); ++mat_it, ++imat) {
185
std::cout <<
"Matrix number "
<< imat << std::endl;
186
std::cout <<
"Number of fired channels: "
<< (*mat_it)->size() << std::endl;
187
RpcCoinMatrix::const_iterator
chan_it;
188
int
ichan = 1;
189
// Printout the fired channels
190
for
(chan_it = (*mat_it)->begin(); chan_it != (*mat_it)->end(); ++chan_it, ++ichan) {
191
std::cout <<
"Fired Channel "
<< ichan <<
" :: bcid "
<< (*chan_it)->bcid() <<
" ijk "
<< (*chan_it)->ijk()
192
<<
" channel "
<< (*chan_it)->channel() << std::endl;
193
}
194
}
195
}
196
}
eta
Scalar eta() const
pseudorapidity method
Definition
AmgMatrixBasePlugin.h:83
phi
Scalar phi() const
phi method
Definition
AmgMatrixBasePlugin.h:67
endmsg
#define endmsg
Definition
AnalysisConfig_Ntuple.cxx:54
SiliconTech::strip
@ strip
Definition
FPGATrackSimTypes.h:25
RpcCoinMatrix
Athena::TPCnvVers::Old Athena::TPCnvVers::Current Athena::TPCnvVers::Old Athena::TPCnvVers::Current Athena::TPCnvVers::Old Athena::TPCnvVers::Current Athena::TPCnvVers::Current RpcCoinMatrix
Definition
MuonEventAthenaPoolTPCnv.cxx:134
RpcPad
Athena::TPCnvVers::Old Athena::TPCnvVers::Current Athena::TPCnvVers::Old Athena::TPCnvVers::Current Athena::TPCnvVers::Old Athena::TPCnvVers::Current Athena::TPCnvVers::Current Athena::TPCnvVers::Current RpcPad
Definition
MuonEventAthenaPoolTPCnv.cxx:146
RpcByteStreamDecoder.h
PAD_Readout
std::map< int, PADreadout, std::less< int > > PAD_Readout
Definition
RpcByteStreamDecoder.h:22
DataVector< RpcCoinMatrix >::const_iterator
DataModel_detail::const_iterator< DataVector > const_iterator
Definition
DataVector.h:838
DataVector::push_back
value_type push_back(value_type pElem)
Add an element to the end of the collection.
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
MatrixReadOutStructure
Definition
MatrixReadOutStructure.h:13
MatrixReadOutStructure::threshold
ubit16 threshold()
Definition
MatrixReadOutStructure.h:37
MatrixReadOutStructure::ijk
ubit16 ijk()
Definition
MatrixReadOutStructure.h:35
MatrixReadOutStructure::channel
ubit16 channel()
Definition
MatrixReadOutStructure.h:36
MatrixReadOutStructure::cmid
ubit16 cmid()
Definition
MatrixReadOutStructure.h:30
MatrixReadOutStructure::isBody
bool isBody()
Definition
MatrixReadOutStructure.cxx:180
MatrixReadOutStructure::fel1id
ubit16 fel1id()
Definition
MatrixReadOutStructure.h:31
MatrixReadOutStructure::overlap
ubit16 overlap()
Definition
MatrixReadOutStructure.h:38
MatrixReadOutStructure::crc
ubit16 crc()
Definition
MatrixReadOutStructure.h:40
MatrixReadOutStructure::isHeader
bool isHeader()
Definition
MatrixReadOutStructure.cxx:166
MatrixReadOutStructure::time
ubit16 time()
Definition
MatrixReadOutStructure.h:34
MatrixReadOutStructure::isFooter
bool isFooter()
Definition
MatrixReadOutStructure.cxx:187
MatrixReadOutStructure::isSubHeader
bool isSubHeader()
Definition
MatrixReadOutStructure.cxx:173
MatrixReadOutStructure::bcid
ubit16 bcid()
Definition
MatrixReadOutStructure.h:33
MatrixReadOutStructure::febcid
ubit16 febcid()
Definition
MatrixReadOutStructure.h:32
MatrixReadOut
Definition
MatrixReadOut.h:18
PADreadout
Definition
PADreadout.h:20
PADreadout::give_pad_readout
PadReadOut * give_pad_readout(void)
Definition
PADreadout.cxx:81
PADreadout::matrices_readout
MatrixReadOut * matrices_readout(int) const
Definition
PADreadout.cxx:72
PADreadout::sector
int sector(void) const
Definition
PADreadout.h:40
PADreadout::PAD
int PAD(void) const
Definition
PADreadout.h:41
PadReadOutStructure
Definition
PadReadOutStructure.h:13
PadReadOutStructure::isHeader
bool isHeader()
Definition
PadReadOutStructure.cxx:166
PadReadOutStructure::isFooter
bool isFooter()
Definition
PadReadOutStructure.cxx:190
PadReadOutStructure::errorCode
ubit16 errorCode() const
Definition
PadReadOutStructure.h:34
PadReadOut
Definition
PadReadOut.h:15
PadReadOut::getFooter
PadReadOutStructure getFooter()
Definition
PadReadOut.cxx:204
PadReadOut::getHeader
PadReadOutStructure getHeader()
Definition
PadReadOut.cxx:199
PadReadOut::numberOfCMROFragments
ubit16 numberOfCMROFragments()
Definition
PadReadOut.h:30
RDOindex
Definition
RDOindex.h:85
RPCbytestream
Definition
RPCbytestream.h:20
RpcByteStreamDecoder::~RpcByteStreamDecoder
~RpcByteStreamDecoder()
Definition
RpcByteStreamDecoder.cxx:25
RpcByteStreamDecoder::decodeMatrix
RpcCoinMatrix * decodeMatrix(MatrixReadOut *matrix, Identifier &id)
Definition
RpcByteStreamDecoder.cxx:131
RpcByteStreamDecoder::m_cabling
const RpcCablingCondData * m_cabling
Definition
RpcByteStreamDecoder.h:47
RpcByteStreamDecoder::decodePad
RpcPad * decodePad(PADreadout &pad)
Definition
RpcByteStreamDecoder.cxx:52
RpcByteStreamDecoder::m_rpcIdHelper
const RpcIdHelper * m_rpcIdHelper
Definition
RpcByteStreamDecoder.h:48
RpcByteStreamDecoder::m_log
MsgStream * m_log
Definition
RpcByteStreamDecoder.h:51
RpcByteStreamDecoder::print
void print()
Definition
RpcByteStreamDecoder.cxx:172
RpcByteStreamDecoder::m_rpcpads
std::vector< RpcPad * > * m_rpcpads
Definition
RpcByteStreamDecoder.h:49
RpcByteStreamDecoder::decodeByteStream
StatusCode decodeByteStream()
Definition
RpcByteStreamDecoder.cxx:32
RpcByteStreamDecoder::RpcByteStreamDecoder
RpcByteStreamDecoder(const RPCbytestream *p_bytestream, const RpcCablingCondData *readCdo, const RpcIdHelper *rpcId, MsgStream *log=nullptr)
Definition
RpcByteStreamDecoder.cxx:11
RpcByteStreamDecoder::m_debug
bool m_debug
Definition
RpcByteStreamDecoder.h:52
RpcByteStreamDecoder::m_bytestream
const RPCbytestream * m_bytestream
Definition
RpcByteStreamDecoder.h:46
RpcByteStreamDecoder::m_verbose
bool m_verbose
Definition
RpcByteStreamDecoder.h:53
RpcCablingCondData
Definition
RpcCablingCondData.h:23
RpcCablingCondData::RDOmap
std::map< int, RDOindex, std::less< int > > RDOmap
Definition
RpcCablingCondData.h:27
RpcCoinMatrix
Definition
RpcCoinMatrix.h:20
RpcFiredChannel
Definition
RpcFiredChannel.h:20
RpcIdHelper
Definition
RpcIdHelper.h:51
RpcPad
Definition
RpcPad.h:21
Identifier
Definition
IdentifierFieldParser.cxx:14
index
Definition
index.py:1
Generated on
for ATLAS Offline Software by
1.17.0