Project
Loading...
Searching...
No Matches
TPCFastTransformGeo.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
16
17#ifndef ALICEO2_GPUCOMMON_TPCFASTTRANSFORMATION_TPCFASTTRANSFORMGEO_H
18#define ALICEO2_GPUCOMMON_TPCFASTTRANSFORMATION_TPCFASTTRANSFORMGEO_H
19
20#include "GPUCommonDef.h"
21#include "GPUCommonMath.h"
23#ifndef GPUCA_GPUCODE_DEVICE
24#include <memory>
25#include "GPUCommonRtypes.h"
26#include "GPUCommonArray.h" // Would work on GPU, but yields performance regressions
27#endif
28
29namespace o2::gpu
30{
31
36{
37
38 public:
40 struct SectorInfo {
41 float sinAlpha{0.f};
42 float cosAlpha{0.f};
44 };
45
47 struct RowInfo {
48 float x{0.f};
49 int32_t maxPad{0};
50 float padWidth{0.f};
51 float yMin{0.f};
52
54 GPUdi() float getYmin() const { return yMin; }
55
57 GPUdi() float getYmax() const { return -yMin; }
58
60#ifndef GPUCA_GPUCODE_DEVICE
61 GPUd() std::array<float, 2> getYrange() const { return {getYmin(), getYmax()}; }
62#endif
63
65 GPUdi() float getYwidth() const { return -2.f * yMin; }
66
67 ClassDefNV(RowInfo, 2);
68 };
69
71
74
77
80
83
85
87 inline static constexpr size_t getClassAlignmentBytes() { return 8; }
88
90
92 void startConstruction(int32_t numberOfRows);
93
95 void setTPCrow(int32_t iRow, float x, int32_t nPads, float padWidth);
96
100 void setTPCzLength(float tpcZlength);
101
103 void finishConstruction();
104
106 bool isConstructed() const { return (mConstructionMask == (uint32_t)ConstructionState::Constructed); }
107
109
111 inline static constexpr int32_t getNumberOfSectors() { return NumberOfSectors; }
112
114 inline static constexpr int32_t getNumberOfSectorsA() { return NumberOfSectorsA; }
115
117 GPUdi() int32_t getNumberOfRows() const { return mNumberOfRows; }
118
120 inline static constexpr int getMaxNumberOfRows() { return MaxNumberOfRows; }
121
123 GPUd() const SectorInfo& getSectorInfo(int32_t sector) const;
124
126 GPUd() const RowInfo& getRowInfo(int32_t row) const;
127
129 GPUdi() float getTPCzLength() const { return mTPCzLength; }
130
132#ifndef GPUCA_GPUCODE_DEVICE
133 GPUdi() std::array<float, 2> getZrange(int32_t sector) const
134 {
136 if (sector < NumberOfSectorsA) { // TPC side A
137 return {0.f, mTPCzLength};
138 } else { // TPC side C
139 return {-mTPCzLength, 0.f};
140 }
141 }
142#endif
143 GPUd() float getZmin(int32_t sector) const;
144 GPUd() float getZmax(int32_t sector) const;
145
147
149 GPUd() void convLocalToGlobal(int32_t sector, float lx, float ly, float lz, float& gx, float& gy, float& gz) const;
150
152 GPUd() void convGlobalToLocal(int32_t sector, float gx, float gy, float gz, float& lx, float& ly, float& lz) const;
153
155 GPUd() void convPadDriftLengthToLocal(int32_t sector, int32_t row, float pad, float driftLength, float& y, float& z) const;
156
158 GPUd() float convDriftLengthToZ(int32_t sector, float driftLength) const;
159
161 GPUd() float convZtoDriftLength(int32_t sector, float z) const;
162
164 GPUd() void convLocalToPadDriftLength(int32_t sector, int32_t row, float y, float z, float& pad, float& l) const;
165
167 void print() const;
168
170 int32_t test(int32_t sector, int32_t row, float ly, float lz) const;
171
173 int32_t test() const;
174
175 private:
177
178 static constexpr int32_t NumberOfSectors = o2::tpc::constants::MAXSECTOR;
179 static constexpr int32_t NumberOfSectorsA = NumberOfSectors / 2;
180 static constexpr int32_t MaxNumberOfRows = 160;
181
183
185 enum ConstructionState : uint32_t {
186 NotConstructed = 0x0,
187 Constructed = 0x1,
188 InProgress = 0x2,
189 GeometryIsSet = 0x4,
190 };
191
192 uint32_t mConstructionMask = ConstructionState::NotConstructed;
193
195
196 int32_t mNumberOfRows = 0;
197 float mTPCzLength = 0.f;
198
199 SectorInfo mSectorInfos[NumberOfSectors + 1];
200 RowInfo mRowInfos[MaxNumberOfRows + 1];
201
202 public:
203 struct SliceInfo { // legacy, needed only for schema evolution
205 };
206
208};
209
210// =======================================================================
211// Inline implementations of some methods
212// =======================================================================
213
214GPUdi() const TPCFastTransformGeo::SectorInfo& TPCFastTransformGeo::getSectorInfo(int32_t sector) const
215{
217 if (sector < 0 || sector >= NumberOfSectors) { // return zero object
218 sector = NumberOfSectors;
219 }
220 return mSectorInfos[sector];
221}
222
223GPUdi() const TPCFastTransformGeo::RowInfo& TPCFastTransformGeo::getRowInfo(int32_t row) const
224{
226 if (row < 0 || row >= mNumberOfRows) { // return zero object
227 row = MaxNumberOfRows;
228 }
229 return mRowInfos[row];
230}
231
232GPUdi() void TPCFastTransformGeo::convLocalToGlobal(int32_t sector, float lx, float ly, float lz, float& gx, float& gy, float& gz) const
233{
235 const SectorInfo& sectorInfo = getSectorInfo(sector);
236 gx = lx * sectorInfo.cosAlpha - ly * sectorInfo.sinAlpha;
237 gy = lx * sectorInfo.sinAlpha + ly * sectorInfo.cosAlpha;
238 gz = lz;
239}
240
241GPUdi() void TPCFastTransformGeo::convGlobalToLocal(int32_t sector, float gx, float gy, float gz, float& lx, float& ly, float& lz) const
242{
244 const SectorInfo& sectorInfo = getSectorInfo(sector);
245 lx = gx * sectorInfo.cosAlpha + gy * sectorInfo.sinAlpha;
246 ly = -gx * sectorInfo.sinAlpha + gy * sectorInfo.cosAlpha;
247 lz = gz;
248}
249
250GPUdi() void TPCFastTransformGeo::convPadDriftLengthToLocal(int32_t sector, int32_t row, float pad, float driftLength, float& y, float& z) const
251{
253 const RowInfo& rowInfo = getRowInfo(row);
254 float u = (pad - 0.5f * rowInfo.maxPad) * rowInfo.padWidth;
255 if (sector < NumberOfSectorsA) { // TPC side A
256 y = u;
257 z = mTPCzLength - driftLength;
258 } else { // TPC side C
259 y = -u; // pads are mirrorred on C-side
260 z = driftLength - mTPCzLength; // drift direction is mirrored on C-side
261 }
262}
263
264GPUdi() float TPCFastTransformGeo::convDriftLengthToZ(int32_t sector, float driftLength) const
265{
267 return (sector < NumberOfSectorsA) ? (mTPCzLength - driftLength) : (driftLength - mTPCzLength);
268}
269
270GPUdi() float TPCFastTransformGeo::convZtoDriftLength(int32_t sector, float z) const
271{
273 return (sector < NumberOfSectorsA) ? (mTPCzLength - z) : (z + mTPCzLength);
274}
275
276GPUdi() float TPCFastTransformGeo::getZmin(int32_t sector) const
277{
279 if (sector < NumberOfSectorsA) { // TPC side A
280 return 0.f;
281 } else { // TPC side C
282 return -mTPCzLength;
283 }
284}
285
286GPUdi() float TPCFastTransformGeo::getZmax(int32_t sector) const
287{
289 if (sector < NumberOfSectorsA) { // TPC side A
290 return mTPCzLength;
291 } else { // TPC side C
292 return 0.f;
293 }
294}
295
296GPUdi() void TPCFastTransformGeo::convLocalToPadDriftLength(int32_t sector, int32_t row, float y, float z, float& pad, float& l) const
297{
299 float u;
300 if (sector < NumberOfSectorsA) { // TPC side A
301 u = y;
302 l = mTPCzLength - z;
303 } else { // TPC side C
304 u = -y; // pads are mirrorred on C-side
305 l = z + mTPCzLength; // drift direction is mirrored on C-side
306 }
307 const TPCFastTransformGeo::RowInfo& rowInfo = getRowInfo(row);
308 pad = u / rowInfo.padWidth + 0.5f * rowInfo.maxPad;
309}
310
311} // namespace o2::gpu
312
313#endif
void finishConstruction()
Finishes initialization: puts everything to the flat buffer, releases temporary memory.
void setTPCzLength(float tpcZlength)
~TPCFastTransformGeo()=default
Destructor.
static constexpr int getMaxNumberOfRows()
Gives number of TPC rows.
GPUdi() std GPUd() float getZmax(int32_t sector) const
Gives Z range for the corresponding TPC side.
float float float float float float &gz const
static constexpr size_t getClassAlignmentBytes()
_____________ FlatObject functionality, see FlatObject class for description ____________
float float float float float & gy
TPCFastTransformGeo()
_____________ Constructors / destructors __________________________
GPUd() const SectorInfo &getSectorInfo(int32_t sector) const
Gives sector info.
void startConstruction(int32_t numberOfRows)
_______________ Construction interface ________________________
void setTPCrow(int32_t iRow, float x, int32_t nPads, float padWidth)
Initializes a TPC row.
TPCFastTransformGeo(const TPCFastTransformGeo &)=default
Copy constructor: disabled to avoid ambiguity. Use cloneFromObject() instead.
static constexpr int32_t getNumberOfSectorsA()
Gives number of TPC sectors on the A side.
bool isConstructed() const
Is the object constructed.
void print() const
Print method.
static constexpr int32_t getNumberOfSectors()
_______________ Getters _________________________________
GPUdi() int32_t getNumberOfRows() const
Gives number of TPC rows.
TPCFastTransformGeo & operator=(const TPCFastTransformGeo &)=default
Assignment operator: disabled to avoid ambiguity. Use cloneFromObject() instead.
float float float float & gx
ClassDefNV(TPCFastTransformGeo, 3)
GLint GLenum GLint x
Definition glcorearb.h:403
GLenum array
Definition glcorearb.h:4274
GLint y
Definition glcorearb.h:270
typedef void(APIENTRYP PFNGLCULLFACEPROC)(GLenum mode)
GLdouble GLdouble GLdouble z
Definition glcorearb.h:843
GPUdi() o2
Definition TrackTRD.h:39
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
FIXME: do not use data model tables.
The struct contains necessary info about TPC padrow.
GPUdi() float getYmax() const
get Y max
GPUdi() float getYmin() const
get Y min
int32_t maxPad
maximal pad number = n pads - 1
The struct contains necessary info for TPC sector.
float cosAlpha
cos of the angle between the local x and the global x
float sinAlpha
sin of the angle between the local x and the global x
std::vector< int > row