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 test1_vec.insert(test1_vec.begin() + 4 + 2 + pos, SYNC_PATTERN.begin(), SYNC_PATTERN.end());
66 result res{pos, 4 + 32 + pos};
67
68 for (int i = 0; i < test1_vec.size() - 4; i += 4) {
69 if (res.position - i <= 4) {
70 mon.addSequence(test1_vec[i], test1_vec[i + 1], test1_vec[i + 2], test1_vec[i + 3]);
71 BOOST_CHECK_EQUAL(mon.getPosition(), res.value);
72 } else {
73 mon.addSequence(test1_vec[i], test1_vec[i + 1], test1_vec[i + 2], test1_vec[i + 3]);
75 }
76 }
77 }
78}
79
81BOOST_AUTO_TEST_CASE(SyncPatternMonitor_test3)
82{
84
85 std::vector<short> SYNC_PATTERN{
86 /*mon.getPatternA(),mon.getPatternA(),*/ mon.getPatternB(), mon.getPatternB(),
87 mon.getPatternA(), mon.getPatternA(), mon.getPatternB(), mon.getPatternB(),
88 mon.getPatternA(), mon.getPatternA(), mon.getPatternB(), mon.getPatternB(),
89 mon.getPatternA(), mon.getPatternA(), mon.getPatternB(), mon.getPatternB(),
90 mon.getPatternA(), mon.getPatternA(), mon.getPatternA(), mon.getPatternA(),
91 mon.getPatternB(), mon.getPatternB(), mon.getPatternB(), mon.getPatternB(),
92 mon.getPatternA(), mon.getPatternA(), mon.getPatternA(), mon.getPatternA(),
93 mon.getPatternB(), mon.getPatternB(), mon.getPatternB(), mon.getPatternB()};
94
95 // loop over 4 possible positions
96 for (int pos = 0; pos < 4; ++pos) {
97 std::vector<short> test1_vec(4 + 4 + 2 + pos, mon.getPatternB());
98 test1_vec.insert(test1_vec.begin() + 4 + 2 + pos, SYNC_PATTERN.begin(), SYNC_PATTERN.end());
99 result res{pos, 4 + 32 + pos};
100
101 // loop over all positions of sync pattern in vector and replace with different pattern
102 for (int v = 4 + 2 + pos; v < 4 + 2 + pos + SYNC_PATTERN.size(); ++v) {
103 short old_Value = test1_vec[v];
104 test1_vec[v] = 0x0;
105
106 mon.reset();
107 for (int i = 0; i < test1_vec.size() - 4; i += 4) {
108 mon.addSequence(test1_vec[i], test1_vec[i + 1], test1_vec[i + 2], test1_vec[i + 3]);
110 }
111 test1_vec[v] = old_Value;
112 }
113 }
114}
115
116} // namespace tpc
117} // 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())