ATLAS Offline Software
Loading...
Searching...
No Matches
MdtAmtReadOut.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3*/
4
5#include "MdtAmtReadOut.h"
6
7//#include "GaudiKernel/ISvcLocator.h"
8//#include "GaudiKernel/Bootstrap.h"
9//#include "GaudiKernel/MsgStream.h"
10//#include "GaudiKernel/IMessageSvc.h"
11
13 m_dataWord(0),
14 m_wordHeader(0),
15 m_tdcId(0),
16 m_ecnt(0),
17 m_bcId(0),
18 m_wcnt(0),
19 m_jt(0),
20 m_channel(0),
21 m_coarse(0),
22 m_fine(0),
23 m_width(0),
24 m_errflag(0),
25 m_errstatus(0),
26 m_masked(0),
27 m_leading(false) {}
28
29void MdtAmtReadOut::decodeWord(uint32_t dataWord) {
30 // Zero all the decoded quantities
31 setZero();
32 m_dataWord = dataWord;
33 m_word = dataWord;
34 m_wordHeader = (dataWord >> s_headerPos) & s_headerBits;
35
36 if (is_TSM()) // TDC single measurement
37 {
38 m_leading = (bool)getBits(getBitsWord(18, 18));
39 m_jt = getBits(getBitsWord(25, 24));
40 m_channel = getBits(getBitsWord(23, 19));
41 m_errflag = getBits(getBitsWord(17, 17));
43 m_fine = getBits(getBitsWord(4, 0));
44 } else if (is_TCM()) // TDC combined measurement
45 {
46 m_jt = getBits(getBitsWord(25, 24));
47 m_channel = getBits(getBitsWord(23, 19));
48 m_width = getBits(getBitsWord(18, 11));
50 m_fine = getBits(getBitsWord(4, 0));
51 } else if (is_BOT()) // Beginning of TDC
52 {
53 // One header bit is used for TDC numbers > 15
54 m_tdcId = getBits(getBitsWord(28, 24));
55 m_ecnt = getBits(getBitsWord(23, 12));
56 m_bcId = getBits(getBitsWord(11, 0));
57 } else if (is_EOT()) // End of TDC
58 {
59 m_ecnt = getBits(getBitsWord(23, 12));
60 m_wcnt = getBits(getBitsWord(11, 0));
61 } else if (is_TMC()) // TDC masked channels flag
62 {
63 m_jt = getBits(getBitsWord(25, 24));
65 } else if (is_TES()) // TDC error status
66 {
67 m_jt = getBits(getBitsWord(25, 24));
69 }
70 // special decoding of the CSM trailer word count - nothing to do here
71 else if (is_TWC()) {}
72}
73
75 m_tdcId = 0;
76 m_ecnt = 0;
77 m_bcId = 0;
78 m_wcnt = 0;
79 m_jt = 0;
80 m_channel = 0;
81 m_coarse = 0;
82 m_fine = 0;
83 m_width = 0;
84 m_errflag = 0;
85 m_errstatus = 0;
86 m_masked = 0;
87 m_leading = false;
88}
89
90// Encoding methods
91// Beginning of TDC
92uint32_t MdtAmtReadOut::makeBOT(uint16_t tdcId, uint16_t ecnt, uint16_t bcid) {
93 uint16_t inputData[4];
94 uint16_t inputPos[4] = {s_headerPos, 24, 12, 0};
95 uint16_t nData = 4;
96
97 if (tdcId < 16) {
98 inputData[0] = s_BOTvalue1;
99 } else {
100 inputData[0] = s_BOTvalue2;
101 tdcId -= 16;
102 }
103
104 inputData[1] = tdcId;
105 inputData[2] = ecnt;
106 inputData[3] = bcid;
107
108 return setBits(nData, inputData, inputPos);
109}
110
111// End of TDC
112uint32_t MdtAmtReadOut::makeEOT(uint16_t jt, uint16_t ecnt, uint16_t wcnt) {
113 uint16_t inputData[5] = {s_EOTvalue, 0, jt, ecnt, wcnt};
114 uint16_t inputPos[5] = {s_headerPos, 26, 24, 12, 0};
115 uint16_t nData = 5;
116
117 return setBits(nData, inputData, inputPos);
118}
119
120// Make a TDC single measurement word
121uint32_t MdtAmtReadOut::makeTSM(uint16_t jt, uint16_t channel, bool leading, bool errflag, uint16_t coarse, uint16_t fine) {
122 uint16_t lead = 1;
123 uint16_t err = 0;
124 if (leading) lead = 0;
125 if (errflag) err = 1;
126
127 uint16_t inputData[8] = {(uint16_t)s_TSMvalue,
128 0,
129 static_cast<uint16_t>(jt & 0x2),
130 static_cast<uint16_t>(channel & 0x1f),
131 static_cast<uint16_t>(lead & 0x1),
132 static_cast<uint16_t>(err & 0x1),
133 static_cast<uint16_t>(coarse & 0xfff),
134 static_cast<uint16_t>(fine & 0x1f)};
135 uint16_t inputPos[8] = {s_headerPos, 26, 24, 19, 18, 17, 5, 0};
136 uint16_t nData = 8;
137
138 return setBits(nData, inputData, inputPos);
139}
140
141// Make a TDC combined measurement word
142uint32_t MdtAmtReadOut::makeTCM(uint16_t jt, uint16_t channel, uint16_t width, uint16_t coarse, uint16_t fine) {
143 uint16_t inputData[7] = {(uint16_t)s_TCMvalue,
144 0,
145 static_cast<uint16_t>(jt & 0x2),
146 static_cast<uint16_t>(channel & 0x1f),
147 static_cast<uint16_t>(width & 0xff),
148 static_cast<uint16_t>(coarse & 0x3f),
149 static_cast<uint16_t>(fine & 0x1f)};
150 uint16_t inputPos[7] = {s_headerPos, 26, 24, 19, 11, 5, 0};
151 uint16_t nData = 7;
152
153 return setBits(nData, inputData, inputPos);
154}
155
156uint32_t MdtAmtReadOut::makeTMC(uint16_t jt, uint32_t masked) {
157 uint16_t masked_low = masked & 0xffff;
158 uint16_t masked_high = masked & 0xff0000;
159
160 uint16_t inputData[5] = {s_TMCvalue, 0, jt, masked_high, masked_low};
161 uint16_t inputPos[5] = {s_headerPos, 26, 24, 16, 0};
162 uint16_t nData = 5;
163
164 return setBits(nData, inputData, inputPos);
165}
uint16_t ecnt()
static constexpr uint16_t s_EOTvalue
static constexpr uint16_t s_headerPos
uint16_t m_tdcId
uint32_t makeTSM(uint16_t jt, uint16_t channel, bool leading, bool errflag, uint16_t coarse, uint16_t fine)
uint16_t m_errstatus
static constexpr uint16_t s_TMCvalue
uint32_t m_dataWord
uint16_t m_bcId
uint32_t makeTMC(uint16_t jt, uint32_t masked)
uint16_t m_fine
uint16_t coarse()
uint16_t tdcId()
static constexpr uint16_t s_headerBits
static constexpr uint16_t s_TCMvalue
uint16_t jt()
uint16_t channel()
uint32_t m_masked
static constexpr uint16_t s_TSMvalue
uint32_t masked()
uint16_t width()
uint32_t makeEOT(uint16_t jt, uint16_t ecnt, uint16_t wcnt)
uint32_t makeTCM(uint16_t jt, uint16_t channel, uint16_t width, uint16_t coarse, uint16_t fine)
static constexpr uint16_t s_BOTvalue1
void decodeWord(uint32_t dataWord)
uint16_t m_width
uint16_t m_wordHeader
uint16_t m_ecnt
uint32_t makeBOT(uint16_t tdcId, uint16_t ecnt, uint16_t bcid)
uint16_t m_channel
uint16_t m_coarse
static constexpr uint16_t s_BOTvalue2
uint16_t fine()
uint16_t m_wcnt
uint32_t getBits(std::pair< uint32_t, uint16_t > wordbstop) const
Definition MdtReadOut.h:27
static uint32_t setBits(uint16_t nData, const uint16_t *inputData, const uint16_t *inputPos)
uint32_t m_word
Definition MdtReadOut.h:38
constexpr std::pair< uint32_t, uint16_t > getBitsWord(const uint16_t bstart, const uint16_t bstop)
Definition MdtReadOut.h:20