Project
Loading...
Searching...
No Matches
ELinkDecoder.cxx
Go to the documentation of this file.
1
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3
// All rights not expressly granted are reserved.
4
//
5
// This software is distributed under the terms of the GNU General Public
6
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7
//
8
// In applying this license CERN does not waive the privileges and immunities
9
// granted to it by virtue of its status as an Intergovernmental Organization
10
// or submit itself to any jurisdiction.
11
16
17
#include "
MIDRaw/ELinkDecoder.h
"
18
19
namespace
o2
20
{
21
namespace
mid
22
{
23
24
void
ELinkDecoder::setBareDecoder
(
bool
isBare)
25
{
27
mMinimumSize = isBare ? 5 : 6;
28
mMaximumSize = isBare ? 21 : 22;
29
mTotalSize = mMinimumSize;
30
}
31
32
bool
ELinkDecoder::add
(
size_t
& idx, gsl::span<const uint8_t> payload,
size_t
nBytes,
size_t
step)
33
{
35
auto
size
= payload.size();
36
auto
end
= idx + step * nBytes;
37
if
(
size
<
end
) {
38
end
=
size
;
39
}
40
size_t
nAdded = 0;
41
for
(; idx <
end
; idx += step) {
42
mBytes.emplace_back(payload[idx]);
43
++nAdded;
44
}
45
return
(nAdded == nBytes);
46
}
47
48
bool
ELinkDecoder::add
(
size_t
& idx, gsl::span<const uint8_t> payload,
size_t
step)
49
{
51
auto
remaining = mTotalSize - mBytes.size();
52
if
(
add
(idx, payload, remaining, step)) {
53
if
(mTotalSize == mMinimumSize) {
54
computeSize();
55
remaining = mTotalSize - mBytes.size();
56
if
(remaining) {
57
return
add
(idx, payload, remaining, step);
58
}
59
}
60
return
true
;
61
}
62
return
false
;
63
}
64
65
void
ELinkDecoder::addAndComputeSize
(uint8_t
byte
)
66
{
68
mBytes.emplace_back(
byte
);
69
if
(mBytes.size() == mMinimumSize) {
70
computeSize();
71
}
72
}
73
74
void
ELinkDecoder::computeSize()
75
{
77
if
(
raw::isLoc
(mBytes[0])) {
78
// This is a local card
79
uint8_t
mask
=
getInputs
();
80
for
(
int
ich = 0; ich < 4; ++ich) {
81
if
((
mask
>> ich) & 0x1) {
82
// We expect 2 bytes for the BP and 2 for the NBP
83
mTotalSize += 4;
84
}
85
}
86
}
87
}
88
89
void
ELinkDecoder::reset
()
90
{
92
mBytes.clear();
93
mTotalSize = mMinimumSize;
94
}
95
96
uint16_t
ELinkDecoder::getPattern
(
int
cathode,
int
chamber)
const
97
{
99
uint8_t
mask
=
getInputs
();
100
if
(((
mask
>> chamber) & 0x1) == 0) {
101
return
0;
102
}
103
104
int
idx = mBytes.size();
105
for
(
int
ich = 0; ich <= chamber; ++ich) {
106
if
((
mask
>> ich) & 0x1) {
107
idx -= 4;
108
}
109
}
110
111
idx += 2 * cathode;
112
113
return
joinBytes(idx);
114
}
115
116
}
// namespace mid
117
}
// namespace o2
ELinkDecoder.h
MID e-link decoder.
o2::mid::ELinkDecoder::getInputs
uint8_t getInputs() const
Gets the inputs.
Definition
ELinkDecoder.h:80
o2::mid::ELinkDecoder::getPattern
uint16_t getPattern(int cathode, int chamber) const
Definition
ELinkDecoder.cxx:96
o2::mid::ELinkDecoder::reset
void reset()
Definition
ELinkDecoder.cxx:89
o2::mid::ELinkDecoder::add
void add(const uint8_t byte)
Adds a byte.
Definition
ELinkDecoder.h:34
o2::mid::ELinkDecoder::setBareDecoder
void setBareDecoder(bool isBare)
Definition
ELinkDecoder.cxx:24
o2::mid::ELinkDecoder::addAndComputeSize
void addAndComputeSize(const uint8_t byte)
Definition
ELinkDecoder.cxx:65
size
GLsizeiptr size
Definition
glcorearb.h:659
end
GLuint GLuint end
Definition
glcorearb.h:469
mask
GLint GLuint mask
Definition
glcorearb.h:291
o2::mid::raw::isLoc
bool isLoc(uint8_t statusWord)
Definition
ROBoard.h:65
o2
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
Definition
BitstreamReader.h:24
Detectors
MUON
MID
Raw
src
ELinkDecoder.cxx
Generated on Tue Feb 25 2025 23:16:24 for Project by
1.9.8