Project
Loading...
Searching...
No Matches
ColumnDataHandler.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
24void ColumnDataHandler::add(uint8_t deId, uint8_t columnId, int lineId, int strip, int cathode)
25{
26 auto uniqueId = getColumnDataUniqueId(deId, columnId);
27 auto dataIt = mData.find(uniqueId);
28 if (dataIt == mData.end()) {
29 auto& newCol = mData[uniqueId];
30 newCol.deId = deId;
31 newCol.columnId = columnId;
32 dataIt = mData.find(uniqueId);
33 }
34 dataIt->second.addStrip(strip, cathode, lineId);
35}
36
37bool ColumnDataHandler::merge(const ColumnData& col, size_t idx)
38{
39 auto uniqueId = getColumnDataUniqueId(col.deId, col.columnId);
40 auto dataIt = mData.find(uniqueId);
41 bool isNew = false;
42 if (dataIt == mData.end()) {
43 isNew = true;
44 mData[uniqueId] = col;
45 } else {
46 dataIt->second |= col;
47 }
48 mCorrespondence[uniqueId].emplace_back(idx);
49
50 return isNew;
51}
52
53void ColumnDataHandler::merge(gsl::span<const ColumnData> colVec, size_t idx)
54{
55 for (size_t ic = 0, end = colVec.size(); ic < end; ++ic) {
56 merge(colVec[ic], idx + ic);
57 }
58}
59
60std::vector<ColumnData> ColumnDataHandler::getMerged() const
61{
63 std::vector<ColumnData> data;
64 for (auto& item : mData) {
65 data.emplace_back(item.second);
66 }
67 return data;
68}
69
71{
72 mData.clear();
73 mCorrespondence.clear();
74}
75
76std::vector<size_t> ColumnDataHandler::getMergedIndexes(const ColumnData& col) const
77{
78 auto uniqueId = getColumnDataUniqueId(col.deId, col.columnId);
79 auto corrIt = mCorrespondence.find(uniqueId);
80 if (corrIt == mCorrespondence.end()) {
81 return std::vector<size_t>{};
82 }
83 return corrIt->second;
84}
85
86} // namespace mid
87} // namespace o2
MID digits handler.
uint32_t col
Definition RawData.h:4
void clear()
Clears inner maps.
std::vector< size_t > getMergedIndexes(const ColumnData &col) const
Returns the indexes of the ColumnData merged into this one.
void add(uint8_t deId, uint8_t columnId, int lineId, int strip, int cathode)
Add single strip.
bool merge(const ColumnData &col, size_t idx=0)
Merges digit.
std::vector< ColumnData > getMerged() const
Returns the merged data.
GLuint GLuint end
Definition glcorearb.h:469
GLboolean * data
Definition glcorearb.h:298
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