ATLAS Offline Software
Loading...
Searching...
No Matches
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
6
7#include <cstring>
8#include <fstream>
9#include <iomanip>
10#include <iostream>
11
12using namespace std;
13
14//----------------------------------------------------------------------------//
15PadReadOut::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();
23 // cout<<" After makeFragment number of Words in PadID" << padID << " body =" << m_numberOfWordsInFragment<<endl;
24 topPADBody();
26 //
27} // end-of-PadReadOut::PadReadOut
28//----------------------------------------------------------------------------//
29PadReadOut::~PadReadOut() {} // end-of-PadReadOut::PadReadOut
30//----------------------------------------------------------------------------//
32 m_Header = 0x0000;
33 m_Footer = 0x0000;
34 for (ubit16 i = 0; i < 8; i++) { m_CMAFragment[i] = 0; }
37 //
38 topPADBody();
39} // end-of-PadReadOut::reset
40//----------------------------------------------------------------------------//
43 m_newCMIndex = 0;
44 m_newCMRO = 1;
48 m_currentCMRO = 0;
49} // end-of-PadReadOut::topPADBody
50//----------------------------------------------------------------------------//
52 makeHeader();
53 makeBody();
54 makeFooter();
55} // end-of-PadReadOut::makeFragment
56//----------------------------------------------------------------------------//
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);
64 // cout<<" Header: "<<hex<<m_Header<<dec<<endl;
65} // end-of-PadReadOut::makeHeader()
66//----------------------------------------------------------------------------//
68 ubit16 errorCodes[6] = {0, 0, 0, 0, 0, 0};
69 // m_Footer = m_PROS.makeFooter(0);
70 m_Footer = m_PROS.makeFooter(errorCodes);
72} // end-of-PadReadOut::makeFooter()
73//----------------------------------------------------------------------------//
74void PadReadOut::makeBody(bool debugPrint) {
75 MatrixReadOut *CMAFragment[8] = {0};
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
115 if (debugPrint) cout << " Number of CMA Fragments= " << m_numberOfCMFragments << endl;
116} // end-of-PadReadOut::makeBody
117//----------------------------------------------------------------------------//
118ubit16 PadReadOut::readHeader() { return m_Header; } // end-of-PadReadOut::readHeader()
119//----------------------------------------------------------------------------//
120ubit16 PadReadOut::readFooter() { return m_Footer; } // end-of-PadReadOut::readFooter()
121//----------------------------------------------------------------------------//
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) {
135 m_currentCMRO->topCMABody();
136 m_numberOfWordsInCMRO = m_currentCMRO->numberOfFragmentWords();
138 m_newCMRO = 0;
139 } // end
140 m_newCMIndex++;
141 } else {
143 } // end
144
145 } // end-of-if(m_newCMRO
146 //
147 if (!m_endOfCMFragments) {
148 output = m_currentCMRO->readCMAWord();
151 } // end-of-if(!m_endOfCMFragments
152 return output;
153} // end-of-PadReadOut::readBody()
154//----------------------------------------------------------------------------//
156 ubit16 output = 0xffff;
157 if (m_addressOfWordScanned == 0)
158 output = readHeader();
160 output = readFooter();
161 else
162 output = readBody();
164 return output;
165} // end-of-PadReadOut::readPADWord
166//----------------------------------------------------------------------------//
167void 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//----------------------------------------------------------------------------//
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//----------------------------------------------------------------------------//
200 PadReadOutStructure theStruct(m_Header);
201 return theStruct;
202} // end-of-PadReadOut::getHeader
203//----------------------------------------------------------------------------//
205 PadReadOutStructure theStruct(m_Footer);
206 return theStruct;
207} // end-of-PadReadOut::getFooter
@ Hardware
Definition BaseObject.h:11
unsigned short int ubit16
BaseObject(ObjectType, const std::string &)
Definition BaseObject.cxx:7
ubit16 decodeFragment(ubit16 inputWord, char &field)
void topPADBody()
ubit16 m_addressOfWordScanned
Definition PadReadOut.h:40
ubit16 readFooter()
PadReadOutStructure getFooter()
void makeFooter()
MatrixReadOut * m_MROlist[8]
Definition PadReadOut.h:52
ubit16 readHeader()
void reset()
MatrixReadOut * m_CMAFragment[8]
Definition PadReadOut.h:55
void bytestream(std::ostream &stream)
ubit16 readBody()
ubit16 m_newCMIndex
Definition PadReadOut.h:43
ubit16 m_numberOfWordsInFragment
Definition PadReadOut.h:42
void makeHeader()
PadReadOutStructure getHeader()
ubit16 m_padID
Definition PadReadOut.h:53
MatrixReadOut * m_currentCMRO
Definition PadReadOut.h:48
ubit16 readPADWord()
ubit16 m_Header
Definition PadReadOut.h:54
void makeBody(bool debugPrint=false)
PadReadOut(ubit16 padID, MatrixReadOut *MROlist[8])
ubit16 m_newCMRO
Definition PadReadOut.h:44
ubit16 m_numberOfWordsRead
Definition PadReadOut.h:45
ubit16 m_endOfCMFragments
Definition PadReadOut.h:47
void decodeBytestream()
void makeFragment()
PadReadOutStructure m_PROS
Definition PadReadOut.h:51
ubit16 m_Footer
Definition PadReadOut.h:56
ubit16 m_numberOfWordsInCMRO
Definition PadReadOut.h:46
ubit16 m_numberOfCMFragments
Definition PadReadOut.h:41
STL namespace.