Project
Loading...
Searching...
No Matches
TPCFastTransformPOD.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_GPU_TPCFastTransformPOD_H
18#define ALICEO2_GPU_TPCFastTransformPOD_H
19
20#include "GPUCommonDef.h"
21
22#include "GPUCommonRtypes.h"
23#include "TPCFastTransform.h"
26#ifndef GPUCA_GPUCODE
27#include <memory>
28#include <cstdlib>
30#endif
31
32/*
33Binary buffer should be cast to TPCFastTransformPOD class using static TPCFastTransformPOD& t = get(buffer); method,
34so that its head becomes `this` pointer of the object.
35
36First we have all the fixed size data members mentioned explicitly. Part of them is duplicating fixed size
37data members of TPCFastSpaceChargeCorrection but those starting with mOffs... provide the offset in bytes
38(wrt this) for dynamic data which cannot be declared as data member explicitly (since we cannot have any
39pointer except `this`) but obtained via getters using stored offsets wrt `this`.
40This is followed dynamic part itself.
41
42dynamic part layout:
431) size_t[ mNumberOfScenarios ] array starting at offset mOffsScenariosOffsets, each element is the offset
44of distict spline object (scenario in TPCFastSpaceChargeCorrection)
452) size_t[ mNSplineIDs ] array starting at offset mOffsSplineDataOffsets, each element is the offset of the
46beginning of splines data for give splineID
47
48*/
49
50namespace o2::gpu
51{
53{
54 public:
58
63
65 GPUd() static const TPCFastTransformPOD& get(const char* head) { return *reinterpret_cast<const TPCFastTransformPOD*>(head); }
66
69 // Methods taking extra reference transform are legacy compound transforms used to scale corrections.
70 GPUd() void Transform(int32_t sector, int32_t row, float pad, float time, float& x, float& y, float& z, float vertexTime = 0) const;
71 GPUd() void TransformXYZ(int32_t sector, int32_t row, float& x, float& y, float& z) const;
72
74 GPUd() void TransformInTimeFrame(int32_t sector, int32_t row, float pad, float time, float& x, float& y, float& z, float maxTimeBin) const;
75 GPUd() void TransformInTimeFrame(int32_t sector, float time, float& z, float maxTimeBin) const;
76
78 GPUd() void InverseTransformInTimeFrame(int32_t sector, int32_t row, float /*x*/, float y, float z, float& pad, float& time, float maxTimeBin) const;
79 GPUd() float InverseTransformInTimeFrame(int32_t sector, float z, float maxTimeBin) const;
80
82 GPUd() void InverseTransformYZtoX(int32_t sector, int32_t row, float y, float z, float& x) const;
83
85 GPUd() void InverseTransformYZtoNominalYZ(int32_t sector, int32_t row, float y, float z, float& ny, float& nz) const;
86
88 GPUd() void InverseTransformXYZtoNominalXYZ(int32_t sector, int32_t row, float x, float y, float z, float& nx, float& ny, float& nz) const;
89
91 GPUd() void TransformIdeal(int32_t sector, int32_t row, float pad, float time, float& x, float& y, float& z, float vertexTime) const;
92 GPUd() void TransformIdealZ(int32_t sector, float time, float& z, float vertexTime) const;
93
94 GPUd() void convPadTimeToLocal(int32_t sector, int32_t row, float pad, float time, float& y, float& z, float vertexTime) const;
95 GPUd() void convPadTimeToLocalInTimeFrame(int32_t sector, int32_t row, float pad, float time, float& y, float& z, float maxTimeBin) const;
96
97 GPUd() void convLocalToPadTime(int32_t sector, int32_t row, float y, float z, float& pad, float& time, float vertexTime) const;
98 GPUd() void convLocalToPadTimeInTimeFrame(int32_t sector, int32_t row, float y, float z, float& pad, float& time, float maxTimeBin) const;
99
100 GPUd() float convTimeToZinTimeFrame(int32_t sector, float time, float maxTimeBin) const;
101 GPUd() float convZtoTimeInTimeFrame(int32_t sector, float z, float maxTimeBin) const;
102 GPUd() float convDeltaTimeToDeltaZinTimeFrame(int32_t sector, float deltaTime) const;
103 GPUd() float convDeltaZtoDeltaTimeInTimeFrame(int32_t sector, float deltaZ) const;
104 GPUd() float convDeltaZtoDeltaTimeInTimeFrameAbs(float deltaZ) const;
105 GPUd() float convZOffsetToVertexTime(int32_t sector, float zOffset, float maxTimeBin) const;
106 GPUd() float convVertexTimeToZOffset(int32_t sector, float vertexTime, float maxTimeBin) const;
107
109 void setApplyCorrectionOn() { mApplyCorrection = 1; }
110 void setApplyCorrectionOff() { mApplyCorrection = 0; }
111 bool isCorrectionApplied() { return mApplyCorrection; }
112
114 GPUd() const TPCFastTransformGeoPOD& getGeometry() const { return mGeo; }
115
117 GPUd() const RowInfo& getRowInfo(int32_t row) const { return mRowInfos[row]; }
118
120 GPUd() RowInfo& getRowInfo(int32_t row) { return mRowInfos[row]; }
121
123 GPUd() size_t size() const { return mTotalSize; }
124
126 GPUd() long int getTimeStamp() const { return mTimeStamp; }
127
129 GPUd() float getVDrift() const { return mVdrift; }
130
132 GPUd() float getT0() const { return mT0; }
133
135 GPUd() float getIDC() const { return mIDC; }
136
138 GPUd() float getLumi() const { return mLumi; }
139
141 GPUd() float getMaxDriftTime(int32_t sector, int32_t row, float pad) const;
142
144 GPUd() float getMaxDriftTime(int32_t sector, int32_t row) const;
145
147 GPUd() float getMaxDriftTime(int32_t sector) const;
148
150 GPUd() void setTimeStamp(long int v) { mTimeStamp = v; }
151
153 GPUd() void setVDrift(float v) { mVdrift = v; }
154
156 GPUd() void setT0(float v) { mT0 = v; }
157
159 GPUd() void setIDC(float v) { mIDC = v; }
160
162 GPUd() void setLumi(float v) { mLumi = v; }
163
164 GPUd() void setCalibration(int64_t timeStamp, float t0, float vDrift);
165
167 GPUd() const SplineType& getSplineForRow(int32_t row) const { return *reinterpret_cast<const SplineType*>(getThis() + getScenarioOffset(getRowInfo(row).splineScenarioID)); }
168
170 GPUd() const float* getCorrectionData(int32_t sector, int32_t row, int32_t iSpline = 0) const { return reinterpret_cast<const float*>(getThis() + mSplineDataOffsets[sector][iSpline] + getRowInfo(row).dataOffsetBytes[iSpline]); }
171
173 GPUd() const SplineTypeInvX& getSplineInvXforRow(int32_t row) const { return reinterpret_cast<const SplineTypeInvX&>(getSplineForRow(row)); }
174
176 GPUd() const float* getCorrectionDataInvX(int32_t sector, int32_t row) const { return getCorrectionData(sector, row, 1); }
177
179 GPUd() const SplineTypeInvYZ& getSplineInvYZforRow(int32_t row) const { return reinterpret_cast<const SplineTypeInvYZ&>(getSplineForRow(row)); }
180
182 GPUd() const float* getCorrectionDataInvYZ(int32_t sector, int32_t row) const { return getCorrectionData(sector, row, 2); }
183
185 GPUdi() void getCorrectionLocal(int32_t sector, int32_t row, float y, float z, float& dx, float& dy, float& dz) const;
186
188 GPUd() float getCorrectionXatRealYZ(int32_t sector, int32_t row, float realY, float realZ) const;
189
191 GPUd() void getCorrectionYZatRealYZ(int32_t sector, int32_t row, float realY, float realZ, float& measuredY, float& measuredZ) const;
192
194 GPUd() void TransformLocal(int32_t sector, int32_t row, float& x, float& y, float& z) const;
195
197
200 GPUd() void convLocalToGrid(int32_t sector, int32_t row, float y, float z, float& u, float& v, float& s) const;
201
204 GPUd() void convGridToLocal(int32_t sector, int32_t row, float u, float v, float& y, float& z) const;
205
208 GPUd() void convRealLocalToGrid(int32_t sector, int32_t row, float y, float z, float& u, float& v, float& s) const;
209
212 GPUd() void convGridToRealLocal(int32_t sector, int32_t row, float u, float v, float& y, float& z) const;
213
214 GPUd() bool isLocalInsideGrid(int32_t sector, int32_t row, float y, float z) const;
215 GPUd() bool isRealLocalInsideGrid(int32_t sector, int32_t row, float y, float z) const;
216
217#if !defined(GPUCA_GPUCODE)
220
223
225 {
226 destVector.alloc(src.size());
227 std::memcpy(destVector.get(), &src, src.size());
228 return destVector.get();
229 }
230
231 static TPCFastTransformPOD* create(char* buff, size_t buffSize, const TPCFastTransform& src);
232 static TPCFastTransformPOD* create(char* buff, size_t buffSize, const TPCFastSpaceChargeCorrection& src);
233 static size_t estimateSize(const TPCFastTransform& src) { return estimateSize(src.getCorrection()); }
234 static size_t estimateSize(const TPCFastSpaceChargeCorrection& origCorr);
235
236 bool test(const TPCFastTransform& src, int32_t npoints = 100000) const { return test(src.getCorrection(), npoints); }
237 bool test(const TPCFastSpaceChargeCorrection& origCorr, int32_t npoints = 100000) const;
238#endif
239
241 void print() const;
242
243 GPUd() float convDriftLengthToTime(float driftLength, float vertexTime) const;
244
245 static GPUglobalconstexpr() int NROWS = o2::tpc::constants::MAXGLOBALPADROW;
246 static GPUglobalconstexpr() int NSECTORS = o2::tpc::constants::MAXSECTOR;
247 static GPUglobalconstexpr() int NSECTORSA = o2::tpc::constants::MAXSECTOR / 2;
248 static GPUglobalconstexpr() int NSplineIDs = 3;
249
250 private:
251#if !defined(GPUCA_GPUCODE)
252 static constexpr size_t AlignmentBytes = 8;
253 static size_t alignOffset(size_t offs)
254 {
255 auto res = offs % AlignmentBytes;
256 return res ? offs + (AlignmentBytes - res) : offs;
257 }
258 GPUd() static TPCFastTransformPOD& getNonConst(char* head) { return *reinterpret_cast<TPCFastTransformPOD*>(head); }
259#endif
260
262 GPUd() const char* getThis() const { return reinterpret_cast<const char*>(this); }
263
265 GPUd() size_t getScenarioOffset(int s) const { return (reinterpret_cast<const size_t*>(getThis() + mOffsScenariosOffsets))[s]; }
266
267 GPUd() size_t getFlatBufferOffset(int s) const { return (reinterpret_cast<const size_t*>(getThis() + mOffsFlatBufferOffsets))[s]; }
268
269 // Returns a pointer to the flat buffer of scenario isc, using only the
270 // stored offset array (mOffsFlatBufferOffsets). No stale pointer involved.
271 GPUd() const char* getSplineFlatBuffer(int32_t isc) const
272 {
273 const size_t* offs = reinterpret_cast<const size_t*>(getThis() + mOffsFlatBufferOffsets);
274 return getThis() + offs[isc];
275 }
276
277 // Returns a pointer to mGridX2's flat buffer inside the spline flat buffer.
278 // Reproduces the layout from Spline2DContainer::setActualBufferAddress using
279 // only safe values: getFlatBufferSize() reads mNumberOfKnots/mUmax (plain ints).
280 template <typename SplineT>
281 GPUd() const char* getGridX2FlatBuffer(const SplineT& spline, int32_t isc) const
282 {
283 const size_t g1sz = spline.getGridX1().getFlatBufferSize();
284 const size_t g2align = spline.getGridX2().getBufferAlignmentBytes();
285 return getSplineFlatBuffer(isc) + FlatObject::alignSize(g1sz, g2align);
286 }
287
288 bool mApplyCorrection{};
289 int mNumberOfScenarios{};
290 size_t mTotalSize{};
291 size_t mOffsScenariosOffsets{};
292 size_t mOffsFlatBufferOffsets{};
293 size_t mSplineDataOffsets[TPCFastTransformGeo::getNumberOfSectors()][NSplineIDs];
294 long int mTimeStamp{};
295 float mT0;
296 float mVdrift;
297 float mLumi;
298 float mIDC;
299
300 TPCFastTransformGeoPOD mGeo;
301 RowInfo mRowInfos[NROWS];
302
303 ClassDefNV(TPCFastTransformPOD, 0);
304};
305
306GPUdi() void TPCFastTransformPOD::getCorrectionLocal(int32_t sector, int32_t row, float y, float z, float& dx, float& dy, float& dz) const
307{
308 const auto& info = getRowInfo(row);
309 const int32_t isc = info.splineScenarioID;
310 const SplineType& spline = getSplineForRow(row);
311 const float* splineData = getCorrectionData(sector, row);
312
313 float u, v, s;
314 convLocalToGrid(sector, row, y, z, u, v, s);
315
316 const char* g1buf = getSplineFlatBuffer(isc);
317 const char* g2buf = getGridX2FlatBuffer(spline, isc);
318
319 float dxyz[3];
320 spline.interpolateAtUZeroCopy(g1buf, g2buf, splineData, u, v, dxyz);
321
322 if (CAMath::Abs(dxyz[0]) > TPCFastSpaceChargeCorrection::kMaxCorrection || CAMath::Abs(dxyz[1]) > TPCFastSpaceChargeCorrection::kMaxCorrection || CAMath::Abs(dxyz[2]) > TPCFastSpaceChargeCorrection::kMaxCorrection) {
323 s = 0.f; // TODO: DR: Protect from FPEs, fix upstream and remove once guaranteed that it is fixed
324 }
325
326 dx = s * dxyz[0];
327 dy = s * dxyz[1];
328 dz = s * dxyz[2];
329}
330
331GPUdi() float TPCFastTransformPOD::getCorrectionXatRealYZ(int32_t sector, int32_t row, float realY, float realZ) const
332{
333 const auto& info = getRowInfo(row);
334 float u, v, s;
335 convRealLocalToGrid(sector, row, realY, realZ, u, v, s);
336
337 const int32_t isc = info.splineScenarioID;
338 const auto& spline = getSplineInvXforRow(row);
339 const char* g1buf = getSplineFlatBuffer(isc);
340 const char* g2buf = getGridX2FlatBuffer(spline, isc);
341
342 float dx = 0;
343 spline.interpolateAtUZeroCopy(g1buf, g2buf, getCorrectionDataInvX(sector, row), u, v, &dx);
344 if (CAMath::Abs(dx) > TPCFastSpaceChargeCorrection::kMaxCorrection) {
345 s = 0.f; // TODO: DR: Protect from FPEs, fix upstream and remove once guaranteed that it is fixed
346 }
347 dx = s * dx;
348 return dx;
349}
350
351GPUdi() void TPCFastTransformPOD::getCorrectionYZatRealYZ(int32_t sector, int32_t row, float realY, float realZ, float& y, float& z) const
352{
353 float u, v, s;
354 convRealLocalToGrid(sector, row, realY, realZ, u, v, s);
355 const auto& info = getRowInfo(row);
356 const int32_t isc = info.splineScenarioID;
357 const auto& spline = getSplineInvYZforRow(row);
358 const char* g1buf = getSplineFlatBuffer(isc);
359 const char* g2buf = getGridX2FlatBuffer(spline, isc);
360
361 float dyz[2];
362 spline.interpolateAtUZeroCopy(g1buf, g2buf, getCorrectionDataInvYZ(sector, row), u, v, dyz);
363 if (CAMath::Abs(dyz[0]) > TPCFastSpaceChargeCorrection::kMaxCorrection || CAMath::Abs(dyz[1]) > TPCFastSpaceChargeCorrection::kMaxCorrection) {
364 s = 0.f; // TODO: DR: Protect from FPEs, fix upstream and remove once guaranteed that it is fixed
365 }
366 y = s * dyz[0];
367 z = s * dyz[1];
368}
369
370GPUdi() void TPCFastTransformPOD::convLocalToGrid(int32_t sector, int32_t row, float y, float z, float& u, float& v, float& s) const
371{
374 const SplineType& spline = getSplineForRow(row);
375 getRowInfo(row).gridMeasured.convLocalToGridUntruncated(sector, y, z, u, v, s);
376 // shrink to the grid
377 u = GPUCommonMath::Clamp(u, 0.f, (float)spline.getGridX1().getUmax());
378 v = GPUCommonMath::Clamp(v, 0.f, (float)spline.getGridX2().getUmax());
379}
380
381GPUdi() void TPCFastTransformPOD::convGridToLocal(int32_t sector, int32_t row, float gridU, float gridV, float& y, float& z) const
382{
384 getRowInfo(row).gridMeasured.convGridToLocal(sector, gridU, gridV, y, z);
385}
386
387GPUdi() void TPCFastTransformPOD::convRealLocalToGrid(int32_t sector, int32_t row, float y, float z, float& u, float& v, float& s) const
388{
390 const SplineType& spline = getSplineForRow(row);
391 getRowInfo(row).gridReal.convLocalToGridUntruncated(sector, y, z, u, v, s);
392 // shrink to the grid
393 u = GPUCommonMath::Clamp(u, 0.f, (float)spline.getGridX1().getUmax());
394 v = GPUCommonMath::Clamp(v, 0.f, (float)spline.getGridX2().getUmax());
395}
396
397GPUdi() void TPCFastTransformPOD::convGridToRealLocal(int32_t sector, int32_t row, float gridU, float gridV, float& y, float& z) const
398{
400 getRowInfo(row).gridReal.convGridToLocal(sector, gridU, gridV, y, z);
401}
402
403GPUdi() bool TPCFastTransformPOD::isLocalInsideGrid(int32_t sector, int32_t row, float y, float z) const
404{
406 float u, v, s;
407 getRowInfo(row).gridMeasured.convLocalToGridUntruncated(sector, y, z, u, v, s);
408 const auto& spline = getSplineForRow(row);
409 // shrink to the grid
410 if (u < 0.f || u > (float)spline.getGridX1().getUmax() || //
411 v < 0.f || v > (float)spline.getGridX2().getUmax()) {
412 return false;
413 }
414 return true;
415}
416
417GPUdi() bool TPCFastTransformPOD::isRealLocalInsideGrid(int32_t sector, int32_t row, float y, float z) const
418{
420 float u, v, s;
421 getRowInfo(row).gridReal.convLocalToGridUntruncated(sector, y, z, u, v, s);
422 const auto& spline = getSplineForRow(row);
423 // shrink to the grid
424 if (u < 0.f || u > (float)spline.getGridX1().getUmax() || //
425 v < 0.f || v > (float)spline.getGridX2().getUmax()) {
426 return false;
427 }
428 return true;
429}
430
431GPUdi() void TPCFastTransformPOD::TransformLocal(int32_t sector, int32_t row, float& x, float& y, float& z) const
432{
433 if (!mApplyCorrection) {
434 return;
435 }
436 float dx, dy, dz;
437 getCorrectionLocal(sector, row, y, z, dx, dy, dz);
438
439 GPUCA_DEBUG_STREAMER_CHECK(if (o2::utils::DebugStreamer::checkStream(o2::utils::StreamFlags::streamFastTransform)) {
440 float lx = x, ly = y, lz = z;
441 float gx, gy, gz;
442 getGeometry().convLocalToGlobal(sector, lx, ly, lz, gx, gy, gz);
443 float lxT = lx + dx;
444 float lyT = ly + dy;
445 float lzT = lz + dz;
446 float invYZtoX;
447 InverseTransformYZtoX(sector, row, lyT, lzT, invYZtoX);
448
449 float YZtoNominalY;
450 float YZtoNominalZ;
451 InverseTransformYZtoNominalYZ(sector, row, lyT, lzT, YZtoNominalY, YZtoNominalZ);
452
453 o2::utils::DebugStreamer::instance()->getStreamer("debug_fasttransform", "UPDATE") << o2::utils::DebugStreamer::instance()->getUniqueTreeName("tree_Transform").data()
454 // corrections in x, u, v
455 << "dx=" << dx
456 << "dy=" << dy
457 << "dz=" << dz
458 << "row=" << row
459 << "sector=" << sector
460 // original local coordinates
461 << "ly=" << ly
462 << "lz=" << lz
463 << "lx=" << lx
464 // corrected local coordinated
465 << "lxT=" << lxT
466 << "lyT=" << lyT
467 << "lzT=" << lzT
468 // global uncorrected coordinates
469 << "gx=" << gx
470 << "gy=" << gy
471 << "gz=" << gz
472 // some transformations which are applied
473 << "invYZtoX=" << invYZtoX
474 << "YZtoNominalY=" << YZtoNominalY
475 << "YZtoNominalZ=" << YZtoNominalZ
476 << "\n";
477 })
478
479 x += dx;
480 y += dy;
481 z += dz;
482}
483
484GPUdi() void TPCFastTransformPOD::Transform(int32_t sector, int32_t row, float pad, float time, float& x, float& y, float& z, float vertexTime) const
485{
491
492 x = getGeometry().getRowInfoX(row);
493 convPadTimeToLocal(sector, row, pad, time, y, z, vertexTime);
494 TransformLocal(sector, row, x, y, z);
495}
496
497GPUdi() void TPCFastTransformPOD::TransformXYZ(int32_t sector, int32_t row, float& x, float& y, float& z) const
498{
499
500 TransformLocal(sector, row, x, y, z);
501}
502
503GPUdi() void TPCFastTransformPOD::TransformInTimeFrame(int32_t sector, float time, float& z, float maxTimeBin) const
504{
505 float l = (time - mT0 - maxTimeBin) * mVdrift; // drift length cm
506 z = getGeometry().convDriftLengthToZ(sector, l);
507}
508
509GPUdi() void TPCFastTransformPOD::TransformInTimeFrame(int32_t sector, int32_t row, float pad, float time, float& x, float& y, float& z, float maxTimeBin) const
510{
516
517 x = getGeometry().getRowInfoX(row);
518 convPadTimeToLocalInTimeFrame(sector, row, pad, time, y, z, maxTimeBin);
519}
520
521GPUdi() void TPCFastTransformPOD::InverseTransformInTimeFrame(int32_t sector, int32_t row, float /*x*/, float y, float z, float& pad, float& time, float maxTimeBin) const
522{
524 convLocalToPadTimeInTimeFrame(sector, row, y, z, pad, time, maxTimeBin);
525}
526
527GPUdi() float TPCFastTransformPOD::InverseTransformInTimeFrame(int32_t sector, float z, float maxTimeBin) const
528{
529 float pad, time;
530 InverseTransformInTimeFrame(sector, 0, 0, 0, z, pad, time, maxTimeBin);
531 return time;
532}
533
534GPUdi() void TPCFastTransformPOD::TransformIdealZ(int32_t sector, float time, float& z, float vertexTime) const
535{
542
543 float l = (time - mT0 - vertexTime) * mVdrift; // drift length cm
544 z = getGeometry().convDriftLengthToZ(sector, l);
545}
546
547GPUdi() void TPCFastTransformPOD::TransformIdeal(int32_t sector, int32_t row, float pad, float time, float& x, float& y, float& z, float vertexTime) const
548{
555
556 x = getGeometry().getRowInfoX(row);
557 float driftLength = (time - mT0 - vertexTime) * mVdrift; // drift length cm
558 getGeometry().convPadDriftLengthToLocal(sector, row, pad, driftLength, y, z);
559}
560
561GPUdi() float TPCFastTransformPOD::convTimeToZinTimeFrame(int32_t sector, float time, float maxTimeBin) const
562{
569
570 float v = (time - mT0 - maxTimeBin) * mVdrift; // drift length cm
571 float z = (sector < getGeometry().getNumberOfSectorsA()) ? -v : v;
572 return z;
573}
574
575GPUdi() float TPCFastTransformPOD::convZtoTimeInTimeFrame(int32_t sector, float z, float maxTimeBin) const
576{
578 float v = (sector < getGeometry().getNumberOfSectorsA()) ? -z : z;
579 return mT0 + maxTimeBin + v / mVdrift;
580}
581
582GPUdi() float TPCFastTransformPOD::convDeltaTimeToDeltaZinTimeFrame(int32_t sector, float deltaTime) const
583{
584 float deltaZ = deltaTime * mVdrift;
585 return sector < getGeometry().getNumberOfSectorsA() ? -deltaZ : deltaZ;
586}
587
588GPUdi() float TPCFastTransformPOD::convDeltaZtoDeltaTimeInTimeFrameAbs(float deltaZ) const
589{
590 return deltaZ / mVdrift;
591}
592
593GPUdi() float TPCFastTransformPOD::convDeltaZtoDeltaTimeInTimeFrame(int32_t sector, float deltaZ) const
594{
595 float deltaT = deltaZ / mVdrift;
596 return sector < getGeometry().getNumberOfSectorsA() ? -deltaT : deltaT;
597}
598
599GPUdi() float TPCFastTransformPOD::getMaxDriftTime(int32_t sector, int32_t row, float pad) const
600{
602 return convDriftLengthToTime(getGeometry().getTPCzLength(), 0.f);
603}
604
605GPUdi() float TPCFastTransformPOD::getMaxDriftTime(int32_t sector, int32_t row) const
606{
608 return convDriftLengthToTime(getGeometry().getTPCzLength(), 0.f);
609}
610
611GPUdi() float TPCFastTransformPOD::getMaxDriftTime(int32_t sector) const
612{
614 return convDriftLengthToTime(getGeometry().getTPCzLength(), 0.f);
615}
616
617GPUdi() void TPCFastTransformPOD::InverseTransformYZtoX(int32_t sector, int32_t row, float realY, float realZ, float& realX) const
618{
620 float dx = 0.f;
621 dx = getCorrectionXatRealYZ(sector, row, realY, realZ);
622 realX = getGeometry().getRowInfoX(row) + dx;
623
624 GPUCA_DEBUG_STREAMER_CHECK(if (o2::utils::DebugStreamer::checkStream(o2::utils::StreamFlags::streamFastTransform)) {
625 o2::utils::DebugStreamer::instance()->getStreamer("debug_fasttransform", "UPDATE") << o2::utils::DebugStreamer::instance()->getUniqueTreeName("tree_InverseTransformYZtoX").data()
626 << "sector=" << sector
627 << "row=" << row
628 << "y=" << realY
629 << "z=" << realZ
630 << "x=" << realX
631 << "\n";
632 })
633}
634
635GPUdi() void TPCFastTransformPOD::InverseTransformYZtoNominalYZ(int32_t sector, int32_t row, float realY, float realZ, float& measuredY, float& measuredZ) const
636{
638 float dy, dz;
639 getCorrectionYZatRealYZ(sector, row, realY, realZ, dy, dz);
640 measuredY = realY - dy;
641 measuredZ = realZ - dz;
642
643 GPUCA_DEBUG_STREAMER_CHECK(if (o2::utils::DebugStreamer::checkStream(o2::utils::StreamFlags::streamFastTransform)) {
644 o2::utils::DebugStreamer::instance()->getStreamer("debug_fasttransform", "UPDATE") << o2::utils::DebugStreamer::instance()->getUniqueTreeName("tree_InverseTransformYZtoNominalYZ").data()
645 << "sector=" << sector
646 << "row=" << row
647 << "real y=" << realY
648 << "real z=" << realZ
649 << "measured y=" << measuredY
650 << "measured z=" << measuredZ
651 << "\n";
652 })
653}
654
655GPUdi() void TPCFastTransformPOD::convPadTimeToLocal(int32_t sector, int32_t row, float pad, float time, float& y, float& z, float vertexTime) const
656{
657 float l = (time - mT0 - vertexTime) * mVdrift;
658 getGeometry().convPadDriftLengthToLocal(sector, row, pad, l, y, z);
659}
660
661GPUdi() void TPCFastTransformPOD::convPadTimeToLocalInTimeFrame(int32_t sector, int32_t row, float pad, float time, float& y, float& z, float maxTimeBin) const
662{
663 float l = getGeometry().getTPCzLength() + (time - mT0 - maxTimeBin) * mVdrift;
664 getGeometry().convPadDriftLengthToLocal(sector, row, pad, l, y, z);
665}
666
667GPUdi() void TPCFastTransformPOD::convLocalToPadTimeInTimeFrame(int32_t sector, int32_t row, float y, float z, float& pad, float& time, float maxTimeBin) const
668{
669 float length = 0;
670 getGeometry().convLocalToPadDriftLength(sector, row, y, z, pad, length);
671 time = convDriftLengthToTime(length, maxTimeBin);
672}
673
674GPUdi() float TPCFastTransformPOD::convDriftLengthToTime(float driftLength, float vertexTime) const
675{
676 return (mT0 + vertexTime + driftLength / mVdrift);
677}
678
679GPUdi() float TPCFastTransformPOD::convZOffsetToVertexTime(int32_t sector, float zOffset, float maxTimeBin) const
680{
681 if (sector < getGeometry().getNumberOfSectorsA()) {
682 return maxTimeBin - (getGeometry().getTPCzLength() + zOffset) / mVdrift;
683 } else {
684 return maxTimeBin - (getGeometry().getTPCzLength() - zOffset) / mVdrift;
685 }
686}
687
688GPUdi() float TPCFastTransformPOD::convVertexTimeToZOffset(int32_t sector, float vertexTime, float maxTimeBin) const
689{
690 if (sector < getGeometry().getNumberOfSectorsA()) {
691 return (maxTimeBin - vertexTime) * mVdrift - getGeometry().getTPCzLength();
692 } else {
693 return -((maxTimeBin - vertexTime) * mVdrift - getGeometry().getTPCzLength());
694 }
695}
696
697#ifndef GPUCA_GPUCODE_DEVICE // Functions not needed during GPU processing
698GPUdi() void TPCFastTransformPOD::setCalibration(int64_t timeStamp, float t0, float vDrift)
699{
700 mTimeStamp = timeStamp;
701 mT0 = t0;
702 mVdrift = vDrift;
703}
704
705GPUdi() void TPCFastTransformPOD::InverseTransformXYZtoNominalXYZ(int32_t sector, int32_t row, float x, float y, float z, float& nx, float& ny, float& nz) const
706{
708 int32_t row2 = row + 1;
709 if (row2 >= getGeometry().getNumberOfRows()) {
710 row2 = row - 1;
711 }
712 float nx1, ny1, nz1; // nominal coordinates for row
713 float nx2, ny2, nz2; // nominal coordinates for row2
714 nx1 = getGeometry().getRowInfoX(row);
715 nx2 = getGeometry().getRowInfoX(row2);
716 InverseTransformYZtoNominalYZ(sector, row, y, z, ny1, nz1);
717 InverseTransformYZtoNominalYZ(sector, row2, y, z, ny2, nz2);
718 float c1 = (nx2 - nx) / (nx2 - nx1);
719 float c2 = (nx - nx1) / (nx2 - nx1);
720 nx = x;
721 ny = (ny1 * c1 + ny2 * c2);
722 nz = (nz1 * c1 + nz2 * c2);
723}
724#endif // GPUCA_GPUCODE_DEVICE
725
726} // namespace o2::gpu
727
728#endif
int16_t time
Definition RawEventData.h:4
#define GPUCA_DEBUG_STREAMER_CHECK(...)
uint32_t res
Definition RawData.h:0
Version using constexpr GPUTPCGeometry to be used for TPCFastTransformationPOD.
Definition of TPCFastTransform class.
static constexpr size_t alignSize(size_t sizeBytes, size_t alignmentBytes)
_______________ Generic utilities _______________________________________________
Definition FlatObject.h:275
Forward declaration — specializations below select ClassDefNV based on FlatBase.
Definition Spline2D.h:104
Spline2D< float, 2, NoFlatObject > SlimSplineTypeInvYZ
Spline2D< float, 3, NoFlatObject > SlimSplineTypeXYZ
Slim variants (NoFlatObject base) for use in TPCFastTransformPOD.
Spline2D< float, 1, NoFlatObject > SlimSplineTypeInvX
static constexpr int32_t getNumberOfSectors()
_______________ Getters _________________________________
TPCFastSpaceChargeCorrection::SlimSplineTypeInvYZ SplineTypeInvYZ
static TPCFastTransformPOD * create(aligned_unique_buffer_ptr< TPCFastTransformPOD > &destVector, const TPCFastTransformPOD &src)
bool test(const TPCFastSpaceChargeCorrection &origCorr, int32_t npoints=100000) const
int32_t float float float float float float vertexTime
GPUd() RowInfo &getRowInfo(int32_t row)
Gives TPC sector & row info.
bool test(const TPCFastTransform &src, int32_t npoints=100000) const
GPUd() float getIDC() const
Return IDC estimator.
static TPCFastTransformPOD * create(aligned_unique_buffer_ptr< TPCFastTransformPOD > &destVector, const TPCFastTransform &src)
Create POD transform from old flat-buffer one. Provided vector will serve as a buffer.
GPUd() const RowInfo &getRowInfo(int32_t row) const
Gives TPC sector & row info.
GPUd() const TPCFastTransformGeoPOD &getGeometry() const
TPC geometry information.
GPUd() long int getTimeStamp() const
Gives the time stamp of the current calibaration parameters.
GPUd() float getVDrift() const
Return mVDrift in cm / time bin.
GPUd() void setLumi(float v)
Sets CTP Lumi estimator.
int32_t float float float float & v
GPUd() void setIDC(float v)
Sets IDC estimator.
GPUd() float getLumi() const
Return Lumi estimator.
void print() const
Print method.
int32_t float float float & u
int32_t float float float & ny
static GPUglobalconstexpr() int NROWS
GPUd() const float *getCorrectionData(int32_t sector
Gives pointer to spline data.
GPUd() void setVDrift(float v)
Sets current vdrift.
GPUd() static const TPCFastTransformPOD &get(const char *head)
convert prefilled buffer to TPCFastTransformPOD
void setApplyCorrectionOn()
_______________ methods a la TPCFastSpaceChargeCorrection: cluster correction _______________________
int32_t float float float &z const
GPUd() void Transform(int32_t sector
GPUd() float getT0() const
Return T0 in time bin units.
GPUd() void setCalibration(int64_t timeStamp
GPUd() void setT0(float v)
Sets current T0.
static size_t estimateSize(const TPCFastTransform &src)
int32_t float float float float & nx
GPUd() size_t size() const
Gives its own size including dynamic part.
TPCFastSpaceChargeCorrection::SlimSplineTypeInvX SplineTypeInvX
TPCFastSpaceChargeCorrection::RowInfo RowInfo
int32_t float float float & measuredY
GLint GLenum GLint x
Definition glcorearb.h:403
GLenum src
Definition glcorearb.h:1767
GLsizeiptr size
Definition glcorearb.h:659
const GLdouble * v
Definition glcorearb.h:832
GLint y
Definition glcorearb.h:270
GLuint GLsizei GLsizei * length
Definition glcorearb.h:790
typedef void(APIENTRYP PFNGLCULLFACEPROC)(GLenum mode)
GLuint GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat t0
Definition glcorearb.h:5034
GLdouble GLdouble GLdouble z
Definition glcorearb.h:843
constexpr unsigned int NROWS
Definition Clusterizer.h:32
GPUdi() o2
Definition TrackTRD.h:39
@ streamFastTransform
stream tpc fast transform
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
std::vector< int > row