Project
Loading...
Searching...
No Matches
ROBoardResponse.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
16
18
19#include <unordered_map>
21
22namespace o2
23{
24namespace mid
25{
26
27ROBoardResponse::ROBoardResponse(const std::vector<ROBoardConfig>& configurations) : mConfigHandler(configurations)
28{
29}
30
32{
33 auto cfg = mConfigHandler.getConfig(loc.boardId);
34 if (cfg.configWord & crateconfig::sXorY) {
35 return false;
36 }
37 for (int ich = 0; ich < 4; ++ich) {
38 if (loc.patternsBP[ich] && loc.patternsNBP[ich]) {
39 return false;
40 }
41 }
42 return true;
43}
44
45bool ROBoardResponse::applyZeroSuppression(std::vector<ROBoard>& locs) const
46{
47 std::vector<ROBoard> zsLocs;
48 bool isSuppressed = false;
49 for (auto& loc : locs) {
50 if (!isZeroSuppressed(loc)) {
51 zsLocs.emplace_back(loc);
52 isSuppressed = true;
53 }
54 }
55 locs.swap(zsLocs);
56 return isSuppressed;
57}
58
59std::vector<ROBoard> ROBoardResponse::getTriggerResponse(uint8_t triggerWord) const
60{
61 std::vector<ROBoard> locBoards;
62 auto& cfgMap = mConfigHandler.getConfigMap();
63 for (auto& item : cfgMap) {
64 locBoards.push_back({raw::sSTARTBIT | raw::sCARDTYPE, triggerWord, item.first, 0});
65 if (triggerWord & (raw::sSOX | raw::sEOX)) {
67 if (item.second.configWord & crateconfig::sMonmoff) {
68 locBoards.back().statusWord |= raw::sMASKED;
69 for (int ich = 0; ich < 4; ++ich) {
70 locBoards.back().patternsBP[ich] = item.second.masksBP[ich];
71 locBoards.back().patternsNBP[ich] = item.second.masksNBP[ich];
72 }
73 }
74 }
75 }
76 auto regBoards = getRegionalResponse(locBoards);
77
78 // The regional response is built out of the local board response.
79 // This mimics what happens for the self-triggered events.
80 // However each GBT link has two regional responses, each collecting 4 boards.
81 // Even if the local boards are not there, the answer of the regional board to the trigger will still be present.
82 // We therefore complete the regional response.
83 std::vector<ROBoard> completeRegs;
84 completeRegs.reserve(regBoards.size());
85 for (auto regIt1 = regBoards.begin(), end = regBoards.end(); regIt1 != end; ++regIt1) {
86 completeRegs.emplace_back(*regIt1);
87 auto crateId1 = raw::getCrateId(regIt1->boardId);
88 auto locId1 = raw::getLocId(regIt1->boardId);
89 auto locId2 = locId1 % 8 == 0 ? locId1 + 1 : locId1 - 1;
90 auto boardId2 = raw::makeUniqueLocID(crateId1, locId2);
91 bool hasOther = false;
92 for (auto regIt2 = regBoards.begin(); regIt2 != end; ++regIt2) {
93
94 if (regIt2->boardId == boardId2) {
95 hasOther = true;
96 break;
97 }
98 }
99 if (!hasOther) {
100 completeRegs.emplace_back(*regIt1);
101 completeRegs.back().boardId = boardId2;
102 completeRegs.back().firedChambers = 0;
103 }
104 }
105
106 locBoards.insert(locBoards.begin(), completeRegs.begin(), completeRegs.end());
107 return locBoards;
108}
109
110std::vector<ROBoard> ROBoardResponse::getRegionalResponse(const std::vector<ROBoard>& locs) const
111{
112 std::unordered_map<uint8_t, uint8_t> firedLocs;
113
114 uint8_t triggerWord = 0;
115 for (auto& loc : locs) {
116 auto locId = raw::getLocId(loc.boardId);
117 auto regId = 8 * crateparams::getGBTIdFromBoardInCrate(locId) + (locId % 8) / 4;
118 auto uniqueRegId = raw::makeUniqueLocID(raw::getCrateId(loc.boardId), regId);
119 int locPos = locId % 4;
120 firedLocs[uniqueRegId] |= (1 << locPos);
121 triggerWord = loc.triggerWord;
122 }
123
124 std::vector<ROBoard> regBoards;
125 for (auto& item : firedLocs) {
126 regBoards.push_back({raw::sSTARTBIT, triggerWord, item.first, item.second});
127 }
128
129 return regBoards;
130}
131
132} // namespace mid
133} // namespace o2
MID RO crate parameters.
Local board response.
const ROBoardConfig getConfig(uint8_t uniqueLocId) const
const std::unordered_map< uint8_t, ROBoardConfig > getConfigMap() const
Returns the configuration map.
ROBoardResponse()=default
Default constructor.
std::vector< ROBoard > getRegionalResponse(const std::vector< ROBoard > &locs) const
std::vector< ROBoard > getTriggerResponse(uint8_t triggerWord) const
bool isZeroSuppressed(const ROBoard &loc) const
Returns true if the local board has no fired digits after zero suppression.
bool applyZeroSuppression(std::vector< ROBoard > &locs) const
GLuint GLuint end
Definition glcorearb.h:469
uint8_t getGBTIdFromBoardInCrate(uint8_t locId)
Gets the link ID in crate from the board ID.
uint8_t getCrateId(uint8_t uniqueLocId)
Definition ROBoard.h:75
uint8_t makeUniqueLocID(uint8_t crateId, uint8_t locId)
Definition ROBoard.h:86
uint8_t getLocId(uint8_t uniqueLocId)
Definition ROBoard.h:80
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
std::array< uint16_t, 4 > patternsNBP
Bending plane pattern.
Definition ROBoard.h:33
std::array< uint16_t, 4 > patternsBP
Fired chambers.
Definition ROBoard.h:32
uint8_t boardId
Trigger word.
Definition ROBoard.h:30