12#ifndef ALICEO2_TPC_CALDET_H_
13#define ALICEO2_TPC_CALDET_H_
27#ifndef GPUCA_ALIGPUCODE
29#include <fmt/format.h>
50 CalDet(
PadSubset padSusbset) : mName{
"PadCalibrationObject"}, mData{}, mPadSubset{padSusbset} { initData(); }
58 const std::vector<CalType>&
getData()
const {
return mData; }
59 std::vector<CalType>&
getData() {
return mData; }
68 const T
getValue(
const int sec,
const int globalPadInSector)
const;
69 void setValue(
const int sec,
const int globalPadInSector,
const T&
value);
70 void setValue(
const int sec,
const int rowInSector,
const int padInRow,
const T&
value);
76 const T
getValue(
const Sector sec,
const int rowInSector,
const int padInRow)
const;
78 void setName(
const std::string_view
name,
bool nameCalArrays =
true)
85 const std::string&
getName()
const {
return mName; }
107 template <
typename U = T>
110 if (mData.size() == 0) {
116 for (
const auto&
data : mData) {
117 const auto& vals =
data.getData();
118 sum += std::accumulate(vals.begin(), vals.end(), U{0});
119 nVal +=
static_cast<U
>(vals.size());
122 return (nVal > 0) ?
sum / nVal : U{0};
125 template <
typename U = T>
128 if (mData.size() == 0) {
133 for (
const auto&
data : mData) {
134 const auto& vals =
data.getData();
135 sum +=
data.template getSum<U>();
143 std::vector<CalType> mData;
159 auto padPos = mapper.
padPos(globalPadInSector);
160 const auto globalRow = padPos.getRow();
162 int rocNumber = sector;
163 int padInROC = globalPadInSector;
165 if (globalPadInSector >= padsInIROC) {
167 padInROC -= padsInIROC;
170 switch (mPadSubset) {
172 return mData[rocNumber].getValue(padInROC);
181 const auto mappedPad = padPos.getPad();
198 const size_t mappedRow =
row % nRows;
200 const size_t mappedPad = pad % nPads;
203 switch (mPadSubset) {
205 return mData[
roc].getValue(mappedRow, mappedPad);
230 const size_t nRows = info.getNumberOfPadRows();
231 const size_t mappedRow =
row % nRows;
232 const size_t nPads = info.getPadsInRowRegion(mappedRow);
233 const size_t mappedPad = pad % nPads;
235 switch (mPadSubset) {
239 const size_t rowROC = mappedRow + info.getGlobalRowOffset() - irocOffset;
242 return mData[
roc].getValue(channel);
249 return mData[cru].getValue(mappedRow, mappedPad);
261 int padInROC = globalPadInSector;
263 if (globalPadInSector >= padsInIROC) {
265 padInROC -= padsInIROC;
267 mData[
roc].setValue(padInROC,
value);
275 int rowInROC = rowInSector;
276 const int rowsInIROC = 63;
277 if (rowInSector >= rowsInIROC) {
279 rowInROC -= rowsInIROC;
281 mData[
roc].setValue(rowInROC, padInRow,
value);
289 int rowInROC = rowInSector;
290 const int rowsInIROC = 63;
291 if (rowInSector >= rowsInIROC) {
293 rowInROC -= rowsInIROC;
295 return mData[
roc].getValue(rowInROC, padInRow);
298#ifndef GPUCA_ALIGPUCODE
306 if (mPadSubset !=
other.mPadSubset) {
307 LOG(error) <<
"Pad subste type of the objects it not compatible";
311 for (
size_t i = 0;
i < mData.size(); ++
i) {
323 if (mPadSubset !=
other.mPadSubset) {
324 LOG(error) <<
"Pad subste type of the objects it not compatible";
328 for (
size_t i = 0;
i < mData.size(); ++
i) {
340 if (mPadSubset !=
other.mPadSubset) {
341 LOG(error) <<
"Pad subste type of the objects it not compatible";
345 for (
size_t i = 0;
i < mData.size(); ++
i) {
357 if (mPadSubset !=
other.mPadSubset) {
358 LOG(error) <<
"Pad subste type of the objects it not compatible";
362 for (
size_t i = 0;
i < mData.size(); ++
i) {
372 for (
auto& cal : mData) {
382 for (
auto& cal : mData) {
392 for (
auto& cal : mData) {
402 for (
auto& cal : mData) {
412 for (
auto& cal : mData) {
424 if (mPadSubset !=
other.mPadSubset) {
425 LOG(error) <<
"Pad subste type of the objects it not compatible";
429 for (
size_t i = 0;
i < mData.size(); ++
i) {
430 if (!(mData[
i] ==
other.mData[
i])) {
456void CalDet<T>::initData()
462 bool hasData = mData.size() > 0;
464 switch (mPadSubset) {
467 frmt =
"{}_ROC_{:02d}";
472 frmt =
"{}_Partition_{:02d}";
477 frmt =
"{}_Region_{:02d}";
482 for (
size_t i = 0;
i <
size; ++
i) {
484 mData.push_back(CalType(mPadSubset,
i));
486 mData[
i].setName(fmt::format(fmt::runtime(frmt), mName,
i));
bool const GPUTPCGMMerger::trackCluster * c1
bool const GPUTPCGMMerger::trackCluster const clcomparestruct * c2
std::enable_if_t< std::is_signed< T >::value, bool > hasData(const CalArray< T > &cal)
unsigned char region() const
const CalDet & operator-=(const CalDet &other)
const CalDet & operator-=(const T &val)
CalDet(PadSubset padSusbset)
const T getValue(const CRU cru, const size_t row, const size_t pad) const
const CalDet & operator+=(const CalDet &other)
friend CalDet< U > operator+(const CalDet< U > &, const CalDet< U > &)
const CalType & getCalArray(size_t position) const
CalDet & operator=(CalDet const &)=default
void setValue(const int sec, const int globalPadInSector, const T &value)
const CalDet & operator=(const T &val)
void setValue(const int sec, const int rowInSector, const int padInRow, const T &value)
const CalDet & operator/=(const T &val)
bool operator==(const CalDet &other) const
CalDet(const std::string_view name, const PadSubset padSusbset=PadSubset::ROC)
const CalDet & operator*=(const CalDet &other)
PadSubset getPadSubset() const
const CalDet & multiply(const T &val)
const CalDet & operator*=(const T &val)
const T getValue(const ROC roc, const size_t row, const size_t pad) const
CalDet(CalDet const &)=default
const CalDet & operator/=(const CalDet &other)
const T getValue(const int sec, const int globalPadInSector) const
CalType & getCalArray(size_t position)
void setName(const std::string_view name, bool nameCalArrays=true)
const T getValue(const Sector sec, const int rowInSector, const int padInRow) const
const std::vector< CalType > & getData() const
const CalDet & operator+=(const T &val)
friend CalDet< U > operator-(const CalDet< U > &, const CalDet< U > &)
const std::string & getName() const
std::vector< CalType > & getData()
const PadPos & padPos(GlobalPadNumber padNumber) const
int getNumberOfRowsROC(ROC roc) const
int getNumberOfPadsInRowROC(int roc, int row) const
static Mapper & instance(const std::string mappingDir="")
static constexpr unsigned short getPadsInIROC()
const PadRegionInfo & getPadRegionInfo(const unsigned char region) const
static constexpr unsigned int NREGIONS
total number of regions in one sector
GlobalPadNumber getPadNumberInROC(const PadROCPos &rocPadPosition) const
static constexpr unsigned int OFFSETCRUGLOBAL[PADROWS]
row offset in cru for given global pad row
static constexpr unsigned short getNumberOfIROCs()
static constexpr unsigned REGION[PADROWS]
region for global pad row
Pad and row inside a ROC.
static constexpr int MAXSECTOR
GLuint const GLchar * name
GLsizei const GLfloat * value
CalDet< T > operator+(const CalDet< T > &c1, const CalDet< T > &c2)
PadSubset
Definition of the different pad subsets.
@ Partition
Partitions (up to 36*5)
@ Region
Regions (up to 36*10)
CalDet< T > operator-(const CalDet< T > &c1, const CalDet< T > &c2)
DataT sum(const Vector< DataT, N > &a)
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
VectorOfTObjectPtrs other
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"