ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Trigger
TrigT1
TrigT1RPChardware
src
PadReadOut.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/PadReadOut.h
"
6
7
#include <cstring>
8
#include <fstream>
9
#include <iomanip>
10
#include <iostream>
11
12
using namespace
std
;
13
14
//----------------------------------------------------------------------------//
15
PadReadOut::PadReadOut
(
ubit16
padID,
MatrixReadOut
*MROlist[8]) :
BaseObject
(
Hardware
,
"PadReadOut"
) {
16
m_padID
= padID;
17
//
18
// copy MROlist pointers to m_MROlist
19
//
20
for
(
ubit16
i = 0; i < 8; i++) {
m_MROlist
[i] = MROlist[i]; }
21
reset
();
22
makeFragment
();
23
// cout<<" After makeFragment number of Words in PadID" << padID << " body =" << m_numberOfWordsInFragment<<endl;
24
topPADBody
();
25
decodeBytestream
();
26
//
27
}
// end-of-PadReadOut::PadReadOut
28
//----------------------------------------------------------------------------//
29
PadReadOut::~PadReadOut
() {}
// end-of-PadReadOut::PadReadOut
30
//----------------------------------------------------------------------------//
31
void
PadReadOut::reset
() {
32
m_Header
= 0x0000;
33
m_Footer
= 0x0000;
34
for
(
ubit16
i = 0; i < 8; i++) {
m_CMAFragment
[i] = 0; }
35
m_numberOfCMFragments
= 0;
36
m_numberOfWordsInFragment
= 0;
37
//
38
topPADBody
();
39
}
// end-of-PadReadOut::reset
40
//----------------------------------------------------------------------------//
41
void
PadReadOut::topPADBody
() {
42
m_addressOfWordScanned
= 0;
43
m_newCMIndex
= 0;
44
m_newCMRO
= 1;
45
m_numberOfWordsInCMRO
= 0;
46
m_numberOfWordsRead
= 0;
47
m_endOfCMFragments
= 0;
48
m_currentCMRO
= 0;
49
}
// end-of-PadReadOut::topPADBody
50
//----------------------------------------------------------------------------//
51
void
PadReadOut::makeFragment
() {
52
makeHeader
();
53
makeBody
();
54
makeFooter
();
55
}
// end-of-PadReadOut::makeFragment
56
//----------------------------------------------------------------------------//
57
void
PadReadOut::makeHeader
() {
58
ubit16
headerval[3];
59
headerval[0] = 0;
60
headerval[1] =
m_padID
;
61
headerval[2] = 0;
// Status bits (to be defined yet)
62
m_Header
=
m_PROS
.makeHeader(headerval);
63
m_numberOfWordsInFragment
+= 1;
64
// cout<<" Header: "<<hex<<m_Header<<dec<<endl;
65
}
// end-of-PadReadOut::makeHeader()
66
//----------------------------------------------------------------------------//
67
void
PadReadOut::makeFooter
() {
68
ubit16
errorCodes[6] = {0, 0, 0, 0, 0, 0};
69
// m_Footer = m_PROS.makeFooter(0);
70
m_Footer
=
m_PROS
.makeFooter(errorCodes);
71
m_numberOfWordsInFragment
+= 1;
72
}
// end-of-PadReadOut::makeFooter()
73
//----------------------------------------------------------------------------//
74
void
PadReadOut::makeBody
(
bool
debugPrint) {
75
MatrixReadOut
*CMAFragment[8] = {0};
76
MatrixReadOutStructure
MROS;
77
ubit16
numberOfCMBodyWords = 0;
78
ubit16
i;
79
if
(debugPrint) cout <<
" makeBody "
<< endl;
80
81
for
(i = 0; i < 8; i++) {
82
if
(
m_MROlist
[i]) {
83
if
(debugPrint) cout <<
m_MROlist
[i] << endl;
84
MROS =
m_MROlist
[i]->getHeader();
85
numberOfCMBodyWords =
m_MROlist
[i]->numberOfBodyWords();
86
ubit16
cmid = MROS.
cmid
();
87
if
(debugPrint)
88
cout <<
" Identificatore di questa Matrice e': "
<< cmid << endl
89
<<
" il numnero di Body words = "
<< numberOfCMBodyWords << endl;
90
if
(cmid < 8) {
91
if
(!CMAFragment[cmid]) {
92
CMAFragment[cmid] =
m_MROlist
[i];
93
}
else
{
94
if
(debugPrint) cout <<
" PadReadOut::makeBody: more than one CMA with address "
<< cmid << endl;
95
}
96
if
(debugPrint) cout <<
" Matrix: "
<< hex <<
m_MROlist
[i]->readHeader() << dec << endl;
97
}
else
{
98
if
(debugPrint) cout <<
" PadReadOut::makeBody: cmid address "
<< cmid <<
" is bad "
<< endl;
99
}
// end-of-if(cmid<8
100
}
// end-of-if(m_MROlist
101
}
// end-of-while
102
//
103
// copy CMAFragment to the array data member m_CMAFragment
104
//
105
ubit16
j = 0;
106
for
(i = 0; i < 8; i++) {
107
if
(CMAFragment[i]) {
108
m_CMAFragment
[j] = CMAFragment[i];
109
if
(debugPrint) cout <<
" makeBody; number of CM WOrds="
<<
m_CMAFragment
[j]->numberOfFragmentWords() << endl;
110
m_numberOfWordsInFragment
+=
m_CMAFragment
[j]->numberOfFragmentWords();
111
j++;
112
}
// end-of-if(
113
}
// end-of-for(i
114
m_numberOfCMFragments
= j;
115
if
(debugPrint) cout <<
" Number of CMA Fragments= "
<<
m_numberOfCMFragments
<< endl;
116
}
// end-of-PadReadOut::makeBody
117
//----------------------------------------------------------------------------//
118
ubit16
PadReadOut::readHeader
() {
return
m_Header
; }
// end-of-PadReadOut::readHeader()
119
//----------------------------------------------------------------------------//
120
ubit16
PadReadOut::readFooter
() {
return
m_Footer
; }
// end-of-PadReadOut::readFooter()
121
//----------------------------------------------------------------------------//
122
ubit16
PadReadOut::readBody
() {
123
ubit16
output = 0xffff;
124
125
// cout<<" m_newCMIndex "<<m_newCMIndex
126
// <<" m_newCMRO "<<m_newCMRO
127
// <<" m_numberOfWordsInCMRO "<<m_numberOfWordsInCMRO
128
// <<" m_numberOfWordsRead "<<m_numberOfWordsRead
129
// <<" m_endOfCMFragments "<<m_endOfCMFragments<<endl;
130
131
if
(
m_newCMRO
) {
132
if
(
m_newCMIndex
< 8) {
133
if
(
m_CMAFragment
[
m_newCMIndex
]) {
134
m_currentCMRO
=
m_CMAFragment
[
m_newCMIndex
];
135
m_currentCMRO
->topCMABody();
136
m_numberOfWordsInCMRO
=
m_currentCMRO
->numberOfFragmentWords();
137
m_numberOfWordsRead
= 0;
138
m_newCMRO
= 0;
139
}
// end
140
m_newCMIndex
++;
141
}
else
{
142
m_endOfCMFragments
= 1;
143
}
// end
144
145
}
// end-of-if(m_newCMRO
146
//
147
if
(!
m_endOfCMFragments
) {
148
output =
m_currentCMRO
->readCMAWord();
149
m_numberOfWordsRead
++;
150
if
(
m_numberOfWordsRead
>=
m_numberOfWordsInCMRO
)
m_newCMRO
= 1;
151
}
// end-of-if(!m_endOfCMFragments
152
return
output;
153
}
// end-of-PadReadOut::readBody()
154
//----------------------------------------------------------------------------//
155
ubit16
PadReadOut::readPADWord
() {
156
ubit16
output = 0xffff;
157
if
(
m_addressOfWordScanned
== 0)
158
output =
readHeader
();
159
else
if
(
m_addressOfWordScanned
== (
m_numberOfWordsInFragment
- 1))
160
output =
readFooter
();
161
else
162
output =
readBody
();
163
m_addressOfWordScanned
++;
164
return
output;
165
}
// end-of-PadReadOut::readPADWord
166
//----------------------------------------------------------------------------//
167
void
PadReadOut::bytestream
(ostream &stream) {
168
stream << hex <<
m_Header
<< dec << endl;
// header
169
for
(
ubit16
i = 0; i <
m_numberOfCMFragments
; i++) {
170
m_CMAFragment
[i]->bytestream(stream);
// body
171
}
// end-of-for(ubit16 i
172
stream << hex <<
m_Footer
<< dec << endl;
// footer
173
}
// end-of-MatrixReadOut::bytestream
174
//----------------------------------------------------------------------------//
175
void
PadReadOut::decodeBytestream
() {
176
PadReadOutStructure
PROS;
177
char
field;
178
ubit16
inputData;
179
//
180
ubit16
padHeaderfound = 0;
181
//
182
topPADBody
();
183
for
(
ubit16
i = 0; i <
m_numberOfWordsInFragment
; i++) {
184
inputData =
readPADWord
();
185
// cout<<" bytestream: current word is "<<hex<<inputData<<dec<<endl;
186
187
if
(!padHeaderfound) {
188
PROS.
decodeFragment
(inputData, field);
189
if
(PROS.
isHeader
()) {
190
padHeaderfound += 1;
191
// cout<<" decodeBytestream: PAD Header Found"<<endl;
192
}
193
}
else
{
194
}
195
196
}
// end-of-for(i
197
}
// end-of-decodeBytestream
198
//----------------------------------------------------------------------------//
199
PadReadOutStructure
PadReadOut::getHeader
() {
200
PadReadOutStructure
theStruct(
m_Header
);
201
return
theStruct;
202
}
// end-of-PadReadOut::getHeader
203
//----------------------------------------------------------------------------//
204
PadReadOutStructure
PadReadOut::getFooter
() {
205
PadReadOutStructure
theStruct(
m_Footer
);
206
return
theStruct;
207
}
// end-of-PadReadOut::getFooter
Hardware
@ Hardware
Definition
BaseObject.h:11
PadReadOut.h
ubit16
unsigned short int ubit16
Definition
RpcByteStreamEncoder.h:20
BaseObject::BaseObject
BaseObject(ObjectType, const std::string &)
Definition
BaseObject.cxx:7
MatrixReadOutStructure
Definition
MatrixReadOutStructure.h:13
MatrixReadOutStructure::cmid
ubit16 cmid()
Definition
MatrixReadOutStructure.h:30
MatrixReadOut
Definition
MatrixReadOut.h:18
PadReadOutStructure
Definition
PadReadOutStructure.h:13
PadReadOutStructure::isHeader
bool isHeader()
Definition
PadReadOutStructure.cxx:166
PadReadOutStructure::decodeFragment
ubit16 decodeFragment(ubit16 inputWord, char &field)
Definition
PadReadOutStructure.cxx:118
PadReadOut::topPADBody
void topPADBody()
Definition
PadReadOut.cxx:41
PadReadOut::m_addressOfWordScanned
ubit16 m_addressOfWordScanned
Definition
PadReadOut.h:40
PadReadOut::readFooter
ubit16 readFooter()
Definition
PadReadOut.cxx:120
PadReadOut::getFooter
PadReadOutStructure getFooter()
Definition
PadReadOut.cxx:204
PadReadOut::makeFooter
void makeFooter()
Definition
PadReadOut.cxx:67
PadReadOut::m_MROlist
MatrixReadOut * m_MROlist[8]
Definition
PadReadOut.h:52
PadReadOut::readHeader
ubit16 readHeader()
Definition
PadReadOut.cxx:118
PadReadOut::reset
void reset()
Definition
PadReadOut.cxx:31
PadReadOut::m_CMAFragment
MatrixReadOut * m_CMAFragment[8]
Definition
PadReadOut.h:55
PadReadOut::bytestream
void bytestream(std::ostream &stream)
Definition
PadReadOut.cxx:167
PadReadOut::readBody
ubit16 readBody()
Definition
PadReadOut.cxx:122
PadReadOut::m_newCMIndex
ubit16 m_newCMIndex
Definition
PadReadOut.h:43
PadReadOut::m_numberOfWordsInFragment
ubit16 m_numberOfWordsInFragment
Definition
PadReadOut.h:42
PadReadOut::makeHeader
void makeHeader()
Definition
PadReadOut.cxx:57
PadReadOut::getHeader
PadReadOutStructure getHeader()
Definition
PadReadOut.cxx:199
PadReadOut::m_padID
ubit16 m_padID
Definition
PadReadOut.h:53
PadReadOut::m_currentCMRO
MatrixReadOut * m_currentCMRO
Definition
PadReadOut.h:48
PadReadOut::~PadReadOut
~PadReadOut()
Definition
PadReadOut.cxx:29
PadReadOut::readPADWord
ubit16 readPADWord()
Definition
PadReadOut.cxx:155
PadReadOut::m_Header
ubit16 m_Header
Definition
PadReadOut.h:54
PadReadOut::makeBody
void makeBody(bool debugPrint=false)
Definition
PadReadOut.cxx:74
PadReadOut::PadReadOut
PadReadOut(ubit16 padID, MatrixReadOut *MROlist[8])
Definition
PadReadOut.cxx:15
PadReadOut::m_newCMRO
ubit16 m_newCMRO
Definition
PadReadOut.h:44
PadReadOut::m_numberOfWordsRead
ubit16 m_numberOfWordsRead
Definition
PadReadOut.h:45
PadReadOut::m_endOfCMFragments
ubit16 m_endOfCMFragments
Definition
PadReadOut.h:47
PadReadOut::decodeBytestream
void decodeBytestream()
Definition
PadReadOut.cxx:175
PadReadOut::makeFragment
void makeFragment()
Definition
PadReadOut.cxx:51
PadReadOut::m_PROS
PadReadOutStructure m_PROS
Definition
PadReadOut.h:51
PadReadOut::m_Footer
ubit16 m_Footer
Definition
PadReadOut.h:56
PadReadOut::m_numberOfWordsInCMRO
ubit16 m_numberOfWordsInCMRO
Definition
PadReadOut.h:46
PadReadOut::m_numberOfCMFragments
ubit16 m_numberOfCMFragments
Definition
PadReadOut.h:41
std
STL namespace.
Generated on
for ATLAS Offline Software by
1.17.0