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 void setNThreads(int nThreads) { mNThreads = nThreads; }
90
91 private:
92 PedestalData::PedestalMatrix initPedestalMatrix(uint16_t solarId);
93
94 o2::mch::raw::Solar2FeeLinkMapper mSolar2FeeLinkMapper;
95 o2::mch::raw::Elec2DetMapper mElec2DetMapper;
96
97 PedestalsMap mPedestals{};
98 uint32_t mSize{0};
99 int mNThreads{1};
100
101 ClassDefNV(PedestalData, 2)
102};
103
104namespace impl
105{
106template <typename T>
108{
109 public:
110 using value_type = T;
111 using difference_type = std::ptrdiff_t;
112 using pointer = T*;
113 using reference = T&;
114 using iterator_category = std::forward_iterator_tag;
115
118 mMapIt{},
119 mCol{0},
120 mRow{0}
121 {
122 if (mData && mData->size() == 0) {
123 mData = nullptr;
124 }
125 if (mData) {
126 mMapIt = mData->mPedestals.begin();
127 }
128 }
129
131 {
132 return mMapIt->second[mRow][mCol];
133 }
135 {
136 return &mMapIt->second[mRow][mCol];
137 }
138
139 bool advance()
140 {
141 if (mMapIt != mData->mPedestals.end()) {
142 if (mCol < PedestalData::MAXCHANNEL - 1) {
143 mCol++;
144 return true;
145 }
146 if (mRow < PedestalData::MAXDS - 1) {
147 mCol = 0;
148 mRow++;
149 return true;
150 }
151 ++mMapIt;
152 mCol = 0;
153 mRow = 0;
154 if (mMapIt != mData->mPedestals.end()) {
155 return true;
156 }
157 mData = nullptr;
158 }
159 // undefined behavior here (should not increment an end iterator)
160 return false;
161 }
162
164 {
165 while (advance()) {
166 if ((*this)->isValid()) {
167 break;
168 }
169 }
170 // undefined behavior here (should not increment an end iterator)
171 return *this;
172 }
173
175 {
176 return mData == rhs.mData &&
177 mMapIt == rhs.mMapIt &&
178 mCol == rhs.mCol &&
179 mRow == rhs.mRow;
180 }
181
182 bool operator!=(const PedestalDataIterator& rhs) { return !(*this == rhs); }
183
185 {
186 auto tmp = *this;
187 ++(*this);
188 return tmp;
189 }
190
191 private:
192 PedestalData* mData;
193 PedestalData::PedestalsMap::iterator mMapIt;
194 int mCol;
195 int mRow;
196};
197} // namespace impl
198
199} // namespace o2::mch::calibration
200#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