Project
Loading...
Searching...
No Matches
MaskMaker.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
20#include "MIDBase/Mapping.h"
25
26namespace o2
27{
28namespace mid
29{
30std::vector<ColumnData> makeBadChannels(const ChannelScalers& scalers, double timeOrTriggers, double threshold)
31{
33 uint32_t nThresholdEvents = static_cast<uint32_t>(threshold * timeOrTriggers);
34 ColumnDataHandler handler;
35 for (const auto scaler : scalers.getScalers()) {
36 if (scaler.second >= nThresholdEvents) {
37 handler.add(scalers.getDeId(scaler.first), scalers.getColumnId(scaler.first), scalers.getLineId(scaler.first), scalers.getStrip(scaler.first), scalers.getCathode(scaler.first));
38 }
39 }
40 return handler.getMerged();
41}
42
43std::vector<ColumnData> makeMasks(const ChannelScalers& scalers, double timeOrTriggers, double threshold, const std::vector<ColumnData>& refMasks)
44{
45 auto badChannels = makeBadChannels(scalers, timeOrTriggers, threshold);
46 ChannelMasksHandler maskHandler;
47 maskHandler.switchOffChannels(badChannels);
48 std::vector<ColumnData> masks(maskHandler.getMasks());
49
50 if (!refMasks.empty()) {
51 ChannelMasksHandler defaultMaskHandler;
52 defaultMaskHandler.setFromChannelMasks(refMasks);
53
54 for (auto& mask : masks) {
55 defaultMaskHandler.applyMask(mask);
56 }
57 }
58
59 return masks;
60}
61
62std::vector<ColumnData> makeDefaultMasks()
63{
65 Mapping mapping;
66 ChannelMasksHandler masksHandler;
67 uint16_t fullPattern = 0xFFFF;
68 for (int ide = 0; ide < detparams::NDetectionElements; ++ide) {
69 for (int icol = mapping.getFirstColumn(ide); icol < 7; ++icol) {
71 mask.deId = static_cast<uint8_t>(ide);
72 mask.columnId = static_cast<uint8_t>(icol);
73 // int nFullPatterns = 0;
74 for (int iline = mapping.getFirstBoardBP(icol, ide), lastLine = mapping.getLastBoardBP(icol, ide); iline <= lastLine; ++iline) {
75 mask.setBendPattern(fullPattern, iline);
76 // ++nFullPatterns;
77 }
78 for (int istrip = 0; istrip < mapping.getNStripsNBP(icol, ide); ++istrip) {
79 mask.addStrip(istrip, 1, 0);
80 }
81 masksHandler.setFromChannelMask(mask);
82 }
83 }
84
85 return masksHandler.getMasks();
86}
87
88std::vector<ROBoard> getActiveBoards(const FEEIdConfig& feeIdConfig, const CrateMasks& masks)
89{
91 std::vector<ROBoard> activeBoards;
92 auto gbtUniqueIds = feeIdConfig.getConfiguredGBTUniqueIDs();
93 ROBoard board;
94 board.statusWord = raw::sCARDTYPE;
95 board.patternsBP.fill(0xFFFF);
96 board.patternsNBP.fill(0xFFFF);
97 board.firedChambers = 0xF;
98 for (auto& gbtUniqueId : gbtUniqueIds) {
99 auto mask = masks.getMask(gbtUniqueId);
100 auto crateId = crateparams::getCrateIdFromGBTUniqueId(gbtUniqueId);
101 for (int iloc = 0; iloc < 8; ++iloc) {
102 if ((mask >> iloc) & 0x1) {
103 board.boardId = raw::makeUniqueLocID(crateId, crateparams::getLocIdInCrate(gbtUniqueId, iloc));
104 activeBoards.emplace_back(board);
105 }
106 }
107 }
108 return activeBoards;
109}
110
111std::vector<ColumnData> makeDefaultMasksFromCrateConfig(const FEEIdConfig& feeIdConfig, const CrateMasks& crateMasks)
112{
114 auto activeBoards = getActiveBoards(feeIdConfig, crateMasks);
115 std::vector<ROFRecord> rofs;
116 rofs.push_back({InteractionRecord(), EventType::Standard, 0, activeBoards.size()});
117 DecodedDataAggregator aggregator;
118 aggregator.process(activeBoards, rofs);
119 std::vector<ColumnData> maskedBoards(aggregator.getData());
120 ChannelMasksHandler masksHandler;
122 for (auto& col : maskedBoards) {
123 masksHandler.applyMask(col);
124 }
125
126 return maskedBoards;
127}
128
129} // namespace mid
130} // namespace o2
MID channels masks handler.
MID digits handler.
MID decoded raw data aggregator.
Useful detector parameters for MID.
unsigned short int uint16_t
Mapping for MID.
Definition of the MID event record.
Function to produce the MID masks.
Structure to store the readout board information.
uint32_t col
Definition RawData.h:4
std::vector< ColumnData > getMasks() const
Gets the masks.
void switchOffChannels(const ColumnData &badChannels)
void setFromChannelMask(const ColumnData &mask)
void setFromChannelMasks(const std::vector< ColumnData > &masks)
bool applyMask(ColumnData &data) const
const std::unordered_map< uint32_t, uint32_t > & getScalers() const
Gets the scalers.
uint8_t getCathode(uint32_t uniqueId) const
Gets cathode from unique Id.
uint8_t getLineId(uint32_t uniqueId) const
Gets lineId from unique Id.
uint8_t getDeId(uint32_t uniqueId) const
Gets deId from unique Id.
uint8_t getColumnId(uint32_t uniqueId) const
Gets columnId from unique Id.
uint8_t getStrip(uint32_t uniqueId) const
Gets strip from unique Id.
void add(uint8_t deId, uint8_t columnId, int lineId, int strip, int cathode)
Add single strip.
std::vector< ColumnData > getMerged() const
Returns the merged data.
uint8_t getMask(uint16_t feeId) const
Gets the mask for the feeId.
Definition CrateMasks.h:41
void process(gsl::span< const ROBoard > localBoards, gsl::span< const ROFRecord > rofRecords)
const std::vector< ColumnData > & getData(EventType eventType=EventType::Standard)
Gets the vector of data.
std::vector< uint16_t > getConfiguredGBTUniqueIDs() const
GLint GLuint mask
Definition glcorearb.h:291
uint8_t getCrateIdFromGBTUniqueId(uint16_t gbtUniqueId)
Gets the crate ID from the GBT unique ID.
uint8_t getLocIdInCrate(uint16_t gbtUniqueId, int iloc)
constexpr int NDetectionElements
Number of RPCs.
uint8_t makeUniqueLocID(uint8_t crateId, uint8_t locId)
Definition ROBoard.h:86
std::vector< ROBoard > getActiveBoards(const FEEIdConfig &feeIdConfig, const CrateMasks &masks)
Definition MaskMaker.cxx:88
std::vector< ColumnData > makeDefaultMasks()
Definition MaskMaker.cxx:62
std::vector< ColumnData > makeDefaultMasksFromCrateConfig(const FEEIdConfig &feeIdConfig=FEEIdConfig(), const CrateMasks &crateMasks=CrateMasks())
std::vector< ColumnData > makeMasks(const ChannelScalers &scalers, double timeOrTriggers, double threshold, const std::vector< ColumnData > &refMasks={})
Definition MaskMaker.cxx:43
std::vector< ColumnData > makeBadChannels(const ChannelScalers &scalers, double timeOrTriggers, double threshold)
Definition MaskMaker.cxx:30
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 deId
Index of the detection element.
Definition ColumnData.h:30
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 statusWord
Definition ROBoard.h:28
uint8_t boardId
Trigger word.
Definition ROBoard.h:30
uint8_t firedChambers
Board ID in crate.
Definition ROBoard.h:31