Project
Loading...
Searching...
No Matches
IDCContainer.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
17
18#ifndef ALICEO2_TPC_IDCCONTAINER_H_
19#define ALICEO2_TPC_IDCCONTAINER_H_
20
21#include <array>
22#include <vector>
23#include <limits>
24#include "DataFormatsTPC/Defs.h"
27
28namespace o2
29{
30namespace tpc
31{
32
34enum class IDCType { IDC = 0,
35 IDCZero = 1,
36 IDCOne = 2,
37 IDCDelta = 3,
38 IDCOutlier = 4 //< IDCOutlier: for outlier maps
39};
40
43
45enum class IDCDeltaCompression { NO = 0,
46 MEDIUM = 1,
47 HIGH = 2
48};
49
51template <typename DataT>
53 std::vector<DataT> mIDCDeltaCont{};
54};
55
59 std::pair<float, float> mFactors{std::pair{1.f, 1.f}};
60};
61
63template <typename DataT>
64struct IDCDelta {
65
69 void setValue(const float idcDelta, const unsigned int index) { mIDCDelta.mIDCDeltaCont[index] = compressValue(idcDelta); }
70
73 void emplace_back(const float idcDelta) { mIDCDelta.mIDCDeltaCont.emplace_back(compressValue(idcDelta)); }
74
77 DataT compressValue(float idcDelta) const
78 {
79 idcDelta = (std::clamp(idcDelta, mCompressionFactor.mFactors.first, mCompressionFactor.mFactors.second) - mCompressionFactor.mFactors.first) * std::numeric_limits<DataT>::max() / (mCompressionFactor.mFactors.second - mCompressionFactor.mFactors.first);
80 return std::nearbyint(idcDelta);
81 }
82
85 float getValue(const unsigned int index) const { return mCompressionFactor.mFactors.first + (mCompressionFactor.mFactors.second - mCompressionFactor.mFactors.first) * static_cast<float>(mIDCDelta.mIDCDeltaCont[index]) / std::numeric_limits<DataT>::max(); }
86
89 void setCompressionFactor(const float factorMin, const float factorMax) { mCompressionFactor.mFactors = std::pair{factorMin, factorMax}; }
90
92 const auto& getIDCDelta() const { return mIDCDelta.mIDCDeltaCont; }
93
95 auto& getIDCDelta() { return mIDCDelta.mIDCDeltaCont; }
96
100 void setIDCDelta(const unsigned int index, const DataT val) { mIDCDelta.mIDCDeltaCont[index] = val; }
101
103 const auto& getCompressionFactors() const { return mCompressionFactor; }
104
107
109 auto getNIDCs() const { return getIDCDelta().size(); }
110
113 ClassDefNV(IDCDelta, 2)
114};
115
116// template specialization for float as no compression factor is needed in this case
117template <>
118struct IDCDelta<float> {
122 void setValue(const float idcDelta, const unsigned int index) { mIDCDelta.mIDCDeltaCont[index] = idcDelta; }
123
126 float getValue(const unsigned int index) const { return mIDCDelta.mIDCDeltaCont[index]; }
127
129 const auto& getIDCDelta() const { return mIDCDelta.mIDCDeltaCont; }
130
132 auto& getIDCDelta() { return mIDCDelta.mIDCDeltaCont; }
133
135 auto getIDCDeltaContainer() && { return std::move(mIDCDelta); }
136
140 void setIDCDelta(const unsigned int index, const float val) { mIDCDelta.mIDCDeltaCont[index] = val; }
141
144 void resize(const unsigned int size) { mIDCDelta.mIDCDeltaCont.resize(size); }
145
147 auto getNIDCs() const { return getIDCDelta().size(); }
148
150 ClassDefNV(IDCDelta, 2)
151};
152
154struct IDCZero {
155
159 void setValueIDCZero(const float idcZero, const unsigned int index) { mIDCZero[index] = idcZero; }
160
164 void fillValueIDCZero(const float idcZero, const unsigned int index) { mIDCZero[index] += idcZero; }
165
168 float getValueIDCZero(const unsigned int index) const { return mIDCZero[index]; }
169
171 void clear() { mIDCZero.clear(); }
172
174 bool empty() const { return mIDCZero.empty(); }
175
177 void resize(const unsigned int size) { mIDCZero.resize(size); }
178
180 auto getNIDC0() const { return mIDCZero.size(); }
181
183 IDCZero& operator+=(const IDCZero& idczero)
184 {
185 std::transform(mIDCZero.begin(), mIDCZero.end(), idczero.mIDCZero.begin(), mIDCZero.begin(), std::plus<>());
186 return *this;
187 }
188
190 {
191 std::transform(mIDCZero.begin(), mIDCZero.end(), mIDCZero.begin(), [value](float idczero) { return idczero / value; });
192 return *this;
193 }
194
195 std::vector<float> mIDCZero{};
196 ClassDefNV(IDCZero, 2)
197};
198
209
211struct IDCOne {
212
214 IDCOne() = default;
215
218 IDCOne(const unsigned int nIDC) : mIDCOne{std::vector<float>(nIDC)} {};
219
222 IDCOne(const unsigned int nIDC, const float val) : mIDCOne{std::vector<float>(nIDC, val)} {};
223
227 void setValueIDCOne(const float idcOne, const unsigned int index) { mIDCOne[index] = idcOne; }
228
231 float getValueIDCOne(const unsigned int index) const { return mIDCOne[index]; }
232
234 auto getNIDCs() const { return mIDCOne.size(); }
235
237 void clear() { mIDCOne.clear(); }
238
240 void resize(const unsigned int size) { mIDCOne.resize(size); }
241
243 void append(const IDCOne& idcone) { mIDCOne.insert(mIDCOne.end(), idcone.mIDCOne.begin(), idcone.mIDCOne.end()); }
244
246 IDCOne& operator*=(const float value)
247 {
248 std::transform(mIDCOne.begin(), mIDCOne.end(), mIDCOne.begin(), [value](float idcone) { return idcone * value; });
249 return *this;
250 }
251
252 std::vector<float> mIDCOne{};
253 std::vector<float> mIDCOneMedian{};
254 std::vector<float> mIDCOneRMS{};
255 ClassDefNV(IDCOne, 3)
256};
257
260{
261 public:
265 void aggregate1DIDCs(const o2::tpc::Side side, const std::vector<float>& idc)
266 {
267 if (mIDCOneAgg[side].mIDCOne.empty()) {
268 mIDCOneAgg[side].mIDCOne = idc;
269 } else {
270 std::transform(mIDCOneAgg[side].mIDCOne.begin(), mIDCOneAgg[side].mIDCOne.end(), idc.begin(), mIDCOneAgg[side].mIDCOne.begin(), std::plus<>());
271 }
272 }
273
274 void aggregate1DIDCsWeights(const o2::tpc::Side side, const std::vector<unsigned int>& idcCount)
275 {
276 if (mWeight[side].empty()) {
277 mWeight[side] = idcCount;
278 } else {
279 std::transform(mWeight[side].begin(), mWeight[side].end(), idcCount.begin(), mWeight[side].begin(), std::plus<>());
280 }
281 }
282
288
291 {
292 std::transform(mIDCOneAgg[side].mIDCOne.begin(), mIDCOneAgg[side].mIDCOne.end(), mWeight[side].begin(), mIDCOneAgg[side].mIDCOne.begin(), std::divides<>());
293 }
294
296 auto get(const Side side) &&
297 {
298 mWeight[side].clear();
299 return std::move(mIDCOneAgg[side]);
300 }
301
303 const auto& getWeight() const { return mWeight; }
304
305 private:
306 std::array<IDCOne, SIDES> mIDCOneAgg{};
307 std::array<std::vector<unsigned int>, o2::tpc::SIDES> mWeight{};
308};
309
315 FourierCoeff(const unsigned int nTimeFrames, const unsigned int nCoeff)
316 : mFourierCoefficients{std::vector<float>(nTimeFrames * nCoeff)}, mCoeffPerTF{nCoeff} {};
317
319 FourierCoeff() = default;
320
322 unsigned long getNCoefficients() const { return mFourierCoefficients.size(); }
323
325 unsigned int getNCoefficientsPerTF() const { return mCoeffPerTF; }
326
328 const auto& getFourierCoefficients() const { return mFourierCoefficients; }
329
333 unsigned int getIndex(const unsigned int interval, const unsigned int coefficient) const { return interval * mCoeffPerTF + coefficient; }
334
336 unsigned int getNTimeFrames() const { return getNCoefficients() / mCoeffPerTF; }
337
340 float operator()(unsigned int index) const { return mFourierCoefficients[index]; }
341
344 float& operator()(unsigned int index) { return mFourierCoefficients[index]; }
345
346 void reset() { std::fill(mFourierCoefficients.begin(), mFourierCoefficients.end(), 0.f); };
347
348 void resize(const unsigned int nTimeFrames) { mFourierCoefficients.resize(nTimeFrames * mCoeffPerTF); }
349
350 std::vector<float> mFourierCoefficients{};
351 unsigned int mCoeffPerTF{};
352
353 ClassDefNV(FourierCoeff, 2)
354};
355
356struct SACZero {
357 float getValueIDCZero(const Side side, const int stackInSector) const { return mSACZero[side].getValueIDCZero(stackInSector); }
358 void clear()
359 {
360 mSACZero[Side::A].clear();
361 mSACZero[Side::C].clear();
362 }
363
364 void resize(const unsigned int size)
365 {
366 mSACZero[Side::A].resize(size);
367 mSACZero[Side::C].resize(size);
368 }
369
370 void setValueSACZero(const float sacZero, const Side side, const unsigned int index) { mSACZero[side].setValueIDCZero(sacZero, index); }
371
372 std::array<IDCZero, SIDES> mSACZero{};
373};
374
375struct SACOne {
376 float getValue(const Side side, const int interval) const { return mSACOne[side].mIDCOne[interval]; }
377 void setValueIDCOne(const float sacOne, const Side side, const unsigned int index) { mSACOne[side].setValueIDCOne(sacOne, index); }
378
379 void clear()
380 {
381 mSACOne[Side::A].clear();
382 mSACOne[Side::C].clear();
383 }
384 void resize(const unsigned int size)
385 {
386 mSACOne[Side::A].resize(size);
387 mSACOne[Side::C].resize(size);
388 }
389 std::array<IDCOne, SIDES> mSACOne{};
390};
391
392template <typename DataT>
393struct SACDelta {
394 float getValue(const Side side, const int index) const { return mSACDelta[side].getValue(index); }
395 void setSACDelta(const Side side, const unsigned int index, const float sacDelta) { mSACDelta[side].setIDCDelta(index, sacDelta); }
396
397 void resize(const unsigned int size)
398 {
399 mSACDelta[Side::A].resize(size);
400 mSACDelta[Side::C].resize(size);
401 }
402 std::array<IDCDelta<DataT>, SIDES> mSACDelta{};
403};
404
406 std::array<FourierCoeff, SIDES> mCoeff{};
407};
408
411template <typename DataT>
413{
414 public:
416
420 static IDCDelta<DataT> getCompressedIDCs(const IDCDelta<float>& idcDeltaUncompressed)
421 {
422 const auto& paramIDCGroup = ParameterIDCCompression::Instance();
423
424 IDCDelta<DataT> idcCompressed{};
425 compress(idcDeltaUncompressed, idcCompressed, paramIDCGroup.minIDCDeltaValue, paramIDCGroup.maxIDCDeltaValue);
426 return idcCompressed;
427 }
428
432 static SACDelta<DataT> getCompressedSACs(const SACDelta<float>& sacDeltaUncompressed)
433 {
434 const auto& paramSAC = ParameterSAC::Instance();
435 SACDelta<DataT> sacCompressed{};
436 compress(sacDeltaUncompressed.mSACDelta[Side::A], sacCompressed.mSACDelta[Side::A], paramSAC.minSACDeltaValue, paramSAC.maxSACDeltaValue);
437 compress(sacDeltaUncompressed.mSACDelta[Side::C], sacCompressed.mSACDelta[Side::C], paramSAC.minSACDeltaValue, paramSAC.maxSACDeltaValue);
438 return sacCompressed;
439 }
440
441 private:
442 static void compress(const IDCDelta<float>& idcDeltaUncompressed, IDCDelta<DataT>& idcCompressed, const float minValue, const float maxValue)
443 {
444 if (idcDeltaUncompressed.getIDCDelta().empty()) {
445 return;
446 }
447 idcCompressed.getIDCDelta().reserve(idcDeltaUncompressed.getIDCDelta().size());
448 const auto minmaxIDC = std::minmax_element(std::begin(idcDeltaUncompressed.getIDCDelta()), std::end(idcDeltaUncompressed.getIDCDelta()));
449 const auto& paramIDCGroup = ParameterIDCCompression::Instance();
450 const float minIDCDelta = std::clamp(*minmaxIDC.first, minValue, maxValue);
451 const float maxIDCDelta = std::clamp(*minmaxIDC.second, minValue, maxValue);
452 idcCompressed.setCompressionFactor(minIDCDelta, maxIDCDelta);
453 for (auto& idc : idcDeltaUncompressed.getIDCDelta()) {
454 idcCompressed.emplace_back(idc);
455 }
456 }
457};
458
459} // namespace tpc
460} // namespace o2
461
462#endif
Definition of the parameter for the grouping of the IDCs.
uint32_t side
Definition RawData.h:0
Definition of the parameters for the SAC processing.
static SACDelta< DataT > getCompressedSACs(const SACDelta< float > &sacDeltaUncompressed)
static IDCDelta< DataT > getCompressedIDCs(const IDCDelta< float > &idcDeltaUncompressed)
Helper class for aggregation of 1D-IDCs from different CRUs.
const auto & getWeight() const
auto get(const Side side) &&
void normalizeIDCOne(const o2::tpc::Side side)
void aggregate1DIDCsWeights(const o2::tpc::Side side, const std::vector< unsigned int > &idcCount)
void aggregate1DIDCs(const o2::tpc::Side side, const std::vector< float > &idc)
GLsizeiptr size
Definition glcorearb.h:659
GLuint GLuint end
Definition glcorearb.h:469
GLuint index
Definition glcorearb.h:781
GLsizei const GLfloat * value
Definition glcorearb.h:819
GLuint GLfloat * val
Definition glcorearb.h:1582
IDCType
IDC types.
@ IDC
integrated and grouped IDCs
Enum< T >::Iterator begin(Enum< T >)
Definition Defs.h:173
constexpr unsigned char SIDES
Definition Defs.h:41
Side
TPC readout sidE.
Definition Defs.h:35
@ A
Definition Defs.h:35
@ C
Definition Defs.h:36
IDCDeltaCompression
IDC Delta IDC Compression types.
@ HIGH
high compression using char (data compression ratio ~5.5 when stored in CCDB)
@ NO
no compression using floats
@ MEDIUM
medium compression using short (data compression ratio 2 when stored in CCDB)
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
Defining DataPointCompositeObject explicitly as copiable.
void empty(int)
std::array< FourierCoeff, SIDES > mCoeff
struct containing the fourier coefficients calculated from IDC0 for n timeframes
const auto & getFourierCoefficients() const
unsigned int mCoeffPerTF
number of real+imag coefficients per TF
std::vector< float > mFourierCoefficients
fourier coefficients. coefficient real and complex parameters are stored alternating
float operator()(unsigned int index) const
unsigned long getNCoefficients() const
unsigned int getNCoefficientsPerTF() const
void resize(const unsigned int nTimeFrames)
FourierCoeff()=default
default constructor for ROOT I/O
unsigned int getIndex(const unsigned int interval, const unsigned int coefficient) const
FourierCoeff(const unsigned int nTimeFrames, const unsigned int nCoeff)
unsigned int getNTimeFrames() const
float & operator()(unsigned int index)
std::pair< float, float > mFactors
compression factors
struct containing the IDC delta values
std::vector< DataT > mIDCDeltaCont
\Delta I(r,\phi,t) = I(r,\phi,t) / ( I_0(r,\phi) * I_1(t) )
float getValue(const unsigned int index) const
const auto & getIDCDelta() const
void setValue(const float idcDelta, const unsigned int index)
void setIDCDelta(const unsigned int index, const float val)
void resize(const unsigned int size)
struct to access and set Delta IDCs
void setIDCDelta(const unsigned int index, const DataT val)
void emplace_back(const float idcDelta)
auto getCompressionFactor() const
auto getNIDCs() const
void setCompressionFactor(const float factorMin, const float factorMax)
float getValue(const unsigned int index) const
DataT compressValue(float idcDelta) const
const auto & getCompressionFactors() const
const auto & getIDCDelta() const
IDCDeltaContainer< DataT > mIDCDelta
storage for Delta IDCs
void setValue(const float idcDelta, const unsigned int index)
IDCDeltaCompressionFactors mCompressionFactor
compression factor for Delta IDCs
std::vector< float > mIDCOne
I_1(t) = <I(r,\phi,t) / I_0(r,\phi)>_{r,\phi}.
std::vector< float > mIDCOneRMS
RMS of IDCs.
auto getNIDCs() const
IDCOne(const unsigned int nIDC, const float val)
IDCOne & operator*=(const float value)
multiply IDCOne values by a factor
void setValueIDCOne(const float idcOne, const unsigned int index)
void clear()
clearing the IDCOne values
IDCOne(const unsigned int nIDC)
std::vector< float > mIDCOneMedian
median of IDCs
void append(const IDCOne &idcone)
append an IDCOne vector
void resize(const unsigned int size)
resize vector
float getValueIDCOne(const unsigned int index) const
IDCOne()=default
default constructor
struct containing the ITPC0 values (integrated TPC clusters)
void fillValueIDCZero(const float idcZero, const unsigned int index)
void resize(const unsigned int size)
resize vector
IDCZero & operator/=(const float value)
void setValueIDCZero(const float idcZero, const unsigned int index)
IDCZero & operator+=(const IDCZero &idczero)
add IDCZero values from other object
bool empty() const
returns check if the IDC0 vector is empty
auto getNIDC0() const
get number of IDC0 values
std::vector< float > mIDCZero
I_0(r,\phi) = <I(r,\phi,t)>_t.
float getValueIDCZero(const unsigned int index) const
struct containing the IDC1
IDCZero mIQMaxC
integrated QMax cluster for C-side
IDCZero mINClC
integrated NCl cluster for C-side
IDCZero mIQTotA
integrated QTot cluster for A-side
IDCZero mIQTotC
integrated QTot cluster for C-side
IDCZero mINClA
integrated NCl cluster for A-side
IDCZero mIQMaxA
integrated QMax cluster for A-side
float getValue(const Side side, const int index) const
void setSACDelta(const Side side, const unsigned int index, const float sacDelta)
void resize(const unsigned int size)
std::array< IDCDelta< DataT >, SIDES > mSACDelta
std::array< IDCOne, SIDES > mSACOne
void setValueIDCOne(const float sacOne, const Side side, const unsigned int index)
float getValue(const Side side, const int interval) const
void resize(const unsigned int size)
float getValueIDCZero(const Side side, const int stackInSector) const
std::array< IDCZero, SIDES > mSACZero
void setValueSACZero(const float sacZero, const Side side, const unsigned int index)
void resize(const unsigned int size)