ATLAS Offline Software
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 
13 using namespace std;
14 
15 // header structure
16 const ubit16 MatrixReadOutStructure::s_headerPos[s_headerNum] = {12, 9, 0};
17 const ubit16 MatrixReadOutStructure::s_headerLen[s_headerNum] = {4, 3, 9};
19 // subheader structure
20 const ubit16 MatrixReadOutStructure::s_subHeaderPos[s_subHeaderNum] = {12, 0};
21 const ubit16 MatrixReadOutStructure::s_subHeaderLen[s_subHeaderNum] = {4, 12};
23 // body structure
24 const ubit16 MatrixReadOutStructure::s_CMABodyPos[s_CMABodyNum] = {14, 11, 8, 5, 0};
25 const ubit16 MatrixReadOutStructure::s_CMABodyLen[s_CMABodyNum] = {2, 3, 3, 3, 5};
27 // footer structure
28 const ubit16 MatrixReadOutStructure::s_footerPos[s_footerNum] = {14, 8, 0};
29 const 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);
72  m_word = set16Bits(s_headerNum, s_headerPos, theHeader);
73  return m_word;
74 } // end-of-MatrixReadOutStructure::makeHeader
75 //----------------------------------------------------------------------------//
77  m_febcid = 1;
78  const ubit16 theSubHeader[s_subHeaderNum] = {s_subHeaderVal, 1};
79  m_word = set16Bits(s_subHeaderNum, s_subHeaderPos, theSubHeader);
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); }
96  m_word = set16Bits(s_CMABodyNum, s_CMABodyPos, theCMABody);
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};
104  m_word = set16Bits(s_footerNum, s_footerPos, theFooter);
105  return m_word;
106 } // end-of-MatrixReadOutStructure::makeFooter
107 //----------------------------------------------------------------------------//
108 ubit16 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]);
139  m_strip = global_channel();
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 //----------------------------------------------------------------------------//
199  ubit16 channel = m_channel;
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 //----------------------------------------------------------------------------//
224 bool 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 //----------------------------------------------------------------------------//
232 bool 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 //----------------------------------------------------------------------------//
240 bool MatrixReadOutStructure::is1LocAdd() { return !is0LocAdd(); } // end-of-MatrixReadOutStructure::1LocAdd()
241 //----------------------------------------------------------------------------//
MatrixReadOutStructure::makeBody
ubit16 makeBody(ubit16 *inputData)
Definition: MatrixReadOutStructure.cxx:83
temp
Definition: JetEventDict.h:21
MatrixReadOutStructure::isHigPt
bool isHigPt()
Definition: MatrixReadOutStructure.cxx:224
MatrixReadOutStructure::MatrixReadOutStructure
MatrixReadOutStructure()
Definition: MatrixReadOutStructure.cxx:40
MatrixReadOutStructure::decodeFragment
ubit16 decodeFragment(ubit16 inputWord, char &field)
Definition: MatrixReadOutStructure.cxx:111
plotting.yearwise_efficiency.channel
channel
Definition: yearwise_efficiency.py:28
MatrixReadOutStructure::makeSubHeader
ubit16 makeSubHeader()
Definition: MatrixReadOutStructure.cxx:76
MatrixReadOutStructure::isBody
bool isBody()
Definition: MatrixReadOutStructure.cxx:180
MatrixReadOutStructure::s_CMABodyVal
static const ubit16 s_CMABodyVal
Definition: MatrixReadOutStructure.h:99
MatrixReadOutStructure::global_channel
ubit16 global_channel()
Definition: MatrixReadOutStructure.cxx:198
MatrixReadOutStructure::is1LocAdd
bool is1LocAdd()
Definition: MatrixReadOutStructure.cxx:240
RPCReadOut.h
MatrixReadOutStructure::s_headerVal
static const ubit16 s_headerVal
Definition: MatrixReadOutStructure.h:91
MatrixReadOutStructure::isEtaProj
bool isEtaProj()
Definition: MatrixReadOutStructure.cxx:226
MatrixReadOutStructure::isHeader
bool isHeader()
Definition: MatrixReadOutStructure.cxx:166
MatrixReadOutStructure::s_CMABodyPos
static const ubit16 s_CMABodyPos[s_CMABodyNum]
Definition: MatrixReadOutStructure.h:97
MatrixReadOutStructure::s_footerLen
static const ubit16 s_footerLen[s_footerNum]
Definition: MatrixReadOutStructure.h:102
ReadOfcFromCool.field
field
Definition: ReadOfcFromCool.py:48
MatrixReadOutStructure::is0LocAdd
bool is0LocAdd()
Definition: MatrixReadOutStructure.cxx:234
MatrixReadOutStructure::s_headerPos
static const ubit16 s_headerPos[s_headerNum]
Definition: MatrixReadOutStructure.h:89
MatrixReadOutStructure::s_subHeaderPos
static const ubit16 s_subHeaderPos[s_subHeaderNum]
Definition: MatrixReadOutStructure.h:93
lumiFormat.i
int i
Definition: lumiFormat.py:92
MatrixReadOutStructure::isFooter
bool isFooter()
Definition: MatrixReadOutStructure.cxx:187
MatrixReadOutStructure::makeFooter
ubit16 makeFooter(ubit16 inputData)
Definition: MatrixReadOutStructure.cxx:100
MatrixReadOutStructure::isTrigger
bool isTrigger()
Definition: MatrixReadOutStructure.cxx:211
MatrixReadOutStructure::isPhiProj
bool isPhiProj()
Definition: MatrixReadOutStructure.cxx:232
merge.output
output
Definition: merge.py:17
MatrixReadOutStructure::makeHeader
ubit16 makeHeader(ubit16 *inputData)
Definition: MatrixReadOutStructure.cxx:68
MatrixReadOutStructure::isSubHeader
bool isSubHeader()
Definition: MatrixReadOutStructure.cxx:173
MatrixReadOutStructure::s_CMABodyLen
static const ubit16 s_CMABodyLen[s_CMABodyNum]
Definition: MatrixReadOutStructure.h:98
MatrixReadOutStructure::s_headerLen
static const ubit16 s_headerLen[s_headerNum]
Definition: MatrixReadOutStructure.h:90
MatrixReadOutStructure::s_subHeaderVal
static const ubit16 s_subHeaderVal
Definition: MatrixReadOutStructure.h:95
MatrixReadOutStructure::isLowPt
bool isLowPt()
Definition: MatrixReadOutStructure.cxx:218
MatrixReadOutStructure::setInit
void setInit()
Definition: MatrixReadOutStructure.cxx:51
MatrixReadOutStructure.h
merge.status
status
Definition: merge.py:17
MatrixReadOutStructure::s_footerPos
static const ubit16 s_footerPos[s_footerNum]
Definition: MatrixReadOutStructure.h:101
MatrixReadOutStructure::isPivot
ubit16 isPivot()
Definition: MatrixReadOutStructure.cxx:204
MatrixReadOutStructure::s_footerVal
static const ubit16 s_footerVal
Definition: MatrixReadOutStructure.h:103
ubit16
unsigned short int ubit16
Definition: RpcByteStreamEncoder.h:20
MatrixReadOutStructure::s_subHeaderLen
static const ubit16 s_subHeaderLen[s_subHeaderNum]
Definition: MatrixReadOutStructure.h:94