Project
Loading...
Searching...
No Matches
testTPCAdcClockMonitor.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 AdcClockMonitor
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
32BOOST_AUTO_TEST_CASE(AdcClockMonitor_test1)
33{
34 AdcClockMonitor mon(0);
35
37}
38
40BOOST_AUTO_TEST_CASE(AdcClockMonitor_test2)
41{
42 // Instantiate clock monitpr
43 AdcClockMonitor mon(0);
44
45 // do test for all possible clock phases
46 for (unsigned phase = 0; phase < 4; ++phase) {
47
48 // prepare valid clock sequence
49 std::vector<unsigned short> clockSequence(10, 0);
50 unsigned clock = (0xFFFF0000 >> phase);
51 for (int i = 0; i < 50; ++i) {
52 clockSequence.emplace_back((clock >> 28) & 0xF);
53 clock = (clock << 4) | (clock >> 28);
54 }
55
56 // feed monitor with clock sequence
57 mon.reset();
58 int seq;
59 for (std::vector<unsigned short>::iterator it = clockSequence.begin(); it != clockSequence.end(); ++it) {
60 seq = std::distance(clockSequence.begin(), it);
61 // only the 18th sequence completes the full cycle
62 // 10 times 000 in the beginning + 8 sequences with needed parts to recognize full pattern
63 BOOST_CHECK_EQUAL(mon.addSequence(*it), (seq >= 18 ? 0 : 1));
64 }
65 }
66}
67
69BOOST_AUTO_TEST_CASE(AdcClockMonitor_test3)
70{
71 // Instantiate clock monitpr
72 AdcClockMonitor mon(0);
73
74 // do test for all possible clock phases
75 for (unsigned phase = 0; phase < 4; ++phase) {
76
77 // prepare valid clock sequence
78 std::vector<unsigned short> clockSequence(10, 0);
79 unsigned clock = (0xFFFF0000 >> phase);
80 for (int i = 0; i < 50; ++i) {
81 clockSequence.emplace_back((clock >> 28) & 0xF);
82 clock = (clock << 4) | (clock >> 28);
83 }
84
85 // feed monitor with clock sequence, replace beforehand one sequence of first pattern with something else
86 unsigned short oldSeq;
87 for (int pos = 10; pos < 18; ++pos) {
88 mon.reset();
89 oldSeq = clockSequence[pos];
90 clockSequence[pos] = 0xA;
91 int seq;
92 for (std::vector<unsigned short>::iterator it = clockSequence.begin(); it != clockSequence.end(); ++it) {
93 seq = std::distance(clockSequence.begin(), it);
94 // only the 26th sequence completes the full cycle
95 // 10 times 000 in the beginning
96 // + 8 sequences with with wrong part
97 // + 8 sequences with correct parts to recognize full pattern
98
99 // one special case for phase = 0 and position of wrong part = 17 (last needed part for full pattern)
100 // phase 0 means the following pattern 0000 FFFF 0000 FFFF ...
101 // ^
102 // |
103 // part 17 wrong means this one wrong (not 0) -------------|
104 //
105 // The finding algorithm neads two clean transitions from 0 to F to recognize
106 // a clock with phase 0. If part 17 is wrong, we won't have this clean transition
107 // at this position, therefore the the clock will be recognized one complete
108 // pattern later. For every other wrong part, we still habe here the first transition
109 // from 0 to F and for every other phase, we don't need two sequences for the
110 // transition just the one with the transition
111 int expGoodSequence = (phase == 0 && pos == 17) ? (18 + 8 + 8) : (18 + 8);
112
113 BOOST_CHECK_EQUAL(mon.addSequence(*it), (seq >= expGoodSequence ? 0 : 1));
114 }
115 clockSequence[pos] = oldSeq;
116 }
117 }
118}
119
120} // namespace tpc
121} // namespace o2
Class to monitor the ADC smapling clock contained in the GBT frame.
uint64_t phase
Definition RawEventData.h:7
int32_t i
uint16_t pos
Definition RawData.h:3
Class to monitor the ADC smapling clock contained in the GBT frame.
int addSequence(const short seq)
void reset()
Reset function to clear history.
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())