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
37{
38namespace 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 slice, float& gdxC, float& gdyC, float& gdzC) const;
50
52#else
54
56 GPUd() void getCorrections(const float gx, const float gy, const float gz, const int32_t slice, 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:
100
103
106
109
110 inline void destroy()
111 {
112 mCorrection.destroy();
114 }
115
117#if !defined(GPUCA_GPUCODE) && !defined(GPUCA_STANDALONE) && defined(GPUCA_O2_LIB)
119 {
120 delete mCorrectionSlow;
121 }
122#else
123 ~TPCFastTransform() = default;
124#endif
125
127
129
132
135
137
138 void cloneFromObject(const TPCFastTransform& obj, char* newFlatBufferPtr);
139
141
143 void moveBufferTo(char* newBufferPtr);
144
146
147 void setActualBufferAddress(char* actualFlatBufferPtr);
148 void setFutureBufferAddress(char* futureFlatBufferPtr);
149
151
153 void startConstruction(const TPCFastSpaceChargeCorrection& correction);
154
159 void setCalibration(int64_t timeStamp, float t0, float vDrift, float vDriftCorrY, float lDriftCorr, float tofCorr, float primVtxZ);
160
162 void setLumi(float l) { mLumi = l; }
163 void setLumiError(float e) { mLumiError = e; }
164 void setLumiScaleFactor(float s) { mLumiScaleFactor = s; }
165
167 void setTimeStamp(int64_t v) { mTimeStamp = v; }
168
170 GPUd() const TPCFastSpaceChargeCorrection& getCorrection() const { return mCorrection; }
171
174
176 void finishConstruction();
177
183 GPUd() void Transform(int32_t slice, 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;
184 GPUd() void TransformXYZ(int32_t slice, 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;
185
187 GPUd() void TransformInTimeFrame(int32_t slice, int32_t row, float pad, float time, float& x, float& y, float& z, float maxTimeBin) const;
188 GPUd() void TransformInTimeFrame(int32_t slice, float time, float& z, float maxTimeBin) const;
189
191 GPUd() void InverseTransformInTimeFrame(int32_t slice, int32_t row, float /*x*/, float y, float z, float& pad, float& time, float maxTimeBin) const;
192
194 GPUd() void InverseTransformYZtoX(int32_t slice, 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;
195
197 GPUd() void InverseTransformYZtoNominalYZ(int32_t slice, 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;
198
200 GPUd() void InverseTransformXYZtoNominalXYZ(int32_t slice, 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;
201
203 GPUd() void TransformIdeal(int32_t slice, int32_t row, float pad, float time, float& x, float& y, float& z, float vertexTime) const;
204 GPUd() void TransformIdealZ(int32_t slice, float time, float& z, float vertexTime) const;
205
206 GPUd() void convPadTimeToUV(int32_t slice, int32_t row, float pad, float time, float& u, float& v, float vertexTime) const;
207 GPUd() void convPadTimeToUVinTimeFrame(int32_t slice, int32_t row, float pad, float time, float& u, float& v, float maxTimeBin) const;
208 GPUd() void convTimeToVinTimeFrame(int32_t slice, float time, float& v, float maxTimeBin) const;
209
210 GPUd() void convUVtoPadTime(int32_t slice, int32_t row, float u, float v, float& pad, float& time, float vertexTime) const;
211 GPUd() void convUVtoPadTimeInTimeFrame(int32_t slice, int32_t row, float u, float v, float& pad, float& time, float maxTimeBin) const;
212 GPUd() void convVtoTime(float v, float& time, float vertexTime) const;
213
214 GPUd() float convTimeToZinTimeFrame(int32_t slice, float time, float maxTimeBin) const;
215 GPUd() float convZtoTimeInTimeFrame(int32_t slice, float z, float maxTimeBin) const;
216 GPUd() float convDeltaTimeToDeltaZinTimeFrame(int32_t slice, float deltaTime) const;
217 GPUd() float convDeltaZtoDeltaTimeInTimeFrame(int32_t slice, float deltaZ) const;
218 GPUd() float convDeltaZtoDeltaTimeInTimeFrameAbs(float deltaZ) const;
219 GPUd() float convZOffsetToVertexTime(int32_t slice, float zOffset, float maxTimeBin) const;
220 GPUd() float convVertexTimeToZOffset(int32_t slice, float vertexTime, float maxTimeBin) const;
221
222 GPUd() void getTOFcorrection(int32_t slice, int32_t row, float x, float y, float z, float& dz) const;
223
224 void setApplyCorrectionOn() { mApplyCorrection = 1; }
225 void setApplyCorrectionOff() { mApplyCorrection = 0; }
226 bool isCorrectionApplied() { return mApplyCorrection; }
227
229
231 GPUd() const TPCFastTransformGeo& getGeometry() const { return mCorrection.getGeometry(); }
232
234 GPUd() int64_t getTimeStamp() const { return mTimeStamp; }
235
237 GPUd() float getVDrift() const { return mVdrift; }
238
240 GPUd() float getT0() const { return mT0; }
241
243 GPUd() float getVdriftCorrY() const { return mVdriftCorrY; }
244
246 GPUd() float getLdriftCorr() const { return mLdriftCorr; }
247
249 GPUd() float getTOFCorr() const { return mLdriftCorr; }
250
252 GPUd() float getLumi() const { return mLumi; }
253
255 GPUd() float getLumiError() const { return mLumiError; }
256
258 GPUd() float getLumiScaleFactor() const { return mLumiScaleFactor; }
259
261 GPUd() float getMaxDriftTime(int32_t slice, int32_t row, float pad) const;
262
264 GPUd() float getMaxDriftTime(int32_t slice, int32_t row) const;
265
267 GPUd() float getMaxDriftTime(int32_t slice) const;
268
269#if !defined(GPUCA_GPUCODE) && !defined(GPUCA_STANDALONE)
270
271 int32_t writeToFile(std::string outFName = "", std::string name = "");
272
274
275 static TPCFastTransform* loadFromFile(std::string inpFName = "", std::string name = "");
276
278 void setSlowTPCSCCorrection(TFile& inpf);
279
281 const auto& getCorrectionSlow() const { return *mCorrectionSlow; }
282
283#endif // !GPUCA_GPUCODE
284
286 void print() const;
287
288 private:
290 enum ConstructionExtraState : uint32_t {
291 CalibrationIsSet = 0x4
292 };
293
295
297
299
300 int64_t mTimeStamp;
301
307 TPCFastSpaceChargeCorrection mCorrection;
308
309 bool mApplyCorrection; // flag for applying correction
310
317 float mT0;
318 float mVdrift;
319 float mVdriftCorrY;
320 float mLdriftCorr;
321
329 float mTOFcorr;
330
331 float mPrimVtxZ;
332
333 float mLumi;
334 float mLumiError;
335 float mLumiScaleFactor;
336
338 TPCSlowSpaceChargeCorrection* mCorrectionSlow{nullptr};
339
340 GPUd() void TransformInternal(int32_t slice, int32_t row, float& u, float& v, float& x, const TPCFastTransform* ref, const TPCFastTransform* ref2, float scale, float scale2, int32_t scaleMode) const;
341
342 ClassDefNV(TPCFastTransform, 3);
343};
344
345// =======================================================================
346// Inline implementations of some methods
347// =======================================================================
348
349GPUdi() void TPCFastTransform::convPadTimeToUV(int32_t slice, int32_t row, float pad, float time, float& u, float& v, float vertexTime) const
350{
351 bool sideC = (slice >= getGeometry().getNumberOfSlicesA());
352
353 const TPCFastTransformGeo::RowInfo& rowInfo = getGeometry().getRowInfo(row);
354 const TPCFastTransformGeo::SliceInfo& sliceInfo = getGeometry().getSliceInfo(slice);
355
356 float x = rowInfo.x;
357 u = (pad - 0.5f * rowInfo.maxPad) * rowInfo.padWidth;
358
359 float y = sideC ? -u : u; // pads are mirrorred on C-side
360 float yLab = y * sliceInfo.cosAlpha + x * sliceInfo.sinAlpha;
361
362 v = (time - mT0 - vertexTime) * (mVdrift + mVdriftCorrY * yLab) + mLdriftCorr; // drift length cm
363}
364
365GPUdi() void TPCFastTransform::convTimeToVinTimeFrame(int32_t slice, float time, float& v, float maxTimeBin) const
366{
367 v = (time - mT0 - maxTimeBin) * mVdrift + mLdriftCorr; // drift length cm
368 if (slice < getGeometry().getNumberOfSlicesA()) {
369 v += getGeometry().getTPCzLengthA();
370 } else {
371 v += getGeometry().getTPCzLengthC();
372 }
373}
374
375GPUdi() void TPCFastTransform::convPadTimeToUVinTimeFrame(int32_t slice, int32_t row, float pad, float time, float& u, float& v, float maxTimeBin) const
376{
377 const TPCFastTransformGeo::RowInfo& rowInfo = getGeometry().getRowInfo(row);
378 u = (pad - 0.5f * rowInfo.maxPad) * rowInfo.padWidth;
379 convTimeToVinTimeFrame(slice, time, v, maxTimeBin);
380}
381
382GPUdi() float TPCFastTransform::convZOffsetToVertexTime(int32_t slice, float zOffset, float maxTimeBin) const
383{
384 if (slice < getGeometry().getNumberOfSlicesA()) {
385 return maxTimeBin - (getGeometry().getTPCzLengthA() + zOffset) / mVdrift;
386 } else {
387 return maxTimeBin - (getGeometry().getTPCzLengthC() - zOffset) / mVdrift;
388 }
389}
390
391GPUdi() float TPCFastTransform::convVertexTimeToZOffset(int32_t slice, float vertexTime, float maxTimeBin) const
392{
393 if (slice < getGeometry().getNumberOfSlicesA()) {
394 return (maxTimeBin - vertexTime) * mVdrift - getGeometry().getTPCzLengthA();
395 } else {
396 return -((maxTimeBin - vertexTime) * mVdrift - getGeometry().getTPCzLengthC());
397 }
398}
399
400GPUdi() void TPCFastTransform::convUVtoPadTime(int32_t slice, int32_t row, float u, float v, float& pad, float& time, float vertexTime) const
401{
402 bool sideC = (slice >= getGeometry().getNumberOfSlicesA());
403
404 const TPCFastTransformGeo::RowInfo& rowInfo = getGeometry().getRowInfo(row);
405 const TPCFastTransformGeo::SliceInfo& sliceInfo = getGeometry().getSliceInfo(slice);
406
407 pad = u / rowInfo.padWidth + 0.5f * rowInfo.maxPad;
408
409 float x = rowInfo.x;
410 float y = sideC ? -u : u; // pads are mirrorred on C-side
411 float yLab = y * sliceInfo.cosAlpha + x * sliceInfo.sinAlpha;
412 time = mT0 + vertexTime + (v - mLdriftCorr) / (mVdrift + mVdriftCorrY * yLab);
413}
414
415GPUdi() void TPCFastTransform::convVtoTime(float v, float& time, float vertexTime) const
416{
417 float yLab = 0.f;
418 time = mT0 + vertexTime + (v - mLdriftCorr) / (mVdrift + mVdriftCorrY * yLab);
419}
420
421GPUdi() void TPCFastTransform::convUVtoPadTimeInTimeFrame(int32_t slice, int32_t row, float u, float v, float& pad, float& time, float maxTimeBin) const
422{
423 if (slice < getGeometry().getNumberOfSlicesA()) {
424 v -= getGeometry().getTPCzLengthA();
425 } else {
426 v -= getGeometry().getTPCzLengthC();
427 }
428 const TPCFastTransformGeo::RowInfo& rowInfo = getGeometry().getRowInfo(row);
429 pad = u / rowInfo.padWidth + 0.5f * rowInfo.maxPad;
430 time = mT0 + maxTimeBin + (v - mLdriftCorr) / mVdrift;
431}
432
433GPUdi() void TPCFastTransform::getTOFcorrection(int32_t slice, int32_t /*row*/, float x, float y, float z, float& dz) const
434{
435 // calculate time of flight correction for z coordinate
436
437 bool sideC = (slice >= getGeometry().getNumberOfSlicesA());
438 float distZ = z - mPrimVtxZ;
439 float dv = -GPUCommonMath::Sqrt(x * x + y * y + distZ * distZ) * mTOFcorr;
440 dz = sideC ? dv : -dv;
441}
442
443GPUdi() void TPCFastTransform::TransformInternal(int32_t slice, int32_t row, float& u, float& v, float& x, const TPCFastTransform* ref, const TPCFastTransform* ref2, float scale, float scale2, int32_t scaleMode) const
444{
445 GPUCA_RTC_SPECIAL_CODE(ref2 = nullptr; scale2 = 0.f;);
446 if (mApplyCorrection) {
447 float dx = 0.f, du = 0.f, dv = 0.f;
448 if ((scale >= 0.f) || (scaleMode == 1) || (scaleMode == 2)) {
449#ifndef GPUCA_GPUCODE
450 if (mCorrectionSlow) {
451 float ly, lz;
452 getGeometry().convUVtoLocal(slice, u, v, ly, lz);
453 float gx, gy, gz;
454 getGeometry().convLocalToGlobal(slice, x, ly, lz, gx, gy, gz);
455
456 float gdxC, gdyC, gdzC;
457 mCorrectionSlow->getCorrections(gx, gy, gz, slice, gdxC, gdyC, gdzC);
458 getGeometry().convGlobalToLocal(slice, gdxC, gdyC, gdzC, dx, du, dv);
459
460 if (slice >= 18) {
461 du = -du; // mirror for c-Side
462 } else {
463 dv = -dv; // mirror z for A-Side
464 }
465 } else
466#endif // GPUCA_GPUCODE
467 {
468 mCorrection.getCorrection(slice, row, u, v, dx, du, dv);
469 if (ref) {
470 if ((scale > 0.f) && (scaleMode == 0)) { // scaling was requested
471 float dxRef, duRef, dvRef;
472 ref->mCorrection.getCorrection(slice, row, u, v, dxRef, duRef, dvRef);
473 dx = (dx - dxRef) * scale + dxRef;
474 du = (du - duRef) * scale + duRef;
475 dv = (dv - dvRef) * scale + dvRef;
476 } else if ((scale != 0.f) && ((scaleMode == 1) || (scaleMode == 2))) {
477 float dxRef, duRef, dvRef;
478 ref->mCorrection.getCorrection(slice, row, u, v, dxRef, duRef, dvRef);
479 dx = dxRef * scale + dx;
480 du = duRef * scale + du;
481 dv = dvRef * scale + dv;
482 }
483 }
484 if (ref2 && (scale2 != 0)) {
485 float dxRef, duRef, dvRef;
486 ref2->mCorrection.getCorrection(slice, row, u, v, dxRef, duRef, dvRef);
487 dx = dxRef * scale2 + dx;
488 du = duRef * scale2 + du;
489 dv = dvRef * scale2 + dv;
490 }
491 }
492 }
493 GPUCA_DEBUG_STREAMER_CHECK(if (o2::utils::DebugStreamer::checkStream(o2::utils::StreamFlags::streamFastTransform)) {
494 float ly, lz;
495 getGeometry().convUVtoLocal(slice, u, v, ly, lz);
496
497 float gx, gy, gz;
498 getGeometry().convLocalToGlobal(slice, x, ly, lz, gx, gy, gz);
499
500 float lyT, lzT;
501 float uCorr = u + du;
502 float vCorr = v + dv;
503 float lxT = x + dx;
504 getGeometry().convUVtoLocal(slice, uCorr, vCorr, lyT, lzT);
505
506 float invYZtoXScaled;
507 InverseTransformYZtoX(slice, row, lyT, lzT, invYZtoXScaled, ref, ref2, scale, scale2, scaleMode);
508
509 float invYZtoX;
510 InverseTransformYZtoX(slice, row, lyT, lzT, invYZtoX);
511
512 float YZtoNominalY;
513 float YZtoNominalZ;
514 InverseTransformYZtoNominalYZ(slice, row, lyT, lzT, YZtoNominalY, YZtoNominalZ);
515
516 float YZtoNominalYScaled;
517 float YZtoNominalZScaled;
518 InverseTransformYZtoNominalYZ(slice, row, lyT, lzT, YZtoNominalYScaled, YZtoNominalZScaled, ref, ref2, scale, scale2, scaleMode);
519
520 float dxRef, duRef, dvRef;
521 if (ref) {
522 ref->mCorrection.getCorrection(slice, row, u, v, dxRef, duRef, dvRef);
523 }
524
525 float dxRef2, duRef2, dvRef2;
526 if (ref2) {
527 ref2->mCorrection.getCorrection(slice, row, u, v, dxRef2, duRef2, dvRef2);
528 }
529
530 float dxOrig, duOrig, dvOrig;
531 mCorrection.getCorrection(slice, row, u, v, dxOrig, duOrig, dvOrig);
532
533 o2::utils::DebugStreamer::instance()->getStreamer("debug_fasttransform", "UPDATE") << o2::utils::DebugStreamer::instance()->getUniqueTreeName("tree_Transform").data()
534 // corrections in x, u, v
535 << "dxOrig=" << dxOrig
536 << "duOrig=" << duOrig
537 << "dvOrig=" << dvOrig
538 << "dxRef=" << dxRef
539 << "duRef=" << duRef
540 << "dvRef=" << dvRef
541 << "dxRef2=" << dxRef2
542 << "duRef2=" << duRef2
543 << "dvRef2=" << dvRef2
544 << "dx=" << dx
545 << "du=" << du
546 << "dv=" << dv
547 << "v=" << v
548 << "u=" << u
549 << "row=" << row
550 << "slice=" << slice
551 << "scale=" << scale
552 << "scale2=" << scale2
553 // original local coordinates
554 << "ly=" << ly
555 << "lz=" << lz
556 << "lx=" << x
557 // corrected local coordinated
558 << "lxT=" << lxT
559 << "lyT=" << lyT
560 << "lzT=" << lzT
561 // global uncorrected coordinates
562 << "gx=" << gx
563 << "gy=" << gy
564 << "gz=" << gz
565 // some transformations which are applied
566 << "invYZtoX=" << invYZtoX
567 << "invYZtoXScaled=" << invYZtoXScaled
568 << "YZtoNominalY=" << YZtoNominalY
569 << "YZtoNominalYScaled=" << YZtoNominalYScaled
570 << "YZtoNominalZ=" << YZtoNominalZ
571 << "YZtoNominalZScaled=" << YZtoNominalZScaled
572 << "scaleMode=" << scaleMode
573 << "\n";
574 })
575
576 x += dx;
577 u += du;
578 v += dv;
579 }
580}
581
582GPUdi() void TPCFastTransform::TransformXYZ(int32_t slice, int32_t row, float& x, float& y, float& z, const TPCFastTransform* ref, const TPCFastTransform* ref2, float scale, float scale2, int32_t scaleMode) const
583{
584 float u, v;
585 getGeometry().convLocalToUV(slice, y, z, u, v);
586 TransformInternal(slice, row, u, v, x, ref, ref2, scale, scale2, scaleMode);
587 getGeometry().convUVtoLocal(slice, u, v, y, z);
588 float dzTOF = 0;
589 getTOFcorrection(slice, row, x, y, z, dzTOF);
590 z += dzTOF;
591}
592
593GPUdi() void TPCFastTransform::Transform(int32_t slice, 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
594{
600
601 const TPCFastTransformGeo::RowInfo& rowInfo = getGeometry().getRowInfo(row);
602
603 // const SliceInfo &sliceInfo = getSliceInfo( slice );
604 // bool sideC = ( slice >= NumberOfSlices / 2 );
605
606 x = rowInfo.x;
607 float u = 0, v = 0;
608 convPadTimeToUV(slice, row, pad, time, u, v, vertexTime);
609
610 TransformInternal(slice, row, u, v, x, ref, ref2, scale, scale2, scaleMode);
611
612 getGeometry().convUVtoLocal(slice, u, v, y, z);
613
614 float dzTOF = 0;
615 getTOFcorrection(slice, row, x, y, z, dzTOF);
616 z += dzTOF;
617}
618
619GPUdi() void TPCFastTransform::TransformInTimeFrame(int32_t slice, float time, float& z, float maxTimeBin) const
620{
621 float v = 0;
622 convTimeToVinTimeFrame(slice, time, v, maxTimeBin);
623 getGeometry().convVtoLocal(slice, v, z);
624}
625
626GPUdi() void TPCFastTransform::TransformInTimeFrame(int32_t slice, int32_t row, float pad, float time, float& x, float& y, float& z, float maxTimeBin) const
627{
633
634 const TPCFastTransformGeo::RowInfo& rowInfo = getGeometry().getRowInfo(row);
635 x = rowInfo.x;
636 float u = 0, v = 0;
637 convPadTimeToUVinTimeFrame(slice, row, pad, time, u, v, maxTimeBin);
638 getGeometry().convUVtoLocal(slice, u, v, y, z);
639}
640
641GPUdi() void TPCFastTransform::InverseTransformInTimeFrame(int32_t slice, int32_t row, float /*x*/, float y, float z, float& pad, float& time, float maxTimeBin) const
642{
644 float u = 0, v = 0;
645 getGeometry().convLocalToUV(slice, y, z, u, v);
646 convUVtoPadTimeInTimeFrame(slice, row, u, v, pad, time, maxTimeBin);
647}
648
649GPUdi() void TPCFastTransform::TransformIdealZ(int32_t slice, float time, float& z, float vertexTime) const
650{
657
658 float v = (time - mT0 - vertexTime) * mVdrift; // drift length cm
659 getGeometry().convVtoLocal(slice, v, z);
660}
661
662GPUdi() void TPCFastTransform::TransformIdeal(int32_t slice, int32_t row, float pad, float time, float& x, float& y, float& z, float vertexTime) const
663{
670
671 const TPCFastTransformGeo::RowInfo& rowInfo = getGeometry().getRowInfo(row);
672
673 x = rowInfo.x;
674 float u = (pad - 0.5f * rowInfo.maxPad) * rowInfo.padWidth;
675 float v = (time - mT0 - vertexTime) * mVdrift; // drift length cm
676
677 getGeometry().convUVtoLocal(slice, u, v, y, z);
678}
679
680GPUdi() float TPCFastTransform::convTimeToZinTimeFrame(int32_t slice, float time, float maxTimeBin) const
681{
688
689 float v = (time - mT0 - maxTimeBin) * mVdrift + mLdriftCorr; // drift length cm
690 float z = getGeometry().getTPCalignmentZ(); // global TPC alignment
691 if (slice < getGeometry().getNumberOfSlicesA()) {
692 z -= v;
693 } else {
694 z += v;
695 }
696 return z;
697}
698
699GPUdi() float TPCFastTransform::convZtoTimeInTimeFrame(int32_t slice, float z, float maxTimeBin) const
700{
702 float v;
703 if (slice < getGeometry().getNumberOfSlicesA()) {
704 v = getGeometry().getTPCalignmentZ() - z;
705 } else {
706 v = z - getGeometry().getTPCalignmentZ();
707 }
708 return mT0 + maxTimeBin + (v - mLdriftCorr) / mVdrift;
709}
710
711GPUdi() float TPCFastTransform::convDeltaTimeToDeltaZinTimeFrame(int32_t slice, float deltaTime) const
712{
713 float deltaZ = deltaTime * mVdrift;
714 return slice < getGeometry().getNumberOfSlicesA() ? -deltaZ : deltaZ;
715}
716
717GPUdi() float TPCFastTransform::convDeltaZtoDeltaTimeInTimeFrameAbs(float deltaZ) const
718{
719 return deltaZ / mVdrift;
720}
721
722GPUdi() float TPCFastTransform::convDeltaZtoDeltaTimeInTimeFrame(int32_t slice, float deltaZ) const
723{
724 float deltaT = deltaZ / mVdrift;
725 return slice < getGeometry().getNumberOfSlicesA() ? -deltaT : deltaT;
726}
727
728/*
729GPUdi() float TPCFastTransform::getLastCalibratedTimeBin(int32_t slice) const
730{
732 float u, v, pad, time;
733 getGeometry().convScaledUVtoUV(slice, 0, 0.f, 1.f, u, v);
734 convUVtoPadTime(slice, 0, u, v, pad, time, 0);
735 return time;
736}
737*/
738
739GPUdi() float TPCFastTransform::getMaxDriftTime(int32_t slice, int32_t row, float pad) const
740{
742 float maxL = mCorrection.getMaxDriftLength(slice, row, pad);
743
744 bool sideC = (slice >= getGeometry().getNumberOfSlicesA());
745 const TPCFastTransformGeo::RowInfo& rowInfo = getGeometry().getRowInfo(row);
746 const TPCFastTransformGeo::SliceInfo& sliceInfo = getGeometry().getSliceInfo(slice);
747
748 float x = rowInfo.x;
749 float u = (pad - 0.5f * rowInfo.maxPad) * rowInfo.padWidth;
750
751 float y = sideC ? -u : u; // pads are mirrorred on C-side
752 float yLab = y * sliceInfo.cosAlpha + x * sliceInfo.sinAlpha;
753 return mT0 + (maxL - mLdriftCorr) / (mVdrift + mVdriftCorrY * yLab);
754}
755
756GPUdi() float TPCFastTransform::getMaxDriftTime(int32_t slice, int32_t row) const
757{
759 float maxL = mCorrection.getMaxDriftLength(slice, row);
760 float maxTime = 0.f;
761 convVtoTime(maxL, maxTime, 0.f);
762 return maxTime;
763}
764
765GPUdi() float TPCFastTransform::getMaxDriftTime(int32_t slice) const
766{
768 float maxL = mCorrection.getMaxDriftLength(slice);
769 float maxTime = 0.f;
770 convVtoTime(maxL, maxTime, 0.f);
771 return maxTime;
772}
773
774GPUdi() void TPCFastTransform::InverseTransformYZtoX(int32_t slice, int32_t row, float y, float z, float& x, const TPCFastTransform* ref, const TPCFastTransform* ref2, float scale, float scale2, int32_t scaleMode) const
775{
776 GPUCA_RTC_SPECIAL_CODE(ref2 = nullptr; scale2 = 0.f;);
778 float u = 0, v = 0;
779 getGeometry().convLocalToUV(slice, y, z, u, v);
780 if ((scale >= 0.f) || (scaleMode == 1) || (scaleMode == 2)) {
781 mCorrection.getCorrectionInvCorrectedX(slice, row, u, v, x);
782 if (ref) { // scaling was requested
783 if (scaleMode == 0 && scale > 0.f) {
784 float xr;
785 ref->mCorrection.getCorrectionInvCorrectedX(slice, row, u, v, xr);
786 x = (x - xr) * scale + xr;
787 } else if ((scale != 0) && ((scaleMode == 1) || (scaleMode == 2))) {
788 float xr;
789 ref->mCorrection.getCorrectionInvCorrectedX(slice, row, u, v, xr);
790 x = (xr - getGeometry().getRowInfo(row).x) * scale + x; // xr=mGeo.getRowInfo(row).x + dx;
791 }
792 }
793 if (ref2 && (scale2 != 0)) {
794 float xr;
795 ref2->mCorrection.getCorrectionInvCorrectedX(slice, row, u, v, xr);
796 x = (xr - getGeometry().getRowInfo(row).x) * scale2 + x; // xr=mGeo.getRowInfo(row).x + dx;
797 }
798 } else {
799 x = mCorrection.getGeometry().getRowInfo(row).x; // corrections are disabled
800 }
801 GPUCA_DEBUG_STREAMER_CHECK(if (o2::utils::DebugStreamer::checkStream(o2::utils::StreamFlags::streamFastTransform)) {
802 o2::utils::DebugStreamer::instance()->getStreamer("debug_fasttransform", "UPDATE") << o2::utils::DebugStreamer::instance()->getUniqueTreeName("tree_InverseTransformYZtoX").data()
803 << "slice=" << slice
804 << "row=" << row
805 << "scale=" << scale
806 << "y=" << y
807 << "z=" << z
808 << "x=" << x
809 << "v=" << v
810 << "u=" << u
811 << "\n";
812 })
813}
814
815GPUdi() void TPCFastTransform::InverseTransformYZtoNominalYZ(int32_t slice, int32_t row, float y, float z, float& ny, float& nz, const TPCFastTransform* ref, const TPCFastTransform* ref2, float scale, float scale2, int32_t scaleMode) const
816{
817 GPUCA_RTC_SPECIAL_CODE(ref2 = nullptr; scale2 = 0.f;);
819 float u = 0, v = 0, un = 0, vn = 0;
820 getGeometry().convLocalToUV(slice, y, z, u, v);
821 if ((scale >= 0.f) || (scaleMode == 1) || (scaleMode == 2)) {
822 mCorrection.getCorrectionInvUV(slice, row, u, v, un, vn);
823 if (ref) { // scaling was requested
824 if (scaleMode == 0 && scale > 0.f) {
825 float unr = 0, vnr = 0;
826 ref->mCorrection.getCorrectionInvUV(slice, row, u, v, unr, vnr);
827 un = (un - unr) * scale + unr;
828 vn = (vn - vnr) * scale + vnr;
829 } else if ((scale != 0) && ((scaleMode == 1) || (scaleMode == 2))) {
830 float unr = 0, vnr = 0;
831 ref->mCorrection.getCorrectionInvUV(slice, row, u, v, unr, vnr);
832 un = (unr - u) * scale + un; // unr = u - duv[0];
833 vn = (vnr - v) * scale + vn;
834 }
835 if (ref2 && (scale2 != 0)) {
836 float unr = 0, vnr = 0;
837 ref2->mCorrection.getCorrectionInvUV(slice, row, u, v, unr, vnr);
838 un = (unr - u) * scale2 + un; // unr = u - duv[0];
839 vn = (vnr - v) * scale2 + vn;
840 }
841 }
842 } else {
843 un = u;
844 vn = v;
845 }
846 getGeometry().convUVtoLocal(slice, un, vn, ny, nz);
847
848 GPUCA_DEBUG_STREAMER_CHECK(if (o2::utils::DebugStreamer::checkStream(o2::utils::StreamFlags::streamFastTransform)) {
849 o2::utils::DebugStreamer::instance()->getStreamer("debug_fasttransform", "UPDATE") << o2::utils::DebugStreamer::instance()->getUniqueTreeName("tree_InverseTransformYZtoNominalYZ").data()
850 << "slice=" << slice
851 << "row=" << row
852 << "scale=" << scale
853 << "y=" << y
854 << "z=" << z
855 << "ny=" << ny
856 << "nz=" << nz
857 << "u=" << u
858 << "v=" << v
859 << "un=" << un
860 << "vn=" << vn
861 << "\n";
862 })
863}
864
865GPUdi() void TPCFastTransform::InverseTransformXYZtoNominalXYZ(int32_t slice, 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
866{
868 int32_t row2 = row + 1;
869 if (row2 >= getGeometry().getNumberOfRows()) {
870 row2 = row - 1;
871 }
872 float nx1, ny1, nz1; // nominal coordinates for row
873 float nx2, ny2, nz2; // nominal coordinates for row2
874 nx1 = getGeometry().getRowInfo(row).x;
875 nx2 = getGeometry().getRowInfo(row2).x;
876 InverseTransformYZtoNominalYZ(slice, row, y, z, ny1, nz1, ref, ref2, scale, scale2, scaleMode);
877 InverseTransformYZtoNominalYZ(slice, row2, y, z, ny2, nz2, ref, ref2, scale, scale2, scaleMode);
878 float c1 = (nx2 - nx) / (nx2 - nx1);
879 float c2 = (nx - nx1) / (nx2 - nx1);
880 nx = x;
881 ny = (ny1 * c1 + ny2 * c2);
882 nz = (nz1 * c1 + nz2 * c2);
883}
884
885} // namespace gpu
886} // namespace o2
887
888#endif
Definition of FlatObject class.
#define GPUCA_DEBUG_STREAMER_CHECK(...)
#define GPUCA_RTC_SPECIAL_CODE(...)
bool const GPUTPCGMMerger::trackCluster * c1
bool const GPUTPCGMMerger::trackCluster const clcomparestruct * c2
Definition of TPCFastSpaceChargeCorrection class.
Definition of TPCFastTransformGeo class.
GPUCA_GPUCODE.
Definition FlatObject.h:176
char * releaseInternalBuffer()
_____________ Methods for making the data buffer external __________________________
Definition FlatObject.h:526
void destroy()
_______________ Utilities _______________________________________________
Definition FlatObject.h:349
void startConstruction()
_____________ Construction _________
Definition FlatObject.h:342
static constexpr size_t getBufferAlignmentBytes()
_____________ FlatObject functionality, see FlatObject class for description ____________
Definition FlatObject.h:197
static constexpr size_t getClassAlignmentBytes()
_____________ Memory alignment __________________________
Definition FlatObject.h:194
GPUd() float getVDrift() const
Return mVDrift in cm / time bin.
void setActualBufferAddress(char *actualFlatBufferPtr)
Moving the class with its external buffer to another location.
int32_t float float float float float & z
int32_t float float float float float float maxTimeBin const
int32_t float float float float float float const TPCFastTransform const TPCFastTransform float float int32_t scaleMode
void setLumi(float l)
Set Lumi info.
void finishConstruction()
Finishes initialization: puts everything to the flat buffer, releases temporary memory.
void moveBufferTo(char *newBufferPtr)
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.
void setCalibration(int64_t timeStamp, float t0, float vDrift, float vDriftCorrY, float lDriftCorr, float tofCorr, float primVtxZ)
int32_t writeToFile(std::string outFName="", std::string name="")
GPUd() float getLumiError() const
Return map lumi error.
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
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 & v
GPUd() float getLumiScaleFactor() const
Return map user defined lumi scale factor.
GPUd() float getVdriftCorrY() const
Return VdriftCorrY in time_bin / cn.
int32_t float float float float & nz
~TPCFastTransform()=default
Destructor.
TPCFastTransform()
_____________ Constructors / destructors __________________________
static TPCFastTransform * loadFromFile(std::string inpFName="", std::string name="")
GPUd() float getTOFCorr() const
Return TOF correction (vdrift / C)
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.
GPUd() int64_t getTimeStamp() const
Gives the time stamp of the current calibaration parameters.
void print() const
Print method.
GPUd() float getLumi() const
Return map lumi.
int32_t float float float & u
int32_t float float float & ny
int32_t float float float & x
GPUd() const TPCFastSpaceChargeCorrection &getCorrection() const
Gives a reference for external initialization of TPC corrections.
const auto & getCorrectionSlow() const
GPUd() const TPCFastTransformGeo &getGeometry() const
_______________ Utilities _______________________________________________
GPUd() void Transform(int32_t slice
GPUd() float getT0() const
Return T0 in time bin units.
int32_t float float float float & nx
GPUd() float getLdriftCorr() const
Return LdriftCorr offset in cm.
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:38
GPUd() const expr uint32_t MultivariatePolynomialHelper< Dim
Global TPC definitions and constants.
Definition SimTraits.h:167
@ streamFastTransform
stream tpc fast transform
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
simple struct to hold the space charge object which can be used for CPU reconstruction only
ClassDefNV(TPCSlowSpaceChargeCorrection, 2)
o2::tpc::SpaceCharge< float > * mCorr
reference space charge corrections
void getCorrections(const float gx, const float gy, const float gz, const int32_t slice, float &gdxC, float &gdyC, float &gdzC) const
getting the corrections for global coordinates