28#include "GPUParam.inc"
39#include <oneapi/tbb.h>
43#define GET_CID(sector, i) (mIOPtrs->clustersNative->clusterOffset[sector][0] + i)
53 vBuf.first->emplace_back(
first);
54 vBuf.second->emplace_back(last -
first);
56inline void GPUDisplay::insertVertexList(int32_t
iSector,
size_t first,
size_t last)
59 insertVertexList(vBuf,
first, last);
62inline void GPUDisplay::drawPointLinestrip(int32_t
iSector, int32_t cid, int32_t
id, int32_t id_limit)
64 mVertexBuffer[
iSector].emplace_back(mGlobalPos[cid].
x, mGlobalPos[cid].
y * mYFactor, mCfgH.projectXY ? 0 : mGlobalPos[cid].
z);
66 while ((curVal = mGlobalPos[cid].
w) < id_limit) {
67 if (CAMath::AtomicCAS(&mGlobalPos[cid].
w, curVal, (
float)
id)) {
70 curVal = mGlobalPos[cid].
w;
74GPUDisplay::vboList GPUDisplay::DrawSpacePointsTRD(int32_t
iSector, int32_t
select, int32_t iCol)
76 size_t startCount = mVertexBufferStart[
iSector].size();
77 size_t startCountInner = mVertexBuffer[
iSector].size();
79 if (iCol == 0 && mCurrentSpacePointsTRD > 0) {
81 int32_t iSec = trdGeometry()->GetSector(mIOPtrs->
trdTracklets[
i].GetDetector());
84 mVertexBuffer[
iSector].emplace_back(mGlobalPosTRD[
i].
x, mGlobalPosTRD[
i].
y * mYFactor, mCfgH.projectXY ? 0 : mGlobalPosTRD[
i].
z);
85 mVertexBuffer[
iSector].emplace_back(mGlobalPosTRD2[
i].
x, mGlobalPosTRD2[
i].
y * mYFactor, mCfgH.projectXY ? 0 : mGlobalPosTRD2[
i].
z);
91 return (vboList(startCount, mVertexBufferStart[
iSector].
size() - startCount,
iSector));
94GPUDisplay::vboList GPUDisplay::DrawSpacePointsTOF(int32_t
iSector, int32_t
select, int32_t iCol)
96 size_t startCount = mVertexBufferStart[
iSector].size();
97 size_t startCountInner = mVertexBuffer[
iSector].size();
99 if (iCol == 0 &&
iSector == 0) {
101 mVertexBuffer[
iSector].emplace_back(mGlobalPosTOF[
i].
x, mGlobalPosTOF[
i].
y * mYFactor, mCfgH.projectXY ? 0 : mGlobalPosTOF[
i].
z);
106 return (vboList(startCount, mVertexBufferStart[
iSector].
size() - startCount,
iSector));
109GPUDisplay::vboList GPUDisplay::DrawSpacePointsITS(int32_t
iSector, int32_t
select, int32_t iCol)
111 size_t startCount = mVertexBufferStart[
iSector].size();
112 size_t startCountInner = mVertexBuffer[
iSector].size();
116 mVertexBuffer[
iSector].emplace_back(mGlobalPosITS[
i].
x, mGlobalPosITS[
i].
y * mYFactor, mCfgH.projectXY ? 0 : mGlobalPosITS[
i].
z);
121 return (vboList(startCount, mVertexBufferStart[
iSector].
size() - startCount,
iSector));
124void GPUDisplay::DrawClusters(int32_t
iSector)
126 std::vector<std::array<vecpod<vtx>, N_POINTS_TYPE_TPC>> vertexCache(mNCollissions);
127 if (mClusterBufferSizeCache[
iSector].
size() < (uint32_t)mNCollissions) {
128 mClusterBufferSizeCache[
iSector].resize(mNCollissions);
130 for (int32_t iCol = 0; iCol < mNCollissions; iCol++) {
131 for (int32_t
i = 0;
i < N_POINTS_TYPE_TPC;
i++) {
132 vertexCache[iCol][
i].reserve(mClusterBufferSizeCache[
iSector][iCol][
i]);
139 for (int32_t cidInSector = 0; cidInSector < nClustersInSector; cidInSector++) {
142 if (checkClusterCollision) {
147 if (mOverlayTFClusters.size()) {
148 while (
col < mOverlayTFClusters.size() && cidInSector >= mOverlayTFClusters[
col][
iSector]) {
152 if (mCfgH.hideUnmatchedClusters && mQA && mQA->
SuppressHit(cid)) {
155 int32_t
select = mGlobalPos[cid].
w;
157 if (mCfgH.markAdjacentClusters) {
160 if (mCfgH.markAdjacentClusters >= 32) {
161 if (mQA && mQA->
clusterRemovable(attach, mCfgH.markAdjacentClusters == 33)) {
172 }
else if (mCfgH.markAdjacentClusters & 8) {
178 }
else if (mCfgH.markClusters) {
181 if (
flags & mCfgH.markClusters) {
184 }
else if (mCfgH.markFakeClusters) {
189 vertexCache[
col][
select].emplace_back(mGlobalPos[cid].
x, mGlobalPos[cid].
y * mYFactor, mCfgH.projectXY ? 0 : mGlobalPos[cid].
z);
192 size_t startCountInner = mVertexBuffer[
iSector].size();
194 for (int32_t iCol = 0; iCol < mNCollissions; iCol++) {
195 for (int32_t
i = 0;
i < N_POINTS_TYPE_TPC;
i++) {
196 uint32_t
count = vertexCache[iCol][
i].size();
197 mClusterBufferSizeCache[
iSector][iCol][
i] = std::max(mClusterBufferSizeCache[
iSector][iCol][
i],
count);
199 memcpy((
void*)(mVertexBuffer[
iSector].
data() + startCountInner), (
const void*)vertexCache[iCol][
i].
data(),
count *
sizeof(vertexCache[iCol][
i][0]));
201 size_t startCount = mVertexBufferStart[
iSector].size();
202 insertVertexList(
iSector, startCountInner, startCountInner +
count);
203 startCountInner +=
count;
209GPUDisplay::vboList GPUDisplay::DrawLinks(
const GPUTPCTracker& tracker, int32_t
id,
bool dodown)
211 uint32_t
iSector = tracker.ISector();
212 if (mCfgH.clustersOnly) {
213 return (vboList(0, 0,
iSector));
215 size_t startCount = mVertexBufferStart[
iSector].size();
216 size_t startCountInner = mVertexBuffer[
iSector].size();
217 for (uint32_t
i = 0;
i < GPUTPCGeometry::NROWS;
i++) {
220 if (
i < GPUTPCGeometry::NROWS - 2) {
221 const GPUTPCRow& rowUp = tracker.Data().Row(
i + 2);
222 for (uint32_t
j = 0;
j <
row.NHits();
j++) {
225 const int32_t cid2 =
GET_CID(
iSector, tracker.Data().ClusterDataIndex(rowUp, tracker.Data().HitLinkUpData(
row,
j)));
226 drawPointLinestrip(
iSector, cid1,
id);
227 drawPointLinestrip(
iSector, cid2,
id);
232 if (dodown &&
i >= 2) {
233 const GPUTPCRow& rowDown = tracker.Data().Row(
i - 2);
234 for (uint32_t
j = 0;
j <
row.NHits();
j++) {
237 const int32_t cid2 =
GET_CID(
iSector, tracker.Data().ClusterDataIndex(rowDown, tracker.Data().HitLinkDownData(
row,
j)));
238 drawPointLinestrip(
iSector, cid1,
id);
239 drawPointLinestrip(
iSector, cid2,
id);
245 return (vboList(startCount, mVertexBufferStart[
iSector].
size() - startCount,
iSector));
248GPUDisplay::vboList GPUDisplay::DrawSeeds(
const GPUTPCTracker& tracker)
250 uint32_t
iSector = tracker.ISector();
251 if (mCfgH.clustersOnly) {
252 return (vboList(0, 0,
iSector));
254 size_t startCount = mVertexBufferStart[
iSector].size();
255 for (uint32_t
i = 0;
i < *tracker.NStartHits();
i++) {
257 size_t startCountInner = mVertexBuffer[
iSector].size();
258 int32_t
ir = hit.RowIndex();
259 calink ih = hit.HitIndex();
263 drawPointLinestrip(
iSector, cid, tSEED);
265 ih = tracker.Data().HitLinkUpData(
row, ih);
269 return (vboList(startCount, mVertexBufferStart[
iSector].
size() - startCount,
iSector));
272GPUDisplay::vboList GPUDisplay::DrawTracklets(
const GPUTPCTracker& tracker)
274 uint32_t
iSector = tracker.ISector();
275 if (mCfgH.clustersOnly) {
276 return (vboList(0, 0,
iSector));
278 size_t startCount = mVertexBufferStart[
iSector].size();
279 for (uint32_t
i = 0;
i < *tracker.NTracklets();
i++) {
281 size_t startCountInner = mVertexBuffer[
iSector].size();
283 for (uint32_t
j = tracklet.FirstRow();
j <= tracklet.LastRow();
j++) {
284 const calink rowHit = tracker.TrackletRowHits()[tracklet.FirstHit() + (
j - tracklet.FirstRow())];
287 const int32_t cid =
GET_CID(
iSector, tracker.Data().ClusterDataIndex(
row, rowHit));
288 oldpos = mGlobalPos[cid];
289 drawPointLinestrip(
iSector, cid, tTRACKLET);
294 return (vboList(startCount, mVertexBufferStart[
iSector].
size() - startCount,
iSector));
297GPUDisplay::vboList GPUDisplay::DrawTracks(
const GPUTPCTracker& tracker, int32_t global)
299 uint32_t
iSector = tracker.ISector();
300 if (mCfgH.clustersOnly) {
301 return (vboList(0, 0,
iSector));
303 size_t startCount = mVertexBufferStart[
iSector].size();
304 for (uint32_t
i = (global ? tracker.CommonMemory()->nLocalTracks : 0);
i < (global ? *tracker.NTracks() : tracker.CommonMemory()->nLocalTracks);
i++) {
306 size_t startCountInner = mVertexBuffer[
iSector].size();
307 for (int32_t
j = 0;
j <
track.NHits();
j++) {
309 const GPUTPCRow&
row = tracker.Data().Row(hit.RowIndex());
310 const int32_t cid =
GET_CID(
iSector, tracker.Data().ClusterDataIndex(
row, hit.HitIndex()));
311 drawPointLinestrip(
iSector, cid, tSECTORTRACK + global);
315 return (vboList(startCount, mVertexBufferStart[
iSector].
size() - startCount,
iSector));
318void GPUDisplay::DrawTrackITS(int32_t trackId, int32_t
iSector)
320 const auto& trk = mIOPtrs->
itsTracks[trackId];
321 for (int32_t k = 0; k < trk.getNClusters(); k++) {
322 int32_t cid = mIOPtrs->
itsTrackClusIdx[trk.getFirstClusterEntry() + k];
323 mVertexBuffer[
iSector].emplace_back(mGlobalPosITS[cid].
x, mGlobalPosITS[cid].
y * mYFactor, mCfgH.projectXY ? 0 : mGlobalPosITS[cid].
z);
324 mGlobalPosITS[cid].
w = tITSATTACHED;
328GPUDisplay::vboList GPUDisplay::DrawFinalITS()
331 size_t startCount = mVertexBufferStart[
iSector].size();
333 if (mITSStandaloneTracks[
i]) {
334 size_t startCountInner = mVertexBuffer[
iSector].size();
339 return (vboList(startCount, mVertexBufferStart[
iSector].
size() - startCount,
iSector));
345 auto& vBuf = threadBuffer.vBuf;
346 auto&
buffer = threadBuffer.buffer;
347 uint32_t nTracks = std::max(trackList[0].
size(), trackList[1].
size());
348 if (mCfgH.clustersOnly) {
351 for (uint32_t ii = 0; ii < nTracks; ii++) {
354 int32_t lastCluster = -1;
356 if (ii >= trackList[0].
size()) {
359 i = trackList[0][ii];
361 if constexpr (std::is_same_v<T, GPUTPCGMMergedTrack>) {
364 }
else if constexpr (std::is_same_v<T, o2::tpc::TrackTPC>) {
371 throw std::runtime_error(
"invalid type");
374 size_t startCountInner = mVertexBuffer[
iSector].size();
375 bool drawing =
false;
376 uint32_t lastSide = -1;
378 if constexpr (std::is_same_v<T, o2::tpc::TrackTPC>) {
387 if (mCfgH.trackFilter && !mTrackFilter[
i]) {
392 if constexpr (std::is_same_v<T, o2::tpc::TrackTPC>) {
396 mVertexBuffer[
iSector].emplace_back(mGlobalPosTOF[cid].
x, mGlobalPosTOF[cid].
y * mYFactor, mCfgH.projectXY ? 0 : mGlobalPosTOF[cid].
z);
397 mGlobalPosTOF[cid].
w = tTOFATTACHED;
398 lastSide = mGlobalPosTOF[cid].
z < 0;
403 auto tmpDoTRDTracklets = [
this, &drawing, &lastSide,
iSector](
const auto& trk) {
404 for (int32_t k = 5; k >= 0; k--) {
405 int32_t cid = trk.getTrackletIndex(k);
410 mVertexBuffer[
iSector].emplace_back(mGlobalPosTRD2[cid].
x, mGlobalPosTRD2[cid].
y * mYFactor, mCfgH.projectXY ? 0 : mGlobalPosTRD2[cid].
z);
411 mVertexBuffer[
iSector].emplace_back(mGlobalPosTRD[cid].
x, mGlobalPosTRD[cid].
y * mYFactor, mCfgH.projectXY ? 0 : mGlobalPosTRD[cid].
z);
412 lastSide = mGlobalPosTRD[cid].
z < 0;
413 mGlobalPosTRD[cid].
w = tTRDATTACHED;
419 tmpDoTRDTracklets(mIOPtrs->
trdTracksO2[mTRDTrackIds[
i]]);
421 tmpDoTRDTracklets(mIOPtrs->
trdTracks[mTRDTrackIds[
i]]);
424 }
else if constexpr (std::is_same_v<T, o2::tpc::TrackTPC>) {
428 const auto& trk = container[mIOPtrs->
tpcLinkTRD[
i] & 0x3FFFFFFF];
429 tmpDoTRDTracklets(trk);
435 int32_t separateExtrapolatedTracksLimit = (mCfgH.separateExtrapolatedTracks ? tEXTRAPOLATEDTRACK : TRACK_TYPE_ID_LIMIT);
436 if constexpr (std::is_same_v<T, GPUTPCGMMergedTrack>) {
437 if (
track->PrevSegment() >= 0) {
439 for (int32_t iChk = prevtrk.NClusters() - 1; iChk >= 0; iChk--) {
440 const auto& hit = mIOPtrs->
mergedTrackHits[prevtrk.FirstClusterRef() + iChk];
442 drawPointLinestrip(
iSector, hit.num, tFINALTRACK, separateExtrapolatedTracksLimit);
443 lastSide = mGlobalPos[hit.num].
z < 0;
451 for (int32_t k = 0; k <
nClusters; k++) {
452 if constexpr (std::is_same_v<T, GPUTPCGMMergedTrack>) {
458 if constexpr (std::is_same_v<T, GPUTPCGMMergedTrack>) {
463 int32_t
w = mGlobalPos[cid].
w;
465 if (mCfgH.splitCETracks && lastSide != (mGlobalPos[cid].z < 0)) {
466 insertVertexList(vBuf[0], startCountInner, mVertexBuffer[
iSector].
size());
470 drawPointLinestrip(
iSector, cid, tFINALTRACK, separateExtrapolatedTracksLimit);
473 if (
w == separateExtrapolatedTracksLimit) {
475 insertVertexList(vBuf[0], startCountInner, mVertexBuffer[
iSector].
size());
480 startCountInner = mVertexBuffer[
iSector].size();
481 if (lastCluster != -1 && (!mCfgH.splitCETracks || lastSide == (mGlobalPos[cid].z < 0))) {
483 if constexpr (std::is_same_v<T, GPUTPCGMMergedTrack>) {
488 drawPointLinestrip(
iSector, lastcid, tFINALTRACK, separateExtrapolatedTracksLimit);
490 drawPointLinestrip(
iSector, cid, tFINALTRACK, separateExtrapolatedTracksLimit);
495 lastSide = mGlobalPos[cid].
z < 0;
499 if constexpr (std::is_same_v<T, o2::tpc::TrackTPC>) {
504 insertVertexList(vBuf[0], startCountInner, mVertexBuffer[
iSector].
size());
511 if (mCfgL.propagateTracks == 0) {
516 for (int32_t iMC = 0; iMC < 2; iMC++) {
518 if (ii >= trackList[1].
size()) {
521 i = trackList[1][ii];
523 if (track ==
nullptr) {
526 if (lastCluster == -1) {
529 if constexpr (std::is_same_v<T, GPUTPCGMMergedTrack>) {
530 if (
track->MergedLooperConnected()) {
536 size_t startCountInner = mVertexBuffer[
iSector].size();
537 for (int32_t inFlyDirection = 0; inFlyDirection < 2; inFlyDirection++) {
546 if constexpr (std::is_same_v<T, GPUTPCGMMergedTrack>) {
547 trkParam.Set(
track->GetParam());
548 alphaOrg = mParam->Alpha(
iSector);
551 convertTrackParam(t, *track);
552 alphaOrg =
track->getAlpha();
557 if constexpr (std::is_same_v<T, GPUTPCGMMergedTrack>) {
560 GPUTPCConvertImpl::convert(*mCalib->
fastTransform, *mParam, cl.sector, cl.row, cln.getPad(), cln.getTime(),
x,
y,
z);
565 GPUTPCConvertImpl::convert(*mCalib->
fastTransform, *mParam, sector,
row, cln.getPad(), cln.getTime(),
x,
y,
z);
577 if (mc.
t0 == -100.f) {
581 alphaOrg = mParam->Alpha(
iSector);
582 float c = cosf(alphaOrg);
583 float s = sinf(alphaOrg);
587 mclocal[0] =
x *
c +
y *
s;
588 mclocal[1] = -
x *
s +
y *
c;
591 mclocal[2] = px *
c + py *
s;
592 mclocal[3] = -px *
s + py *
c;
597 trkParam.Set(mclocal[0], mclocal[1], mc.
z, mclocal[2], mclocal[3], mc.
pZ, -
charge);
598 if (mParam->
par.continuousTracking) {
602 if (fabsf(mc.
z) > GPUTPCGeometry::TPCLength()) {
603 ZOffset = mc.
z > 0 ? (mc.
z - GPUTPCGeometry::TPCLength()) : (mc.
z +
GPUTPCGeometry::TPCLength());
605 trkParam.Set(mclocal[0], mclocal[1], mc.
z - ZOffset, mclocal[2], mclocal[3], mc.
pZ,
charge);
608 float z0 = trkParam.
Z();
609 if (iMC && inFlyDirection == 0) {
615 if (fabsf(trkParam.SinPhi()) > 1) {
618 float alpha = alphaOrg;
622 while (nPoints++ < 5000) {
623 if ((inFlyDirection == 0 &&
x < 0) || (inFlyDirection &&
x *
x + trkParam.
Y() * trkParam.
Y() > (iMC ? (450 * 450) : (300 * 300)))) {
626 if (fabsf(trkParam.
Z() + ZOffset) > mMaxClusterZ) {
629 if (fabsf(trkParam.
Z() - z0) > (iMC ? GPUTPCGeometry::TPCLength() :
GPUTPCGeometry::TPCLength())) {
632 if (inFlyDirection) {
633 if (fabsf(trkParam.SinPhi()) > 0.4f) {
634 float dalpha = asinf(trkParam.SinPhi());
635 trkParam.Rotate(dalpha);
638 x = trkParam.X() + 1.f;
639 if (!mCfgH.propagateLoopers) {
640 float diff = fabsf(
alpha - alphaOrg) / (2.f * CAMath::Pi());
642 if (diff > 0.25f && diff < 0.75f) {
648 prop->GetBxByBz(
alpha, trkParam.GetX(), trkParam.GetY(), trkParam.GetZ(),
B);
650 if (trkParam.PropagateToXBxByBz(
x,
B[0],
B[1],
B[2], dLp)) {
653 if (fabsf(trkParam.SinPhi()) > 0.9f) {
657 float drawX = trkParam.X() + mCfgH.xAdd;
658 useBuffer.emplace_back((ca * drawX - sa * trkParam.
Y()) * GL_SCALE_FACTOR, (ca * trkParam.
Y() + sa * drawX) * mYFactor * GL_SCALE_FACTOR, mCfgH.projectXY ? 0 : (trkParam.Z() + ZOffset) * GL_SCALE_FACTOR);
659 x += inFlyDirection ? 1 : -1;
662 if (inFlyDirection == 0) {
664 for (int32_t k = (int32_t)
buffer.size() - 1; k >= 0; k--) {
668 insertVertexList(vBuf[1], startCountInner, mVertexBuffer[
iSector].
size());
669 startCountInner = mVertexBuffer[
iSector].size();
673 insertVertexList(vBuf[iMC ? 3 : 2], startCountInner, mVertexBuffer[
iSector].
size());
678GPUDisplay::vboList GPUDisplay::DrawGrid(
const GPUTPCTracker& tracker)
680 uint32_t
iSector = tracker.ISector();
681 size_t startCount = mVertexBufferStart[
iSector].size();
682 size_t startCountInner = mVertexBuffer[
iSector].size();
683 for (uint32_t
i = 0;
i < GPUTPCGeometry::NROWS;
i++) {
685 for (int32_t
j = 0;
j <= (signed)
row.Grid().Ny();
j++) {
686 float z1 =
row.Grid().ZMin();
687 float z2 =
row.Grid().ZMax();
688 float x =
row.X() + mCfgH.xAdd;
689 float y =
row.Grid().YMin() + (float)
j /
row.Grid().StepYInv();
690 float zz1, zz2, yy1, yy2, xx1, xx2;
691 mParam->Sector2Global(tracker.ISector(),
x,
y,
z1, &xx1, &yy1, &zz1);
692 mParam->Sector2Global(tracker.ISector(),
x,
y,
z2, &xx2, &yy2, &zz2);
700 mVertexBuffer[
iSector].emplace_back(xx1 * GL_SCALE_FACTOR, yy1 * GL_SCALE_FACTOR * mYFactor, zz1 * GL_SCALE_FACTOR);
701 mVertexBuffer[
iSector].emplace_back(xx2 * GL_SCALE_FACTOR, yy2 * GL_SCALE_FACTOR * mYFactor, zz2 * GL_SCALE_FACTOR);
703 for (int32_t
j = 0;
j <= (signed)
row.Grid().Nz();
j++) {
704 float y1 =
row.Grid().YMin();
705 float y2 =
row.Grid().YMax();
706 float x =
row.X() + mCfgH.xAdd;
707 float z =
row.Grid().ZMin() + (float)
j /
row.Grid().StepZInv();
708 float zz1, zz2, yy1, yy2, xx1, xx2;
709 mParam->Sector2Global(tracker.ISector(),
x,
y1,
z, &xx1, &yy1, &zz1);
710 mParam->Sector2Global(tracker.ISector(),
x,
y2,
z, &xx2, &yy2, &zz2);
718 mVertexBuffer[
iSector].emplace_back(xx1 * GL_SCALE_FACTOR, yy1 * GL_SCALE_FACTOR * mYFactor, zz1 * GL_SCALE_FACTOR);
719 mVertexBuffer[
iSector].emplace_back(xx2 * GL_SCALE_FACTOR, yy2 * GL_SCALE_FACTOR * mYFactor, zz2 * GL_SCALE_FACTOR);
722 insertVertexList(tracker.ISector(), startCountInner, mVertexBuffer[
iSector].size());
723 return (vboList(startCount, mVertexBufferStart[
iSector].
size() - startCount,
iSector));
726GPUDisplay::vboList GPUDisplay::DrawGridTRD(int32_t sector)
729 size_t startCount = mVertexBufferStart[sector].size();
730 size_t startCountInner = mVertexBuffer[sector].size();
731 auto* geo = trdGeometry();
733 int32_t trdsector = NSECTORS / 2 - 1 - sector;
734 float alpha = geo->GetAlpha() / 2.f + geo->GetAlpha() * trdsector;
735 if (trdsector >= 9) {
736 alpha -= 2 * CAMath::Pi();
740 int32_t iDet = geo->GetDetector(iLy, iStack, trdsector);
741 auto matrix = geo->GetClusterMatrix(iDet);
745 auto pp = geo->GetPadPlane(iDet);
746 for (int32_t
i = 0;
i < pp->GetNrows();
i++) {
751 xyzLoc1[0] = xyzLoc2[0] = geo->AnodePos();
752 xyzLoc1[1] = pp->GetCol0();
753 xyzLoc2[1] = pp->GetColEnd();
754 xyzLoc1[2] = xyzLoc2[2] = pp->GetRowPos(
i) - pp->GetRowPos(pp->GetNrows() / 2);
755 matrix->LocalToMaster(xyzLoc1, xyzGlb1);
756 matrix->LocalToMaster(xyzLoc2, xyzGlb2);
757 float x1Tmp = xyzGlb1[0];
758 xyzGlb1[0] = xyzGlb1[0] * cosf(
alpha) + xyzGlb1[1] * sinf(
alpha);
759 xyzGlb1[1] = -x1Tmp * sinf(
alpha) + xyzGlb1[1] * cosf(
alpha);
760 float x2Tmp = xyzGlb2[0];
761 xyzGlb2[0] = xyzGlb2[0] * cosf(
alpha) + xyzGlb2[1] * sinf(
alpha);
762 xyzGlb2[1] = -x2Tmp * sinf(
alpha) + xyzGlb2[1] * cosf(
alpha);
763 mVertexBuffer[sector].emplace_back(xyzGlb1[0] * GL_SCALE_FACTOR, xyzGlb1[1] * GL_SCALE_FACTOR * mYFactor, xyzGlb1[2] * GL_SCALE_FACTOR);
764 mVertexBuffer[sector].emplace_back(xyzGlb2[0] * GL_SCALE_FACTOR, xyzGlb2[1] * GL_SCALE_FACTOR * mYFactor, xyzGlb2[2] * GL_SCALE_FACTOR);
766 for (int32_t
j = 0;
j < pp->GetNcols(); ++
j) {
771 xyzLoc1[0] = xyzLoc2[0] = geo->AnodePos();
772 xyzLoc1[1] = xyzLoc2[1] = pp->GetColPos(
j) + pp->GetColSize(
j) / 2.f;
773 xyzLoc1[2] = pp->GetRow0() - pp->GetRowPos(pp->GetNrows() / 2);
774 xyzLoc2[2] = pp->GetRowEnd() - pp->GetRowPos(pp->GetNrows() / 2);
775 matrix->LocalToMaster(xyzLoc1, xyzGlb1);
776 matrix->LocalToMaster(xyzLoc2, xyzGlb2);
777 float x1Tmp = xyzGlb1[0];
778 xyzGlb1[0] = xyzGlb1[0] * cosf(
alpha) + xyzGlb1[1] * sinf(
alpha);
779 xyzGlb1[1] = -x1Tmp * sinf(
alpha) + xyzGlb1[1] * cosf(
alpha);
780 float x2Tmp = xyzGlb2[0];
781 xyzGlb2[0] = xyzGlb2[0] * cosf(
alpha) + xyzGlb2[1] * sinf(
alpha);
782 xyzGlb2[1] = -x2Tmp * sinf(
alpha) + xyzGlb2[1] * cosf(
alpha);
783 mVertexBuffer[sector].emplace_back(xyzGlb1[0] * GL_SCALE_FACTOR, xyzGlb1[1] * GL_SCALE_FACTOR * mYFactor, xyzGlb1[2] * GL_SCALE_FACTOR);
784 mVertexBuffer[sector].emplace_back(xyzGlb2[0] * GL_SCALE_FACTOR, xyzGlb2[1] * GL_SCALE_FACTOR * mYFactor, xyzGlb2[2] * GL_SCALE_FACTOR);
789 insertVertexList(sector, startCountInner, mVertexBuffer[sector].
size());
790 return (vboList(startCount, mVertexBufferStart[sector].
size() - startCount, sector));
793size_t GPUDisplay::DrawGLScene_updateVertexList()
796 for (int32_t
i = 0;
i < NSECTORS;
i++) {
797 mVertexBuffer[
i].clear();
798 mVertexBufferStart[
i].clear();
799 mVertexBufferCount[
i].clear();
802 for (int32_t
i = 0;
i < mCurrentClusters;
i++) {
803 mGlobalPos[
i].
w = tCLUSTER;
805 for (int32_t
i = 0;
i < mCurrentSpacePointsTRD;
i++) {
806 mGlobalPosTRD[
i].
w = tTRDCLUSTER;
810 for (int32_t
i = 0;
i < N_POINTS_TYPE;
i++) {
811 mGlDLPoints[
iSector][
i].resize(mNCollissions);
813 for (int32_t
i = 0;
i < N_FINAL_TYPE;
i++) {
814 mGlDLFinal[
iSector].resize(mNCollissions);
817 if (timer.IsRunning()) {
818 GPUInfo(
"Display Time: Vertex Init:\t\t\t%6.0f us", timer.GetCurrentElapsedTime(
true) * 1e6);
821 int32_t numThreads = getNumThreads();
822 tbb::task_arena(numThreads).execute([
this, &timer, numThreads] {
824 tbb::parallel_for(0, NSECTORS, [this](int32_t iSector) {
825 GPUTPCTracker& tracker = (GPUTPCTracker&)sectorTracker(iSector);
826 tracker.SetPointersDataLinks(tracker.LinkTmpMemory());
827 mGlDLLines[iSector][tINITLINK] = DrawLinks(tracker, tINITLINK, true);
828 tracker.SetPointersDataLinks(mChain->rec()->Res(tracker.MemoryResLinks()).Ptr());
829 }, tbb::simple_partitioner());
830 if (timer.IsRunning()) {
831 GPUInfo(
"Display Time: Vertex Links:\t\t\t%6.0f us", timer.GetCurrentElapsedTime(
true) * 1e6);
834 tbb::parallel_for(0, NSECTORS, [
this](int32_t
iSector) {
837 mGlDLLines[
iSector][tLINK] = DrawLinks(tracker, tLINK);
838 mGlDLLines[
iSector][tSEED] = DrawSeeds(tracker);
839 mGlDLLines[
iSector][tTRACKLET] = DrawTracklets(tracker);
840 mGlDLLines[
iSector][tSECTORTRACK] = DrawTracks(tracker, 0);
841 mGlDLGrid[
iSector] = DrawGrid(tracker);
845 }, tbb::simple_partitioner());
846 if (timer.IsRunning()) {
847 GPUInfo(
"Display Time: Vertex Seeds:\t\t\t%6.0f us", timer.GetCurrentElapsedTime(
true) * 1e6);
850 tbb::parallel_for(0, NSECTORS, [
this](int32_t
iSector) {
852 mGlDLLines[
iSector][tEXTRAPOLATEDTRACK] = DrawTracks(tracker, 1);
853 }, tbb::simple_partitioner());
854 if (timer.IsRunning()) {
855 GPUInfo(
"Display Time: Vertex Sector Tracks:\t\t%6.0f us", timer.GetCurrentElapsedTime(
true) * 1e6);
858 tbb::parallel_for(0, numThreads, [
this](int32_t iThread) {
859 mThreadTracks[iThread].resize(mNCollissions);
860 for (int32_t
i = 0;
i < mNCollissions;
i++) {
861 for (int32_t
j = 0;
j < NSECTORS;
j++) {
862 for (int32_t k = 0; k < 2; k++) {
863 mThreadTracks[iThread][
i][
j][k].clear();
867 }, tbb::simple_partitioner());
868 if (mConfig.showTPCTracksFromO2Format) {
873 if (mIOPtrs->clustersNative) {
874 mIOPtrs->outputTracksTPCO2[i].getCluster(mIOPtrs->outputClusRefsTPCO2, 0, *mIOPtrs->clustersNative, sector, row);
879 col = mQA->GetMCLabelCol(mIOPtrs->outputTracksTPCO2MC[i]);
885 tbb::parallel_for<uint32_t>(0, mIOPtrs->nMergedTracks, [
this](
auto i) {
886 const GPUTPCGMMergedTrack* track = &mIOPtrs->mergedTracks[i];
887 if (track->NClusters() == 0) {
890 if (mCfgH.hideRejectedTracks && !
track->OK()) {
893 int32_t sector = mIOPtrs->mergedTrackHits[
track->FirstClusterRef() +
track->NClusters() - 1].sector;
896 const auto&
label = mQA->GetMCTrackLabel(
i);
900 while (
label.isValid() &&
col < mOverlayTFClusters.size() && mOverlayTFClusters[
col][NSECTORS] <
label.track) {
908 for (uint32_t
col = 0;
col < mIOPtrs->nMCInfosTPCCol;
col++) {
909 tbb::parallel_for(mIOPtrs->mcInfosTPCCol[
col].first, mIOPtrs->mcInfosTPCCol[
col].first + mIOPtrs->mcInfosTPCCol[
col].num, [
this,
col](uint32_t
i) {
910 const GPUTPCMCInfo& mc = mIOPtrs->mcInfosTPC[i];
911 if (mc.charge == 0.f) {
918 float alpha = atan2f(mc.
y, mc.
x);
920 alpha += 2 * CAMath::Pi();
922 int32_t sector =
alpha / (2 * CAMath::Pi()) * 18;
929 if (timer.IsRunning()) {
930 GPUInfo(
"Display Time: Vertex Sort merged tracks:\t%6.0f us", timer.GetCurrentElapsedTime(
true) * 1e6);
934 prop.SetMaxSinPhi(.999);
935 prop.SetMaterialTPC();
936 prop.SetPolynomialField(&mParam->polynomialField);
938 tbb::parallel_for(0, NSECTORS, [
this, numThreads, prop](int32_t
iSector) {
940 for (int32_t iCol = 0; iCol < mNCollissions; iCol++) {
941 mThreadBuffers[numThread].clear();
942 for (int32_t iSet = 0; iSet < numThreads; iSet++) {
943 if (mConfig.showTPCTracksFromO2Format) {
944 DrawFinal<o2::tpc::TrackTPC>(
iSector, iCol, &prop, mThreadTracks[iSet][iCol][
iSector], mThreadBuffers[numThread]);
946 DrawFinal<GPUTPCGMMergedTrack>(
iSector, iCol, &prop, mThreadTracks[iSet][iCol][
iSector], mThreadBuffers[numThread]);
950 for (int32_t
i = 0;
i < N_FINAL_TYPE;
i++) {
951 size_t startCount = mVertexBufferStart[
iSector].size();
952 for (uint32_t
j = 0;
j < mThreadBuffers[numThread].start[
i].size();
j++) {
953 mVertexBufferStart[
iSector].emplace_back(mThreadBuffers[numThread].
start[
i][
j]);
954 mVertexBufferCount[
iSector].emplace_back(mThreadBuffers[numThread].
count[
i][
j]);
959 }, tbb::simple_partitioner());
960 if (timer.IsRunning()) {
961 GPUInfo(
"Display Time: Vertex Merged Tracks:\t\t%6.0f us", timer.GetCurrentElapsedTime(
true) * 1e6);
964 tbb::parallel_for(0, NSECTORS, [
this](int32_t
iSector) {
966 }, tbb::simple_partitioner());
967 if (timer.IsRunning()) {
968 GPUInfo(
"Display Time: Vertex Clusters:\t\t\t%6.0f us", timer.GetCurrentElapsedTime(
true) * 1e6);
973 mGlDLFinalITS = DrawFinalITS();
975 for (int32_t
i = N_POINTS_TYPE_TPC + N_POINTS_TYPE_TRD + N_POINTS_TYPE_TOF;
i < N_POINTS_TYPE_TPC + N_POINTS_TYPE_TRD + N_POINTS_TYPE_TOF + N_POINTS_TYPE_ITS;
i++) {
976 for (int32_t iCol = 0; iCol < mNCollissions; iCol++) {
984 if (timer.IsRunning()) {
985 GPUInfo(
"Display Time: Vertex ITS:\t\t\t%6.0f us", timer.GetCurrentElapsedTime(
true) * 1e6);
989 for (int32_t
i = N_POINTS_TYPE_TPC;
i < N_POINTS_TYPE_TPC + N_POINTS_TYPE_TRD;
i++) {
990 for (int32_t iCol = 0; iCol < mNCollissions; iCol++) {
995 if (timer.IsRunning()) {
996 GPUInfo(
"Display Time: Vertex TRD:\t\t\t%6.0f us", timer.GetCurrentElapsedTime(
true) * 1e6);
1000 for (int32_t
i = N_POINTS_TYPE_TPC + N_POINTS_TYPE_TRD;
i < N_POINTS_TYPE_TPC + N_POINTS_TYPE_TRD + N_POINTS_TYPE_TOF;
i++) {
1001 for (int32_t iCol = 0; iCol < mNCollissions; iCol++) {
1008 if (timer.IsRunning()) {
1009 GPUInfo(
"Display Time: Vertex TOF:\t\t\t%6.0f us", timer.GetCurrentElapsedTime(
true) * 1e6);
1012 mTracksArePropagated = mCfgL.propagateTracks != 0;
1013 mUpdateVertexLists =
false;
1014 size_t totalVertizes = 0;
1015 for (int32_t
i = 0;
i < NSECTORS;
i++) {
1016 totalVertizes += mVertexBuffer[
i].size();
1018 if (totalVertizes > 0xFFFFFFFF) {
1019 throw std::runtime_error(
"Display vertex count exceeds 32bit uint32_t counter");
1021 size_t needMultiVBOSize = mBackend->needMultiVBO();
1022 mUseMultiVBO = needMultiVBOSize && (totalVertizes *
sizeof(mVertexBuffer[0][0]) >= needMultiVBOSize);
1023 if (!mUseMultiVBO) {
1024 size_t totalYet = mVertexBuffer[0].size();
1025 mVertexBuffer[0].resize(totalVertizes);
1026 for (uint32_t
i = 1;
i < GPUTPCGeometry::NSECTORS;
i++) {
1027 for (uint32_t
j = 0;
j < mVertexBufferStart[
i].size();
j++) {
1028 mVertexBufferStart[
i][
j] += totalYet;
1030 memcpy(&mVertexBuffer[0][totalYet], &mVertexBuffer[
i][0], mVertexBuffer[
i].
size() *
sizeof(mVertexBuffer[
i][0]));
1031 totalYet += mVertexBuffer[
i].size();
1032 mVertexBuffer[
i].clear();
1035 mBackend->loadDataToGPU(totalVertizes);
1036 for (uint32_t
i = 0;
i < (mUseMultiVBO ? GPUTPCGeometry::NSECTORS : 1);
i++) {
1037 mVertexBuffer[
i].clear();
1039 if (timer.IsRunning()) {
1040 GPUInfo(
"Display Time: Vertex Final:\t\t\t%6.0f us", timer.GetCurrentElapsedTime(
true) * 1e6);
1043 return totalVertizes;
A const (ready only) version of MCTruthContainer.
#define GET_CID(sector, i)
#define CALINK_DEAD_CHANNEL
Online TRD tracker based on extrapolated TPC tracks.
TRD Tracklet word for GPU tracker - 32bit tracklet info + half chamber ID + index.
std::vector< o2::MCCompLabel > labels
Definition of the ITS track.
GPUReconstruction::RecoStepField GetRecoSteps() const
const GPUSettingsProcessing & GetProcessingSettings() const
const GPUConstantMem * GetProcessors() const
const GPUSettingsProcessing & GetProcessingSettings() const
bool clusterRemovable(int32_t attach, bool prot) const
int32_t HitAttachStatus(int32_t iHit) const
bool SuppressHit(int32_t iHit) const
static int32_t getHostThreadIndex()
GLfloat GLfloat GLfloat alpha
GLuint GLfloat GLfloat GLfloat GLfloat y1
GLuint GLsizei const GLchar * label
GLubyte GLubyte GLubyte GLubyte w
GLdouble GLdouble GLdouble z
bool list(IEventListener &reporter, Config const &config)
uint8_t itsSharedClusterMap uint8_t
std::vector< InputSpec > select(char const *matcher="")
float float float float float z2
float float float float z1
const bool const int TrackITSInternal< NLayers > & track
if(!okForPhiMin(phi0, phi1))
S< o2::trd::GeometryFlat >::type * trdGeometry
S< TPCFastTransformPOD >::type * fastTransform
GPUTPCTracker tpcTrackers[GPUTPCGeometry::NSECTORS]
const o2::tpc::ClusterNativeAccess * clustersNative
const GPUTPCMCInfo * mcInfosTPC
const uint32_t * outputClusRefsTPCO2
const int32_t * itsTrackClusIdx
const o2::BaseCluster< float > * itsClusters
const uint32_t * mergedTrackHitAttachment
const GPUTRDTrackGPU * trdTracks
uint32_t nTRDTracksTPCTRD
const GPUTRDTrackletWord * trdTracklets
const GPUTRDTrack * trdTracksO2
const o2::its::TrackITS * itsTracks
const o2::MCCompLabel * outputTracksTPCO2MC
uint32_t nOutputTracksTPCO2
const o2::tpc::TrackTPC * outputTracksTPCO2
const GPUTPCGMMergedTrackHit * mergedTrackHits
const GPUTRDTrack * trdTracksITSTPCTRD
uint32_t nTRDTracksITSTPCTRD
const GPUTPCGMMergedTrack * mergedTracks
int32_t continuousMaxTimeBin
unsigned int nClustersSector[constants::MAXSECTOR]
const o2::dataformats::ConstMCTruthContainerView< o2::MCCompLabel > * clustersMCTruth
const ClusterNative * clustersLinear
o2::InteractionRecord ir(0, 0)
typename std::vector< T, vecpod_allocator< T > > vecpod