|
| 1 | +// Copyright CERN and copyright holders of ALICE O2. This software is |
| 2 | +// distributed under the terms of the GNU General Public License v3 (GPL |
| 3 | +// Version 3), copied verbatim in the file "COPYING". |
| 4 | +// |
| 5 | +// See http://alice-o2.web.cern.ch/license for full licensing information. |
| 6 | +// |
| 7 | +// In applying this license CERN does not waive the privileges and immunities |
| 8 | +// granted to it by virtue of its status as an Intergovernmental Organization |
| 9 | +// or submit itself to any jurisdiction. |
| 10 | + |
| 11 | +/// \file testTRDGeometry.cxx |
| 12 | +/// \brief This task tests the Geometry |
| 13 | +/// \author Sean Murray, murrays@cern.ch |
| 14 | + |
| 15 | +#define BOOST_TEST_MODULE Test TRD_Digit |
| 16 | +#define BOOST_TEST_MAIN |
| 17 | +#define BOOST_TEST_DYN_LINK |
| 18 | +#include <boost/test/unit_test.hpp> |
| 19 | +#include <iostream> |
| 20 | +#include <numeric> |
| 21 | + |
| 22 | +#include "TRDBase/Digit.h" |
| 23 | +#include "DataFormatsTRD/Constants.h" |
| 24 | + |
| 25 | +namespace o2 |
| 26 | +{ |
| 27 | +namespace trd |
| 28 | +{ |
| 29 | + |
| 30 | +using namespace o2::trd::constants; |
| 31 | + |
| 32 | +void testDigitDetRowPad(Digit& test, int det, int row, int pad) |
| 33 | +{ |
| 34 | + BOOST_CHECK(test.getPad() == pad); |
| 35 | + BOOST_CHECK(test.getRow() == row); |
| 36 | + BOOST_CHECK(test.getDetector() == det); |
| 37 | +} |
| 38 | + |
| 39 | +void testDigitDetROBMCM(Digit& test, int det, int rob, int mcm, int channel) |
| 40 | +{ |
| 41 | + BOOST_CHECK(test.getMCM() == mcm); |
| 42 | + BOOST_CHECK(test.getROB() == rob); |
| 43 | + BOOST_CHECK(test.getChannel() == channel); |
| 44 | + BOOST_CHECK(test.getDetector() == det); |
| 45 | +} |
| 46 | + |
| 47 | +BOOST_AUTO_TEST_CASE(TRDDigit_test) |
| 48 | +{ |
| 49 | + //TPD |
| 50 | + //pg 14 for rob to chamber |
| 51 | + // |
| 52 | + // 540 read out chambers (detector) |
| 53 | + // each one is made up of 16 row of 144 pads. |
| 54 | + // each one is also made up of 8 or 6 read out boards comprising 16 mcm and 21 adc each. |
| 55 | + // we need to check the pad,row to rob,mcm and back and the inverse holds true. |
| 56 | + // also the boundaries hold true.ends, of readout boards, ends of mcm. |
| 57 | + // |
| 58 | + //check digit at bottom of row is correctly assigned. |
| 59 | + |
| 60 | + // a pad row spans 2 read out boards. with 4 mcm in each. |
| 61 | + // 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. |
| 62 | + // 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 |
| 63 | + // 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. |
| 64 | + |
| 65 | + // so check various combinations of that, mostly just the boundaries. |
| 66 | + Digit first(0, 0, 0); //det row pad |
| 67 | + BOOST_CHECK(first.getMCM() == 0); |
| 68 | + |
| 69 | + Digit last(MAXCHAMBER - 1, NROWC1 - 1, NCOLUMN - 1); // last det row and pad |
| 70 | + BOOST_CHECK(last.getMCM() == NMCMROB - 1); |
| 71 | + // end of first mcm |
| 72 | + Digit a(0, 0, NCOLMCM - 1); |
| 73 | + BOOST_CHECK(a.getMCM() == 0); |
| 74 | + // start of new mcm? |
| 75 | + Digit b(0, 0, NCOLMCM); |
| 76 | + BOOST_CHECK(b.getMCM() == 1); |
| 77 | + // last pad connected to start of new mcm? |
| 78 | + Digit c(0, 0, 89); |
| 79 | + BOOST_CHECK(c.getMCM() == 0); |
| 80 | + // last pad connected to start of new mcm? |
| 81 | + Digit d(0, 0, 90); |
| 82 | + BOOST_CHECK(d.getMCM() == 1); |
| 83 | + // now to test if we set the rob and mcm do we get the correct pad and row. |
| 84 | + // using the reciprical of the values above for simplicity. |
| 85 | + // |
| 86 | + //test block 1. |
| 87 | + Digit e(0, 0, 0, 0); |
| 88 | + //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 ... |
| 89 | + Digit f(0, e.getRow(), e.getPad()); // createa digit based on the above digits pad and row. |
| 90 | + // we *shoulud* end up with a rob:mcm of 0:1 and channel 18 |
| 91 | + testDigitDetROBMCM(f, 0, 0, 1, NCOLMCM); |
| 92 | + |
| 93 | + Digit g(0, 0, NCOLMCM - 1); // row 0 pad 17 --- should be mcm 0 and channel 2 |
| 94 | + testDigitDetROBMCM(g, 0, 0, 0, 2); |
| 95 | + |
| 96 | + Digit h(0, 0, 0, 2); |
| 97 | + testDigitDetRowPad(h, 0, 0, NCOLMCM - 1); |
| 98 | + |
| 99 | + //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) |
| 100 | + Digit i(0, 0, (NCOLUMN / 2) - 1); |
| 101 | + testDigitDetROBMCM(i, 0, 0, 3, 2); |
| 102 | + //check the reverse creation |
| 103 | + Digit k(0, 0, 3, 2); |
| 104 | + testDigitDetRowPad(k, 0, 0, (NCOLUMN / 2) - 1); |
| 105 | + |
| 106 | + Digit j(0, 0, NCOLUMN / 2); |
| 107 | + testDigitDetROBMCM(j, 0, 1, 0, 19); |
| 108 | + //check the reverse creation |
| 109 | + Digit l(0, 1, 0, 19); |
| 110 | + testDigitDetRowPad(l, 0, 0, NCOLUMN / 2); |
| 111 | + |
| 112 | + // now repeat the same for another part of the first chamber, middle rows |
| 113 | + // |
| 114 | + Digit m(0, 12, (NCOLUMN / 2) - 1); |
| 115 | + testDigitDetROBMCM(m, 0, 6, 3, 2); |
| 116 | + //check the reverse creation |
| 117 | + Digit n(0, 6, 3, 2); |
| 118 | + testDigitDetRowPad(n, 0, 12, (NCOLUMN / 2) - 1); |
| 119 | + |
| 120 | + Digit o(0, 12, NCOLMCM - 1); |
| 121 | + testDigitDetROBMCM(o, 0, 6, 0, 2); |
| 122 | + Digit p(0, 6, 0, 2); |
| 123 | + testDigitDetRowPad(p, 0, 12, NCOLMCM - 1); |
| 124 | + |
| 125 | + //and now for the last row. |
| 126 | + Digit q(0, 15, (NCOLUMN / 2) - 1); |
| 127 | + testDigitDetROBMCM(q, 0, 6, 15, 2); |
| 128 | + //check the reverse creation |
| 129 | + Digit r(0, 6, 3, 2); |
| 130 | + testDigitDetRowPad(r, 0, 12, (NCOLUMN / 2) - 1); |
| 131 | + |
| 132 | + Digit s(0, 15, NCOLMCM - 1); |
| 133 | + testDigitDetROBMCM(s, 0, 6, 12, 2); |
| 134 | + Digit t(0, 6, 0, 2); |
| 135 | + testDigitDetRowPad(t, 0, 12, NCOLMCM - 1); |
| 136 | + |
| 137 | + // as a last check that for detector changes. |
| 138 | + // |
| 139 | + Digit u(1, 15, (NCOLUMN / 2) - 1); |
| 140 | + testDigitDetROBMCM(u, 1, 6, 15, 2); |
| 141 | + //check the reverse creation |
| 142 | + Digit v(1, 6, 3, 2); |
| 143 | + testDigitDetRowPad(v, 1, 12, (NCOLUMN / 2) - 1); |
| 144 | + |
| 145 | + Digit w(10, 15, NCOLMCM - 1); |
| 146 | + testDigitDetROBMCM(w, 10, 6, 12, 2); |
| 147 | + Digit x(10, 6, 0, 2); |
| 148 | + testDigitDetRowPad(x, 10, 12, NCOLMCM - 1); |
| 149 | + |
| 150 | + /* |
| 151 | + * The below is left in, it helps to remove confusion when debugging |
| 152 | + for(int rob=0;rob<8;rob++)for(int mcm=0;mcm<16;mcm++)for(int channel=0;channel<21;channel++){ |
| 153 | + std::cout << "Digit e(0,"<<rob<<"," << mcm <<","<< channel<<");" << std::endl; |
| 154 | + Digit e(0,rob,mcm,channel); |
| 155 | + std::cout << " e is " << e.getRow() << " " << e.getPad(); |
| 156 | + std::cout << " for an rob:mcm combo of " << e.getROB() << ":"<< e.getMCM() << " and adc channel:" << e.getChannel() <<std::endl; |
| 157 | + std::cout << "Digit f(0,e.getRow(),e.getPad())" << std::endl;; |
| 158 | + Digit f(0,e.getRow(),e.getPad()); |
| 159 | + std::cout << " f is " << f.getRow() << " " << f.getPad(); |
| 160 | + std::cout << " for an rob:mcm combo of " << f.getROB() << ":"<< f.getMCM() << " and adc channel:" << f.getChannel() <<std::endl; |
| 161 | + std::cout << "*********************************************************************" << std::endl; |
| 162 | + } |
| 163 | + */ |
| 164 | + |
| 165 | + //now check that the timebins get correctly assigned on instantiation |
| 166 | + ArrayADC data; |
| 167 | + std::iota(data.begin(), data.end(), 42); // 42 for my personal amusement. |
| 168 | + Digit z(10, 15, NCOLMCM - 1, data); |
| 169 | + testDigitDetROBMCM(z, 10, 6, 12, 2); |
| 170 | + //test adc values are true. |
| 171 | + BOOST_CHECK(z.getADC()[4] == 46); // 4th time bin should be 46; |
| 172 | + BOOST_CHECK(z.getADC()[6] == 48); // 6th time bin should be 48; |
| 173 | + |
| 174 | + Digit za(10, 6, 0, 2, data); |
| 175 | + testDigitDetRowPad(za, 10, 12, NCOLMCM - 1); |
| 176 | + BOOST_CHECK(za.getADC()[14] == 56); // 14th time bin should be 56; |
| 177 | + BOOST_CHECK(za.getADC()[16] == 58); // 16th time bin should be 58; |
| 178 | +} |
| 179 | + |
| 180 | +} // namespace trd |
| 181 | +} // namespace o2 |
0 commit comments