Project
Loading...
Searching...
No Matches
testTPCSyncPatternMonitor.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
15
16#define BOOST_TEST_MODULE Test TPC SyncPatternMonitor
17#define BOOST_TEST_MAIN
18#define BOOST_TEST_DYN_LINK
19#include <boost/test/unit_test.hpp>
21
22#include <vector>
23#include <iostream>
24#include <iomanip>
25
26namespace o2
27{
28namespace tpc
29{
30
31struct result {
32 int value;
34};
35
37BOOST_AUTO_TEST_CASE(SyncPatternMonitor_test1)
38{
39 SyncPatternMonitor mon(0, 0);
40
41 BOOST_CHECK_EQUAL(mon.getPatternA(), 0x15);
42 BOOST_CHECK_EQUAL(mon.getPatternB(), 0x0A);
44}
45
47BOOST_AUTO_TEST_CASE(SyncPatternMonitor_test2)
48{
50
51 std::vector<short> SYNC_PATTERN{
52 /*mon.getPatternA(),mon.getPatternA(),*/ mon.getPatternB(), mon.getPatternB(),
53 mon.getPatternA(), mon.getPatternA(), mon.getPatternB(), mon.getPatternB(),
54 mon.getPatternA(), mon.getPatternA(), mon.getPatternB(), mon.getPatternB(),
55 mon.getPatternA(), mon.getPatternA(), mon.getPatternB(), mon.getPatternB(),
56 mon.getPatternA(), mon.getPatternA(), mon.getPatternA(), mon.getPatternA(),
57 mon.getPatternB(), mon.getPatternB(), mon.getPatternB(), mon.getPatternB(),
58 mon.getPatternA(), mon.getPatternA(), mon.getPatternA(), mon.getPatternA(),
59 mon.getPatternB(), mon.getPatternB(), mon.getPatternB(), mon.getPatternB()};
60
61 // loop over 4 possible positions
62 for (int pos = 0; pos < 4; ++pos) {
63 mon.reset();
64 std::vector<short> test1_vec(4 + 4 + 2 + pos, mon.getPatternB());
65#pragma GCC diagnostic push // TODO: Remove once this is fixed in GCC
66#pragma GCC diagnostic ignored "-Wstringop-overflow" // TODO: Remove once this is fixed in GCC
67 test1_vec.insert(test1_vec.begin() + 4 + 2 + pos, SYNC_PATTERN.begin(), SYNC_PATTERN.end());
68#pragma GCC diagnostic pop // TODO: Remove once this is fixed in GCC
69 result res{pos, 4 + 32 + pos};
70
71 for (int i = 0; i < test1_vec.size() - 4; i += 4) {
72 if (res.position - i <= 4) {
73 mon.addSequence(test1_vec[i], test1_vec[i + 1], test1_vec[i + 2], test1_vec[i + 3]);
74 BOOST_CHECK_EQUAL(mon.getPosition(), res.value);
75 } else {
76 mon.addSequence(test1_vec[i], test1_vec[i + 1], test1_vec[i + 2], test1_vec[i + 3]);
78 }
79 }
80 }
81}
82
84BOOST_AUTO_TEST_CASE(SyncPatternMonitor_test3)
85{
87
88 std::vector<short> SYNC_PATTERN{
89 /*mon.getPatternA(),mon.getPatternA(),*/ mon.getPatternB(), mon.getPatternB(),
90 mon.getPatternA(), mon.getPatternA(), mon.getPatternB(), mon.getPatternB(),
91 mon.getPatternA(), mon.getPatternA(), mon.getPatternB(), mon.getPatternB(),
92 mon.getPatternA(), mon.getPatternA(), mon.getPatternB(), mon.getPatternB(),
93 mon.getPatternA(), mon.getPatternA(), mon.getPatternA(), mon.getPatternA(),
94 mon.getPatternB(), mon.getPatternB(), mon.getPatternB(), mon.getPatternB(),
95 mon.getPatternA(), mon.getPatternA(), mon.getPatternA(), mon.getPatternA(),
96 mon.getPatternB(), mon.getPatternB(), mon.getPatternB(), mon.getPatternB()};
97
98 // loop over 4 possible positions
99 for (int pos = 0; pos < 4; ++pos) {
100 std::vector<short> test1_vec(4 + 4 + 2 + pos, mon.getPatternB());
101#pragma GCC diagnostic push // TODO: Remove once this is fixed in GCC
102#pragma GCC diagnostic ignored "-Wstringop-overflow" // TODO: Remove once this is fixed in GCC
103 test1_vec.insert(test1_vec.begin() + 4 + 2 + pos, SYNC_PATTERN.begin(), SYNC_PATTERN.end());
104#pragma GCC diagnostic pop // TODO: Remove once this is fixed in GCC
105 result res{pos, 4 + 32 + pos};
106
107 // loop over all positions of sync pattern in vector and replace with different pattern
108 for (int v = 4 + 2 + pos; v < 4 + 2 + pos + SYNC_PATTERN.size(); ++v) {
109 short old_Value = test1_vec[v];
110 test1_vec[v] = 0x0;
111
112 mon.reset();
113 for (int i = 0; i < test1_vec.size() - 4; i += 4) {
114 mon.addSequence(test1_vec[i], test1_vec[i + 1], test1_vec[i + 2], test1_vec[i + 3]);
116 }
117 test1_vec[v] = old_Value;
118 }
119 }
120}
121
122} // namespace tpc
123} // namespace o2
int32_t i
uint16_t pos
Definition RawData.h:3
uint32_t res
Definition RawData.h:0
Class to monitor the data stream and detect synchronization patterns.
Class to monitor the data stream and detect synchronization patterns.
short addSequence(const short hw0, const short hw1, const short hw2, const short hw3)
void reset()
Reset function to clear history.
const GLdouble * v
Definition glcorearb.h:832
BOOST_AUTO_TEST_CASE(ClusterHardware_test1)
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
BOOST_CHECK_EQUAL(triggersD.size(), triggers.size())