Project
Loading...
Searching...
No Matches
TPCPadGainCalib.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
14
15#ifndef O2_GPU_TPC_PAD_GAIN_CALIB_H
16#define O2_GPU_TPC_PAD_GAIN_CALIB_H
17
18#include "clusterFinderDefs.h"
19#include "GPUCommonMath.h"
20
21namespace o2::tpc
22{
23template <class T>
24class CalDet;
25} // namespace o2::tpc
26
27namespace o2::gpu
28{
29
30template <typename T>
33
34template <>
36 static constexpr int32_t value = 254;
37};
38
39template <>
41 static constexpr int32_t value = 65534;
42};
43
45 public:
46#ifndef GPUCA_GPUCODE
49
54 TPCPadGainCalib(const o2::tpc::CalDet<float>&, const float minValue, const float maxValue, const bool inv);
55
58 void setFromMap(const o2::tpc::CalDet<float>&, const bool inv = true);
59#endif
60
61 // Deal with pad gain correction from here on
62 GPUdi() void setGainCorrection(int32_t sector, tpccf::Row row, tpccf::Pad pad, float c)
63 {
64 mGainCorrection[sector].set(globalPad(row, pad), c);
65 }
66
67 GPUdi() void setGainCorrection(int32_t sector, uint16_t globalPad, float c)
68 {
69 mGainCorrection[sector].set(globalPad, c);
70 }
71
72 GPUdi() float getGainCorrection(int32_t sector, tpccf::Row row, tpccf::Pad pad) const
73 {
74 return mGainCorrection[sector].get(globalPad(row, pad));
75 }
76
77 GPUdi() uint16_t globalPad(tpccf::Row row, tpccf::Pad pad) const
78 {
79 return mPadOffsetPerRow[row] + pad;
80 }
81
82 GPUdi() void setMinCorrectionFactor(const float minCorrectionFactor)
83 {
84 for (int32_t sector = 0; sector < GPUCA_NSECTORS; sector++) {
85 mGainCorrection[sector].mMinCorrectionFactor = minCorrectionFactor;
86 }
87 }
88
89 GPUdi() void setMaxCorrectionFactor(const float maxCorrectionFactor)
90 {
91 for (int32_t sector = 0; sector < GPUCA_NSECTORS; sector++) {
92 mGainCorrection[sector].mMaxCorrectionFactor = maxCorrectionFactor;
93 }
94 }
95
96 private:
97 template <typename T = uint16_t>
98 class SectorPadGainCorrection
99 {
100
101 public:
102 float mMinCorrectionFactor = 0.f;
103 float mMaxCorrectionFactor = 2.f;
104 constexpr static int32_t NumOfSteps = TPCPadGainCorrectionStepNum<T>::value;
105
106 GPUdi() SectorPadGainCorrection()
107 {
108 reset();
109 }
110
111 GPUdi() void set(uint16_t globalPad, float c)
112 {
113 at(globalPad) = pack(c);
114 }
115
116 GPUdi() float get(uint16_t globalPad) const
117 {
118 return unpack(at(globalPad));
119 }
120
121 GPUd() void reset()
122 {
123 for (uint16_t p = 0; p < TPC_PADS_IN_SECTOR; p++) {
124 set(p, 1.0f);
125 }
126 }
127
128 private:
129 GPUd() T pack(float f) const
130 {
131 f = CAMath::Clamp(f, mMinCorrectionFactor, mMaxCorrectionFactor);
132 f -= mMinCorrectionFactor;
133 f *= float(NumOfSteps);
134 f /= (mMaxCorrectionFactor - mMinCorrectionFactor);
135 return CAMath::Round(f);
136 }
137
138 GPUd() float unpack(T c) const
139 {
140 return mMinCorrectionFactor + (mMaxCorrectionFactor - mMinCorrectionFactor) * float(c) / float(NumOfSteps);
141 }
142
143 T mGainCorrection[TPC_PADS_IN_SECTOR];
144
145 GPUdi() T& at(uint16_t globalPad)
146 {
147 return mGainCorrection[globalPad];
148 }
149
150 GPUdi() const T& at(uint16_t globalPad) const
151 {
152 return mGainCorrection[globalPad];
153 }
154 };
155
156 uint16_t mPadOffsetPerRow[GPUCA_ROW_COUNT];
157 SectorPadGainCorrection<uint16_t> mGainCorrection[GPUCA_NSECTORS];
158};
159
160} // namespace o2::gpu
161
162#endif
#define GPUdi()
#define GPUd()
#define GPUCA_NSECTORS
#define GPUCA_ROW_COUNT
#define TPC_PADS_IN_SECTOR
GLdouble f
Definition glcorearb.h:310
GLsizei const GLfloat * value
Definition glcorearb.h:819
typedef void(APIENTRYP PFNGLCULLFACEPROC)(GLenum mode)
void set(T *h, size_t v)
Definition PageParser.h:107
Global TPC definitions and constants.
Definition SimTraits.h:167
tpccf::Row tpccf::Pad pad const
void setFromMap(const o2::tpc::CalDet< float > &, const bool inv=true)
tpccf::Row tpccf::Pad float c
tpccf::Row tpccf::Pad pad
GPUdi() uint16_t globalPad(tpccf
GPUdi() void setGainCorrection(int32_t sector
GPUdi() void setMaxCorrectionFactor(const float maxCorrectionFactor)