ATLAS Offline Software
Loading...
Searching...
No Matches
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
6
7#include <cstring>
8#include <fstream>
9#include <iostream>
10
12
13using namespace std;
14
15// header structure
16const ubit16 MatrixReadOutStructure::s_headerPos[s_headerNum] = {12, 9, 0};
17const ubit16 MatrixReadOutStructure::s_headerLen[s_headerNum] = {4, 3, 9};
19// subheader structure
20const ubit16 MatrixReadOutStructure::s_subHeaderPos[s_subHeaderNum] = {12, 0};
21const ubit16 MatrixReadOutStructure::s_subHeaderLen[s_subHeaderNum] = {4, 12};
23// body structure
24const ubit16 MatrixReadOutStructure::s_CMABodyPos[s_CMABodyNum] = {14, 11, 8, 5, 0};
25const ubit16 MatrixReadOutStructure::s_CMABodyLen[s_CMABodyNum] = {2, 3, 3, 3, 5};
27// footer structure
28const ubit16 MatrixReadOutStructure::s_footerPos[s_footerNum] = {14, 8, 0};
29const ubit16 MatrixReadOutStructure::s_footerLen[s_footerNum] = {2, 6, 8};
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//----------------------------------------------------------------------------//
41 //
42 // Constructor used by the simulation program
43 //
44 setInit();
45} // end-of-MatrixReadOutStructure::MatrixReadOutStructure()
46//----------------------------------------------------------------------------//
48 decodeFragment(inputData, m_field);
49} // end-of-MatrixReadOutStructure::MatrixReadOutStructure(ubit16 inputData)
50//----------------------------------------------------------------------------//
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//----------------------------------------------------------------------------//
69 const ubit16 theHeader[s_headerNum] = {s_headerVal, *(inputData + 1), *(inputData + 2)};
70 m_cmid = *(inputData + 1);
71 m_fel1id = *(inputData + 2);
73 return m_word;
74} // end-of-MatrixReadOutStructure::makeHeader
75//----------------------------------------------------------------------------//
77 m_febcid = 1;
78 const ubit16 theSubHeader[s_subHeaderNum] = {s_subHeaderVal, 1};
80 return m_word;
81} // end-of-MatrixReadOutStructure::makeSubHeader
82//----------------------------------------------------------------------------//
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); }
97 return m_word;
98} // end-of-MatrixReadOutStructure::makeBodyHit
99//----------------------------------------------------------------------------//
101 m_status = 1;
102 m_crc = inputData;
103 const ubit16 theFooter[s_footerNum] = {s_footerVal, m_status, m_crc};
105 return m_word;
106} // end-of-MatrixReadOutStructure::makeFooter
107//----------------------------------------------------------------------------//
108ubit16 MatrixReadOutStructure::makeFooter(ubit16 *inputData) { return (*inputData) & 0x0; } // end-of-MatrixReadOutStructure::makeFooter
109
110//----------------------------------------------------------------------------//
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]);
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
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//----------------------------------------------------------------------------//
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//----------------------------------------------------------------------------//
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//----------------------------------------------------------------------------//
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//----------------------------------------------------------------------------//
200 if (m_ijk == 3 || m_ijk == 5) channel = channel + 32;
201 return channel;
202}
203
205 if (m_ijk == 0 || m_ijk == 1)
206 return 1;
207 else
208 return 0;
209}
210
212 if (m_ijk == 6)
213 return true;
214 else
215 return false;
216}
217//----------------------------------------------------------------------------//
219 bool output;
220 m_cmid & 0x0004 ? output = false : output = true;
221 return output;
222} // end-of-MatrixReadOutStructure::lowPt()
223//----------------------------------------------------------------------------//
224bool MatrixReadOutStructure::isHigPt() { return !isLowPt(); } // end-of-MatrixReadOutStructure::higPt()
225//----------------------------------------------------------------------------//
227 bool output;
228 m_cmid & 0x0002 ? output = false : output = true;
229 return output;
230} // end-of-MatrixReadOutStructure::etaProj()
231//----------------------------------------------------------------------------//
232bool MatrixReadOutStructure::isPhiProj() { return !isEtaProj(); } // end-of-MatrixReadOutStructure::phiProj()
233//----------------------------------------------------------------------------//
235 bool output;
236 m_cmid & 0x0001 ? output = false : output = true;
237 return output;
238} // end-of-MatrixReadOutStructure::0LocAdd()
239//----------------------------------------------------------------------------//
240bool MatrixReadOutStructure::is1LocAdd() { return !is0LocAdd(); } // end-of-MatrixReadOutStructure::1LocAdd()
241//----------------------------------------------------------------------------//
unsigned short int ubit16
static const ubit16 s_footerVal
static const ubit16 s_headerLen[s_headerNum]
static const ubit16 s_headerPos[s_headerNum]
static const ubit16 s_footerNum
static const ubit16 s_CMABodyLen[s_CMABodyNum]
static const ubit16 s_subHeaderVal
static const ubit16 s_headerVal
ubit16 decodeFragment(ubit16 inputWord, char &field)
static const ubit16 s_footerLen[s_footerNum]
static const ubit16 s_CMABodyNum
ubit16 makeBody(ubit16 *inputData)
static const ubit16 s_subHeaderLen[s_subHeaderNum]
static const ubit16 s_subHeaderPos[s_subHeaderNum]
ubit16 makeHeader(ubit16 *inputData)
static const ubit16 s_CMABodyVal
ubit16 makeFooter(ubit16 inputData)
static const ubit16 s_headerNum
static const ubit16 s_subHeaderNum
static const ubit16 s_footerPos[s_footerNum]
static const ubit16 s_CMABodyPos[s_CMABodyNum]
static constexpr ubit16 s_last2bitsON
Definition RPCReadOut.h:55
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
STL namespace.