ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Trigger
TrigT1
TrigT1RPChardware
src
MatrixReadOutStructure.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include "
TrigT1RPChardware/MatrixReadOutStructure.h
"
6
7
#include <cstring>
8
#include <fstream>
9
#include <iostream>
10
11
#include "
TrigT1RPChardware/RPCReadOut.h
"
12
13
using namespace
std
;
14
15
// header structure
16
const
ubit16
MatrixReadOutStructure::s_headerPos
[s_headerNum] = {12, 9, 0};
17
const
ubit16
MatrixReadOutStructure::s_headerLen
[s_headerNum] = {4, 3, 9};
18
const
ubit16
MatrixReadOutStructure::s_headerVal
= 0x000c;
19
// subheader structure
20
const
ubit16
MatrixReadOutStructure::s_subHeaderPos
[s_subHeaderNum] = {12, 0};
21
const
ubit16
MatrixReadOutStructure::s_subHeaderLen
[s_subHeaderNum] = {4, 12};
22
const
ubit16
MatrixReadOutStructure::s_subHeaderVal
= 8;
23
// body structure
24
const
ubit16
MatrixReadOutStructure::s_CMABodyPos
[s_CMABodyNum] = {14, 11, 8, 5, 0};
25
const
ubit16
MatrixReadOutStructure::s_CMABodyLen
[s_CMABodyNum] = {2, 3, 3, 3, 5};
26
const
ubit16
MatrixReadOutStructure::s_CMABodyVal
= 0;
27
// footer structure
28
const
ubit16
MatrixReadOutStructure::s_footerPos
[s_footerNum] = {14, 8, 0};
29
const
ubit16
MatrixReadOutStructure::s_footerLen
[s_footerNum] = {2, 6, 8};
30
const
ubit16
MatrixReadOutStructure::s_footerVal
= 1;
31
//
32
// old structure: valid till march 2006; replaced with the new
33
// footer length: 2 bits instead of 4 (see above)
34
//
35
// const ubit16 MatrixReadOutStructure::s_footerPos[s_footerNum]={ 12, 8, 0};
36
// const ubit16 MatrixReadOutStructure::s_footerLen[s_footerNum]={ 4, 4, 8};
37
// const ubit16 MatrixReadOutStructure::s_footerVal=4;
38
39
//----------------------------------------------------------------------------//
40
MatrixReadOutStructure::MatrixReadOutStructure
() {
41
//
42
// Constructor used by the simulation program
43
//
44
setInit
();
45
}
// end-of-MatrixReadOutStructure::MatrixReadOutStructure()
46
//----------------------------------------------------------------------------//
47
MatrixReadOutStructure::MatrixReadOutStructure
(
ubit16
inputData) {
48
decodeFragment
(inputData,
m_field
);
49
}
// end-of-MatrixReadOutStructure::MatrixReadOutStructure(ubit16 inputData)
50
//----------------------------------------------------------------------------//
51
void
MatrixReadOutStructure::setInit
() {
52
m_field
=
'U'
;
53
m_word
= 0xffff;
54
m_cmid
= 0xffff;
55
m_fel1id
= 0xffff;
56
m_febcid
= 0xffff;
57
m_bcid
= 0xffff;
58
m_time
= 0xffff;
59
m_ijk
= 0xffff;
60
m_channel
= 0xffff;
61
m_strip
= 0xffff;
62
m_threshold
= 0xffff;
63
m_overlap
= 0xffff;
64
m_status
= 0xffff;
65
m_crc
= 0xffff;
66
}
// end-of-MatrixReadOutStructure::MatrixReadOutStructure
67
//----------------------------------------------------------------------------//
68
ubit16
MatrixReadOutStructure::makeHeader
(
ubit16
*inputData) {
69
const
ubit16
theHeader[
s_headerNum
] = {
s_headerVal
, *(inputData + 1), *(inputData + 2)};
70
m_cmid
= *(inputData + 1);
71
m_fel1id
= *(inputData + 2);
72
m_word
=
set16Bits
(
s_headerNum
,
s_headerPos
, theHeader);
73
return
m_word
;
74
}
// end-of-MatrixReadOutStructure::makeHeader
75
//----------------------------------------------------------------------------//
76
ubit16
MatrixReadOutStructure::makeSubHeader
() {
77
m_febcid
= 1;
78
const
ubit16
theSubHeader[
s_subHeaderNum
] = {
s_subHeaderVal
, 1};
79
m_word
=
set16Bits
(
s_subHeaderNum
,
s_subHeaderPos
, theSubHeader);
80
return
m_word
;
81
}
// end-of-MatrixReadOutStructure::makeSubHeader
82
//----------------------------------------------------------------------------//
83
ubit16
MatrixReadOutStructure::makeBody
(
ubit16
*inputData) {
84
m_bcid
= *(inputData);
85
m_time
= *(inputData + 1);
86
m_ijk
= *(inputData + 2);
87
if
(
m_ijk
< 7) {
88
m_channel
= *(inputData + 3);
89
}
else
{
90
ubit16
temp
= *(inputData + 3);
91
m_overlap
=
temp
>> 2;
92
m_threshold
=
temp
& 3;
93
}
94
ubit16
theCMABody[
s_CMABodyNum
];
95
for
(
ubit16
i = 0; i <
s_CMABodyNum
; i++) { theCMABody[i] = *(inputData + i); }
96
m_word
=
set16Bits
(
s_CMABodyNum
,
s_CMABodyPos
, theCMABody);
97
return
m_word
;
98
}
// end-of-MatrixReadOutStructure::makeBodyHit
99
//----------------------------------------------------------------------------//
100
ubit16
MatrixReadOutStructure::makeFooter
(
ubit16
inputData) {
101
m_status
= 1;
102
m_crc
= inputData;
103
const
ubit16
theFooter[
s_footerNum
] = {
s_footerVal
,
m_status
,
m_crc
};
104
m_word
=
set16Bits
(
s_footerNum
,
s_footerPos
, theFooter);
105
return
m_word
;
106
}
// end-of-MatrixReadOutStructure::makeFooter
107
//----------------------------------------------------------------------------//
108
ubit16
MatrixReadOutStructure::makeFooter
(
ubit16
*inputData) {
return
(*inputData) & 0x0; }
// end-of-MatrixReadOutStructure::makeFooter
109
110
//----------------------------------------------------------------------------//
111
ubit16
MatrixReadOutStructure::decodeFragment
(
ubit16
inputWord,
char
&
field
) {
112
//
113
// method to decode the words present in the CM event fragment
114
//
115
// inputWord 16-bit input word;
116
//
117
// field character that returns the type of the word "inputWord">
118
// H header;
119
// S subheader;
120
// B body;
121
// F footer;
122
// U unkown: none of the types above listed.
123
//
124
// The value 0 is returned if the word is recognized; otherwise 1 is returned.
125
//
126
// The results of the decoding are stored in the class members.
127
128
setInit
();
129
m_word
= inputWord;
130
ubit16
temp
;
131
ubit16
outputFlag = 0;
132
if
(
isBody
()) {
133
m_field
=
'B'
;
134
m_bcid
=
get16Bits
(inputWord,
s_CMABodyPos
[1],
s_CMABodyLen
[1]);
135
m_time
=
get16Bits
(inputWord,
s_CMABodyPos
[2],
s_CMABodyLen
[2]);
136
m_ijk
=
get16Bits
(inputWord,
s_CMABodyPos
[3],
s_CMABodyLen
[3]);
137
if
(
m_ijk
< 7) {
138
m_channel
=
get16Bits
(inputWord,
s_CMABodyPos
[4],
s_CMABodyLen
[4]);
139
m_strip
=
global_channel
();
140
}
else
{
141
temp
=
get16Bits
(inputWord,
s_CMABodyPos
[4],
s_CMABodyLen
[4]);
142
m_overlap
=
temp
>> 2;
143
m_threshold
=
temp
& 3;
144
}
145
}
else
if
(
isHeader
()) {
146
m_field
=
'H'
;
147
m_cmid
=
get16Bits
(inputWord,
s_headerPos
[1],
s_headerLen
[1]);
148
m_fel1id
=
get16Bits
(inputWord,
s_headerPos
[2],
s_headerLen
[2]);
149
}
else
if
(
isSubHeader
()) {
150
m_field
=
'S'
;
151
m_febcid
=
get16Bits
(inputWord,
s_subHeaderPos
[1],
s_subHeaderLen
[1]);
152
}
else
if
(
isFooter
()) {
153
m_field
=
'F'
;
154
m_status
=
get16Bits
(inputWord,
s_footerPos
[1],
s_footerLen
[1]);
155
m_crc
=
get16Bits
(inputWord,
s_footerPos
[2],
s_footerLen
[2]);
156
}
else
{
157
m_field
=
'U'
;
158
outputFlag = 1;
159
}
160
161
field
=
m_field
;
162
return
outputFlag;
163
}
// end-of-decodeFragment
164
//----------------------------------------------------------------------------//
165
166
bool
MatrixReadOutStructure::isHeader
() {
167
bool
status
=
false
;
168
ubit16
theHeader[
s_headerNum
] = {
s_headerVal
};
169
if
((
m_word
&
s_last4bitsON
) ==
set16Bits
(1,
s_headerPos
, theHeader))
status
=
true
;
170
return
status
;
171
}
172
//----------------------------------------------------------------------------//
173
bool
MatrixReadOutStructure::isSubHeader
() {
174
bool
status
=
false
;
175
ubit16
theSubHeader[
s_subHeaderNum
] = {
s_subHeaderVal
};
176
if
((
m_word
&
s_last4bitsON
) ==
set16Bits
(1,
s_subHeaderPos
, theSubHeader))
status
=
true
;
177
return
status
;
178
}
179
//----------------------------------------------------------------------------//
180
bool
MatrixReadOutStructure::isBody
() {
181
bool
status
=
false
;
182
ubit16
theCMABody[
s_CMABodyNum
] = {
s_CMABodyVal
};
183
if
((
m_word
&
s_last2bitsON
) ==
set16Bits
(1,
s_CMABodyPos
, theCMABody))
status
=
true
;
184
return
status
;
185
}
186
//----------------------------------------------------------------------------//
187
bool
MatrixReadOutStructure::isFooter
() {
188
bool
status
=
false
;
189
ubit16
theFooter[
s_footerNum
] = {
s_footerVal
};
190
//
191
// old field mapping
192
//
193
// if( (m_word&last4bitsON)== set16Bits(1,s_footerPos,theFooter)) status=true;
194
if
((
m_word
&
s_last2bitsON
) ==
set16Bits
(1,
s_footerPos
, theFooter))
status
=
true
;
195
return
status
;
196
}
197
//----------------------------------------------------------------------------//
198
ubit16
MatrixReadOutStructure::global_channel
() {
199
ubit16
channel
=
m_channel
;
200
if
(
m_ijk
== 3 ||
m_ijk
== 5)
channel
=
channel
+ 32;
201
return
channel
;
202
}
203
204
ubit16
MatrixReadOutStructure::isPivot
() {
205
if
(
m_ijk
== 0 ||
m_ijk
== 1)
206
return
1;
207
else
208
return
0;
209
}
210
211
bool
MatrixReadOutStructure::isTrigger
() {
212
if
(
m_ijk
== 6)
213
return
true
;
214
else
215
return
false
;
216
}
217
//----------------------------------------------------------------------------//
218
bool
MatrixReadOutStructure::isLowPt
() {
219
bool
output;
220
m_cmid
& 0x0004 ? output = false : output =
true
;
221
return
output;
222
}
// end-of-MatrixReadOutStructure::lowPt()
223
//----------------------------------------------------------------------------//
224
bool
MatrixReadOutStructure::isHigPt
() {
return
!
isLowPt
(); }
// end-of-MatrixReadOutStructure::higPt()
225
//----------------------------------------------------------------------------//
226
bool
MatrixReadOutStructure::isEtaProj
() {
227
bool
output;
228
m_cmid
& 0x0002 ? output = false : output =
true
;
229
return
output;
230
}
// end-of-MatrixReadOutStructure::etaProj()
231
//----------------------------------------------------------------------------//
232
bool
MatrixReadOutStructure::isPhiProj
() {
return
!
isEtaProj
(); }
// end-of-MatrixReadOutStructure::phiProj()
233
//----------------------------------------------------------------------------//
234
bool
MatrixReadOutStructure::is0LocAdd
() {
235
bool
output;
236
m_cmid
& 0x0001 ? output = false : output =
true
;
237
return
output;
238
}
// end-of-MatrixReadOutStructure::0LocAdd()
239
//----------------------------------------------------------------------------//
240
bool
MatrixReadOutStructure::is1LocAdd
() {
return
!
is0LocAdd
(); }
// end-of-MatrixReadOutStructure::1LocAdd()
241
//----------------------------------------------------------------------------//
MatrixReadOutStructure.h
RPCReadOut.h
ubit16
unsigned short int ubit16
Definition
RpcByteStreamEncoder.h:20
MatrixReadOutStructure::s_footerVal
static const ubit16 s_footerVal
Definition
MatrixReadOutStructure.h:103
MatrixReadOutStructure::isLowPt
bool isLowPt()
Definition
MatrixReadOutStructure.cxx:218
MatrixReadOutStructure::s_headerLen
static const ubit16 s_headerLen[s_headerNum]
Definition
MatrixReadOutStructure.h:17
MatrixReadOutStructure::m_time
ubit16 m_time
Definition
MatrixReadOutStructure.h:78
MatrixReadOutStructure::s_headerPos
static const ubit16 s_headerPos[s_headerNum]
Definition
MatrixReadOutStructure.h:16
MatrixReadOutStructure::s_footerNum
static const ubit16 s_footerNum
Definition
MatrixReadOutStructure.h:100
MatrixReadOutStructure::s_CMABodyLen
static const ubit16 s_CMABodyLen[s_CMABodyNum]
Definition
MatrixReadOutStructure.h:25
MatrixReadOutStructure::isPivot
ubit16 isPivot()
Definition
MatrixReadOutStructure.cxx:204
MatrixReadOutStructure::is0LocAdd
bool is0LocAdd()
Definition
MatrixReadOutStructure.cxx:234
MatrixReadOutStructure::channel
ubit16 channel()
Definition
MatrixReadOutStructure.h:36
MatrixReadOutStructure::status
ubit16 status()
Definition
MatrixReadOutStructure.h:39
MatrixReadOutStructure::global_channel
ubit16 global_channel()
Definition
MatrixReadOutStructure.cxx:198
MatrixReadOutStructure::s_subHeaderVal
static const ubit16 s_subHeaderVal
Definition
MatrixReadOutStructure.h:95
MatrixReadOutStructure::s_headerVal
static const ubit16 s_headerVal
Definition
MatrixReadOutStructure.h:91
MatrixReadOutStructure::m_overlap
ubit16 m_overlap
Definition
MatrixReadOutStructure.h:83
MatrixReadOutStructure::isBody
bool isBody()
Definition
MatrixReadOutStructure.cxx:180
MatrixReadOutStructure::decodeFragment
ubit16 decodeFragment(ubit16 inputWord, char &field)
Definition
MatrixReadOutStructure.cxx:111
MatrixReadOutStructure::MatrixReadOutStructure
MatrixReadOutStructure()
Definition
MatrixReadOutStructure.cxx:40
MatrixReadOutStructure::s_footerLen
static const ubit16 s_footerLen[s_footerNum]
Definition
MatrixReadOutStructure.h:29
MatrixReadOutStructure::is1LocAdd
bool is1LocAdd()
Definition
MatrixReadOutStructure.cxx:240
MatrixReadOutStructure::s_CMABodyNum
static const ubit16 s_CMABodyNum
Definition
MatrixReadOutStructure.h:96
MatrixReadOutStructure::makeSubHeader
ubit16 makeSubHeader()
Definition
MatrixReadOutStructure.cxx:76
MatrixReadOutStructure::setInit
void setInit()
Definition
MatrixReadOutStructure.cxx:51
MatrixReadOutStructure::isTrigger
bool isTrigger()
Definition
MatrixReadOutStructure.cxx:211
MatrixReadOutStructure::isHeader
bool isHeader()
Definition
MatrixReadOutStructure.cxx:166
MatrixReadOutStructure::isEtaProj
bool isEtaProj()
Definition
MatrixReadOutStructure.cxx:226
MatrixReadOutStructure::makeBody
ubit16 makeBody(ubit16 *inputData)
Definition
MatrixReadOutStructure.cxx:83
MatrixReadOutStructure::s_subHeaderLen
static const ubit16 s_subHeaderLen[s_subHeaderNum]
Definition
MatrixReadOutStructure.h:21
MatrixReadOutStructure::m_threshold
ubit16 m_threshold
Definition
MatrixReadOutStructure.h:82
MatrixReadOutStructure::m_ijk
ubit16 m_ijk
Definition
MatrixReadOutStructure.h:79
MatrixReadOutStructure::isPhiProj
bool isPhiProj()
Definition
MatrixReadOutStructure.cxx:232
MatrixReadOutStructure::m_crc
ubit16 m_crc
Definition
MatrixReadOutStructure.h:85
MatrixReadOutStructure::m_strip
ubit16 m_strip
Definition
MatrixReadOutStructure.h:81
MatrixReadOutStructure::s_subHeaderPos
static const ubit16 s_subHeaderPos[s_subHeaderNum]
Definition
MatrixReadOutStructure.h:20
MatrixReadOutStructure::makeHeader
ubit16 makeHeader(ubit16 *inputData)
Definition
MatrixReadOutStructure.cxx:68
MatrixReadOutStructure::m_channel
ubit16 m_channel
Definition
MatrixReadOutStructure.h:80
MatrixReadOutStructure::m_bcid
ubit16 m_bcid
Definition
MatrixReadOutStructure.h:77
MatrixReadOutStructure::isHigPt
bool isHigPt()
Definition
MatrixReadOutStructure.cxx:224
MatrixReadOutStructure::m_cmid
ubit16 m_cmid
Definition
MatrixReadOutStructure.h:74
MatrixReadOutStructure::isFooter
bool isFooter()
Definition
MatrixReadOutStructure.cxx:187
MatrixReadOutStructure::s_CMABodyVal
static const ubit16 s_CMABodyVal
Definition
MatrixReadOutStructure.h:99
MatrixReadOutStructure::makeFooter
ubit16 makeFooter(ubit16 inputData)
Definition
MatrixReadOutStructure.cxx:100
MatrixReadOutStructure::isSubHeader
bool isSubHeader()
Definition
MatrixReadOutStructure.cxx:173
MatrixReadOutStructure::s_headerNum
static const ubit16 s_headerNum
Definition
MatrixReadOutStructure.h:88
MatrixReadOutStructure::m_status
ubit16 m_status
Definition
MatrixReadOutStructure.h:84
MatrixReadOutStructure::m_febcid
ubit16 m_febcid
Definition
MatrixReadOutStructure.h:76
MatrixReadOutStructure::s_subHeaderNum
static const ubit16 s_subHeaderNum
Definition
MatrixReadOutStructure.h:92
MatrixReadOutStructure::s_footerPos
static const ubit16 s_footerPos[s_footerNum]
Definition
MatrixReadOutStructure.h:28
MatrixReadOutStructure::m_fel1id
ubit16 m_fel1id
Definition
MatrixReadOutStructure.h:75
MatrixReadOutStructure::s_CMABodyPos
static const ubit16 s_CMABodyPos[s_CMABodyNum]
Definition
MatrixReadOutStructure.h:24
RPCReadOut::s_last2bitsON
static constexpr ubit16 s_last2bitsON
Definition
RPCReadOut.h:55
RPCReadOut::s_last4bitsON
static constexpr ubit16 s_last4bitsON
Definition
RPCReadOut.h:56
RPCReadOut::field
char field() const
Definition
RPCReadOut.h:19
RPCReadOut::get16Bits
ubit16 get16Bits(const ubit16 input, const ubit16 position, const ubit16 length) const
Definition
RPCReadOut.h:47
RPCReadOut::set16Bits
ubit16 set16Bits(const ubit16 n, const ubit16 *pos, const ubit16 *val) const
Definition
RPCReadOut.h:30
RPCReadOut::m_word
ubit16 m_word
Definition
RPCReadOut.h:27
RPCReadOut::m_field
char m_field
Definition
RPCReadOut.h:28
std
STL namespace.
temp
Definition
JetEventDict.h:21
Generated on
for ATLAS Offline Software by
1.17.0