Project
Loading...
Searching...
No Matches
PedestalData.h
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
12#ifndef O2_MCH_CALIBRATION_PEDESTAL_DATA_H_
13#define O2_MCH_CALIBRATION_PEDESTAL_DATA_H_
14
18#include "Rtypes.h"
19#include <array>
20#include <gsl/span>
21#include <unordered_map>
22
24{
25
26class PedestalDigit;
27class PedestalData;
28
29namespace impl
30{
31template <typename T>
33}
34
48{
49 public:
52
53 friend iterator;
55
57 iterator end();
58 const_iterator cbegin() const;
59 const_iterator cend() const;
60
62 ~PedestalData() = default;
63
64 void reset();
65
66 static constexpr int MAXDS = 40; // max number of dual sampas per solar
67 static constexpr int MAXCHANNEL = 64; // max number of channels per dual sampa
68
70 using PedestalMatrix = std::array<std::array<PedestalChannel, MAXCHANNEL>, MAXDS>;
72 using PedestalsMap = std::unordered_map<int, PedestalMatrix>;
73
77 void fill(const gsl::span<const PedestalDigit> digits);
78
82 void merge(const PedestalData* other);
83
85 void print() const;
86
87 uint32_t size() const;
88
89 private:
90 PedestalData::PedestalMatrix initPedestalMatrix(uint16_t solarId);
91
92 o2::mch::raw::Solar2FeeLinkMapper mSolar2FeeLinkMapper;
93 o2::mch::raw::Elec2DetMapper mElec2DetMapper;
94
95 PedestalsMap mPedestals{};
96 uint32_t mSize{0};
97
98 ClassDefNV(PedestalData, 1)
99};
100
101namespace impl
102{
103template <typename T>
105{
106 public:
107 using value_type = T;
108 using difference_type = std::ptrdiff_t;
109 using pointer = T*;
110 using reference = T&;
111 using iterator_category = std::forward_iterator_tag;
112
115 mMapIt{},
116 mCol{0},
117 mRow{0}
118 {
119 if (mData && mData->size() == 0) {
120 mData = nullptr;
121 }
122 if (mData) {
123 mMapIt = mData->mPedestals.begin();
124 }
125 }
126
128 {
129 return mMapIt->second[mRow][mCol];
130 }
132 {
133 return &mMapIt->second[mRow][mCol];
134 }
135
136 bool advance()
137 {
138 if (mMapIt != mData->mPedestals.end()) {
139 if (mCol < PedestalData::MAXCHANNEL - 1) {
140 mCol++;
141 return true;
142 }
143 if (mRow < PedestalData::MAXDS - 1) {
144 mCol = 0;
145 mRow++;
146 return true;
147 }
148 ++mMapIt;
149 mCol = 0;
150 mRow = 0;
151 if (mMapIt != mData->mPedestals.end()) {
152 return true;
153 }
154 mData = nullptr;
155 }
156 // undefined behavior here (should not increment an end iterator)
157 return false;
158 }
159
161 {
162 while (advance()) {
163 if ((*this)->isValid()) {
164 break;
165 }
166 }
167 // undefined behavior here (should not increment an end iterator)
168 return *this;
169 }
170
172 {
173 return mData == rhs.mData &&
174 mMapIt == rhs.mMapIt &&
175 mCol == rhs.mCol &&
176 mRow == rhs.mRow;
177 }
178
179 bool operator!=(const PedestalDataIterator& rhs) { return !(*this == rhs); }
180
182 {
183 auto tmp = *this;
184 ++(*this);
185 return tmp;
186 }
187
188 private:
189 PedestalData* mData;
190 PedestalData::PedestalsMap::iterator mMapIt;
191 int mCol;
192 int mRow;
193};
194} // namespace impl
195
196} // namespace o2::mch::calibration
197#endif
Compute and store the mean and RMS of the pedestal digit amplitudes.
static constexpr int MAXCHANNEL
std::unordered_map< int, PedestalMatrix > PedestalsMap
std::array< std::array< PedestalChannel, MAXCHANNEL >, MAXDS > PedestalMatrix
void fill(const gsl::span< const PedestalDigit > digits)
void merge(const PedestalData *other)
bool operator!=(const PedestalDataIterator &rhs)
bool operator==(const PedestalDataIterator &rhs)
GLboolean * data
Definition glcorearb.h:298
std::function< std::optional< DsDetId >(DsElecId)> Elec2DetMapper
Definition Mapper.h:42
std::function< std::optional< FeeLinkId >(uint16_t solarId)> Solar2FeeLinkMapper
From solarId to (feeId,linkId)
Definition Mapper.h:57
VectorOfTObjectPtrs other
std::vector< Digit > digits