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#ifndef GPUCA_GPUCODE_DEVICE
22#include <memory>
23#include "GPUCommonRtypes.h"
24#endif
25
26namespace o2
27{
28namespace gpu
29{
30
35{
36 public:
38 struct SliceInfo {
39 float sinAlpha;
40 float cosAlpha;
42 };
43
45 struct RowInfo {
46 float x;
47 int32_t maxPad;
48 float padWidth;
49 float u0;
50 float scaleUtoSU;
51 float scaleSUtoU;
52
54 GPUd() float getUwidth() const { return -2.f * u0; }
56 };
57
59
62
65
68
71
73
75 static constexpr size_t getClassAlignmentBytes() { return 8; }
76
78
80 void startConstruction(int32_t numberOfRows);
81
83 void setTPCrow(int32_t iRow, float x, int32_t nPads, float padWidth);
84
88 void setTPCzLength(float tpcZlengthSideA, float tpcZlengthSideC);
89
94 void setTPCalignmentZ(float tpcAlignmentZ);
95
97 void finishConstruction();
98
100 bool isConstructed() const { return (mConstructionMask == (uint32_t)ConstructionState::Constructed); }
101
103
105 GPUd() static constexpr int32_t getNumberOfSlices() { return NumberOfSlices; }
106
108 GPUd() static constexpr int32_t getNumberOfSlicesA() { return NumberOfSlicesA; }
109
111 GPUd() int32_t getNumberOfRows() const { return mNumberOfRows; }
112
114 GPUd() const SliceInfo& getSliceInfo(int32_t slice) const;
115
117 GPUd() const RowInfo& getRowInfo(int32_t row) const;
118
120 GPUd() float getTPCzLengthA() const { return mTPCzLengthA; }
121
123 GPUd() float getTPCzLengthC() const { return mTPCzLengthC; }
124
126 GPUd() float getTPCzLength(int32_t slice) const
127 {
128 return (slice < NumberOfSlicesA) ? mTPCzLengthA
129 : mTPCzLengthC;
130 }
131
133 GPUd() float getTPCalignmentZ() const { return mTPCalignmentZ; }
134
136
138 GPUd() void convLocalToGlobal(int32_t slice, float lx, float ly, float lz, float& gx, float& gy, float& gz) const;
139
141 GPUd() void convGlobalToLocal(int32_t slice, float gx, float gy, float gz, float& lx, float& ly, float& lz) const;
142
144 GPUd() void convUVtoLocal(int32_t slice, float u, float v, float& y, float& z) const;
145 GPUd() void convVtoLocal(int32_t slice, float v, float& z) const;
146
148 GPUd() void convLocalToUV(int32_t slice, float y, float z, float& u, float& v) const;
149
151 GPUd() void convUVtoScaledUV(int32_t slice, int32_t row, float u, float v, float& su, float& sv) const;
152
154 GPUd() void convScaledUVtoUV(int32_t slice, int32_t row, float su, float sv, float& u, float& v) const;
155
157 GPUd() void convScaledUVtoLocal(int32_t slice, int32_t row, float su, float sv, float& ly, float& lz) const;
158
160 GPUd() float convPadToU(int32_t row, float pad) const;
161
163 GPUd() float convUtoPad(int32_t row, float u) const;
164
166 void print() const;
167
169 int32_t test(int32_t slice, int32_t row, float ly, float lz) const;
170
172 int32_t test() const;
173
174 private:
176
177 static constexpr int32_t NumberOfSlices = 36;
178 static constexpr int32_t NumberOfSlicesA = NumberOfSlices / 2;
179 static constexpr int32_t MaxNumberOfRows = 160;
180
182
184 enum ConstructionState : uint32_t {
185 NotConstructed = 0x0,
186 Constructed = 0x1,
187 InProgress = 0x2,
188 GeometryIsSet = 0x4,
189 AlignmentIsSet = 0x8
190 };
191
192 uint32_t mConstructionMask = ConstructionState::NotConstructed;
193
195
196 int32_t mNumberOfRows = 0;
197 float mTPCzLengthA = 0.f;
198 float mTPCzLengthC = 0.f;
199 float mTPCalignmentZ = 0.f;
200 float mScaleVtoSVsideA = 0.f;
201 float mScaleVtoSVsideC = 0.f;
202 float mScaleSVtoVsideA = 0.f;
203 float mScaleSVtoVsideC = 0.f;
204
205 SliceInfo mSliceInfos[NumberOfSlices + 1];
206 RowInfo mRowInfos[MaxNumberOfRows + 1];
207
208 ClassDefNV(TPCFastTransformGeo, 1);
209};
210
211// =======================================================================
212// Inline implementations of some methods
213// =======================================================================
214
215GPUdi() const TPCFastTransformGeo::SliceInfo& TPCFastTransformGeo::getSliceInfo(int32_t slice) const
216{
218 if (slice < 0 || slice >= NumberOfSlices) { // return zero object
219 slice = NumberOfSlices;
220 }
221 return mSliceInfos[slice];
222}
223
224GPUdi() const TPCFastTransformGeo::RowInfo& TPCFastTransformGeo::getRowInfo(int32_t row) const
225{
227 if (row < 0 || row >= mNumberOfRows) { // return zero object
228 row = MaxNumberOfRows;
229 }
230 return mRowInfos[row];
231}
232
233GPUdi() void TPCFastTransformGeo::convLocalToGlobal(int32_t slice, float lx, float ly, float lz, float& gx, float& gy, float& gz) const
234{
236 const SliceInfo& sliceInfo = getSliceInfo(slice);
237 gx = lx * sliceInfo.cosAlpha - ly * sliceInfo.sinAlpha;
238 gy = lx * sliceInfo.sinAlpha + ly * sliceInfo.cosAlpha;
239 gz = lz;
240}
241
242GPUdi() void TPCFastTransformGeo::convGlobalToLocal(int32_t slice, float gx, float gy, float gz, float& lx, float& ly, float& lz) const
243{
245 const SliceInfo& sliceInfo = getSliceInfo(slice);
246 lx = gx * sliceInfo.cosAlpha + gy * sliceInfo.sinAlpha;
247 ly = -gx * sliceInfo.sinAlpha + gy * sliceInfo.cosAlpha;
248 lz = gz;
249}
250
251GPUdi() void TPCFastTransformGeo::convVtoLocal(int32_t slice, float v, float& lz) const
252{
254 if (slice < NumberOfSlicesA) { // TPC side A
255 lz = mTPCzLengthA - v;
256 } else { // TPC side C
257 lz = v - mTPCzLengthC; // drift direction is mirrored on C-side
258 }
259 lz += mTPCalignmentZ; // global TPC alignment
260}
261
262GPUdi() void TPCFastTransformGeo::convUVtoLocal(int32_t slice, float u, float v, float& ly, float& lz) const
263{
265 if (slice < NumberOfSlicesA) { // TPC side A
266 ly = u;
267 lz = mTPCzLengthA - v;
268 } else { // TPC side C
269 ly = -u; // pads are mirrorred on C-side
270 lz = v - mTPCzLengthC; // drift direction is mirrored on C-side
271 }
272 lz += mTPCalignmentZ; // global TPC alignment
273}
274
275GPUdi() void TPCFastTransformGeo::convLocalToUV(int32_t slice, float ly, float lz, float& u, float& v) const
276{
278 lz = lz - mTPCalignmentZ; // global TPC alignment
279 if (slice < NumberOfSlicesA) { // TPC side A
280 u = ly;
281 v = mTPCzLengthA - lz;
282 } else { // TPC side C
283 u = -ly; // pads are mirrorred on C-side
284 v = lz + mTPCzLengthC; // drift direction is mirrored on C-side
285 }
286}
287
288GPUdi() void TPCFastTransformGeo::convUVtoScaledUV(int32_t slice, int32_t row, float u, float v, float& su, float& sv) const
289{
291 const RowInfo& rowInfo = getRowInfo(row);
292 su = (u - rowInfo.u0) * rowInfo.scaleUtoSU;
293 if (slice < NumberOfSlicesA) {
294 sv = v * mScaleVtoSVsideA;
295 } else {
296 sv = v * mScaleVtoSVsideC;
297 }
298}
299
300GPUdi() void TPCFastTransformGeo::convScaledUVtoUV(int32_t slice, int32_t row, float su, float sv, float& u, float& v) const
301{
303 const RowInfo& rowInfo = getRowInfo(row);
304 u = rowInfo.u0 + su * rowInfo.scaleSUtoU;
305 if (slice < NumberOfSlicesA) {
306 v = sv * mScaleSVtoVsideA;
307 } else {
308 v = sv * mScaleSVtoVsideC;
309 }
310}
311
312GPUdi() void TPCFastTransformGeo::convScaledUVtoLocal(int32_t slice, int32_t row, float su, float sv, float& ly, float& lz) const
313{
315 float u, v;
316 convScaledUVtoUV(slice, row, su, sv, u, v);
317 convUVtoLocal(slice, u, v, ly, lz);
318}
319
320GPUdi() float TPCFastTransformGeo::convPadToU(int32_t row, float pad) const
321{
323 const RowInfo& rowInfo = getRowInfo(row);
324 return (pad - 0.5f * rowInfo.maxPad) * rowInfo.padWidth;
325}
326
327GPUdi() float TPCFastTransformGeo::convUtoPad(int32_t row, float u) const
328{
330 const RowInfo& rowInfo = getRowInfo(row);
331 return u / rowInfo.padWidth + 0.5f * rowInfo.maxPad;
332}
333
334} // namespace gpu
335} // namespace o2
336
337#endif
void finishConstruction()
Finishes initialization: puts everything to the flat buffer, releases temporary memory.
GPUd() static const expr int32_t getNumberOfSlices()
_______________ Getters _________________________________
GPUd() const SliceInfo &getSliceInfo(int32_t slice) const
Gives slice info.
~TPCFastTransformGeo()=default
Destructor.
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
int32_t float float float & su
TPCFastTransformGeo()
_____________ Constructors / destructors __________________________
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.
GPUd() static const expr int32_t getNumberOfSlicesA()
Gives number of TPC slices in A side.
void setTPCalignmentZ(float tpcAlignmentZ)
GPUd() float getTPCalignmentZ() const
Gives TPC alignment in Z.
bool isConstructed() const
Is the object constructed.
GPUd() float getTPCzLength(int32_t slice) const
Gives Z length of the TPC, depending on the slice.
void print() const
Print method.
GPUd() int32_t getNumberOfRows() const
Gives number of TPC rows.
GPUd() float getTPCzLengthC() const
Gives Z length of the TPC, side C.
void setTPCzLength(float tpcZlengthSideA, float tpcZlengthSideC)
TPCFastTransformGeo & operator=(const TPCFastTransformGeo &)=default
Assignment operator: disabled to avoid ambiguity. Use cloneFromObject() instead.
float float float float & gx
GLint GLenum GLint x
Definition glcorearb.h:403
const GLdouble * v
Definition glcorearb.h:832
typedef void(APIENTRYP PFNGLCULLFACEPROC)(GLenum mode)
GLdouble GLdouble GLdouble z
Definition glcorearb.h:843
GPUdi() o2
Definition TrackTRD.h:38
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.
float x
nominal X coordinate of the row [cm]
float scaleUtoSU
scale for su (scaled u ) coordinate
float scaleSUtoU
scale for u coordinate
GPUd() float getUwidth() const
get width in U
int32_t maxPad
maximal pad number = n pads - 1
The struct contains necessary info for TPC slice.
std::vector< int > row