Project
Loading...
Searching...
No Matches
TPCFastTransform.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_TPCFASTTRANSFORM_H
18#define ALICEO2_GPUCOMMON_TPCFASTTRANSFORMATION_TPCFASTTRANSFORM_H
19
20#include "GPUCommonDef.h"
21
22#include "FlatObject.h"
23#include "TPCFastTransformGeo.h"
25#include "GPUCommonMath.h"
26#include "GPUDebugStreamer.h"
27
28#if !defined(GPUCA_GPUCODE)
29#include <string>
30#endif // !GPUCA_GPUCODE
31
32namespace o2::tpc
33{
34template <class T>
35class SpaceCharge;
36}
37
38namespace o2::gpu
39{
40
43
44#if !defined(GPUCA_GPUCODE) && !defined(GPUCA_STANDALONE)
47
49 void getCorrections(const float gx, const float gy, const float gz, const int32_t sector, float& gdxC, float& gdyC, float& gdzC) const;
50
52#else
54
56 GPUdi() void getCorrections(const float gx, const float gy, const float gz, const int32_t sector, float& gdxC, float& gdyC, float& gdzC) const
57 {
58 gdxC = 0;
59 gdyC = 0;
60 gdzC = 0;
61 }
62#endif
63
65};
66
95
97{
98 public:
99 static GPUglobalconstexpr() float DEFLUMI = -1e6f; // default value to check if member was set
100 static GPUglobalconstexpr() float DEFIDC = -1e6f; // default value to check if member was set
101
103
106
109
112
113 inline void destroy()
114 {
115 mCorrection.destroy();
117 }
118
120#if !defined(GPUCA_GPUCODE)
122 {
123 delete mCorrectionSlow;
124 }
125#else
126 ~TPCFastTransform() = default;
127#endif
128
130
132
135
138
140
141 void cloneFromObject(const TPCFastTransform& obj, char* newFlatBufferPtr);
142
144
146 void moveBufferTo(char* newBufferPtr);
147
149
150 void setActualBufferAddress(char* actualFlatBufferPtr);
151 void setFutureBufferAddress(char* futureFlatBufferPtr);
152
154
156 void startConstruction(const TPCFastSpaceChargeCorrection& correction);
157
162 void setCalibration(int64_t timeStamp, float t0, float vDrift);
163
165 void setLumi(float l) { mLumi = l; }
166 void setLumiError(float e) { mLumiError = e; }
167 void setLumiScaleFactor(float s) { mLumiScaleFactor = s; }
168 void setIDC(float l) { mIDC = l; }
169 void setIDCError(float e) { mIDCError = e; }
170 void setCTP2IDCFallBackThreshold(float v) { mCTP2IDCFallBackThreshold = v; }
172 void setTimeStamp(int64_t v) { mTimeStamp = v; }
173
175 GPUdi() const TPCFastSpaceChargeCorrection& getCorrection() const { return mCorrection; }
176
179
181 void finishConstruction();
182
188 GPUd() void Transform(int32_t sector, int32_t row, float pad, float time, float& x, float& y, float& z, float vertexTime = 0, const TPCFastTransform* ref = nullptr, const TPCFastTransform* ref2 = nullptr, float scale = 0.f, float scale2 = 0.f, int32_t scaleMode = 0) const;
189 GPUd() void TransformXYZ(int32_t sector, int32_t row, float& x, float& y, float& z, const TPCFastTransform* ref = nullptr, const TPCFastTransform* ref2 = nullptr, float scale = 0.f, float scale2 = 0.f, int32_t scaleMode = 0) const;
190
192 GPUd() void TransformInTimeFrame(int32_t sector, int32_t row, float pad, float time, float& x, float& y, float& z, float maxTimeBin) const;
193 GPUd() void TransformInTimeFrame(int32_t sector, float time, float& z, float maxTimeBin) const;
194
196 GPUd() void InverseTransformInTimeFrame(int32_t sector, int32_t row, float /*x*/, float y, float z, float& pad, float& time, float maxTimeBin) const;
197 GPUd() float InverseTransformInTimeFrame(int32_t sector, float z, float maxTimeBin) const;
198
200 GPUd() void InverseTransformYZtoX(int32_t sector, int32_t row, float y, float z, float& x, const TPCFastTransform* ref = nullptr, const TPCFastTransform* ref2 = nullptr, float scale = 0.f, float scale2 = 0.f, int32_t scaleMode = 0) const;
201
203 GPUd() void InverseTransformYZtoNominalYZ(int32_t sector, int32_t row, float y, float z, float& ny, float& nz, const TPCFastTransform* ref = nullptr, const TPCFastTransform* ref2 = nullptr, float scale = 0.f, float scale2 = 0.f, int32_t scaleMode = 0) const;
204
206 GPUd() void InverseTransformXYZtoNominalXYZ(int32_t sector, int32_t row, float x, float y, float z, float& nx, float& ny, float& nz, const TPCFastTransform* ref = nullptr, const TPCFastTransform* ref2 = nullptr, float scale = 0.f, float scale2 = 0.f, int32_t scaleMode = 0) const;
207
209 GPUd() void TransformIdeal(int32_t sector, int32_t row, float pad, float time, float& x, float& y, float& z, float vertexTime) const;
210 GPUd() void TransformIdealZ(int32_t sector, float time, float& z, float vertexTime) const;
211
212 GPUd() void convPadTimeToLocal(int32_t sector, int32_t row, float pad, float time, float& y, float& z, float vertexTime) const;
213 GPUd() void convPadTimeToLocalInTimeFrame(int32_t sector, int32_t row, float pad, float time, float& y, float& z, float maxTimeBin) const;
214
215 GPUd() void convLocalToPadTime(int32_t sector, int32_t row, float y, float z, float& pad, float& time, float vertexTime) const;
216 GPUd() void convLocalToPadTimeInTimeFrame(int32_t sector, int32_t row, float y, float z, float& pad, float& time, float maxTimeBin) const;
217
218 GPUd() float convTimeToZinTimeFrame(int32_t sector, float time, float maxTimeBin) const;
219 GPUd() float convZtoTimeInTimeFrame(int32_t sector, float z, float maxTimeBin) const;
220 GPUd() float convDeltaTimeToDeltaZinTimeFrame(int32_t sector, float deltaTime) const;
221 GPUd() float convDeltaZtoDeltaTimeInTimeFrame(int32_t sector, float deltaZ) const;
222 GPUd() float convDeltaZtoDeltaTimeInTimeFrameAbs(float deltaZ) const;
223 GPUd() float convZOffsetToVertexTime(int32_t sector, float zOffset, float maxTimeBin) const;
224 GPUd() float convVertexTimeToZOffset(int32_t sector, float vertexTime, float maxTimeBin) const;
225
226 void setApplyCorrectionOn() { mApplyCorrection = 1; }
227 void setApplyCorrectionOff() { mApplyCorrection = 0; }
228 bool isCorrectionApplied() { return mApplyCorrection; }
229
231
233 GPUdi() const TPCFastTransformGeo& getGeometry() const { return mCorrection.getGeometry(); }
234
236 GPUdi() int64_t getTimeStamp() const { return mTimeStamp; }
237
239 GPUdi() float getVDrift() const { return mVdrift; }
240
242 GPUdi() float getT0() const { return mT0; }
243
245 GPUdi() float getLumi() const { return mLumi; }
246
247 GPUdi() float isLumiSet() const { return mLumi != DEFLUMI; }
248
250 GPUdi() float getLumiError() const { return mLumiError; }
251
253 GPUd() float getIDC() const;
254
255 GPUdi() bool isIDCSet() const { return mIDC != DEFIDC; }
256
258 GPUdi() float getIDCError() const { return mIDCError; }
259
260 GPUdi() float getCTP2IDCFallBackThreshold() const { return mCTP2IDCFallBackThreshold; }
261
263 GPUdi() float getLumiScaleFactor() const { return mLumiScaleFactor; }
264
266 GPUd() float getMaxDriftTime(int32_t sector, int32_t row, float pad) const;
267
269 GPUd() float getMaxDriftTime(int32_t sector, int32_t row) const;
270
272 GPUd() float getMaxDriftTime(int32_t sector) const;
273
274#if !defined(GPUCA_GPUCODE) && !defined(GPUCA_STANDALONE)
275
276 int32_t writeToFile(std::string outFName = "", std::string name = "");
277
279
280 static TPCFastTransform* loadFromFile(std::string inpFName = "", std::string name = "");
281
283 void setSlowTPCSCCorrection(TFile& inpf);
284
286 const auto& getCorrectionSlow() const { return *mCorrectionSlow; }
287
288#endif // !GPUCA_GPUCODE
289
291 void print() const;
292
293 GPUd() float convDriftLengthToTime(float driftLength, float vertexTime) const;
294
295 private:
297 enum ConstructionExtraState : uint32_t {
298 CalibrationIsSet = 0x4
299 };
300
302
304
306
307 int64_t mTimeStamp;
308
315
316 bool mApplyCorrection; // flag for applying correction
317
324 float mT0;
325 float mVdrift;
326
327 float mLumi;
328 float mLumiError;
329 float mLumiScaleFactor;
330
331 float mIDC;
332 float mIDCError;
333 float mCTP2IDCFallBackThreshold;
334
336 TPCSlowSpaceChargeCorrection* mCorrectionSlow{nullptr};
337
338 GPUd() void TransformLocal(int32_t sector, int32_t row, float& x, float& y, float& z, const TPCFastTransform* ref, const TPCFastTransform* ref2, float scale, float scale2, int32_t scaleMode) const;
339
340 ClassDefNV(TPCFastTransform, 5);
341};
342
343// =======================================================================
344// Inline implementations of some methods
345// =======================================================================
346
347// ----------------------------------------------------------------------
348
349GPUdi() void TPCFastTransform::convPadTimeToLocal(int32_t sector, int32_t row, float pad, float time, float& y, float& z, float vertexTime) const
350{
351 float l = (time - mT0 - vertexTime) * mVdrift; // drift length [cm]
352 getGeometry().convPadDriftLengthToLocal(sector, row, pad, l, y, z);
353}
354
355GPUdi() void TPCFastTransform::convPadTimeToLocalInTimeFrame(int32_t sector, int32_t row, float pad, float time, float& y, float& z, float maxTimeBin) const
356{
357 float l = getGeometry().getTPCzLength() + (time - mT0 - maxTimeBin) * mVdrift; // drift length [cm]
358 getGeometry().convPadDriftLengthToLocal(sector, row, pad, l, y, z);
359}
360
361// ----------------------------------------------------------------------
362
363GPUdi() float TPCFastTransform::convZOffsetToVertexTime(int32_t sector, float zOffset, float maxTimeBin) const
364{
365 if (sector < getGeometry().getNumberOfSectorsA()) {
366 return maxTimeBin - (getGeometry().getTPCzLength() + zOffset) / mVdrift;
367 } else {
368 return maxTimeBin - (getGeometry().getTPCzLength() - zOffset) / mVdrift;
369 }
370}
371
372GPUdi() float TPCFastTransform::convVertexTimeToZOffset(int32_t sector, float vertexTime, float maxTimeBin) const
373{
374 if (sector < getGeometry().getNumberOfSectorsA()) {
375 return (maxTimeBin - vertexTime) * mVdrift - getGeometry().getTPCzLength();
376 } else {
377 return -((maxTimeBin - vertexTime) * mVdrift - getGeometry().getTPCzLength());
378 }
379}
380
381GPUdi() float TPCFastTransform::convDriftLengthToTime(float driftLength, float vertexTime) const
382{
383 return (mT0 + vertexTime + driftLength / mVdrift);
384}
385
386// ----------------------------------------------------------------------
387
388GPUdi() void TPCFastTransform::convLocalToPadTime(int32_t sector, int32_t row, float y, float z, float& pad, float& time, float vertexTime) const
389{
390 float l;
391 getGeometry().convLocalToPadDriftLength(sector, row, y, z, pad, l);
392 time = convDriftLengthToTime(l, vertexTime);
393}
394
395GPUdi() void TPCFastTransform::convLocalToPadTimeInTimeFrame(int32_t sector, int32_t row, float y, float z, float& pad, float& time, float maxTimeBin) const
396{
397 float l;
398 getGeometry().convLocalToPadDriftLength(sector, row, y, z, pad, l);
399 time = convDriftLengthToTime(l, maxTimeBin);
400}
401
402// ----------------------------------------------------------------------
403
404GPUdi() void TPCFastTransform::TransformLocal(int32_t sector, int32_t row, float& x, float& y, float& z, const TPCFastTransform* ref, const TPCFastTransform* ref2, float scale, float scale2, int32_t scaleMode) const
405{
406 GPUCA_RTC_SPECIAL_CODE(ref2 = nullptr; scale2 = 0.f;);
407
408 if (!mApplyCorrection) {
409 return;
410 }
411
412 float dx = 0.f, dy = 0.f, dz = 0.f;
413
414 if ((scale >= 0.f) || (scaleMode == 1) || (scaleMode == 2)) {
415#ifndef GPUCA_GPUCODE
416 if (mCorrectionSlow) {
417 float gx, gy, gz;
418 getGeometry().convLocalToGlobal(sector, x, y, z, gx, gy, gz);
419 float gdxC, gdyC, gdzC;
420 mCorrectionSlow->getCorrections(gx, gy, gz, sector, gdxC, gdyC, gdzC);
421 getGeometry().convGlobalToLocal(sector, gdxC, gdyC, gdzC, dx, dy, dz);
422 } else
423#endif // GPUCA_GPUCODE
424 {
425 mCorrection.getCorrectionLocal(sector, row, y, z, dx, dy, dz);
426 if (ref) {
427 if ((scale > 0.f) && (scaleMode == 0)) { // scaling was requested
428 float dx1, dy1, dz1;
429 ref->mCorrection.getCorrectionLocal(sector, row, y, z, dx1, dy1, dz1);
430 dx = (dx - dx1) * scale + dx1;
431 dy = (dy - dy1) * scale + dy1;
432 dz = (dz - dz1) * scale + dz1;
433 } else if ((scale != 0.f) && ((scaleMode == 1) || (scaleMode == 2))) {
434 float dx1, dy1, dz1;
435 ref->mCorrection.getCorrectionLocal(sector, row, y, z, dx1, dy1, dz1);
436 dx = dx1 * scale + dx;
437 dy = dy1 * scale + dy;
438 dz = dz1 * scale + dz;
439 }
440 }
441 if (ref2 && (scale2 != 0)) {
442 float dx1, dy1, dz1;
443 ref2->mCorrection.getCorrectionLocal(sector, row, y, z, dx1, dy1, dz1);
444 dx = dx1 * scale2 + dx;
445 dy = dy1 * scale2 + dy;
446 dz = dz1 * scale2 + dz;
447 }
448 }
449 }
450
451 GPUCA_DEBUG_STREAMER_CHECK(if (o2::utils::DebugStreamer::checkStream(o2::utils::StreamFlags::streamFastTransform)) {
452 float lx = x, ly = y, lz = z;
453
454 float gx, gy, gz;
455 getGeometry().convLocalToGlobal(sector, lx, ly, lz, gx, gy, gz);
456
457 float lxT = lx + dx;
458 float lyT = ly + dy;
459 float lzT = lz + dz;
460
461 float invYZtoXScaled;
462 InverseTransformYZtoX(sector, row, lyT, lzT, invYZtoXScaled, ref, ref2, scale, scale2, scaleMode);
463
464 float invYZtoX;
465 InverseTransformYZtoX(sector, row, lyT, lzT, invYZtoX);
466
467 float YZtoNominalY;
468 float YZtoNominalZ;
469 InverseTransformYZtoNominalYZ(sector, row, lyT, lzT, YZtoNominalY, YZtoNominalZ);
470
471 float YZtoNominalYScaled;
472 float YZtoNominalZScaled;
473 InverseTransformYZtoNominalYZ(sector, row, lyT, lzT, YZtoNominalYScaled, YZtoNominalZScaled, ref, ref2, scale, scale2, scaleMode);
474
475 float dxRef = 0.f, dyRef = 0.f, dzRef = 0.f;
476 if (ref) {
477 ref->mCorrection.getCorrectionLocal(sector, row, y, z, dxRef, dyRef, dzRef);
478 }
479
480 float dxRef2 = 0.f, dyRef2 = 0.f, dzRef2 = 0.f;
481 if (ref2) {
482 ref2->mCorrection.getCorrectionLocal(sector, row, y, z, dxRef2, dyRef2, dzRef2);
483 }
484
485 float dxOrig, dyOrig, dzOrig;
486 mCorrection.getCorrectionLocal(sector, row, y, z, dxOrig, dyOrig, dzOrig);
487
488 o2::utils::DebugStreamer::instance()->getStreamer("debug_fasttransform", "UPDATE") << o2::utils::DebugStreamer::instance()->getUniqueTreeName("tree_Transform").data()
489 // corrections in x, u, v
490 << "dxOrig=" << dxOrig
491 << "dyOrig=" << dyOrig
492 << "dzOrig=" << dzOrig
493 << "dxRef=" << dxRef
494 << "dyRef=" << dyRef
495 << "dzRef=" << dzRef
496 << "dxRef2=" << dxRef2
497 << "dyRef2=" << dyRef2
498 << "dzRef2=" << dzRef2
499 << "dx=" << dx
500 << "dy=" << dy
501 << "dz=" << dz
502 << "row=" << row
503 << "sector=" << sector
504 << "scale=" << scale
505 << "scale2=" << scale2
506 // original local coordinates
507 << "ly=" << ly
508 << "lz=" << lz
509 << "lx=" << lx
510 // corrected local coordinated
511 << "lxT=" << lxT
512 << "lyT=" << lyT
513 << "lzT=" << lzT
514 // global uncorrected coordinates
515 << "gx=" << gx
516 << "gy=" << gy
517 << "gz=" << gz
518 // some transformations which are applied
519 << "invYZtoX=" << invYZtoX
520 << "invYZtoXScaled=" << invYZtoXScaled
521 << "YZtoNominalY=" << YZtoNominalY
522 << "YZtoNominalYScaled=" << YZtoNominalYScaled
523 << "YZtoNominalZ=" << YZtoNominalZ
524 << "YZtoNominalZScaled=" << YZtoNominalZScaled
525 << "scaleMode=" << scaleMode
526 << "\n";
527 })
528
529 x += dx;
530 y += dy;
531 z += dz;
532}
533
534GPUdi() void TPCFastTransform::TransformXYZ(int32_t sector, int32_t row, float& x, float& y, float& z, const TPCFastTransform* ref, const TPCFastTransform* ref2, float scale, float scale2, int32_t scaleMode) const
535{
536
537 TransformLocal(sector, row, x, y, z, ref, ref2, scale, scale2, scaleMode);
538}
539
540GPUdi() void TPCFastTransform::Transform(int32_t sector, int32_t row, float pad, float time, float& x, float& y, float& z, float vertexTime, const TPCFastTransform* ref, const TPCFastTransform* ref2, float scale, float scale2, int32_t scaleMode) const
541{
547
548 const TPCFastTransformGeo::RowInfo& rowInfo = getGeometry().getRowInfo(row);
549
550 x = rowInfo.x;
551 convPadTimeToLocal(sector, row, pad, time, y, z, vertexTime);
552 TransformLocal(sector, row, x, y, z, ref, ref2, scale, scale2, scaleMode);
553}
554
555GPUdi() void TPCFastTransform::TransformInTimeFrame(int32_t sector, float time, float& z, float maxTimeBin) const
556{
557 float l = (time - mT0 - maxTimeBin) * mVdrift; // drift length cm
558 z = getGeometry().convDriftLengthToZ(sector, l);
559}
560
561GPUdi() void TPCFastTransform::TransformInTimeFrame(int32_t sector, int32_t row, float pad, float time, float& x, float& y, float& z, float maxTimeBin) const
562{
568
569 const TPCFastTransformGeo::RowInfo& rowInfo = getGeometry().getRowInfo(row);
570 x = rowInfo.x;
571 convPadTimeToLocalInTimeFrame(sector, row, pad, time, y, z, maxTimeBin);
572}
573
574GPUdi() void TPCFastTransform::InverseTransformInTimeFrame(int32_t sector, int32_t row, float /*x*/, float y, float z, float& pad, float& time, float maxTimeBin) const
575{
577 convLocalToPadTimeInTimeFrame(sector, row, y, z, pad, time, maxTimeBin);
578}
579
580GPUdi() float TPCFastTransform::InverseTransformInTimeFrame(int32_t sector, float z, float maxTimeBin) const
581{
582 float pad, time;
583 InverseTransformInTimeFrame(sector, 0, 0, 0, z, pad, time, maxTimeBin);
584 return time;
585}
586
587GPUdi() void TPCFastTransform::TransformIdealZ(int32_t sector, float time, float& z, float vertexTime) const
588{
595
596 float l = (time - mT0 - vertexTime) * mVdrift; // drift length cm
597 z = getGeometry().convDriftLengthToZ(sector, l);
598}
599
600GPUdi() void TPCFastTransform::TransformIdeal(int32_t sector, int32_t row, float pad, float time, float& x, float& y, float& z, float vertexTime) const
601{
608
609 x = getGeometry().getRowInfo(row).x;
610 float driftLength = (time - mT0 - vertexTime) * mVdrift; // drift length cm
611 getGeometry().convPadDriftLengthToLocal(sector, row, pad, driftLength, y, z);
612}
613
614GPUdi() float TPCFastTransform::convTimeToZinTimeFrame(int32_t sector, float time, float maxTimeBin) const
615{
622
623 float v = (time - mT0 - maxTimeBin) * mVdrift; // drift length cm
624 float z = (sector < getGeometry().getNumberOfSectorsA()) ? -v : v;
625 return z;
626}
627
628GPUdi() float TPCFastTransform::convZtoTimeInTimeFrame(int32_t sector, float z, float maxTimeBin) const
629{
631 float v = (sector < getGeometry().getNumberOfSectorsA()) ? -z : z;
632 return mT0 + maxTimeBin + v / mVdrift;
633}
634
635GPUdi() float TPCFastTransform::convDeltaTimeToDeltaZinTimeFrame(int32_t sector, float deltaTime) const
636{
637 float deltaZ = deltaTime * mVdrift;
638 return sector < getGeometry().getNumberOfSectorsA() ? -deltaZ : deltaZ;
639}
640
641GPUdi() float TPCFastTransform::convDeltaZtoDeltaTimeInTimeFrameAbs(float deltaZ) const
642{
643 return deltaZ / mVdrift;
644}
645
646GPUdi() float TPCFastTransform::convDeltaZtoDeltaTimeInTimeFrame(int32_t sector, float deltaZ) const
647{
648 float deltaT = deltaZ / mVdrift;
649 return sector < getGeometry().getNumberOfSectorsA() ? -deltaT : deltaT;
650}
651
652GPUdi() float TPCFastTransform::getMaxDriftTime(int32_t sector, int32_t row, float pad) const
653{
655 return convDriftLengthToTime(getGeometry().getTPCzLength(), 0.f);
656}
657
658GPUdi() float TPCFastTransform::getMaxDriftTime(int32_t sector, int32_t row) const
659{
661 return convDriftLengthToTime(getGeometry().getTPCzLength(), 0.f);
662}
663
664GPUdi() float TPCFastTransform::getMaxDriftTime(int32_t sector) const
665{
667 return convDriftLengthToTime(getGeometry().getTPCzLength(), 0.f);
668}
669
670GPUdi() void TPCFastTransform::InverseTransformYZtoX(int32_t sector, int32_t row, float realY, float realZ, float& realX, const TPCFastTransform* ref, const TPCFastTransform* ref2, float scale, float scale2, int32_t scaleMode) const
671{
672 GPUCA_RTC_SPECIAL_CODE(ref2 = nullptr; scale2 = 0.f;);
674
675 float dx = 0.f;
676
677 if ((scale >= 0.f) || (scaleMode == 1) || (scaleMode == 2)) {
678 dx = mCorrection.getCorrectionXatRealYZ(sector, row, realY, realZ);
679 if (ref) { // scaling was requested
680 if (scaleMode == 0 && scale > 0.f) {
681 float dxref = ref->mCorrection.getCorrectionXatRealYZ(sector, row, realY, realZ);
682 dx = (dx - dxref) * scale + dxref;
683 } else if ((scale != 0) && ((scaleMode == 1) || (scaleMode == 2))) {
684 float dxref = ref->mCorrection.getCorrectionXatRealYZ(sector, row, realY, realZ);
685 dx = dxref * scale + dx;
686 }
687 }
688 if (ref2 && (scale2 != 0)) {
689 float dxref = ref2->mCorrection.getCorrectionXatRealYZ(sector, row, realY, realZ);
690 dx = dxref * scale2 + dx;
691 }
692 }
693
694 realX = mCorrection.getGeometry().getRowInfo(row).x + dx;
695
696 GPUCA_DEBUG_STREAMER_CHECK(if (o2::utils::DebugStreamer::checkStream(o2::utils::StreamFlags::streamFastTransform)) {
697 o2::utils::DebugStreamer::instance()->getStreamer("debug_fasttransform", "UPDATE") << o2::utils::DebugStreamer::instance()->getUniqueTreeName("tree_InverseTransformYZtoX").data()
698 << "sector=" << sector
699 << "row=" << row
700 << "scale=" << scale
701 << "y=" << realY
702 << "z=" << realZ
703 << "x=" << realX
704 << "\n";
705 })
706}
707
708GPUdi() void TPCFastTransform::InverseTransformYZtoNominalYZ(int32_t sector, int32_t row, float realY, float realZ, float& measuredY, float& measuredZ, const TPCFastTransform* ref, const TPCFastTransform* ref2, float scale, float scale2, int32_t scaleMode) const
709{
711
712 GPUCA_RTC_SPECIAL_CODE(ref2 = nullptr; scale2 = 0.f;);
713
714 float dy = 0;
715 float dz = 0;
716
717 if ((scale >= 0.f) || (scaleMode == 1) || (scaleMode == 2)) {
718 mCorrection.getCorrectionYZatRealYZ(sector, row, realY, realZ, dy, dz);
719
720 if (ref) { // scaling was requested
721 if (scaleMode == 0 && scale > 0.f) {
722 float dy1, dz1;
723 ref->mCorrection.getCorrectionYZatRealYZ(sector, row, realY, realZ, dy1, dz1);
724 dy = (dy - dy1) * scale + dy1;
725 dz = (dz - dz1) * scale + dz1;
726 } else if ((scale != 0) && ((scaleMode == 1) || (scaleMode == 2))) {
727 float dy1, dz1;
728 ref->mCorrection.getCorrectionYZatRealYZ(sector, row, realY, realZ, dy1, dz1);
729 dy = dy1 * scale + dy;
730 dz = dz1 * scale + dz;
731 }
732 if (ref2 && (scale2 != 0)) {
733 float dy1, dz1;
734 ref2->mCorrection.getCorrectionYZatRealYZ(sector, row, realY, realZ, dy1, dz1);
735 dy = dy1 * scale2 + dy;
736 dz = dz1 * scale2 + dz;
737 }
738 }
739 }
740
741 measuredY = realY - dy;
742 measuredZ = realZ - dz;
743
744 GPUCA_DEBUG_STREAMER_CHECK(if (o2::utils::DebugStreamer::checkStream(o2::utils::StreamFlags::streamFastTransform)) {
745 o2::utils::DebugStreamer::instance()->getStreamer("debug_fasttransform", "UPDATE") << o2::utils::DebugStreamer::instance()->getUniqueTreeName("tree_InverseTransformYZtoNominalYZ").data()
746 << "sector=" << sector
747 << "row=" << row
748 << "scale=" << scale
749 << "real y=" << realY
750 << "real z=" << realZ
751 << "measured y=" << measuredY
752 << "measured z=" << measuredZ
753 << "\n";
754 })
755}
756
757GPUdi() void TPCFastTransform::InverseTransformXYZtoNominalXYZ(int32_t sector, int32_t row, float x, float y, float z, float& nx, float& ny, float& nz, const TPCFastTransform* ref, const TPCFastTransform* ref2, float scale, float scale2, int32_t scaleMode) const
758{
760 int32_t row2 = row + 1;
761 if (row2 >= getGeometry().getNumberOfRows()) {
762 row2 = row - 1;
763 }
764 float nx1, ny1, nz1; // nominal coordinates for row
765 float nx2, ny2, nz2; // nominal coordinates for row2
766 nx1 = getGeometry().getRowInfo(row).x;
767 nx2 = getGeometry().getRowInfo(row2).x;
768 InverseTransformYZtoNominalYZ(sector, row, y, z, ny1, nz1, ref, ref2, scale, scale2, scaleMode);
769 InverseTransformYZtoNominalYZ(sector, row2, y, z, ny2, nz2, ref, ref2, scale, scale2, scaleMode);
770 float c1 = (nx2 - nx) / (nx2 - nx1);
771 float c2 = (nx - nx1) / (nx2 - nx1);
772 nx = x;
773 ny = (ny1 * c1 + ny2 * c2);
774 nz = (nz1 * c1 + nz2 * c2);
775}
776
777} // namespace o2::gpu
778
779#endif
Definition of FlatObject class.
#define GPUCA_DEBUG_STREAMER_CHECK(...)
#define GPUCA_RTC_SPECIAL_CODE(...)
Definition of TPCFastSpaceChargeCorrection class.
Definition of TPCFastTransformGeo class.
char * releaseInternalBuffer()
_____________ Methods for making the data buffer external __________________________
Definition FlatObject.h:538
void destroy()
_______________ Utilities _______________________________________________
Definition FlatObject.h:361
void startConstruction()
_____________ Construction _________
Definition FlatObject.h:354
static constexpr size_t getBufferAlignmentBytes()
_____________ FlatObject functionality, see FlatObject class for description ____________
Definition FlatObject.h:195
static constexpr size_t getClassAlignmentBytes()
GPUCA_GPUCODE.
Definition FlatObject.h:192
void setActualBufferAddress(char *actualFlatBufferPtr)
Moving the class with its external buffer to another location.
int32_t float float float float float float maxTimeBin const
GPUdi() float getVDrift() const
Return mVDrift in cm / time bin.
GPUdi() const TPCFastTransformGeo &getGeometry() const
_______________ Utilities _______________________________________________
int32_t float float float float float float const TPCFastTransform const TPCFastTransform float float int32_t scaleMode
void setLumi(float l)
Set Lumi info.
GPUdi() float getLumi() const
Return map lumi.
void finishConstruction()
Finishes initialization: puts everything to the flat buffer, releases temporary memory.
void moveBufferTo(char *newBufferPtr)
GPUd() float getIDC() const
Return map lumi.
void setTimeStamp(int64_t v)
Sets the time stamp of the current calibaration.
void cloneFromObject(const TPCFastTransform &obj, char *newFlatBufferPtr)
Construction interface.
static constexpr size_t getBufferAlignmentBytes()
Gives minimal alignment in bytes required for the flat buffer.
int32_t writeToFile(std::string outFName="", std::string name="")
void setCTP2IDCFallBackThreshold(float v)
GPUdi() float getCTP2IDCFallBackThreshold() const
int32_t float float float float float & z
int32_t float float float float float float vertexTime
int32_t float float float float float float const TPCFastTransform const TPCFastTransform float scale
void setSlowTPCSCCorrection(TFile &inpf)
setting the reference corrections
GPUdi() const TPCFastSpaceChargeCorrection &getCorrection() const
Gives a reference for external initialization of TPC corrections.
static constexpr size_t getClassAlignmentBytes()
_____________ FlatObject functionality, see FlatObject class for description ____________
static GPUglobalconstexpr() float DEFLUMI
TPCFastSpaceChargeCorrection & getCorrection()
Gives a reference for external initialization of TPC corrections.
int32_t float float float float & y
int32_t float float float float & nz
void setCalibration(int64_t timeStamp, float t0, float vDrift)
GPUdi() float getIDCError() const
Return map lumi error.
TPCFastTransform()
_____________ Constructors / destructors __________________________
static TPCFastTransform * loadFromFile(std::string inpFName="", std::string name="")
GPUdi() float isLumiSet() const
int32_t float float float & x
void setFutureBufferAddress(char *futureFlatBufferPtr)
int32_t float float float float float float const TPCFastTransform const TPCFastTransform float float scale2
int32_t float float float float float float const TPCFastTransform const TPCFastTransform * ref2
void print() const
Print method.
int32_t float float float & ny
GPUdi() float getT0() const
Return T0 in time bin units.
GPUdi() int64_t getTimeStamp() const
Gives the time stamp of the current calibaration parameters.
const auto & getCorrectionSlow() const
GPUdi() float getLumiScaleFactor() const
Return map user defined lumi scale factor.
GPUd() void Transform(int32_t sector
GPUdi() float getLumiError() const
Return map lumi error.
int32_t float float float float & nx
GLint GLenum GLint x
Definition glcorearb.h:403
const GLdouble * v
Definition glcorearb.h:832
GLuint const GLchar * name
Definition glcorearb.h:781
GLdouble f
Definition glcorearb.h:310
GLint y
Definition glcorearb.h:270
typedef void(APIENTRYP PFNGLCULLFACEPROC)(GLenum mode)
GLuint GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat t0
Definition glcorearb.h:5034
GLint ref
Definition glcorearb.h:291
GLdouble GLdouble GLdouble z
Definition glcorearb.h:843
GPUdi() o2
Definition TrackTRD.h:39
const float dx1
Definition MathUtils.h:56
const float dy1
Definition MathUtils.h:56
Global TPC definitions and constants.
Definition SimTraits.h:172
@ streamFastTransform
stream tpc fast transform
simple struct to hold the space charge object which can be used for CPU reconstruction only
ClassDefNV(TPCSlowSpaceChargeCorrection, 2)
void getCorrections(const float gx, const float gy, const float gz, const int32_t sector, float &gdxC, float &gdyC, float &gdzC) const
getting the corrections for global coordinates
o2::tpc::SpaceCharge< float > * mCorr
reference space charge corrections