Project
Loading...
Searching...
No Matches
testGBTEncoder.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
12
#define BOOST_TEST_MODULE Test MCHRaw GBTEncoder
13
#define BOOST_TEST_MAIN
14
#define BOOST_TEST_DYN_LINK
15
16
#include <boost/test/unit_test.hpp>
17
#include "
BareElinkEncoder.h
"
18
#include "
UserLogicElinkEncoder.h
"
19
#include "
BareElinkEncoderMerger.h
"
20
#include "
UserLogicElinkEncoderMerger.h
"
21
#include <array>
22
#include <array>
23
#include <fmt/printf.h>
24
#include <boost/mpl/list.hpp>
25
#include "
GBTEncoder.h
"
26
27
using namespace
o2::mch::raw
;
28
29
BOOST_AUTO_TEST_SUITE(o2_mch_raw)
30
31
BOOST_AUTO_TEST_SUITE(gbtencoder)
32
33
typedef
boost
::mpl::
list
<
BareFormat
,
UserLogicFormat
>
testTypes
;
34
35
template <typename FORMAT, typename CHARGESUM>
36
float
expectedSize
();
37
38
template <>
39
float
expectedSize
<
BareFormat
,
ChargeSumMode
>()
40
{
41
return
4 * 640;
42
}
43
44
template
<>
45
float
expectedSize<UserLogicFormat, ChargeSumMode>
()
46
{
47
return
96;
48
}
49
50
BOOST_AUTO_TEST_CASE_TEMPLATE
(GBTEncoderAddFewChannels, T,
testTypes
)
51
{
52
GBTEncoder<T, ChargeSumMode>::forceNoPhase
=
true
;
53
GBTEncoder<T, ChargeSumMode>
enc(0);
54
uint32_t bx(0);
55
uint16_t ts(0);
56
int
elinkGroupId = 0;
57
int
elinkIndexInGroup = 0;
58
enc.
addChannelData
(elinkGroupId, elinkIndexInGroup, 0, {
SampaCluster
(ts, 0, 10, 11)});
59
enc.
addChannelData
(elinkGroupId, elinkIndexInGroup, 31, {
SampaCluster
(ts, 0, 160, 161)});
60
elinkIndexInGroup = 3;
61
enc.
addChannelData
(elinkGroupId, elinkIndexInGroup, 3, {
SampaCluster
(ts, 0, 13, 14)});
62
enc.
addChannelData
(elinkGroupId, elinkIndexInGroup, 13, {
SampaCluster
(ts, 0, 133, 134)});
63
enc.
addChannelData
(elinkGroupId, elinkIndexInGroup, 23, {
SampaCluster
(ts, 0, 163, 164)});
64
BOOST_CHECK_THROW(enc.
addChannelData
(8, 0, 0, {SampaCluster(ts, 0, 10, 11)}), std::invalid_argument);
65
std::vector<std::byte>
buffer
;
66
enc.
moveToBuffer
(
buffer
);
67
float
e = expectedSize<T, ChargeSumMode>();
68
BOOST_CHECK_EQUAL
(
buffer
.size(), e);
69
}
70
71
template
<
typename
FORMAT,
typename
CHARGESUM>
72
float
expectedMaxSize
();
73
74
template
<>
75
float
expectedMaxSize<BareFormat, ChargeSumMode>
()
76
{
77
return
4 * 11620;
78
}
79
80
template
<>
81
float
expectedMaxSize<UserLogicFormat, ChargeSumMode>
()
82
{
83
return
944;
84
}
85
86
BOOST_AUTO_TEST_CASE_TEMPLATE
(GBTEncoderAdd64Channels, T,
testTypes
)
87
{
88
GBTEncoder<T, ChargeSumMode>::forceNoPhase
=
true
;
89
GBTEncoder<T, ChargeSumMode>
enc(0);
90
std::vector<std::byte>
buffer
;
91
enc.
moveToBuffer
(
buffer
);
92
uint32_t bx(0);
93
uint16_t ts(0);
94
int
elinkGroupId = 0;
95
for
(
int
i
= 0;
i
< 64;
i
++) {
96
enc.
addChannelData
(elinkGroupId, 0,
i
, {
SampaCluster
(ts, 0,
i
* 10, (
i
* 10) + 1)});
97
}
98
enc.
moveToBuffer
(
buffer
);
99
// impl::dumpBuffer<T>(buffer);
100
float
e = expectedMaxSize<T, ChargeSumMode>();
101
BOOST_CHECK_EQUAL
(
buffer
.size(), e);
102
}
103
104
BOOST_AUTO_TEST_CASE_TEMPLATE
(GBTEncoderMoveToBufferClearsTheInternalBuffer, T,
testTypes
)
105
{
106
GBTEncoder<T, ChargeSumMode>
enc(0);
107
enc.
addChannelData
(0, 0, 0, {
SampaCluster
(0, 0, 10, 11)});
108
std::vector<std::byte>
buffer
;
109
size_t
n
= enc.
moveToBuffer
(
buffer
);
110
BOOST_CHECK_GE(
n
, 0);
111
n
= enc.
moveToBuffer
(
buffer
);
112
BOOST_CHECK_EQUAL
(
n
, 0);
113
}
114
115
BOOST_AUTO_TEST_SUITE_END()
116
BOOST_AUTO_TEST_SUITE_END()
BareElinkEncoderMerger.h
BareElinkEncoder.h
GBTEncoder.h
i
int32_t i
Definition
GPUCommonAlgorithm.h:443
UserLogicElinkEncoderMerger.h
UserLogicElinkEncoder.h
o2::mch::raw::GBTEncoder
A GBTEncoder manages 40 ElinkEncoder to encode the data of one GBT.
Definition
GBTEncoder.h:44
o2::mch::raw::GBTEncoder::addChannelData
void addChannelData(uint8_t elinkGroupId, uint8_t elinkIndexInGroup, uint8_t chId, const std::vector< SampaCluster > &data)
Definition
GBTEncoder.h:131
o2::mch::raw::GBTEncoder::moveToBuffer
size_t moveToBuffer(std::vector< std::byte > &buffer)
Definition
GBTEncoder.h:150
n
GLdouble n
Definition
glcorearb.h:1982
buffer
GLuint buffer
Definition
glcorearb.h:655
boost
Definition
BoostOptionsRetriever.h:22
o2::mch::raw
Definition
pedestal-decoding-workflow.cxx:58
list
Definition
list.h:40
o2::mch::raw::BareFormat
Definition
DataFormats.h:21
o2::mch::raw::ChargeSumMode
Definition
DataFormats.h:27
o2::mch::raw::SampaCluster
Piece of data for one Sampa channel.
Definition
SampaCluster.h:40
o2::mch::raw::UserLogicFormat
Definition
DataFormats.h:24
testTypes
boost::mpl::list< o2::dcs::DataPointIdentifier, o2::dcs::DataPointValue, o2::dcs::DataPointCompositeObject > testTypes
Definition
testDataPointTypes.cxx:25
BOOST_AUTO_TEST_CASE_TEMPLATE
BOOST_AUTO_TEST_CASE_TEMPLATE(GBTEncoderAddFewChannels, T, testTypes)
Definition
testGBTEncoder.cxx:50
expectedMaxSize
float expectedMaxSize()
expectedSize
float expectedSize()
expectedMaxSize< UserLogicFormat, ChargeSumMode >
float expectedMaxSize< UserLogicFormat, ChargeSumMode >()
Definition
testGBTEncoder.cxx:81
expectedSize< UserLogicFormat, ChargeSumMode >
float expectedSize< UserLogicFormat, ChargeSumMode >()
Definition
testGBTEncoder.cxx:45
expectedMaxSize< BareFormat, ChargeSumMode >
float expectedMaxSize< BareFormat, ChargeSumMode >()
Definition
testGBTEncoder.cxx:75
BOOST_CHECK_EQUAL
BOOST_CHECK_EQUAL(triggersD.size(), triggers.size())
Detectors
MUON
MCH
Raw
Encoder
Payload
testGBTEncoder.cxx
Generated on Tue Feb 25 2025 23:16:23 for Project by
1.9.8