ATLAS Offline Software
Loading...
Searching...
No Matches
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
13using namespace std;
14
15// header structure
16const ubit16 RXReadOutStructure::s_headerPos[s_headerNum] = {12, 8, 0};
17const ubit16 RXReadOutStructure::s_headerLen[s_headerNum] = {4, 4, 8};
19// footer structure
20const ubit16 RXReadOutStructure::s_footerPos[s_footerNum] = {12, 0};
21const 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//----------------------------------------------------------------------------//
47unsigned 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);
52 return m_word;
53} // end-of-RXReadOutStructure::makeHeader
54//----------------------------------------------------------------------------//
57 const ubit16 theFooter[s_footerNum] = {s_footerVal, m_errorCode};
59 return m_word;
60} // end-of-RXReadOutStructure::makeFooter
61//----------------------------------------------------------------------------//
62unsigned 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//----------------------------------------------------------------------------//
78unsigned 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
unsigned short int ubit16
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
static const ubit16 s_footerLen[s_footerNum]
ubit16 makeHeader(ubit16 *inputData)
ubit16 makeFooter(ubit16 errorCode)
static const ubit16 s_headerNum
ubit16 decodeFragment(ubit16 inputWord, char &field)
static const ubit16 s_footerNum
static const ubit16 s_footerPos[s_footerNum]
static const ubit16 s_headerLen[s_headerNum]
static const ubit16 s_footerVal
static const ubit16 s_headerPos[s_headerNum]
RXReadOutStructure(DataVersion vers=Atlas)
static const ubit16 s_headerVal
STL namespace.