ATLAS Offline Software
RXReadOutStructure.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 RXReadOutStructure::s_headerPos[s_headerNum] = {12, 8, 0};
17 const ubit16 RXReadOutStructure::s_headerLen[s_headerNum] = {4, 4, 8};
19 // footer structure
20 const ubit16 RXReadOutStructure::s_footerPos[s_footerNum] = {12, 0};
21 const ubit16 RXReadOutStructure::s_footerLen[s_footerNum] = {4, 12};
23 //----------------------------------------------------------------------------//
25  //
26  // Constructor used by the simulation program
27  //
28  setInit();
29 } // end-of-RXReadOutStructure::RXReadOutStructure()
30 //----------------------------------------------------------------------------//
32  //
33  // Constructor used by the simulation program
34  //
35 
36  decodeFragment(inputData, m_field);
37 } // end-of-RXReadOutStructure::RXReadOutStructure()
38 //----------------------------------------------------------------------------//
40  m_field = 'U';
41  m_word = 0xffff;
42  m_secid = 0xffff;
43  m_status = 0xffff;
44  m_errorCode = 0xffff;
45 } // end-of-RXReadOutStructure::setInit()
46 //----------------------------------------------------------------------------//
47 unsigned short int RXReadOutStructure::makeHeader(ubit16 *inputData) {
48  const ubit16 theHeader[s_headerNum] = {s_headerVal, *(inputData + 1), *(inputData + 2)};
49  m_secid = *(inputData + 1);
50  m_status = *(inputData + 2);
51  m_word = set16Bits(s_headerNum, s_headerPos, theHeader);
52  return m_word;
53 } // end-of-RXReadOutStructure::makeHeader
54 //----------------------------------------------------------------------------//
55 unsigned short int RXReadOutStructure::makeFooter(ubit16 errorCode) {
57  const ubit16 theFooter[s_footerNum] = {s_footerVal, m_errorCode};
58  m_word = set16Bits(s_footerNum, s_footerPos, theFooter);
59  return m_word;
60 } // end-of-RXReadOutStructure::makeFooter
61 //----------------------------------------------------------------------------//
62 unsigned short int RXReadOutStructure::makeFooter(ubit16 *errorCode) { return (*errorCode) & 0x0; } // end-of-RXReadOutStructure::makeFooter
63 //----------------------------------------------------------------------------//
65  bool status = false;
66  ubit16 theHeader[s_headerNum] = {s_headerVal};
67  if ((m_word & s_last4bitsON) == set16Bits(1, s_headerPos, theHeader)) status = true;
68  return status;
69 }
70 //----------------------------------------------------------------------------//
72  bool status = false;
73  ubit16 theFooter[s_footerNum] = {s_footerVal};
74  if ((m_word & s_last4bitsON) == set16Bits(1, s_footerPos, theFooter)) status = true;
75  return status;
76 }
77 //----------------------------------------------------------------------------//
78 unsigned short int RXReadOutStructure::decodeFragment(ubit16 inputWord, char &field) {
80  // Removed last because it is not used
81  // bool last=false;
82  ubit16 errorCode = 0;
83  setInit();
84  m_word = inputWord;
85  //
86  errorCode = 0;
87  if (isHeader()) {
88  m_field = 'H';
90  m_secid = get16Bits(inputWord, s_headerPos[1], s_headerLen[1]) >> 3;
91  m_status = get16Bits(inputWord, s_headerPos[2], s_headerLen[2]);
92  } else if (m_dataVersion == Simulation0) {
93  m_status = get16Bits(inputWord, s_headerPos[1], s_headerLen[1]);
94  m_secid = get16Bits(inputWord, s_headerPos[2], s_headerLen[2]);
95  } else {
96  // Unknown format, so leave data invalid.
97  m_field = 'U';
98  }
99  } else if (isFooter()) {
100  m_field = 'F';
101  m_errorCode = get16Bits(inputWord, s_footerPos[1], s_footerLen[1]);
102  } else {
103  m_field = 'B';
104  if ((m_word & 0xf000) == (MRS.getFooterVal() << MRS.getFooterPos())) {
105  /* last=true; */
106  } else {
107  /* last=false; */
108  } // end-of-if((m_word
109  }
110  field = m_field;
111  return errorCode; // temporary: force return to 0
112 } // end-of-decodeFragment
RXReadOutStructure::status
ubit16 status()
Definition: RXReadOutStructure.h:34
RXReadOutStructure::s_headerLen
static const ubit16 s_headerLen[s_headerNum]
Definition: RXReadOutStructure.h:53
RPCReadOut.h
RPCReadOut::s_last4bitsON
static constexpr ubit16 s_last4bitsON
Definition: RPCReadOut.h:56
RXReadOutStructure::m_dataVersion
DataVersion m_dataVersion
Definition: RXReadOutStructure.h:47
RXReadOutStructure::s_footerVal
static const ubit16 s_footerVal
Definition: RXReadOutStructure.h:58
MatrixReadOutStructure::getFooterVal
ubit16 getFooterVal()
Definition: MatrixReadOutStructure.h:49
ReadOfcFromCool.field
field
Definition: ReadOfcFromCool.py:48
RXReadOutStructure::s_headerNum
static const ubit16 s_headerNum
Definition: RXReadOutStructure.h:51
RPCReadOut::get16Bits
ubit16 get16Bits(const ubit16 input, const ubit16 position, const ubit16 length) const
Definition: RPCReadOut.h:47
RXReadOutStructure::m_secid
ubit16 m_secid
Definition: RXReadOutStructure.h:44
RXReadOutStructure::RXReadOutStructure
RXReadOutStructure(DataVersion vers=Atlas)
Definition: RXReadOutStructure.cxx:24
RXReadOutStructure::errorCode
ubit16 errorCode()
Definition: RXReadOutStructure.h:35
RXReadOutStructure::s_headerVal
static const ubit16 s_headerVal
Definition: RXReadOutStructure.h:54
MatrixReadOutStructure::getFooterPos
ubit16 getFooterPos()
Definition: MatrixReadOutStructure.h:50
RXReadOutStructure::makeFooter
ubit16 makeFooter(ubit16 errorCode)
Definition: RXReadOutStructure.cxx:55
RXReadOutStructure::makeHeader
ubit16 makeHeader(ubit16 *inputData)
Definition: RXReadOutStructure.cxx:47
RXReadOutStructure::setInit
void setInit()
Definition: RXReadOutStructure.cxx:39
RPCReadOut::m_field
char m_field
Definition: RPCReadOut.h:28
RPCReadOut::field
char field() const
Definition: RPCReadOut.h:19
RXReadOutStructure::decodeFragment
ubit16 decodeFragment(ubit16 inputWord, char &field)
Definition: RXReadOutStructure.cxx:78
RXReadOutStructure::m_errorCode
ubit16 m_errorCode
Definition: RXReadOutStructure.h:46
MatrixReadOutStructure
Definition: MatrixReadOutStructure.h:13
RXReadOutStructure::s_headerPos
static const ubit16 s_headerPos[s_headerNum]
Definition: RXReadOutStructure.h:52
RXReadOutStructure::m_status
ubit16 m_status
Definition: RXReadOutStructure.h:45
RXReadOutStructure::s_footerNum
static const ubit16 s_footerNum
Definition: RXReadOutStructure.h:55
RPCReadOut::set16Bits
ubit16 set16Bits(const ubit16 n, const ubit16 *pos, const ubit16 *val) const
Definition: RPCReadOut.h:30
RXReadOutStructure::DataVersion
DataVersion
Definition: RXReadOutStructure.h:16
RXReadOutStructure::isFooter
bool isFooter()
Definition: RXReadOutStructure.cxx:71
RXReadOutStructure::Simulation1
@ Simulation1
Definition: RXReadOutStructure.h:16
RXReadOutStructure::s_footerPos
static const ubit16 s_footerPos[s_footerNum]
Definition: RXReadOutStructure.h:56
ubit16
unsigned short int ubit16
Definition: RpcByteStreamEncoder.h:20
RXReadOutStructure::Simulation0
@ Simulation0
Definition: RXReadOutStructure.h:16
RXReadOutStructure::s_footerLen
static const ubit16 s_footerLen[s_footerNum]
Definition: RXReadOutStructure.h:57
RXReadOutStructure.h
RXReadOutStructure::isHeader
bool isHeader()
Definition: RXReadOutStructure.cxx:64
Atlas
Definition: Atlas.UnixStandardJob.py:1
RPCReadOut::m_word
ubit16 m_word
Definition: RPCReadOut.h:27