forked from AliceO2Group/AliceO2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTPCPadGainCalib.h
More file actions
162 lines (131 loc) · 4.13 KB
/
Copy pathTPCPadGainCalib.h
File metadata and controls
162 lines (131 loc) · 4.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
// All rights not expressly granted are reserved.
//
// This software is distributed under the terms of the GNU General Public
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
//
// In applying this license CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.
/// \file TPCPadGainCalib.h
/// \author Felix Weiglhofer
#ifndef O2_GPU_TPC_PAD_GAIN_CALIB_H
#define O2_GPU_TPC_PAD_GAIN_CALIB_H
#include "clusterFinderDefs.h"
#include "GPUCommonMath.h"
namespace o2::tpc
{
template <class T>
class CalDet;
} // namespace o2::tpc
namespace o2::gpu
{
template <typename T>
struct TPCPadGainCorrectionStepNum {
};
template <>
struct TPCPadGainCorrectionStepNum<uint8_t> {
static constexpr int32_t value = 254;
};
template <>
struct TPCPadGainCorrectionStepNum<uint16_t> {
static constexpr int32_t value = 65534;
};
struct TPCPadGainCalib {
public:
#ifndef GPUCA_GPUCODE
TPCPadGainCalib();
TPCPadGainCalib(const o2::tpc::CalDet<float>&);
/// constructor
/// \param minValue minimum value which will be stored
/// \param maxValue maximum value which will be stored
/// \param inv setting the inverse value
TPCPadGainCalib(const o2::tpc::CalDet<float>&, const float minValue, const float maxValue, const bool inv);
/// setting the stored values from CalDet
/// \param inv setting the inverse value
void setFromMap(const o2::tpc::CalDet<float>&, const bool inv = true);
#endif
// Deal with pad gain correction from here on
GPUdi() void setGainCorrection(int32_t sector, tpccf::Row row, tpccf::Pad pad, float c)
{
mGainCorrection[sector].set(globalPad(row, pad), c);
}
GPUdi() void setGainCorrection(int32_t sector, uint16_t globalPad, float c)
{
mGainCorrection[sector].set(globalPad, c);
}
GPUdi() float getGainCorrection(int32_t sector, tpccf::Row row, tpccf::Pad pad) const
{
return mGainCorrection[sector].get(globalPad(row, pad));
}
GPUdi() uint16_t globalPad(tpccf::Row row, tpccf::Pad pad) const
{
return mPadOffsetPerRow[row] + pad;
}
GPUdi() void setMinCorrectionFactor(const float minCorrectionFactor)
{
for (int32_t sector = 0; sector < GPUCA_NSECTORS; sector++) {
mGainCorrection[sector].mMinCorrectionFactor = minCorrectionFactor;
}
}
GPUdi() void setMaxCorrectionFactor(const float maxCorrectionFactor)
{
for (int32_t sector = 0; sector < GPUCA_NSECTORS; sector++) {
mGainCorrection[sector].mMaxCorrectionFactor = maxCorrectionFactor;
}
}
private:
template <typename T = uint16_t>
class SectorPadGainCorrection
{
public:
float mMinCorrectionFactor = 0.f;
float mMaxCorrectionFactor = 2.f;
constexpr static int32_t NumOfSteps = TPCPadGainCorrectionStepNum<T>::value;
GPUdi() SectorPadGainCorrection()
{
reset();
}
GPUdi() void set(uint16_t globalPad, float c)
{
at(globalPad) = pack(c);
}
GPUdi() float get(uint16_t globalPad) const
{
return unpack(at(globalPad));
}
GPUd() void reset()
{
for (uint16_t p = 0; p < TPC_REAL_PADS_IN_SECTOR; p++) {
set(p, 1.0f);
}
}
private:
T mGainCorrection[TPC_REAL_PADS_IN_SECTOR];
GPUd() T pack(float f) const
{
f = CAMath::Clamp(f, mMinCorrectionFactor, mMaxCorrectionFactor);
f -= mMinCorrectionFactor;
f *= float(NumOfSteps);
f /= (mMaxCorrectionFactor - mMinCorrectionFactor);
return CAMath::Round(f);
}
GPUd() float unpack(T c) const
{
return mMinCorrectionFactor + (mMaxCorrectionFactor - mMinCorrectionFactor) * float(c) / float(NumOfSteps);
}
GPUdi() T& at(uint16_t globalPad)
{
return mGainCorrection[globalPad];
}
GPUdi() const T& at(uint16_t globalPad) const
{
return mGainCorrection[globalPad];
}
};
uint16_t mPadOffsetPerRow[GPUCA_ROW_COUNT];
SectorPadGainCorrection<uint16_t> mGainCorrection[GPUCA_NSECTORS];
};
} // namespace o2::gpu
#endif