ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
MuonSpectrometer
MuonCnv
MuonRPC_CnvTools
src
RpcROD_Encoder.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
// Implementation of RpcROD_Encoder class
6
7
#include "
RpcROD_Encoder.h
"
8
9
#include <algorithm>
10
11
#include "
TrigT1RPChardware/MatrixReadOutStructure.h
"
12
#include "
TrigT1RPChardware/PadReadOutStructure.h
"
13
#include "
TrigT1RPChardware/RPCRODStructure.h
"
14
#include "
TrigT1RPChardware/RXReadOutStructure.h
"
15
18
19
RpcROD_Encoder::RpcROD_Encoder
() :
m_hid2re
(nullptr) {}
20
23
RpcROD_Encoder::~RpcROD_Encoder
() =
default
;
24
27
void
RpcROD_Encoder::set
(
const
RPC_Hid2RESrcID
* hid2re) {
28
m_hid2re
= hid2re;
29
}
30
33
void
RpcROD_Encoder::add
(
const
RpcPad
*
rc
) {
34
m_vRpcPad
.push_back(
rc
);
35
}
36
39
void
RpcROD_Encoder::clear
() {
40
m_vRpcPad
.erase(
m_vRpcPad
.begin(),
m_vRpcPad
.end());
41
}
42
46
47
void
RpcROD_Encoder::fillROD
(std::vector<uint32_t>& v) {
48
if
(
m_vRpcPad
.empty()) {
return
; }
49
std::vector<unsigned short int> v16;
50
51
RPCRODStructure
rodReadout;
52
RXReadOutStructure
rxReadout;
53
PadReadOutStructure
padReadout;
54
MatrixReadOutStructure
matrixReadout;
55
56
// first group the pads into their receivers
57
58
typedef
std::vector<const RpcPad*> receiver;
59
std::map<int, receiver> mapReceiver;
60
61
for
(
const
auto
& pPad :
m_vRpcPad
) {
62
int
sector = pPad->sector();
63
mapReceiver[sector].push_back(pPad);
64
}
65
66
std::map<int, receiver>::iterator
re
= mapReceiver.begin();
67
std::map<int, receiver>::iterator re_end = mapReceiver.end();
68
69
// make the header of the ROD
70
v.push_back(rodReadout.
getHeaderMarker
());
71
v.push_back(rodReadout.
getHeaderSize
());
72
v.push_back(rodReadout.
getFormatVersion
());
73
uint16_t side = ((*re).first < 32) ? 0 : 1;
74
uint16_t rodId = ((*re).first % 32) / 2;
75
assert(rodId <= 15);
76
77
v.push_back(rodReadout.
getSourceID
(side, rodId));
78
v.push_back(0);
// Level1ID
79
v.push_back(0);
// BunchCrossingID
80
v.push_back(0);
// Level1TriggerType
81
v.push_back(0);
// DetectorEventType
82
83
// make the body of the ROD
84
for
(;
re
!= re_end; ++
re
) {
85
// make the header of the receiver
86
uint16_t rxHeader[3];
87
rxHeader[0] = 0;
88
rxHeader[1] = ((*re).first % 32) % 2 << 3;
89
rxHeader[2] = 0;
90
91
uint16_t receiverHeader = rxReadout.
makeHeader
(rxHeader);
92
93
v16.push_back(receiverHeader);
94
95
// make the receiver body
96
std::vector<const RpcPad*>::const_iterator it = (*re).second.begin();
97
std::vector<const RpcPad*>::const_iterator it_end = (*re).second.end();
98
99
for
(; it != it_end; ++it) {
100
const
RpcPad
* pad = (*it);
101
102
// make the pad header
103
unsigned
short
int
padHeader[3];
104
padHeader[0] = 0;
105
padHeader[1] = pad->
onlineId
();
106
padHeader[2] = pad->
status
();
107
v16.push_back(padReadout.
makeHeader
(padHeader));
108
// make the pad body:: cma header, sub-header, body, and footer
109
RpcPad::const_iterator
it_cma = pad->
begin
();
110
RpcPad::const_iterator
it_cma_end = pad->
end
();
111
for
(; it_cma != it_cma_end; ++it_cma) {
112
const
RpcCoinMatrix
* cma = (*it_cma);
113
unsigned
short
int
cmaHeader[3];
114
cmaHeader[0] = 0;
115
cmaHeader[1] = cma->
onlineId
();
116
cmaHeader[2] = cma->
fel1Id
();
117
v16.push_back(matrixReadout.
makeHeader
(cmaHeader));
118
v16.push_back(matrixReadout.
makeSubHeader
());
119
RpcCoinMatrix::const_iterator
it_fCh = cma->
begin
();
120
RpcCoinMatrix::const_iterator
it_fCh_end = cma->
end
();
121
for
(; it_fCh != it_fCh_end; ++it_fCh) {
122
const
RpcFiredChannel
* firedChannel = (*it_fCh);
123
unsigned
short
int
body[5];
124
body[0] = 0;
125
body[1] = firedChannel->
bcid
();
126
body[2] = firedChannel->
time
();
127
body[3] = firedChannel->
ijk
();
128
129
if
(body[3] < 7) {
130
body[4] = firedChannel->
channel
();
131
}
else
{
132
body[4] = firedChannel->
thr
() | ((firedChannel->
ovl
()) << 2);
133
}
134
135
v16.push_back(matrixReadout.
makeBody
(body));
136
}
137
v16.push_back(matrixReadout.
makeFooter
(cma->
crc
()));
138
}
139
140
// make the pad footer
141
142
ubit16
errorCodes[6] = {0, 0, 0, 0, 0, 0};
143
v16.push_back(padReadout.
makeFooter
(errorCodes));
144
}
145
// make the receiver footer
146
v16.push_back(rxReadout.
makeFooter
((uint16_t)0));
147
}
// end of receivers
148
149
// if numbers of 16 words is odd, add 0 to make it even
150
int
n16words = v16.size();
151
if
(n16words % 2 == 1) {
152
v16.push_back(0);
153
n16words++;
154
}
155
packFragments
(v16, v, n16words);
156
157
// finally make the ROD footer
158
v.push_back(0);
// NumberOfStatusElements
159
v.push_back(0);
// NumberOfDataElements
160
v.push_back(0); }
161
162
void
RpcROD_Encoder::packFragments
(
const
std::vector<uint16_t>& v16, std::vector<uint32_t>& v,
int
n)
const
{
163
// now merge 2 consecutive 16 bit words in 32 bit words
164
const
unsigned
short
int
nWords = 2;
165
unsigned
short
int
position[nWords] = {0, 16};
166
unsigned
short
int
v16words[nWords] = {0, 0};
167
for
(
int
i = 0; i < n;) {
168
v16words[i % nWords] = v16[i];
169
v16words[(i + 1) % nWords] = v16[i + 1];
170
v.push_back(
set32bits
(v16words, position, nWords));
171
i += nWords;
172
}
173
}
174
175
uint32_t
RpcROD_Encoder::set32bits
(
const
unsigned
short
int
* v16,
const
unsigned
short
int
* pos,
const
unsigned
short
int
n) {
176
uint32_t v32 = 0;
177
uint32_t p = 0, v = 0;
178
179
for
(
ubit16
i = 0; i < n; i++) {
180
v = (uint32_t)(*(v16 + i));
181
p = (uint32_t)(*(pos + i));
182
v32 = v32 | (v << p);
183
}
184
return
v32;
185
}
re
const std::regex re(r_e)
rc
static Double_t rc
Definition
LArPhysWaveHECTool.cxx:37
MatrixReadOutStructure.h
PadReadOutStructure.h
RPCRODStructure.h
RXReadOutStructure.h
ubit16
unsigned short int ubit16
Definition
RpcByteStreamEncoder.h:20
RpcROD_Encoder.h
DataVector< RpcCoinMatrix >::const_iterator
DataModel_detail::const_iterator< DataVector > const_iterator
Definition
DataVector.h:838
DataVector::end
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
DataVector::begin
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
MatrixReadOutStructure
Definition
MatrixReadOutStructure.h:13
MatrixReadOutStructure::makeSubHeader
ubit16 makeSubHeader()
Definition
MatrixReadOutStructure.cxx:76
MatrixReadOutStructure::makeBody
ubit16 makeBody(ubit16 *inputData)
Definition
MatrixReadOutStructure.cxx:83
MatrixReadOutStructure::makeHeader
ubit16 makeHeader(ubit16 *inputData)
Definition
MatrixReadOutStructure.cxx:68
MatrixReadOutStructure::makeFooter
ubit16 makeFooter(ubit16 inputData)
Definition
MatrixReadOutStructure.cxx:100
PadReadOutStructure
Definition
PadReadOutStructure.h:13
PadReadOutStructure::makeFooter
ubit16 makeFooter(ubit16 errorCode)
Definition
PadReadOutStructure.h:25
PadReadOutStructure::makeHeader
ubit16 makeHeader(ubit16 *inputData)
Definition
PadReadOutStructure.cxx:74
RPCRODStructure
Definition
RPCRODStructure.h:16
RPCRODStructure::getHeaderSize
RODword getHeaderSize()
Definition
RPCRODStructure.h:44
RPCRODStructure::getSourceID
RODword getSourceID(ubit16 subsystem, ubit16 RODID)
Definition
RPCRODStructure.cxx:43
RPCRODStructure::getFormatVersion
RODword getFormatVersion()
Definition
RPCRODStructure.h:46
RPCRODStructure::getHeaderMarker
RODword getHeaderMarker()
Definition
RPCRODStructure.h:43
RPC_Hid2RESrcID
Definition
RPC_Hid2RESrcID.h:16
RXReadOutStructure
Definition
RXReadOutStructure.h:14
RXReadOutStructure::makeHeader
ubit16 makeHeader(ubit16 *inputData)
Definition
RXReadOutStructure.cxx:47
RXReadOutStructure::makeFooter
ubit16 makeFooter(ubit16 errorCode)
Definition
RXReadOutStructure.cxx:55
RpcCoinMatrix
Definition
RpcCoinMatrix.h:20
RpcCoinMatrix::crc
ubit16 crc() const
Definition
RpcCoinMatrix.h:69
RpcCoinMatrix::fel1Id
ubit16 fel1Id() const
Definition
RpcCoinMatrix.h:71
RpcCoinMatrix::onlineId
ubit16 onlineId() const
Definition
RpcCoinMatrix.h:67
RpcFiredChannel
Definition
RpcFiredChannel.h:20
RpcFiredChannel::bcid
ubit16 bcid() const
Definition
RpcFiredChannel.h:52
RpcFiredChannel::thr
ubit16 thr() const
Definition
RpcFiredChannel.h:65
RpcFiredChannel::channel
ubit16 channel() const
Definition
RpcFiredChannel.h:58
RpcFiredChannel::ovl
ubit16 ovl() const
Definition
RpcFiredChannel.h:61
RpcFiredChannel::ijk
ubit16 ijk() const
Definition
RpcFiredChannel.h:56
RpcFiredChannel::time
ubit16 time() const
Definition
RpcFiredChannel.h:54
RpcPad
Definition
RpcPad.h:21
RpcPad::onlineId
ubit16 onlineId() const
Definition
RpcPad.h:107
RpcPad::status
ubit16 status() const
Definition
RpcPad.h:105
RpcROD_Encoder::m_vRpcPad
std::vector< const RpcPad * > m_vRpcPad
Definition
RpcROD_Encoder.h:65
RpcROD_Encoder::set32bits
static uint32_t set32bits(const unsigned short int *v16, const unsigned short int *pos, const unsigned short int n)
Definition
RpcROD_Encoder.cxx:175
RpcROD_Encoder::clear
void clear()
clear the current pad list
Definition
RpcROD_Encoder.cxx:39
RpcROD_Encoder::RpcROD_Encoder
RpcROD_Encoder()
constructor
Definition
RpcROD_Encoder.cxx:19
RpcROD_Encoder::m_hid2re
const RPC_Hid2RESrcID * m_hid2re
Definition
RpcROD_Encoder.h:64
RpcROD_Encoder::add
void add(const RpcPad *rc)
add Rpc pads to the current list
Definition
RpcROD_Encoder.cxx:33
RpcROD_Encoder::packFragments
void packFragments(const std::vector< uint16_t > &v16, std::vector< uint32_t > &v, int n) const
Definition
RpcROD_Encoder.cxx:162
RpcROD_Encoder::set
void set(const RPC_Hid2RESrcID *hid2re)
initialize the map
Definition
RpcROD_Encoder.cxx:27
RpcROD_Encoder::~RpcROD_Encoder
~RpcROD_Encoder()
destructor
RpcROD_Encoder::fillROD
void fillROD(std::vector< uint32_t > &v)
convert all pad in the current list to a vector of 32bit words
Definition
RpcROD_Encoder.cxx:47
Generated on
for ATLAS Offline Software by
1.17.0