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 "FlatObject.h"
21#include "TPCFastTransformGeo.h"
23#include "GPUCommonMath.h"
24#include "GPUDebugStreamer.h"
25
26#if !defined(GPUCA_GPUCODE)
27#include <string>
28#endif // !GPUCA_GPUCODE
29
30namespace o2::tpc
31{
32template <class T>
33class SpaceCharge;
34}
35
36namespace o2::gpu
37{
38
41
42#if !defined(GPUCA_GPUCODE) && !defined(GPUCA_STANDALONE)
45
47 void getCorrections(const float gx, const float gy, const float gz, const int32_t sector, float& gdxC, float& gdyC, float& gdzC) const;
48
50#else
52
54 GPUdi() void getCorrections(const float gx, const float gy, const float gz, const int32_t sector, float& gdxC, float& gdyC, float& gdzC) const
55 {
56 gdxC = 0;
57 gdyC = 0;
58 gdzC = 0;
59 }
60#endif
61
63};
64
93
95{
96 public:
97 static constexpr float DEFLUMI = -1e6f; // default value to check if member was set
98 static constexpr float DEFIDC = -1e6f; // default value to check if member was set
99
101
104
107
110
111 inline void destroy()
112 {
113 mCorrection.destroy();
115 }
116
118#if !defined(GPUCA_GPUCODE)
120 {
121 delete mCorrectionSlow;
122 }
123#else
124 ~TPCFastTransform() = default;
125#endif
126
128
130
133
136
138
139 void cloneFromObject(const TPCFastTransform& obj, char* newFlatBufferPtr);
140
142
144 void moveBufferTo(char* newBufferPtr);
145
147
148 void setActualBufferAddress(char* actualFlatBufferPtr);
149 void setFutureBufferAddress(char* futureFlatBufferPtr);
150
152
154 void startConstruction(const TPCFastSpaceChargeCorrection& correction);
155
160 void setCalibration(int64_t timeStamp, float t0, float vDrift);
161
163 void setLumi(float l) { mLumi = l; }
164 void setLumiError(float e) { mLumiError = e; }
165 void setLumiScaleFactor(float s) { mLumiScaleFactor = s; }
166 void setIDC(float l) { mIDC = l; }
167 void setIDCError(float e) { mIDCError = e; }
168 void setCTP2IDCFallBackThreshold(float v) { mCTP2IDCFallBackThreshold = v; }
170 void setTimeStamp(int64_t v) { mTimeStamp = v; }
171
173 GPUdi() const TPCFastSpaceChargeCorrection& getCorrection() const { return mCorrection; }
174
177
179 void finishConstruction();
180
186 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;
187 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;
188
190 GPUd() void TransformInTimeFrame(int32_t sector, int32_t row, float pad, float time, float& x, float& y, float& z, float maxTimeBin) const;
191 GPUd() void TransformInTimeFrame(int32_t sector, float time, float& z, float maxTimeBin) const;
192
194 GPUd() void InverseTransformInTimeFrame(int32_t sector, int32_t row, float /*x*/, float y, float z, float& pad, float& time, float maxTimeBin) const;
195 GPUd() float InverseTransformInTimeFrame(int32_t sector, float z, float maxTimeBin) const;
196
198 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;
199
201 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;
202
204 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;
205
207 GPUd() void TransformIdeal(int32_t sector, int32_t row, float pad, float time, float& x, float& y, float& z, float vertexTime) const;
208 GPUd() void TransformIdealZ(int32_t sector, float time, float& z, float vertexTime) const;
209
210 GPUd() void convPadTimeToLocal(int32_t sector, int32_t row, float pad, float time, float& y, float& z, float vertexTime) const;
211 GPUd() void convPadTimeToLocalInTimeFrame(int32_t sector, int32_t row, float pad, float time, float& y, float& z, float maxTimeBin) const;
212
213 GPUd() void convLocalToPadTime(int32_t sector, int32_t row, float y, float z, float& pad, float& time, float vertexTime) const;
214 GPUd() void convLocalToPadTimeInTimeFrame(int32_t sector, int32_t row, float y, float z, float& pad, float& time, float maxTimeBin) const;
215
216 GPUd() float convTimeToZinTimeFrame(int32_t sector, float time, float maxTimeBin) const;
217 GPUd() float convZtoTimeInTimeFrame(int32_t sector, float z, float maxTimeBin) const;
218 GPUd() float convDeltaTimeToDeltaZinTimeFrame(int32_t sector, float deltaTime) const;
219 GPUd() float convDeltaZtoDeltaTimeInTimeFrame(int32_t sector, float deltaZ) const;
220 GPUd() float convDeltaZtoDeltaTimeInTimeFrameAbs(float deltaZ) const;
221 GPUd() float convZOffsetToVertexTime(int32_t sector, float zOffset, float maxTimeBin) const;
222 GPUd() float convVertexTimeToZOffset(int32_t sector, float vertexTime, float maxTimeBin) const;
223
224 void setApplyCorrectionOn() { mApplyCorrection = 1; }
225 void setApplyCorrectionOff() { mApplyCorrection = 0; }
226 bool isCorrectionApplied() { return mApplyCorrection; }
227
229
231 GPUdi() const TPCFastTransformGeo& getGeometry() const { return mCorrection.getGeometry(); }
232
234 GPUdi() int64_t getTimeStamp() const { return mTimeStamp; }
235
237 GPUdi() float getVDrift() const { return mVdrift; }
238
240 GPUdi() float getT0() const { return mT0; }
241
243 GPUdi() float getLumi() const { return mLumi; }
244
245 GPUdi() float isLumiSet() const { return mLumi != DEFLUMI; }
246
248 GPUdi() float getLumiError() const { return mLumiError; }
249
251 GPUd() float getIDC() const;
252
253 GPUdi() bool isIDCSet() const { return mIDC != DEFIDC; }
254
256 GPUdi() float getIDCError() const { return mIDCError; }
257
258 GPUdi() float getCTP2IDCFallBackThreshold() const { return mCTP2IDCFallBackThreshold; }
259
261 GPUdi() float getLumiScaleFactor() const { return mLumiScaleFactor; }
262
264 GPUd() float getMaxDriftTime(int32_t sector, int32_t row, float pad) const;
265
267 GPUd() float getMaxDriftTime(int32_t sector, int32_t row) const;
268
270 GPUd() float getMaxDriftTime(int32_t sector) const;
271
272#if !defined(GPUCA_GPUCODE) && !defined(GPUCA_STANDALONE)
273
274 int32_t writeToFile(std::string outFName = "", std::string name = "");
275
277
278 static TPCFastTransform* loadFromFile(std::string inpFName = "", std::string name = "");
279
281 void setSlowTPCSCCorrection(TFile& inpf);
282
284 const auto& getCorrectionSlow() const { return *mCorrectionSlow; }
285
286#endif // !GPUCA_GPUCODE
287
289 void print() const;
290
291 GPUd() float convDriftLengthToTime(float driftLength, float vertexTime) const;
292
293 private:
295 enum ConstructionExtraState : uint32_t {
296 CalibrationIsSet = 0x4
297 };
298
300
302
304
305 int64_t mTimeStamp;
306
313
314 bool mApplyCorrection; // flag for applying correction
315
322 float mT0;
323 float mVdrift;
324
325 float mLumi;
326 float mLumiError;
327 float mLumiScaleFactor;
328
329 float mIDC;
330 float mIDCError;
331 float mCTP2IDCFallBackThreshold;
332
334 TPCSlowSpaceChargeCorrection* mCorrectionSlow{nullptr};
335
336 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;
337
338 ClassDefNV(TPCFastTransform, 5);
339};
340
341// =======================================================================
342// Inline implementations of some methods
343// =======================================================================
344
345// ----------------------------------------------------------------------
346
347GPUdi() void TPCFastTransform::convPadTimeToLocal(int32_t sector, int32_t row, float pad, float time, float& y, float& z, float vertexTime) const
348{
349 float l = (time - mT0 - vertexTime) * mVdrift; // drift length [cm]
350 getGeometry().convPadDriftLengthToLocal(sector, row, pad, l, y, z);
351}
352
353GPUdi() void TPCFastTransform::convPadTimeToLocalInTimeFrame(int32_t sector, int32_t row, float pad, float time, float& y, float& z, float maxTimeBin) const
354{
355 float l = getGeometry().getTPCzLength() + (time - mT0 - maxTimeBin) * mVdrift; // drift length [cm]
356 getGeometry().convPadDriftLengthToLocal(sector, row, pad, l, y, z);
357}
358
359// ----------------------------------------------------------------------
360
361GPUdi() float TPCFastTransform::convZOffsetToVertexTime(int32_t sector, float zOffset, float maxTimeBin) const
362{
363 if (sector < getGeometry().getNumberOfSectorsA()) {
364 return maxTimeBin - (getGeometry().getTPCzLength() + zOffset) / mVdrift;
365 } else {
366 return maxTimeBin - (getGeometry().getTPCzLength() - zOffset) / mVdrift;
367 }
368}
369
370GPUdi() float TPCFastTransform::convVertexTimeToZOffset(int32_t sector, float vertexTime, float maxTimeBin) const
371{
372 if (sector < getGeometry().getNumberOfSectorsA()) {
373 return (maxTimeBin - vertexTime) * mVdrift - getGeometry().getTPCzLength();
374 } else {
375 return -((maxTimeBin - vertexTime) * mVdrift - getGeometry().getTPCzLength());
376 }
377}
378
379GPUdi() float TPCFastTransform::convDriftLengthToTime(float driftLength, float vertexTime) const
380{
381 return (mT0 + vertexTime + driftLength / mVdrift);
382}
383
384// ----------------------------------------------------------------------
385
386GPUdi() void TPCFastTransform::convLocalToPadTime(int32_t sector, int32_t row, float y, float z, float& pad, float& time, float vertexTime) const
387{
388 float l;
389 getGeometry().convLocalToPadDriftLength(sector, row, y, z, pad, l);
390 time = convDriftLengthToTime(l, vertexTime);
391}
392
393GPUdi() void TPCFastTransform::convLocalToPadTimeInTimeFrame(int32_t sector, int32_t row, float y, float z, float& pad, float& time, float maxTimeBin) const
394{
395 float l;
396 getGeometry().convLocalToPadDriftLength(sector, row, y, z, pad, l);
397 time = convDriftLengthToTime(l, maxTimeBin);
398}
399
400// ----------------------------------------------------------------------
401
402GPUdi() 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
403{
404 GPUCA_RTC_SPECIAL_CODE(ref2 = nullptr; scale2 = 0.f;);
405
406 if (!mApplyCorrection) {
407 return;
408 }
409
410 float dx = 0.f, dy = 0.f, dz = 0.f;
411
412 if ((scale >= 0.f) || (scaleMode == 1) || (scaleMode == 2)) {
413#ifndef GPUCA_GPUCODE
414 if (mCorrectionSlow) {
415 float gx, gy, gz;
416 getGeometry().convLocalToGlobal(sector, x, y, z, gx, gy, gz);
417 float gdxC, gdyC, gdzC;
418 mCorrectionSlow->getCorrections(gx, gy, gz, sector, gdxC, gdyC, gdzC);
419 getGeometry().convGlobalToLocal(sector, gdxC, gdyC, gdzC, dx, dy, dz);
420 } else
421#endif // GPUCA_GPUCODE
422 {
423 mCorrection.getCorrectionLocal(sector, row, y, z, dx, dy, dz);
424 if (ref) {
425 if ((scale > 0.f) && (scaleMode == 0)) { // scaling was requested
426 float dx1, dy1, dz1;
427 ref->mCorrection.getCorrectionLocal(sector, row, y, z, dx1, dy1, dz1);
428 dx = (dx - dx1) * scale + dx1;
429 dy = (dy - dy1) * scale + dy1;
430 dz = (dz - dz1) * scale + dz1;
431 } else if ((scale != 0.f) && ((scaleMode == 1) || (scaleMode == 2))) {
432 float dx1, dy1, dz1;
433 ref->mCorrection.getCorrectionLocal(sector, row, y, z, dx1, dy1, dz1);
434 dx = dx1 * scale + dx;
435 dy = dy1 * scale + dy;
436 dz = dz1 * scale + dz;
437 }
438 }
439 if (ref2 && (scale2 != 0)) {
440 float dx1, dy1, dz1;
441 ref2->mCorrection.getCorrectionLocal(sector, row, y, z, dx1, dy1, dz1);
442 dx = dx1 * scale2 + dx;
443 dy = dy1 * scale2 + dy;
444 dz = dz1 * scale2 + dz;
445 }
446 }
447 }
448
449 GPUCA_DEBUG_STREAMER_CHECK(if (o2::utils::DebugStreamer::checkStream(o2::utils::StreamFlags::streamFastTransform)) {
450 float lx = x, ly = y, lz = z;
451
452 float gx, gy, gz;
453 getGeometry().convLocalToGlobal(sector, lx, ly, lz, gx, gy, gz);
454
455 float lxT = lx + dx;
456 float lyT = ly + dy;
457 float lzT = lz + dz;
458
459 float invYZtoXScaled;
460 InverseTransformYZtoX(sector, row, lyT, lzT, invYZtoXScaled, ref, ref2, scale, scale2, scaleMode);
461
462 float invYZtoX;
463 InverseTransformYZtoX(sector, row, lyT, lzT, invYZtoX);
464
465 float YZtoNominalY;
466 float YZtoNominalZ;
467 InverseTransformYZtoNominalYZ(sector, row, lyT, lzT, YZtoNominalY, YZtoNominalZ);
468
469 float YZtoNominalYScaled;
470 float YZtoNominalZScaled;
471 InverseTransformYZtoNominalYZ(sector, row, lyT, lzT, YZtoNominalYScaled, YZtoNominalZScaled, ref, ref2, scale, scale2, scaleMode);
472
473 float dxRef = 0.f, dyRef = 0.f, dzRef = 0.f;
474 if (ref) {
475 ref->mCorrection.getCorrectionLocal(sector, row, y, z, dxRef, dyRef, dzRef);
476 }
477
478 float dxRef2 = 0.f, dyRef2 = 0.f, dzRef2 = 0.f;
479 if (ref2) {
480 ref2->mCorrection.getCorrectionLocal(sector, row, y, z, dxRef2, dyRef2, dzRef2);
481 }
482
483 float dxOrig, dyOrig, dzOrig;
484 mCorrection.getCorrectionLocal(sector, row, y, z, dxOrig, dyOrig, dzOrig);
485
486 o2::utils::DebugStreamer::instance()->getStreamer("debug_fasttransform", "UPDATE") << o2::utils::DebugStreamer::instance()->getUniqueTreeName("tree_Transform").data()
487 // corrections in x, u, v
488 << "dxOrig=" << dxOrig
489 << "dyOrig=" << dyOrig
490 << "dzOrig=" << dzOrig
491 << "dxRef=" << dxRef
492 << "dyRef=" << dyRef
493 << "dzRef=" << dzRef
494 << "dxRef2=" << dxRef2
495 << "dyRef2=" << dyRef2
496 << "dzRef2=" << dzRef2
497 << "dx=" << dx
498 << "dy=" << dy
499 << "dz=" << dz
500 << "row=" << row
501 << "sector=" << sector
502 << "scale=" << scale
503 << "scale2=" << scale2
504 // original local coordinates
505 << "ly=" << ly
506 << "lz=" << lz
507 << "lx=" << lx
508 // corrected local coordinated
509 << "lxT=" << lxT
510 << "lyT=" << lyT
511 << "lzT=" << lzT
512 // global uncorrected coordinates
513 << "gx=" << gx
514 << "gy=" << gy
515 << "gz=" << gz
516 // some transformations which are applied
517 << "invYZtoX=" << invYZtoX
518 << "invYZtoXScaled=" << invYZtoXScaled
519 << "YZtoNominalY=" << YZtoNominalY
520 << "YZtoNominalYScaled=" << YZtoNominalYScaled
521 << "YZtoNominalZ=" << YZtoNominalZ
522 << "YZtoNominalZScaled=" << YZtoNominalZScaled
523 << "scaleMode=" << scaleMode
524 << "\n";
525 })
526
527 x += dx;
528 y += dy;
529 z += dz;
530}
531
532GPUdi() 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
533{
534
535 TransformLocal(sector, row, x, y, z, ref, ref2, scale, scale2, scaleMode);
536}
537
538GPUdi() 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
539{
545
546 const TPCFastTransformGeo::RowInfo& rowInfo = getGeometry().getRowInfo(row);
547
548 x = rowInfo.x;
549 convPadTimeToLocal(sector, row, pad, time, y, z, vertexTime);
550 TransformLocal(sector, row, x, y, z, ref, ref2, scale, scale2, scaleMode);
551}
552
553GPUdi() void TPCFastTransform::TransformInTimeFrame(int32_t sector, float time, float& z, float maxTimeBin) const
554{
555 float l = (time - mT0 - maxTimeBin) * mVdrift; // drift length cm
556 z = getGeometry().convDriftLengthToZ(sector, l);
557}
558
559GPUdi() void TPCFastTransform::TransformInTimeFrame(int32_t sector, int32_t row, float pad, float time, float& x, float& y, float& z, float maxTimeBin) const
560{
566
567 const TPCFastTransformGeo::RowInfo& rowInfo = getGeometry().getRowInfo(row);
568 x = rowInfo.x;
569 convPadTimeToLocalInTimeFrame(sector, row, pad, time, y, z, maxTimeBin);
570}
571
572GPUdi() void TPCFastTransform::InverseTransformInTimeFrame(int32_t sector, int32_t row, float /*x*/, float y, float z, float& pad, float& time, float maxTimeBin) const
573{
575 convLocalToPadTimeInTimeFrame(sector, row, y, z, pad, time, maxTimeBin);
576}
577
578GPUdi() float TPCFastTransform::InverseTransformInTimeFrame(int32_t sector, float z, float maxTimeBin) const
579{
580 float pad, time;
581 InverseTransformInTimeFrame(sector, 0, 0, 0, z, pad, time, maxTimeBin);
582 return time;
583}
584
585GPUdi() void TPCFastTransform::TransformIdealZ(int32_t sector, float time, float& z, float vertexTime) const
586{
593
594 float l = (time - mT0 - vertexTime) * mVdrift; // drift length cm
595 z = getGeometry().convDriftLengthToZ(sector, l);
596}
597
598GPUdi() void TPCFastTransform::TransformIdeal(int32_t sector, int32_t row, float pad, float time, float& x, float& y, float& z, float vertexTime) const
599{
606
607 x = getGeometry().getRowInfo(row).x;
608 float driftLength = (time - mT0 - vertexTime) * mVdrift; // drift length cm
609 getGeometry().convPadDriftLengthToLocal(sector, row, pad, driftLength, y, z);
610}
611
612GPUdi() float TPCFastTransform::convTimeToZinTimeFrame(int32_t sector, float time, float maxTimeBin) const
613{
620
621 float v = (time - mT0 - maxTimeBin) * mVdrift; // drift length cm
622 float z = (sector < getGeometry().getNumberOfSectorsA()) ? -v : v;
623 return z;
624}
625
626GPUdi() float TPCFastTransform::convZtoTimeInTimeFrame(int32_t sector, float z, float maxTimeBin) const
627{
629 float v = (sector < getGeometry().getNumberOfSectorsA()) ? -z : z;
630 return mT0 + maxTimeBin + v / mVdrift;
631}
632
633GPUdi() float TPCFastTransform::convDeltaTimeToDeltaZinTimeFrame(int32_t sector, float deltaTime) const
634{
635 float deltaZ = deltaTime * mVdrift;
636 return sector < getGeometry().getNumberOfSectorsA() ? -deltaZ : deltaZ;
637}
638
639GPUdi() float TPCFastTransform::convDeltaZtoDeltaTimeInTimeFrameAbs(float deltaZ) const
640{
641 return deltaZ / mVdrift;
642}
643
644GPUdi() float TPCFastTransform::convDeltaZtoDeltaTimeInTimeFrame(int32_t sector, float deltaZ) const
645{
646 float deltaT = deltaZ / mVdrift;
647 return sector < getGeometry().getNumberOfSectorsA() ? -deltaT : deltaT;
648}
649
650GPUdi() float TPCFastTransform::getMaxDriftTime(int32_t sector, int32_t row, float pad) const
651{
653 return convDriftLengthToTime(getGeometry().getTPCzLength(), 0.f);
654}
655
656GPUdi() float TPCFastTransform::getMaxDriftTime(int32_t sector, int32_t row) const
657{
659 return convDriftLengthToTime(getGeometry().getTPCzLength(), 0.f);
660}
661
662GPUdi() float TPCFastTransform::getMaxDriftTime(int32_t sector) const
663{
665 return convDriftLengthToTime(getGeometry().getTPCzLength(), 0.f);
666}
667
668GPUdi() 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
669{
670 GPUCA_RTC_SPECIAL_CODE(ref2 = nullptr; scale2 = 0.f;);
672
673 float dx = 0.f;
674
675 if ((scale >= 0.f) || (scaleMode == 1) || (scaleMode == 2)) {
676 dx = mCorrection.getCorrectionXatRealYZ(sector, row, realY, realZ);
677 if (ref) { // scaling was requested
678 if (scaleMode == 0 && scale > 0.f) {
679 float dxref = ref->mCorrection.getCorrectionXatRealYZ(sector, row, realY, realZ);
680 dx = (dx - dxref) * scale + dxref;
681 } else if ((scale != 0) && ((scaleMode == 1) || (scaleMode == 2))) {
682 float dxref = ref->mCorrection.getCorrectionXatRealYZ(sector, row, realY, realZ);
683 dx = dxref * scale + dx;
684 }
685 }
686 if (ref2 && (scale2 != 0)) {
687 float dxref = ref2->mCorrection.getCorrectionXatRealYZ(sector, row, realY, realZ);
688 dx = dxref * scale2 + dx;
689 }
690 }
691
692 realX = mCorrection.getGeometry().getRowInfo(row).x + dx;
693
694 GPUCA_DEBUG_STREAMER_CHECK(if (o2::utils::DebugStreamer::checkStream(o2::utils::StreamFlags::streamFastTransform)) {
695 o2::utils::DebugStreamer::instance()->getStreamer("debug_fasttransform", "UPDATE") << o2::utils::DebugStreamer::instance()->getUniqueTreeName("tree_InverseTransformYZtoX").data()
696 << "sector=" << sector
697 << "row=" << row
698 << "scale=" << scale
699 << "y=" << realY
700 << "z=" << realZ
701 << "x=" << realX
702 << "\n";
703 })
704}
705
706GPUdi() 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
707{
709
710 GPUCA_RTC_SPECIAL_CODE(ref2 = nullptr; scale2 = 0.f;);
711
712 float dy = 0;
713 float dz = 0;
714
715 if ((scale >= 0.f) || (scaleMode == 1) || (scaleMode == 2)) {
716 mCorrection.getCorrectionYZatRealYZ(sector, row, realY, realZ, dy, dz);
717
718 if (ref) { // scaling was requested
719 if (scaleMode == 0 && scale > 0.f) {
720 float dy1, dz1;
721 ref->mCorrection.getCorrectionYZatRealYZ(sector, row, realY, realZ, dy1, dz1);
722 dy = (dy - dy1) * scale + dy1;
723 dz = (dz - dz1) * scale + dz1;
724 } else if ((scale != 0) && ((scaleMode == 1) || (scaleMode == 2))) {
725 float dy1, dz1;
726 ref->mCorrection.getCorrectionYZatRealYZ(sector, row, realY, realZ, dy1, dz1);
727 dy = dy1 * scale + dy;
728 dz = dz1 * scale + dz;
729 }
730 if (ref2 && (scale2 != 0)) {
731 float dy1, dz1;
732 ref2->mCorrection.getCorrectionYZatRealYZ(sector, row, realY, realZ, dy1, dz1);
733 dy = dy1 * scale2 + dy;
734 dz = dz1 * scale2 + dz;
735 }
736 }
737 }
738
739 measuredY = realY - dy;
740 measuredZ = realZ - dz;
741
742 GPUCA_DEBUG_STREAMER_CHECK(if (o2::utils::DebugStreamer::checkStream(o2::utils::StreamFlags::streamFastTransform)) {
743 o2::utils::DebugStreamer::instance()->getStreamer("debug_fasttransform", "UPDATE") << o2::utils::DebugStreamer::instance()->getUniqueTreeName("tree_InverseTransformYZtoNominalYZ").data()
744 << "sector=" << sector
745 << "row=" << row
746 << "scale=" << scale
747 << "real y=" << realY
748 << "real z=" << realZ
749 << "measured y=" << measuredY
750 << "measured z=" << measuredZ
751 << "\n";
752 })
753}
754
755GPUdi() 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
756{
758 int32_t row2 = row + 1;
759 if (row2 >= getGeometry().getNumberOfRows()) {
760 row2 = row - 1;
761 }
762 float nx1, ny1, nz1; // nominal coordinates for row
763 float nx2, ny2, nz2; // nominal coordinates for row2
764 nx1 = getGeometry().getRowInfo(row).x;
765 nx2 = getGeometry().getRowInfo(row2).x;
766 InverseTransformYZtoNominalYZ(sector, row, y, z, ny1, nz1, ref, ref2, scale, scale2, scaleMode);
767 InverseTransformYZtoNominalYZ(sector, row2, y, z, ny2, nz2, ref, ref2, scale, scale2, scaleMode);
768 float c1 = (nx2 - nx) / (nx2 - nx1);
769 float c2 = (nx - nx1) / (nx2 - nx1);
770 nx = x;
771 ny = (ny1 * c1 + ny2 * c2);
772 nz = (nz1 * c1 + nz2 * c2);
773}
774
775} // namespace o2::gpu
776
777#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.
TPCFastTransform(const TPCFastTransform &)=delete
Copy constructor: disabled to avoid ambiguity. Use cloneFromObject() instead.
static constexpr size_t getBufferAlignmentBytes()
Gives minimal alignment in bytes required for the flat buffer.
static constexpr float DEFLUMI
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 ____________
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
TPCFastTransform & operator=(const TPCFastTransform &)=delete
Assignment operator: disabled to avoid ambiguity. Use cloneFromObject() instead.
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.
static constexpr float DEFIDC
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
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
GPUdi() o2
Definition TrackTRD.h:39
const float dx1
Definition MathUtils.h:51
const float dy1
Definition MathUtils.h:51
Global TPC definitions and constants.
Definition SimTraits.h:168
@ 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