ATLAS Offline Software
Loading...
Searching...
No Matches
PadReadOutStructure.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 <fstream>
8#include <iostream>
9#include <string>
10
11// header structure
12const ubit16 PadReadOutStructure::s_headerPos[s_headerNum] = {12, 9, 0};
13// const ubit16 PadReadOutStructure::s_headerPos[s_headerNum] ={ 12, 8, 0};
14const ubit16 PadReadOutStructure::s_headerLen[s_headerNum] = {4, 3, 9};
15// const ubit16 PadReadOutStructure::s_headerLen[s_headerNum] ={ 4, 4, 8};
17// subheader structure
18const ubit16 PadReadOutStructure::s_subHeaderPos[s_subHeaderNum] = {12, 0};
19const ubit16 PadReadOutStructure::s_subHeaderLen[s_subHeaderNum] = {4, 12};
21// prefooter structure
22const ubit16 PadReadOutStructure::s_prefooterPos[s_prefooterNum] = {12, 3, 2, 1, 0};
23const ubit16 PadReadOutStructure::s_prefooterLen[s_prefooterNum] = {4, 1, 1, 1, 1};
25// footer structure
26const ubit16 PadReadOutStructure::s_footerPos[s_footerNum] = {12, 11, 10, 9, 8, 0};
27// const ubit16 PadReadOutStructure::s_footerPos[s_footerNum]={ 12,0};
28const ubit16 PadReadOutStructure::s_footerLen[s_footerNum] = {4, 1, 1, 1, 1, 8};
29// const ubit16 PadReadOutStructure::s_footerLen[s_footerNum]={ 4,12};
31
32//----------------------------------------------------------------------------//
34 //
35 // Constructor used by the simulation program
36 //
37 m_padid = 0xffff;
38 m_l1id = 0xffff;
39 m_bcid = 0xffff;
40 m_fifoCM = 0xffff;
41 m_fifoOR = 0xffff;
42 m_fifoL1 = 0xffff;
43 m_fifoPAD = 0xffff;
44 m_status = 0xffff;
45 m_errorSH = 0xffff;
46 m_errorL1 = 0xffff;
47 m_errorH = 0xffff;
48 m_errorCM = 0xffff;
49 m_errorCMID = 0xffff;
50 m_errorCode = 0xffff;
52 setInit();
53}
54//----------------------------------------------------------------------------//
56 //
57 // Constructor used by the simulation program
58 //
60 decodeFragment(inputData, m_field);
61}
62//----------------------------------------------------------------------------//
63
65 m_field = 'U';
66 // m_word =0xffff;
67 // m_padid =0xffff;
68 // m_status =0xffff;
69 // m_errorCode =0xffff;
70}
71
72//----------------------------------------------------------------------------//
73
75 // m_status = *(inputData+2);
76 m_padid = *(inputData + 1);
77 m_l1id = *(inputData + 2);
78 // ubit16 theHeader[s_headerNum] = *inputData;
79 //={s_headerVal,*(inputData+1),*(inputData+2)};
80 m_vectorStruct = inputData;
83 return m_word;
84}
85//----------------------------------------------------------------------------//
86/*
87ubit16 PadReadOutStructure::makeFooter_new(ubit16* inputData) {
88 // m_errorCode= *inputData;
89 m_errorSH = *(inputData+1);
90 m_errorL1 = *(inputData+2);
91 m_errorH = *(inputData+3);
92 m_errorCM = *(inputData+4);
93 m_errorCMID =*(inputData+5);
94 m_vectorStruct = inputData;
95 *(m_vectorStruct)= s_footerVal;
96 // ubit16 theFooter[s_footerNum]={s_footerVal};
97 //for(int i=1;i<5;i++) *(theFooter+i) = *(inputData+i);
98 m_word = set16Bits(s_footerNum,s_footerPos,m_vectorStruct);//theFooter);
99 return m_word;
100}
101*/
102//----------------------------------------------------------------------------//
104 // m_errorCode= *inputData;
105 m_errorSH = *(inputData + 1);
106 m_errorL1 = *(inputData + 2);
107 m_errorH = *(inputData + 3);
108 m_errorCM = *(inputData + 4);
109 m_errorCMID = *(inputData + 5);
110 m_vectorStruct = inputData;
112 // ubit16 theFooter[s_footerNum]={s_footerVal};
113 // for(int i=1;i<5;i++) *(theFooter+i) = *(inputData+i);
115 return m_word;
116}
117//----------------------------------------------------------------------------//
119 // Removed last because it is not used
120 // bool last=false;
121 ubit16 errorCode = 0;
122 setInit();
123 m_word = inputWord;
124 errorCode = 0;
125 if (isHeader()) {
126 m_field = 'H';
127 m_padid = get16Bits(inputWord, s_headerPos[1], s_headerLen[1]);
128 m_l1id = get16Bits(inputWord, s_headerPos[2], s_headerLen[2]);
129 } else if (isSubHeader()) {
130 m_field = 'S';
131 m_bcid = get16Bits(inputWord, s_subHeaderPos[1], s_subHeaderLen[1]);
132 } else if (isPreFooter()) {
133 m_field = 'P';
134 m_fifoCM = get16Bits(inputWord, s_prefooterPos[1], s_prefooterLen[1]);
135 m_fifoOR = get16Bits(inputWord, s_prefooterPos[2], s_prefooterLen[2]);
136 m_fifoL1 = get16Bits(inputWord, s_prefooterPos[3], s_prefooterLen[3]);
138 m_status = inputWord & 0x0fff;
139 } else if (isFooter()) {
140 m_field = 'F';
141 m_errorSH = get16Bits(inputWord, s_footerPos[1], s_footerLen[1]);
142 m_errorL1 = get16Bits(inputWord, s_footerPos[2], s_footerLen[2]);
143 m_errorH = get16Bits(inputWord, s_footerPos[3], s_footerLen[3]);
144 m_errorCM = get16Bits(inputWord, s_footerPos[4], s_footerLen[4]);
145 m_errorCMID = get16Bits(inputWord, s_footerPos[5], s_footerLen[5]);
146 m_errorCode = inputWord & 0x0fff;
147 } else {
148 m_field = 'B';
149 if ((m_word & 0xf000) == (m_MRS.getFooterVal() << 12)) {
150 /* last=true; */
151 } else {
152 /* last=false; */
153 }
154 }
155 field = m_field;
156 return errorCode; // temporary: force return to 0
157}
158
159//----------------------------------------------------------------------------//
161 ubit16 theword = (m_word & 0xf000) >> 12;
162 if ((theword != s_headerVal) && (theword != s_subHeaderVal) && (theword != s_prefooterVal) && (theword != s_footerVal)) return true;
163 return false;
164}
165//----------------------------------------------------------------------------//
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//-----------------------------------------------------------------------//
175 bool status = false;
176 ubit16 theSubHeader[s_subHeaderNum] = {s_subHeaderVal};
177 if ((m_word & s_last4bitsON) == set16Bits(1, s_subHeaderPos, theSubHeader)) status = true;
178 return status;
179}
180
181//-----------------------------------------------------------------------//
183 bool status = false;
184 ubit16 thepreFooter[s_prefooterNum] = {s_prefooterVal};
185 if ((m_word & s_last4bitsON) == set16Bits(1, s_prefooterPos, thepreFooter)) status = true;
186 return status;
187}
188
189//-----------------------------------------------------------------------//
191 bool status = false;
192 ubit16 theFooter[s_footerNum] = {s_footerVal};
193 if ((m_word & s_last4bitsON) == set16Bits(1, s_footerPos, theFooter)) status = true;
194 return status;
195}
unsigned short int ubit16
static const ubit16 s_subHeaderNum
ubit16 makeFooter(ubit16 errorCode)
static const ubit16 s_footerNum
static const ubit16 s_prefooterLen[s_prefooterNum]
static const ubit16 s_subHeaderVal
static const ubit16 s_subHeaderLen[s_subHeaderNum]
static const ubit16 s_footerLen[s_footerNum]
static const ubit16 s_headerVal
static const ubit16 s_prefooterVal
static const ubit16 s_prefooterPos[s_prefooterNum]
static const ubit16 s_headerNum
static const ubit16 s_footerPos[s_footerNum]
static const ubit16 s_subHeaderPos[s_subHeaderNum]
static const ubit16 s_footerVal
MatrixReadOutStructure m_MRS
static const ubit16 s_prefooterNum
static const ubit16 s_headerLen[s_headerNum]
ubit16 makeHeader(ubit16 *inputData)
static const ubit16 s_headerPos[s_headerNum]
ubit16 decodeFragment(ubit16 inputWord, char &field)
static constexpr ubit16 s_last4bitsON
Definition RPCReadOut.h:56
char field() const
Definition RPCReadOut.h:19
ubit16 get16Bits(const ubit16 input, const ubit16 position, const ubit16 length) const
Definition RPCReadOut.h:47
ubit16 set16Bits(const ubit16 n, const ubit16 *pos, const ubit16 *val) const
Definition RPCReadOut.h:30
ubit16 m_word
Definition RPCReadOut.h:27
char m_field
Definition RPCReadOut.h:28