Project
Loading...
Searching...
No Matches
testCrateMapper.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
14
15#define BOOST_TEST_MODULE Test MID CrateMapper
16#define BOOST_TEST_DYN_LINK
17
18#include <boost/test/unit_test.hpp>
19
20#include <boost/test/data/test_case.hpp>
21#include <iostream>
23#include "MIDBase/Mapping.h"
25#include "MIDRaw/CrateMapper.h"
27
28BOOST_AUTO_TEST_SUITE(o2_mid_CrateMapper)
29
31{
32 o2::mid::CrateMapper crateMapper;
33 for (uint8_t icrate = 0; icrate < o2::mid::crateparams::sNCrates; ++icrate) {
34 int crateIdInSide = icrate % (o2::mid::crateparams::sNCrates / 2);
35 for (uint8_t iboard = 0; iboard < o2::mid::crateparams::sMaxNBoardsInCrate; ++iboard) {
36 int boardInSide = iboard % o2::mid::crateparams::sMaxNBoardsInLink;
37 bool exceptionExpected = false;
38 if ((crateIdInSide == 1 || crateIdInSide == 3) && iboard == 15) {
39 exceptionExpected = true;
40 } else if (crateIdInSide == 2 && boardInSide == 7) {
41 exceptionExpected = true;
42 } else if (crateIdInSide == 7 && iboard > 8) {
43 exceptionExpected = true;
44 }
45 bool exceptionReceived = false;
46 try {
47 crateMapper.roLocalBoardToDE(o2::mid::raw::makeUniqueLocID(icrate, iboard));
48 } catch (std::runtime_error except) {
49 exceptionReceived = true;
50 }
51 std::stringstream ss;
52 ss << "CrateId: " << static_cast<int>(icrate) << " boardId: " << static_cast<int>(iboard) << " exception expected: " << exceptionExpected << " received: " << exceptionReceived;
53 BOOST_TEST(exceptionExpected == exceptionReceived, ss.str());
54 }
55 }
56}
57
59{
60 o2::mid::Mapping mapping;
61 o2::mid::CrateMapper crateMapper;
62 for (int ide = 0; ide < o2::mid::detparams::NDetectionElements; ++ide) {
63 for (int icol = mapping.getFirstColumn(ide); icol < 7; ++icol) {
64 for (int iline = mapping.getFirstBoardBP(icol, ide); iline <= mapping.getLastBoardBP(icol, ide); ++iline) {
65 try {
66 crateMapper.deLocalBoardToRO(ide, icol, iline);
67 } catch (std::runtime_error except) {
68 std::stringstream ss;
69 ss << "DEId: " << static_cast<int>(ide) << " colId: " << static_cast<int>(icol) << " lineId: " << static_cast<int>(iline) << " exception received!";
70 BOOST_TEST(false, ss.str());
71 }
72 }
73 }
74 }
75}
76
78{
79 o2::mid::Mapping mapping;
80 o2::mid::CrateMapper crateMapper;
81 for (int ide = 0; ide < o2::mid::detparams::NDetectionElements; ++ide) {
82 for (int icol = mapping.getFirstColumn(ide); icol < 7; ++icol) {
83 for (int iline = mapping.getFirstBoardBP(icol, ide); iline <= mapping.getLastBoardBP(icol, ide); ++iline) {
84 auto uniqueLocId = crateMapper.deLocalBoardToRO(ide, icol, iline);
85 auto crateId = o2::mid::raw::getCrateId(uniqueLocId);
86 auto deBoardId = crateMapper.roLocalBoardToDE(uniqueLocId);
87 BOOST_TEST(static_cast<int>(o2::mid::detparams::getColumnIdFromFEEId(deBoardId)) == icol);
88 BOOST_TEST(static_cast<int>(o2::mid::detparams::getLineIdFromFEEId(deBoardId)) == iline);
89 int rpcLineId = o2::mid::detparams::getDEIdFromFEEId(deBoardId);
91 int ich = o2::mid::detparams::getChamber(ide);
93 }
94 }
95 }
96}
97
98BOOST_AUTO_TEST_SUITE_END()
Mapper to convert the RO Ids to a format suitable for O2.
MID RO crate parameters.
Useful detector parameters for MID.
Mapping for MID.
Structure to store the readout board information.
uint8_t deLocalBoardToRO(uint8_t deId, uint8_t columnId, uint8_t lineId) const
Converts the LOC ID expressed in the offline convention into the readout convention.
uint16_t roLocalBoardToDE(uint8_t uniqueLocId) const
Converts the LOC ID expressed in readout convention into the LOC ID in MT11 right in the offline conv...
int getFirstColumn(int deId) const
Definition Mapping.cxx:169
int getLastBoardBP(int column, int deId) const
Definition Mapping.cxx:188
int getFirstBoardBP(int column, int deId) const
Definition Mapping.cxx:178
bool isRightSide(uint8_t crateId)
Tests if the crate is in the right side.
constexpr int NDetectionElements
Number of RPCs.
int getColumnIdFromFEEId(uint16_t uniqueFEEId)
int getDEIdFromFEEId(uint16_t uniqueFEEId)
int getLineIdFromFEEId(uint16_t uniqueFEEId)
int getDEId(bool isRight, int chamber, int rpc)
uint8_t getCrateId(uint8_t uniqueLocId)
Definition ROBoard.h:75
uint8_t makeUniqueLocID(uint8_t crateId, uint8_t locId)
Definition ROBoard.h:86
BOOST_AUTO_TEST_CASE(FEEBoardToDE)
BOOST_TEST(digits==digitsD, boost::test_tools::per_element())