ATLAS Offline Software
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 
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();
26  //
27 } // end-of-PadReadOut::PadReadOut
28 //----------------------------------------------------------------------------//
29 PadReadOut::~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 //----------------------------------------------------------------------------//
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;
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 //----------------------------------------------------------------------------//
118 ubit16 PadReadOut::readHeader() { return m_Header; } // end-of-PadReadOut::readHeader()
119 //----------------------------------------------------------------------------//
120 ubit16 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) {
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) {
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 //----------------------------------------------------------------------------//
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 //----------------------------------------------------------------------------//
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 //----------------------------------------------------------------------------//
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
PadReadOut::bytestream
void bytestream(std::ostream &stream)
Definition: PadReadOut.cxx:167
MatrixReadOut::numberOfFragmentWords
ubit16 numberOfFragmentWords()
Definition: MatrixReadOut.h:50
PadReadOut::m_numberOfWordsInFragment
ubit16 m_numberOfWordsInFragment
Definition: PadReadOut.h:42
PadReadOut.h
PadReadOutStructure::makeHeader
ubit16 makeHeader(ubit16 *inputData)
Definition: PadReadOutStructure.cxx:74
PadReadOutStructure
Definition: PadReadOutStructure.h:13
PadReadOut::makeHeader
void makeHeader()
Definition: PadReadOut.cxx:57
MatrixReadOut::getHeader
MatrixReadOutStructure getHeader()
Definition: MatrixReadOut.cxx:948
MatrixReadOut::readCMAWord
ubit16 readCMAWord()
Definition: MatrixReadOut.cxx:685
PadReadOut::~PadReadOut
~PadReadOut()
Definition: PadReadOut.cxx:29
PadReadOut::m_Footer
ubit16 m_Footer
Definition: PadReadOut.h:56
MatrixReadOut::readHeader
ubit16 readHeader()
Definition: MatrixReadOut.cxx:657
PadReadOut::makeFooter
void makeFooter()
Definition: PadReadOut.cxx:67
ReadOfcFromCool.field
field
Definition: ReadOfcFromCool.py:48
MatrixReadOutStructure::cmid
ubit16 cmid()
Definition: MatrixReadOutStructure.h:30
PadReadOut::getFooter
PadReadOutStructure getFooter()
Definition: PadReadOut.cxx:204
PadReadOut::m_numberOfCMFragments
ubit16 m_numberOfCMFragments
Definition: PadReadOut.h:41
PadReadOut::makeBody
void makeBody(bool debugPrint=false)
Definition: PadReadOut.cxx:74
AthenaPoolTestWrite.stream
string stream
Definition: AthenaPoolTestWrite.py:12
PadReadOut::readPADWord
ubit16 readPADWord()
Definition: PadReadOut.cxx:155
PadReadOut::m_PROS
PadReadOutStructure m_PROS
Definition: PadReadOut.h:51
MatrixReadOut
Definition: MatrixReadOut.h:18
PadReadOut::PadReadOut
PadReadOut(ubit16 padID, MatrixReadOut *MROlist[8])
Definition: PadReadOut.cxx:15
PadReadOutStructure::decodeFragment
ubit16 decodeFragment(ubit16 inputWord, char &field)
Definition: PadReadOutStructure.cxx:118
lumiFormat.i
int i
Definition: lumiFormat.py:85
PadReadOut::m_addressOfWordScanned
ubit16 m_addressOfWordScanned
Definition: PadReadOut.h:40
PadReadOutStructure::makeFooter
ubit16 makeFooter(ubit16 errorCode)
Definition: PadReadOutStructure.h:25
PadReadOutStructure::isHeader
bool isHeader()
Definition: PadReadOutStructure.cxx:166
PadReadOut::m_numberOfWordsRead
ubit16 m_numberOfWordsRead
Definition: PadReadOut.h:45
MatrixReadOut::topCMABody
void topCMABody()
Definition: MatrixReadOut.cxx:718
PadReadOut::decodeBytestream
void decodeBytestream()
Definition: PadReadOut.cxx:175
PadReadOut::readFooter
ubit16 readFooter()
Definition: PadReadOut.cxx:120
PadReadOut::topPADBody
void topPADBody()
Definition: PadReadOut.cxx:41
PadReadOut::m_endOfCMFragments
ubit16 m_endOfCMFragments
Definition: PadReadOut.h:47
merge.output
output
Definition: merge.py:17
PadReadOut::m_newCMRO
ubit16 m_newCMRO
Definition: PadReadOut.h:44
Hardware
@ Hardware
Definition: BaseObject.h:11
PadReadOut::m_MROlist
MatrixReadOut * m_MROlist[8]
Definition: PadReadOut.h:52
BaseObject
Definition: BaseObject.h:13
MatrixReadOutStructure
Definition: MatrixReadOutStructure.h:13
PadReadOut::readHeader
ubit16 readHeader()
Definition: PadReadOut.cxx:118
PadReadOut::m_Header
ubit16 m_Header
Definition: PadReadOut.h:54
MatrixReadOut::numberOfBodyWords
ubit16 numberOfBodyWords()
Definition: MatrixReadOut.h:49
PadReadOut::m_newCMIndex
ubit16 m_newCMIndex
Definition: PadReadOut.h:43
PadReadOut::m_numberOfWordsInCMRO
ubit16 m_numberOfWordsInCMRO
Definition: PadReadOut.h:46
MatrixReadOut::bytestream
void bytestream(std::ostream &stream)
Definition: MatrixReadOut.cxx:795
PadReadOut::m_currentCMRO
MatrixReadOut * m_currentCMRO
Definition: PadReadOut.h:48
PadReadOut::getHeader
PadReadOutStructure getHeader()
Definition: PadReadOut.cxx:199
PadReadOut::reset
void reset()
Definition: PadReadOut.cxx:31
ubit16
unsigned short int ubit16
Definition: RpcByteStreamEncoder.h:20
Overlay::debugPrint
std::string debugPrint(const IDC_Container *container, unsigned numprint=25)
Diagnostic output of Identifiable Containers.
PadReadOut::m_CMAFragment
MatrixReadOut * m_CMAFragment[8]
Definition: PadReadOut.h:55
PadReadOut::readBody
ubit16 readBody()
Definition: PadReadOut.cxx:122
PadReadOut::makeFragment
void makeFragment()
Definition: PadReadOut.cxx:51
PadReadOut::m_padID
ubit16 m_padID
Definition: PadReadOut.h:53