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"
21#include <array>
22#include <array>
23#include <fmt/printf.h>
24#include <boost/mpl/list.hpp>
25#include "GBTEncoder.h"
26
27using namespace o2::mch::raw;
28
29BOOST_AUTO_TEST_SUITE(o2_mch_raw)
30
31BOOST_AUTO_TEST_SUITE(gbtencoder)
32
34
35template <typename FORMAT, typename CHARGESUM>
37
38template <>
40{
41 return 4 * 640;
42}
43
44template <>
49
50BOOST_AUTO_TEST_CASE_TEMPLATE(GBTEncoderAddFewChannels, T, testTypes)
51{
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;
67 float e = expectedSize<T, ChargeSumMode>();
68 BOOST_CHECK_EQUAL(buffer.size(), e);
69}
70
71template <typename FORMAT, typename CHARGESUM>
73
74template <>
76{
77 return 4 * 11620;
78}
79
80template <>
85
86BOOST_AUTO_TEST_CASE_TEMPLATE(GBTEncoderAdd64Channels, T, testTypes)
87{
90 std::vector<std::byte> 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 }
99 // impl::dumpBuffer<T>(buffer);
100 float e = expectedMaxSize<T, ChargeSumMode>();
101 BOOST_CHECK_EQUAL(buffer.size(), e);
102}
103
104BOOST_AUTO_TEST_CASE_TEMPLATE(GBTEncoderMoveToBufferClearsTheInternalBuffer, T, testTypes)
105{
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);
113}
114
115BOOST_AUTO_TEST_SUITE_END()
116BOOST_AUTO_TEST_SUITE_END()
int32_t i
A GBTEncoder manages 40 ElinkEncoder to encode the data of one GBT.
Definition GBTEncoder.h:44
void addChannelData(uint8_t elinkGroupId, uint8_t elinkIndexInGroup, uint8_t chId, const std::vector< SampaCluster > &data)
Definition GBTEncoder.h:131
size_t moveToBuffer(std::vector< std::byte > &buffer)
Definition GBTEncoder.h:150
GLdouble n
Definition glcorearb.h:1982
GLuint buffer
Definition glcorearb.h:655
Definition list.h:40
Piece of data for one Sampa channel.
boost::mpl::list< o2::dcs::DataPointIdentifier, o2::dcs::DataPointValue, o2::dcs::DataPointCompositeObject > testTypes
BOOST_AUTO_TEST_CASE_TEMPLATE(GBTEncoderAddFewChannels, T, testTypes)
float expectedMaxSize()
float expectedSize()
float expectedMaxSize< UserLogicFormat, ChargeSumMode >()
float expectedSize< UserLogicFormat, ChargeSumMode >()
float expectedMaxSize< BareFormat, ChargeSumMode >()
BOOST_CHECK_EQUAL(triggersD.size(), triggers.size())