Project
Loading...
Searching...
No Matches
testDigit.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 TRD_Digit
17#define BOOST_TEST_MAIN
18#define BOOST_TEST_DYN_LINK
19#include <boost/test/unit_test.hpp>
20#include <iostream>
21#include <numeric>
22
25
26namespace o2
27{
28namespace trd
29{
30
31using namespace o2::trd::constants;
32
33void testDigitDetRowPad(Digit& test, int det, int row, int pad)
34{
35 BOOST_CHECK(test.getPadCol() == pad);
36 BOOST_CHECK(test.getPadRow() == row);
37 BOOST_CHECK(test.getDetector() == det);
38}
39
40void testDigitDetROBMCM(Digit& test, int det, int rob, int mcm, int channel)
41{
42 BOOST_CHECK(test.getMCM() == mcm);
43 BOOST_CHECK(test.getROB() == rob);
44 BOOST_CHECK(test.getChannel() == channel);
45 BOOST_CHECK(test.getDetector() == det);
46}
47
49{
50 //TPD
51 //pg 14 for rob to chamber
52 //
53 // 540 read out chambers (detector)
54 // each one is made up of 16 row of 144 pads.
55 // each one is also made up of 8 or 6 read out boards comprising 16 mcm and 21 adc each.
56 // we need to check the pad,row to rob,mcm and back and the inverse holds true.
57 // also the boundaries hold true.ends, of readout boards, ends of mcm.
58 //
59 //check digit at bottom of row is correctly assigned.
60
61 // a pad row spans 2 read out boards. with 4 mcm in each.
62 // i.e. pad row 0 will have read out board 0 and 1 and mcm 0-4 and 0-4 in each making up the 8 mcm in the pad row.
63 // channel 0 and 1 of MCM n are shared with 18 and 19 (respectively) of MCM n+1 and channel 20 of MCM n is shared with MCM n-1 channel 2
64 // channel 20 of MCM n is connected to the preceding MCM's highest number pad. i.e. MCM01 channel 20 is connected to MCM00 pad 17 (18th pad) of row.
65
66 // so check various combinations of that, mostly just the boundaries.
67 Digit first(0, 0, 0); //det row pad
68 BOOST_CHECK(first.getMCM() == 0);
69
70 Digit last(MAXCHAMBER - 1, NROWC1 - 1, NCOLUMN - 1); // last det row and pad
71 BOOST_CHECK(last.getMCM() == NMCMROB - 1);
72 // end of first mcm
73 Digit a(0, 0, NCOLMCM - 1);
74 BOOST_CHECK(a.getMCM() == 0);
75 // start of new mcm?
76 Digit b(0, 0, NCOLMCM);
77 BOOST_CHECK(b.getMCM() == 1);
78 // last pad connected to start of new mcm?
79 Digit c(0, 0, 89);
80 BOOST_CHECK(c.getMCM() == 0);
81 // last pad connected to start of new mcm?
82 Digit d(0, 0, 90);
83 BOOST_CHECK(d.getMCM() == 1);
84 // now to test if we set the rob and mcm do we get the correct pad and row.
85 // using the reciprical of the values above for simplicity.
86 //
87 //test block 1.
88 Digit e(0, 0, 0, 0);
89 //first channel of the first mcm, this is in fact the 19 pad of the first row, and connected to the 18th adc of the second trap ...
90 Digit f(0, e.getPadRow(), e.getPadCol()); // createa digit based on the above digits pad and row.
91 // we *shoulud* end up with a rob:mcm of 0:1 and channel 18
92 testDigitDetROBMCM(f, 0, 0, 1, NCOLMCM);
93
94 Digit g(0, 0, NCOLMCM - 1); // row 0 pad 17 --- should be mcm 0 and channel 2
95 testDigitDetROBMCM(g, 0, 0, 0, 2);
96
97 Digit h(0, 0, 0, 2);
98 testDigitDetRowPad(h, 0, 0, NCOLMCM - 1);
99
100 //test block2 repeat block1 but at the edge of a rob boundary i.e. going from row0 the 72nd pad to 73rd. Spanning the half of 144(NCOLUMN)
101 Digit i(0, 0, (NCOLUMN / 2) - 1);
102 testDigitDetROBMCM(i, 0, 0, 3, 2);
103 //check the reverse creation
104 Digit k(0, 0, 3, 2);
105 testDigitDetRowPad(k, 0, 0, (NCOLUMN / 2) - 1);
106
107 Digit j(0, 0, NCOLUMN / 2);
108 testDigitDetROBMCM(j, 0, 1, 0, 19);
109 //check the reverse creation
110 Digit l(0, 1, 0, 19);
111 testDigitDetRowPad(l, 0, 0, NCOLUMN / 2);
112
113 // now repeat the same for another part of the first chamber, middle rows
114 //
115 Digit m(0, 12, (NCOLUMN / 2) - 1);
116 testDigitDetROBMCM(m, 0, 6, 3, 2);
117 //check the reverse creation
118 Digit n(0, 6, 3, 2);
119 testDigitDetRowPad(n, 0, 12, (NCOLUMN / 2) - 1);
120
121 Digit o(0, 12, NCOLMCM - 1);
122 testDigitDetROBMCM(o, 0, 6, 0, 2);
123 Digit p(0, 6, 0, 2);
124 testDigitDetRowPad(p, 0, 12, NCOLMCM - 1);
125
126 //and now for the last row.
127 Digit q(0, 15, (NCOLUMN / 2) - 1);
128 testDigitDetROBMCM(q, 0, 6, 15, 2);
129 //check the reverse creation
130 Digit r(0, 6, 3, 2);
131 testDigitDetRowPad(r, 0, 12, (NCOLUMN / 2) - 1);
132
133 Digit s(0, 15, NCOLMCM - 1);
134 testDigitDetROBMCM(s, 0, 6, 12, 2);
135 Digit t(0, 6, 0, 2);
136 testDigitDetRowPad(t, 0, 12, NCOLMCM - 1);
137
138 // as a last check that for detector changes.
139 //
140 Digit u(1, 15, (NCOLUMN / 2) - 1);
141 testDigitDetROBMCM(u, 1, 6, 15, 2);
142 //check the reverse creation
143 Digit v(1, 6, 3, 2);
144 testDigitDetRowPad(v, 1, 12, (NCOLUMN / 2) - 1);
145
146 Digit w(10, 15, NCOLMCM - 1);
147 testDigitDetROBMCM(w, 10, 6, 12, 2);
148 Digit x(10, 6, 0, 2);
149 testDigitDetRowPad(x, 10, 12, NCOLMCM - 1);
150
151 /*
152 * The below is left in, it helps to remove confusion when debugging
153 for(int rob=0;rob<8;rob++)for(int mcm=0;mcm<16;mcm++)for(int channel=0;channel<21;channel++){
154 std::cout << "Digit e(0,"<<rob<<"," << mcm <<","<< channel<<");" << std::endl;
155 Digit e(0,rob,mcm,channel);
156 std::cout << " e is " << e.getPadRow() << " " << e.getPadCol();
157 std::cout << " for an rob:mcm combo of " << e.getROB() << ":"<< e.getMCM() << " and adc channel:" << e.getChannel() <<std::endl;
158 std::cout << "Digit f(0,e.getPadRow(),e.getPadCol())" << std::endl;;
159 Digit f(0,e.getPadRow(),e.getPadCol());
160 std::cout << " f is " << f.getPadRow() << " " << f.getPadCol();
161 std::cout << " for an rob:mcm combo of " << f.getROB() << ":"<< f.getMCM() << " and adc channel:" << f.getChannel() <<std::endl;
162 std::cout << "*********************************************************************" << std::endl;
163 }
164 */
165
166 //now check that the timebins get correctly assigned on instantiation
168 std::iota(data.begin(), data.end(), 42); // 42 for my personal amusement.
169 Digit z(10, 15, NCOLMCM - 1, data);
170 testDigitDetROBMCM(z, 10, 6, 12, 2);
171 //test adc values are true.
172 BOOST_CHECK(z.getADC()[4] == 46); // 4th time bin should be 46;
173 BOOST_CHECK(z.getADC()[6] == 48); // 6th time bin should be 48;
174
175 Digit za(10, 6, 0, 2, data);
176 testDigitDetRowPad(za, 10, 12, NCOLMCM - 1);
177 BOOST_CHECK(za.getADC()[14] == 56); // 14th time bin should be 56;
178 BOOST_CHECK(za.getADC()[16] == 58); // 16th time bin should be 58;
179
180 // check the setting and reading of the phase for various combinations of setting the detector and phase.
181 Digit withphase(10, 6, 0, 2, data, 3);
182 BOOST_CHECK(withphase.getPreTrigPhase() == 0x3);
183 withphase.setPreTrigPhase(1);
184 BOOST_CHECK(withphase.getPreTrigPhase() == 0x1);
185 withphase.setDetector(12);
186 BOOST_CHECK(withphase.getPreTrigPhase() == 0x1);
187 BOOST_CHECK(withphase.getDetector() == 0xc);
188 withphase.setDetector(539);
189 BOOST_CHECK(withphase.getPreTrigPhase() == 0x1);
190 BOOST_CHECK(withphase.getDetector() == 539);
191 withphase.setDetector(12);
192 BOOST_CHECK(withphase.getPreTrigPhase() == 0x1);
193 BOOST_CHECK(withphase.getDetector() == 12);
194 withphase.setDetector(0);
195 BOOST_CHECK(withphase.getPreTrigPhase() == 0x1);
196 BOOST_CHECK(withphase.getDetector() == 0);
197 withphase.setPreTrigPhase(0);
198 BOOST_CHECK(withphase.getPreTrigPhase() == 0x0);
199 BOOST_CHECK(withphase.getDetector() == 0);
200}
201
202} // namespace trd
203} // namespace o2
uint16_t mcm
uint16_t rob
Global TRD definitions and constants.
int32_t i
bool o
uint32_t j
Definition RawData.h:0
uint32_t c
Definition RawData.h:2
Class for time synchronization of RawReader instances.
int getPreTrigPhase() const
Definition Digit.h:87
int getDetector() const
Definition Digit.h:79
int getPadRow() const
Definition Digit.h:81
void setPreTrigPhase(int phase)
Definition Digit.h:77
int getMCM() const
Definition Digit.h:84
ArrayADC const & getADC() const
Definition Digit.h:91
int getPadCol() const
Definition Digit.h:82
void setDetector(int det)
Definition Digit.h:74
GLdouble n
Definition glcorearb.h:1982
GLint GLenum GLint x
Definition glcorearb.h:403
const GLfloat * m
Definition glcorearb.h:4066
const GLdouble * v
Definition glcorearb.h:832
GLint first
Definition glcorearb.h:399
GLdouble f
Definition glcorearb.h:310
GLboolean GLboolean GLboolean b
Definition glcorearb.h:1233
GLboolean * data
Definition glcorearb.h:298
GLboolean GLboolean g
Definition glcorearb.h:1233
GLboolean r
Definition glcorearb.h:1233
GLboolean GLboolean GLboolean GLboolean a
Definition glcorearb.h:1233
GLubyte GLubyte GLubyte GLubyte w
Definition glcorearb.h:852
GLdouble GLdouble GLdouble z
Definition glcorearb.h:843
constexpr int NCOLUMN
the number of pad columns for each chamber
Definition Constants.h:41
constexpr int NMCMROB
the number of MCMs per ROB
Definition Constants.h:46
constexpr int NCOLMCM
the number of pads per MCM
Definition Constants.h:53
constexpr int MAXCHAMBER
the maximum number of installed chambers
Definition Constants.h:30
constexpr int NROWC1
the number of pad rows for chambers of type C1 (installed in stacks 0, 1, 3 and 4)
Definition Constants.h:43
void testDigitDetRowPad(Digit &test, int det, int row, int pad)
Definition testDigit.cxx:33
void testDigitDetROBMCM(Digit &test, int det, int rob, int mcm, int channel)
Definition testDigit.cxx:40
std::array< ADC_t, constants::TIMEBINS > ArrayADC
Definition Digit.h:32
BOOST_AUTO_TEST_CASE(TRDDigit_test)
Definition testDigit.cxx:48
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
FIXME: do not use data model tables.
BOOST_CHECK(tree)
std::vector< int > row