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