Project
Loading...
Searching...
No Matches
ChannelMasksHandler.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
19namespace o2
20{
21namespace mid
22{
23
24ColumnData& ChannelMasksHandler::getMask(uint8_t deId, uint8_t columnId)
25{
26 auto uniqueId = getColumnDataUniqueId(deId, columnId);
27 auto maskIt = mMasks.find(uniqueId);
28 if (maskIt == mMasks.end()) {
29 auto& newMask = mMasks[uniqueId];
30 newMask.deId = deId;
31 newMask.columnId = columnId;
32 newMask.patterns.fill(0xFFFF);
33 return newMask;
34 }
35 return maskIt->second;
36}
37
38void ChannelMasksHandler::switchOffChannel(uint8_t deId, uint8_t columnId, int lineId, int strip, int cathode)
39{
40 auto& mask = getMask(deId, columnId);
41 uint16_t pattern = (1 << strip);
42 if (cathode == 0) {
43 mask.setBendPattern(mask.getBendPattern(lineId) & ~pattern, lineId);
44 } else {
45 mask.setNonBendPattern(mask.getNonBendPattern() & ~pattern);
46 }
47}
48
50{
51 auto& mask = getMask(badChannels.deId, badChannels.columnId);
52 mask.setNonBendPattern(mask.getNonBendPattern() & (~badChannels.getNonBendPattern()));
53 for (int iline = 0; iline < 4; ++iline) {
54 mask.setBendPattern(mask.getBendPattern(iline) & (~badChannels.getBendPattern(iline)), iline);
55 }
56}
57
58void ChannelMasksHandler::switchOffChannels(const std::vector<ColumnData>& badChannelsList)
59{
60 for (auto& bad : badChannelsList) {
62 }
63}
64
66{
67 auto uniqueId = getColumnDataUniqueId(data.deId, data.columnId);
68 auto maskIt = mMasks.find(uniqueId);
69 if (maskIt == mMasks.end()) {
70 return true;
71 }
72 uint16_t allPatterns = 0;
73 data.setNonBendPattern(data.getNonBendPattern() & maskIt->second.getNonBendPattern());
74 allPatterns |= data.getNonBendPattern();
75 for (int iline = 0; iline < 4; ++iline) {
76 data.setBendPattern(data.getBendPattern(iline) & maskIt->second.getBendPattern(iline), iline);
77 allPatterns |= data.getBendPattern(iline);
78 }
79 return (allPatterns != 0);
80}
81
82std::vector<ColumnData> ChannelMasksHandler::getMasks() const
83{
85 std::vector<ColumnData> masks;
86 for (auto& maskIt : mMasks) {
87 masks.emplace_back(maskIt.second);
88 }
89 return masks;
90}
91
93{
95 auto uniqueColumnId = getColumnDataUniqueId(mask.deId, mask.columnId);
96 mMasks[uniqueColumnId] = mask;
97}
98
99void ChannelMasksHandler::setFromChannelMasks(const std::vector<ColumnData>& masks)
100{
102 mMasks.clear();
103 for (auto& mask : masks) {
105 }
106}
107void ChannelMasksHandler::merge(const std::vector<ColumnData>& masks)
108{
109 for (auto& mask : masks) {
110 auto& inMask = getMask(mask.deId, mask.columnId);
111 inMask.setNonBendPattern(inMask.getNonBendPattern() & mask.getNonBendPattern());
112 for (int iline = 0; iline < 4; ++iline) {
113 inMask.setBendPattern(inMask.getBendPattern(iline) & mask.getBendPattern(iline), iline);
114 }
115 }
116}
117} // namespace mid
118} // namespace o2
MID channels masks handler.
std::vector< ColumnData > getMasks() const
Gets the masks.
void switchOffChannel(uint8_t deId, uint8_t columnId, int lineId, int strip, int cathode)
void switchOffChannels(const ColumnData &badChannels)
void setFromChannelMask(const ColumnData &mask)
void setFromChannelMasks(const std::vector< ColumnData > &masks)
bool applyMask(ColumnData &data) const
void merge(const std::vector< ColumnData > &masks)
GLboolean * data
Definition glcorearb.h:298
GLint GLuint mask
Definition glcorearb.h:291
uint16_t getColumnDataUniqueId(uint8_t deId, uint8_t columnId)
Gets an unique ID for the ColumnData.
Definition ColumnData.h:66
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
Column data structure for MID.
Definition ColumnData.h:29
uint8_t columnId
Column in DE.
Definition ColumnData.h:31
uint16_t getBendPattern(int line) const
Gets the bending plane pattern.
Definition ColumnData.h:37
uint8_t deId
Index of the detection element.
Definition ColumnData.h:30
uint16_t getNonBendPattern() const
Gets the non-bending plane pattern.
Definition ColumnData.h:42
std::array< uint16_t, 5 > pattern