ATLAS Offline Software
MdtHptdcReadOut.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 "MdtHptdcReadOut.h"
6 
8  m_dataWord(0),
9  m_wordHeader(0),
10  m_tdcId(0),
11  m_ecnt(0),
12  m_bcId(0),
13  m_wcnt(0),
14  m_channel(0),
15  m_coarse(0),
16  m_fine(0),
17  m_width(0),
18  m_errflag(0),
19  m_leading(false) {}
20 
22  // Zero all the decoded quantities
23  setZero();
24  m_dataWord = dataWord;
25  m_word = dataWord;
26  m_wordHeader = (dataWord >> HEADERPOS) & HEADERBITS;
27 
28  if (is_TSM()) // TDC single measurement
29  {
30  m_leading = !((bool)getBits(getBitsWord(28, 28)));
31  m_tdcId = getBits(getBitsWord(27, 24));
32  m_channel = getBits(getBitsWord(23, 19));
33  m_coarse = getBits(getBitsWord(18, 5));
34  m_fine = getBits(getBitsWord(4, 0));
35  } else if (is_TCM()) // TDC combined measurement
36  {
37  m_tdcId = getBits(getBitsWord(27, 24));
38  m_channel = getBits(getBitsWord(23, 19));
39  m_width = getBits(getBitsWord(18, 12));
40  m_coarse = getBits(getBitsWord(11, 5));
41  m_fine = getBits(getBitsWord(4, 0));
42  } else if (is_BOT()) // Beginning of TDC
43  {
44  // One header bit is used for TDC numbers > 15
45  m_tdcId = getBits(getBitsWord(28, 24));
46  m_ecnt = getBits(getBitsWord(23, 12));
47  m_bcId = getBits(getBitsWord(11, 0));
48  } else if (is_EOT()) // End of TDC
49  {
50  m_tdcId = getBits(getBitsWord(27, 24));
51  m_ecnt = getBits(getBitsWord(23, 12));
52  m_wcnt = getBits(getBitsWord(11, 0));
53  } else if (is_TES()) // TDC error status
54  {
55  m_tdcId = getBits(getBitsWord(27, 24));
56  m_errflag = getBits(getBitsWord(14, 0));
57  }
58 }
59 
61  m_tdcId = 0;
62  m_ecnt = 0;
63  m_bcId = 0;
64  m_wcnt = 0;
65  m_channel = 0;
66  m_coarse = 0;
67  m_fine = 0;
68  m_width = 0;
69  m_errflag = 0;
70  m_leading = false;
71 }
72 
73 // Encoding methods
74 // Beginning of TDC
76  uint16_t inputData[4];
77  constexpr uint16_t inputPos[4] = {HEADERPOS, 24, 12, 0};
78  uint16_t nData = 4;
79 
80  if (tdcId < 16) {
81  inputData[0] = BOTVALUE1;
82  } else {
83  inputData[0] = BOTVALUE2;
84  tdcId -= 16;
85  }
86 
87  inputData[1] = tdcId;
88  inputData[2] = ecnt;
89  inputData[3] = bcid;
90 
91  return setBits(nData, inputData, inputPos);
92 }
93 
94 // End of TDC
96  uint16_t inputData[4] = {EOTVALUE, tdcId, ecnt, wcnt};
97  constexpr uint16_t inputPos[4] = {HEADERPOS, 24, 12, 0};
98  uint16_t nData = 4;
99 
100  return setBits(nData, inputData, inputPos);
101 }
102 
103 // Make a TDC single measurement word
104 uint32_t MdtHptdcReadOut::makeTSM(uint16_t tdcId, uint16_t channel, bool leading, uint16_t coarse, uint16_t /*fine*/) {
105  uint16_t TSMvalue = leading ? TSMVALUE_LEAD : TSMVALUE_TAIL;
106 
107  uint16_t inputData[4] = {TSMvalue, static_cast<uint16_t>(tdcId & 0xf), static_cast<uint16_t>(channel & 0x1f),
108  static_cast<uint16_t>(coarse & 0x7ffff)};
109  constexpr uint16_t inputPos[4] = {HEADERPOS, 24, 19, 0};
110  uint16_t nData = 4;
111 
112  return setBits(nData, inputData, inputPos);
113 }
114 
115 // Make a TDC combined measurement word
117  uint16_t inputData[5] = {TCMVALUE, static_cast<uint16_t>(tdcId & 0xf), static_cast<uint16_t>(channel & 0x1f),
118  static_cast<uint16_t>(width & 0x7f), static_cast<uint16_t>(coarse & 0xfff)};
119  constexpr uint16_t inputPos[5] = {HEADERPOS, 24, 19, 12, 0};
120  uint16_t nData = 5;
121 
122  return setBits(nData, inputData, inputPos);
123 }
MdtHptdcReadOut::TCMVALUE
static constexpr uint16_t TCMVALUE
Definition: MdtHptdcReadOut.h:59
MdtHptdcReadOut::m_bcId
uint16_t m_bcId
Definition: MdtHptdcReadOut.h:25
MdtHptdcReadOut::m_fine
uint16_t m_fine
Definition: MdtHptdcReadOut.h:33
MdtHptdcReadOut::is_TSM
bool is_TSM() const
Definition: MdtHptdcReadOut.h:79
MdtHptdcReadOut::m_dataWord
uint32_t m_dataWord
Definition: MdtHptdcReadOut.h:18
MdtHptdcReadOut::decodeWord
void decodeWord(uint32_t dataWord)
Definition: MdtHptdcReadOut.cxx:21
MdtHptdcReadOut::m_wordHeader
uint16_t m_wordHeader
Definition: MdtHptdcReadOut.h:20
plotting.yearwise_efficiency.channel
channel
Definition: yearwise_efficiency.py:24
MdtReadOut::m_word
uint32_t m_word
Definition: MdtReadOut.h:38
MdtHptdcReadOut::makeEOT
uint32_t makeEOT(uint16_t tdcId, uint16_t ecnt, uint16_t wcnt)
Definition: MdtHptdcReadOut.cxx:95
MdtHptdcReadOut::m_width
uint16_t m_width
Definition: MdtHptdcReadOut.h:34
MdtHptdcReadOut::m_tdcId
uint16_t m_tdcId
Definition: MdtHptdcReadOut.h:23
MdtHptdcReadOut::coarse
uint16_t coarse() const
Definition: MdtHptdcReadOut.h:91
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
MdtHptdcReadOut::m_errflag
bool m_errflag
Definition: MdtHptdcReadOut.h:35
MdtReadOut::getBits
uint32_t getBits(std::pair< uint32_t, uint16_t > wordbstop) const
Definition: MdtReadOut.h:27
MdtHptdcReadOut::makeTSM
uint32_t makeTSM(uint16_t tdcId, uint16_t channel, bool leading, uint16_t coarse, uint16_t fine)
Definition: MdtHptdcReadOut.cxx:104
MdtHptdcReadOut::MdtHptdcReadOut
MdtHptdcReadOut()
Definition: MdtHptdcReadOut.cxx:7
MdtHptdcReadOut::width
uint16_t width() const
Definition: MdtHptdcReadOut.h:93
MdtHptdcReadOut::makeBOT
uint32_t makeBOT(uint16_t tdcId, uint16_t ecnt, uint16_t bcid)
Definition: MdtHptdcReadOut.cxx:75
MdtHptdcReadOut::EOTVALUE
static constexpr uint16_t EOTVALUE
Definition: MdtHptdcReadOut.h:52
MdtHptdcReadOut::m_channel
uint16_t m_channel
Definition: MdtHptdcReadOut.h:31
MdtHptdcReadOut::is_BOT
bool is_BOT() const
Definition: MdtHptdcReadOut.h:75
xAOD::uint16_t
setWord1 uint16_t
Definition: eFexEMRoI_v1.cxx:88
MdtHptdcReadOut::m_leading
bool m_leading
Definition: MdtHptdcReadOut.h:37
MdtHptdcReadOut::is_EOT
bool is_EOT() const
Definition: MdtHptdcReadOut.h:77
MdtHptdcReadOut::is_TCM
bool is_TCM() const
Definition: MdtHptdcReadOut.h:81
MdtHptdcReadOut::tdcId
uint16_t tdcId() const
Definition: MdtHptdcReadOut.h:86
MdtHptdcReadOut::BOTVALUE1
static constexpr uint16_t BOTVALUE1
Definition: MdtHptdcReadOut.h:48
MdtHptdcReadOut::BOTVALUE2
static constexpr uint16_t BOTVALUE2
Definition: MdtHptdcReadOut.h:49
MdtReadOut::setBits
static uint32_t setBits(uint16_t nData, const uint16_t *inputData, const uint16_t *inputPos)
Definition: MdtReadOut.cxx:14
xAOD::bcid
setEventNumber setTimeStamp bcid
Definition: EventInfo_v1.cxx:133
MdtHptdcReadOut::m_ecnt
uint16_t m_ecnt
Definition: MdtHptdcReadOut.h:24
MdtHptdcReadOut::TSMVALUE_LEAD
static constexpr uint16_t TSMVALUE_LEAD
Definition: MdtHptdcReadOut.h:55
MdtHptdcReadOut::m_coarse
uint16_t m_coarse
Definition: MdtHptdcReadOut.h:32
MdtHptdcReadOut::makeTCM
uint32_t makeTCM(uint16_t tdcId, uint16_t channel, uint16_t width, uint16_t coarse, uint16_t fine)
Definition: MdtHptdcReadOut.cxx:116
MdtHptdcReadOut::TSMVALUE_TAIL
static constexpr uint16_t TSMVALUE_TAIL
Definition: MdtHptdcReadOut.h:56
Base_Fragment.width
width
Definition: Sherpa_i/share/common/Base_Fragment.py:59
MdtHptdcReadOut::m_wcnt
uint16_t m_wcnt
Definition: MdtHptdcReadOut.h:28
MdtHptdcReadOut::HEADERPOS
static constexpr uint16_t HEADERPOS
Definition: MdtHptdcReadOut.h:43
MdtHptdcReadOut::is_TES
bool is_TES() const
Definition: MdtHptdcReadOut.h:83
MdtHptdcReadOut::HEADERBITS
static constexpr uint16_t HEADERBITS
Definition: MdtHptdcReadOut.h:44
xAOD::bool
setBGCode setTAP setLVL2ErrorBits bool
Definition: TrigDecision_v1.cxx:60
MdtHptdcReadOut::ecnt
uint16_t ecnt() const
Definition: MdtHptdcReadOut.h:87
MdtReadOut::getBitsWord
constexpr std::pair< uint32_t, uint16_t > getBitsWord(const uint16_t bstart, const uint16_t bstop)
Definition: MdtReadOut.h:20
MdtHptdcReadOut.h
MdtHptdcReadOut::setZero
void setZero()
Definition: MdtHptdcReadOut.cxx:60
MdtHptdcReadOut::channel
uint16_t channel() const
Definition: MdtHptdcReadOut.h:90