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)
58 std::pair<vecpod<int32_t>*,
vecpod<uint32_t>*> vBuf(mVertexBufferStart + iSector, mVertexBufferCount + iSector);
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();
81 int32_t iSec = trdGeometry()->GetSector(mIOPtrs->
trdTracklets[
i].GetDetector());
82 bool draw = iSector == iSec && mGlobalPosTRD[
i].
w ==
select;
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);
90 insertVertexList(iSector, startCountInner, mVertexBuffer[iSector].
size());
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);
105 insertVertexList(iSector, startCountInner, mVertexBuffer[iSector].
size());
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();
114 if (iCol == 0 && iSector == 0 && mIOPtrs->
itsClusters) {
116 mVertexBuffer[iSector].emplace_back(mGlobalPosITS[
i].
x, mGlobalPosITS[
i].
y * mYFactor, mCfgH.projectXY ? 0 : mGlobalPosITS[
i].
z);
120 insertVertexList(iSector, startCountInner, mVertexBuffer[iSector].
size());
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++) {
140 const int32_t cid =
GET_CID(iSector, cidInSector);
141#ifdef GPUCA_TPC_GEOMETRY_O2
142 if (checkClusterCollision) {
144 col = labels.size() ? mQA->GetMCLabelCol(labels[0]) : 0;
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();
193 mVertexBuffer[iSector].resize(mVertexBuffer[iSector].
size() + nClustersInSector);
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);
198 memcpy((
void*)&mVertexBuffer[iSector][startCountInner], (
const void*)vertexCache[iCol][
i].
data(),
count *
sizeof(vertexCache[iCol][
i][0]));
199 size_t startCount = mVertexBufferStart[iSector].size();
200 insertVertexList(iSector, startCountInner, startCountInner +
count);
201 startCountInner +=
count;
202 mGlDLPoints[iSector][
i][iCol] = vboList(startCount, mVertexBufferStart[iSector].
size() - startCount, iSector);
207GPUDisplay::vboList GPUDisplay::DrawLinks(
const GPUTPCTracker& tracker, int32_t
id,
bool dodown)
209 int32_t iSector = tracker.ISector();
210 if (mCfgH.clustersOnly) {
211 return (vboList(0, 0, iSector));
213 size_t startCount = mVertexBufferStart[iSector].size();
214 size_t startCountInner = mVertexBuffer[iSector].size();
219 const GPUTPCRow& rowUp = tracker.Data().Row(
i + 2);
220 for (int32_t
j = 0;
j <
row.NHits();
j++) {
222 const int32_t cid1 =
GET_CID(iSector, tracker.Data().ClusterDataIndex(
row,
j));
223 const int32_t cid2 =
GET_CID(iSector, tracker.Data().ClusterDataIndex(rowUp, tracker.Data().HitLinkUpData(
row,
j)));
224 drawPointLinestrip(iSector, cid1,
id);
225 drawPointLinestrip(iSector, cid2,
id);
230 if (dodown &&
i >= 2) {
231 const GPUTPCRow& rowDown = tracker.Data().Row(
i - 2);
232 for (int32_t
j = 0;
j <
row.NHits();
j++) {
234 const int32_t cid1 =
GET_CID(iSector, tracker.Data().ClusterDataIndex(
row,
j));
235 const int32_t cid2 =
GET_CID(iSector, tracker.Data().ClusterDataIndex(rowDown, tracker.Data().HitLinkDownData(
row,
j)));
236 drawPointLinestrip(iSector, cid1,
id);
237 drawPointLinestrip(iSector, cid2,
id);
242 insertVertexList(iSector, startCountInner, mVertexBuffer[iSector].
size());
243 return (vboList(startCount, mVertexBufferStart[iSector].
size() - startCount, iSector));
246GPUDisplay::vboList GPUDisplay::DrawSeeds(
const GPUTPCTracker& tracker)
248 int32_t iSector = tracker.ISector();
249 if (mCfgH.clustersOnly) {
250 return (vboList(0, 0, iSector));
252 size_t startCount = mVertexBufferStart[iSector].size();
253 for (uint32_t
i = 0;
i < *tracker.NStartHits();
i++) {
255 size_t startCountInner = mVertexBuffer[iSector].size();
256 int32_t
ir = hit.RowIndex();
257 calink ih = hit.HitIndex();
260 const int32_t cid =
GET_CID(iSector, tracker.Data().ClusterDataIndex(
row, ih));
261 drawPointLinestrip(iSector, cid, tSEED);
263 ih = tracker.Data().HitLinkUpData(
row, ih);
265 insertVertexList(iSector, startCountInner, mVertexBuffer[iSector].
size());
267 return (vboList(startCount, mVertexBufferStart[iSector].
size() - startCount, iSector));
270GPUDisplay::vboList GPUDisplay::DrawTracklets(
const GPUTPCTracker& tracker)
272 int32_t iSector = tracker.ISector();
273 if (mCfgH.clustersOnly) {
274 return (vboList(0, 0, iSector));
276 size_t startCount = mVertexBufferStart[iSector].size();
277 for (uint32_t
i = 0;
i < *tracker.NTracklets();
i++) {
279 size_t startCountInner = mVertexBuffer[iSector].size();
281 for (int32_t
j = tracklet.FirstRow();
j <= tracklet.LastRow();
j++) {
282 const calink rowHit = tracker.TrackletRowHits()[tracklet.FirstHit() + (
j - tracklet.FirstRow())];
285 const int32_t cid =
GET_CID(iSector, tracker.Data().ClusterDataIndex(
row, rowHit));
286 oldpos = mGlobalPos[cid];
287 drawPointLinestrip(iSector, cid, tTRACKLET);
290 insertVertexList(iSector, startCountInner, mVertexBuffer[iSector].
size());
292 return (vboList(startCount, mVertexBufferStart[iSector].
size() - startCount, iSector));
295GPUDisplay::vboList GPUDisplay::DrawTracks(
const GPUTPCTracker& tracker, int32_t global)
297 int32_t iSector = tracker.ISector();
298 if (mCfgH.clustersOnly) {
299 return (vboList(0, 0, iSector));
301 size_t startCount = mVertexBufferStart[iSector].size();
302 for (uint32_t
i = (global ? tracker.CommonMemory()->nLocalTracks : 0);
i < (global ? *tracker.NTracks() : tracker.CommonMemory()->nLocalTracks);
i++) {
304 size_t startCountInner = mVertexBuffer[iSector].size();
305 for (int32_t
j = 0;
j < track.NHits();
j++) {
306 const GPUTPCHitId& hit = tracker.TrackHits()[track.FirstHitID() +
j];
307 const GPUTPCRow&
row = tracker.Data().Row(hit.RowIndex());
308 const int32_t cid =
GET_CID(iSector, tracker.Data().ClusterDataIndex(
row, hit.HitIndex()));
309 drawPointLinestrip(iSector, cid, tSECTORTRACK + global);
311 insertVertexList(iSector, startCountInner, mVertexBuffer[iSector].
size());
313 return (vboList(startCount, mVertexBufferStart[iSector].
size() - startCount, iSector));
316void GPUDisplay::DrawTrackITS(int32_t trackId, int32_t iSector)
318 const auto& trk = mIOPtrs->
itsTracks[trackId];
319 for (int32_t k = 0; k < trk.getNClusters(); k++) {
320 int32_t cid = mIOPtrs->
itsTrackClusIdx[trk.getFirstClusterEntry() + k];
321 mVertexBuffer[iSector].emplace_back(mGlobalPosITS[cid].
x, mGlobalPosITS[cid].
y * mYFactor, mCfgH.projectXY ? 0 : mGlobalPosITS[cid].
z);
322 mGlobalPosITS[cid].
w = tITSATTACHED;
326GPUDisplay::vboList GPUDisplay::DrawFinalITS()
328 const int32_t iSector = 0;
329 size_t startCount = mVertexBufferStart[iSector].size();
331 if (mITSStandaloneTracks[
i]) {
332 size_t startCountInner = mVertexBuffer[iSector].size();
333 DrawTrackITS(
i, iSector);
334 insertVertexList(iSector, startCountInner, mVertexBuffer[iSector].
size());
337 return (vboList(startCount, mVertexBufferStart[iSector].
size() - startCount, iSector));
341void GPUDisplay::DrawFinal(int32_t iSector, int32_t ,
const GPUTPCGMPropagator* prop, std::array<
vecpod<int32_t>, 2>& trackList, threadVertexBuffer& threadBuffer)
343 auto& vBuf = threadBuffer.vBuf;
344 auto&
buffer = threadBuffer.buffer;
345 uint32_t nTracks = std::max(trackList[0].
size(), trackList[1].
size());
346 if (mCfgH.clustersOnly) {
349 for (uint32_t ii = 0; ii < nTracks; ii++) {
351 const T* track =
nullptr;
352 int32_t lastCluster = -1;
354 if (ii >= trackList[0].
size()) {
357 i = trackList[0][ii];
359 if constexpr (std::is_same_v<T, GPUTPCGMMergedTrack>) {
362 }
else if constexpr (std::is_same_v<T, o2::tpc::TrackTPC>) {
369 throw std::runtime_error(
"invalid type");
372 size_t startCountInner = mVertexBuffer[iSector].size();
373 bool drawing =
false;
374 uint32_t lastSide = -1;
376 if constexpr (std::is_same_v<T, o2::tpc::TrackTPC>) {
385 if (mCfgH.trackFilter && !mTrackFilter[
i]) {
390 if constexpr (std::is_same_v<T, o2::tpc::TrackTPC>) {
394 mVertexBuffer[iSector].emplace_back(mGlobalPosTOF[cid].
x, mGlobalPosTOF[cid].
y * mYFactor, mCfgH.projectXY ? 0 : mGlobalPosTOF[cid].
z);
395 mGlobalPosTOF[cid].
w = tTOFATTACHED;
396 lastSide = mGlobalPosTOF[cid].
z < 0;
401 auto tmpDoTRDTracklets = [&](
const auto& trk) {
402 for (int32_t k = 5; k >= 0; k--) {
403 int32_t cid = trk.getTrackletIndex(k);
408 mVertexBuffer[iSector].emplace_back(mGlobalPosTRD2[cid].
x, mGlobalPosTRD2[cid].
y * mYFactor, mCfgH.projectXY ? 0 : mGlobalPosTRD2[cid].
z);
409 mVertexBuffer[iSector].emplace_back(mGlobalPosTRD[cid].
x, mGlobalPosTRD[cid].
y * mYFactor, mCfgH.projectXY ? 0 : mGlobalPosTRD[cid].
z);
410 lastSide = mGlobalPosTRD[cid].
z < 0;
411 mGlobalPosTRD[cid].
w = tTRDATTACHED;
417 tmpDoTRDTracklets(mIOPtrs->
trdTracksO2[mTRDTrackIds[
i]]);
419 tmpDoTRDTracklets(mIOPtrs->
trdTracks[mTRDTrackIds[
i]]);
422 }
else if constexpr (std::is_same_v<T, o2::tpc::TrackTPC>) {
426 const auto& trk = container[mIOPtrs->
tpcLinkTRD[
i] & 0x3FFFFFFF];
427 tmpDoTRDTracklets(trk);
433 int32_t separateExtrapolatedTracksLimit = (mCfgH.separateExtrapolatedTracks ? tEXTRAPOLATEDTRACK : TRACK_TYPE_ID_LIMIT);
434 if constexpr (std::is_same_v<T, GPUTPCGMMergedTrack>) {
435 if (track->PrevSegment() >= 0) {
436 const auto& prevtrk = mIOPtrs->
mergedTracks[track->PrevSegment()];
437 for (int32_t iChk = prevtrk.NClusters() - 1; iChk >= 0; iChk--) {
438 const auto& hit = mIOPtrs->
mergedTrackHits[prevtrk.FirstClusterRef() + iChk];
440 drawPointLinestrip(iSector, hit.num, tFINALTRACK, separateExtrapolatedTracksLimit);
441 lastSide = mGlobalPos[hit.num].
z < 0;
449 for (int32_t k = 0; k <
nClusters; k++) {
450 if constexpr (std::is_same_v<T, GPUTPCGMMergedTrack>) {
456 if constexpr (std::is_same_v<T, GPUTPCGMMergedTrack>) {
461 int32_t
w = mGlobalPos[cid].
w;
463 if (mCfgH.splitCETracks && lastSide != (mGlobalPos[cid].z < 0)) {
464 insertVertexList(vBuf[0], startCountInner, mVertexBuffer[iSector].
size());
468 drawPointLinestrip(iSector, cid, tFINALTRACK, separateExtrapolatedTracksLimit);
471 if (
w == separateExtrapolatedTracksLimit) {
473 insertVertexList(vBuf[0], startCountInner, mVertexBuffer[iSector].
size());
478 startCountInner = mVertexBuffer[iSector].size();
479 if (lastCluster != -1 && (!mCfgH.splitCETracks || lastSide == (mGlobalPos[cid].z < 0))) {
481 if constexpr (std::is_same_v<T, GPUTPCGMMergedTrack>) {
486 drawPointLinestrip(iSector, lastcid, tFINALTRACK, separateExtrapolatedTracksLimit);
488 drawPointLinestrip(iSector, cid, tFINALTRACK, separateExtrapolatedTracksLimit);
493 lastSide = mGlobalPos[cid].
z < 0;
497 if constexpr (std::is_same_v<T, o2::tpc::TrackTPC>) {
502 insertVertexList(vBuf[0], startCountInner, mVertexBuffer[iSector].
size());
509 if (mCfgL.propagateTracks == 0) {
514 for (int32_t iMC = 0; iMC < 2; iMC++) {
516 if (ii >= trackList[1].
size()) {
519 i = trackList[1][ii];
521 if (track ==
nullptr) {
524 if (lastCluster == -1) {
527 if constexpr (std::is_same_v<T, GPUTPCGMMergedTrack>) {
528 if (track->MergedLooperConnected()) {
534 size_t startCountInner = mVertexBuffer[iSector].size();
535 for (int32_t inFlyDirection = 0; inFlyDirection < 2; inFlyDirection++) {
544 if constexpr (std::is_same_v<T, GPUTPCGMMergedTrack>) {
545 trkParam.Set(track->GetParam());
546 alphaOrg = mParam->Alpha(iSector);
549 convertTrackParam(t, *track);
550 alphaOrg = track->getAlpha();
555 if constexpr (std::is_same_v<T, GPUTPCGMMergedTrack>) {
556 auto cl = mIOPtrs->
mergedTrackHits[track->FirstClusterRef() + lastCluster];
558 GPUTPCConvertImpl::convert(*mCalib->
fastTransform, *mParam, cl.sector, cl.row, cln.getPad(), cln.getTime(),
x,
y,
z);
563 GPUTPCConvertImpl::convert(*mCalib->
fastTransform, *mParam, sector,
row, cln.getPad(), cln.getTime(),
x,
y,
z);
574 if (mc.t0 == -100.f) {
578 alphaOrg = mParam->Alpha(iSector);
579 float c = cosf(alphaOrg);
580 float s = sinf(alphaOrg);
584 mclocal[0] =
x *
c +
y *
s;
585 mclocal[1] = -
x *
s +
y *
c;
588 mclocal[2] = px *
c + py *
s;
589 mclocal[3] = -px *
s + py *
c;
593#ifdef GPUCA_TPC_GEOMETRY_O2
594 trkParam.Set(mclocal[0], mclocal[1], mc.
z, mclocal[2], mclocal[3], mc.
pZ, -
charge);
595 if (mParam->
par.continuousTracking) {
599 if (fabsf(mc.
z) > GPUTPCGeometry::TPCLength()) {
600 ZOffset = mc.
z > 0 ? (mc.
z - GPUTPCGeometry::TPCLength()) : (mc.
z +
GPUTPCGeometry::TPCLength());
602 trkParam.Set(mclocal[0], mclocal[1], mc.
z - ZOffset, mclocal[2], mclocal[3], mc.
pZ,
charge);
605 float z0 = trkParam.
Z();
606 if (iMC && inFlyDirection == 0) {
612 if (fabsf(trkParam.SinPhi()) > 1) {
615 float alpha = alphaOrg;
616 vecpod<vtx>& useBuffer = iMC && inFlyDirection == 0 ?
buffer : mVertexBuffer[iSector];
619 while (nPoints++ < 5000) {
620 if ((inFlyDirection == 0 &&
x < 0) || (inFlyDirection &&
x *
x + trkParam.
Y() * trkParam.
Y() > (iMC ? (450 * 450) : (300 * 300)))) {
623 if (fabsf(trkParam.
Z() + ZOffset) > mMaxClusterZ) {
626 if (fabsf(trkParam.
Z() - z0) > (iMC ? GPUTPCGeometry::TPCLength() :
GPUTPCGeometry::TPCLength())) {
629 if (inFlyDirection) {
630 if (fabsf(trkParam.SinPhi()) > 0.4f) {
631 float dalpha = asinf(trkParam.SinPhi());
632 trkParam.Rotate(dalpha);
635 x = trkParam.X() + 1.f;
636 if (!mCfgH.propagateLoopers) {
637 float diff = fabsf(
alpha - alphaOrg) / (2.f * CAMath::Pi());
639 if (diff > 0.25f && diff < 0.75f) {
645 prop->GetBxByBz(
alpha, trkParam.GetX(), trkParam.GetY(), trkParam.GetZ(),
B);
647 if (trkParam.PropagateToXBxByBz(
x,
B[0],
B[1],
B[2], dLp)) {
650 if (fabsf(trkParam.SinPhi()) > 0.9f) {
654 float drawX = trkParam.X() + mCfgH.xAdd;
655 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);
656 x += inFlyDirection ? 1 : -1;
659 if (inFlyDirection == 0) {
661 for (int32_t k = (int32_t)
buffer.size() - 1; k >= 0; k--) {
662 mVertexBuffer[iSector].emplace_back(
buffer[k]);
665 insertVertexList(vBuf[1], startCountInner, mVertexBuffer[iSector].
size());
666 startCountInner = mVertexBuffer[iSector].size();
670 insertVertexList(vBuf[iMC ? 3 : 2], startCountInner, mVertexBuffer[iSector].
size());
675GPUDisplay::vboList GPUDisplay::DrawGrid(
const GPUTPCTracker& tracker)
677 int32_t iSector = tracker.ISector();
678 size_t startCount = mVertexBufferStart[iSector].size();
679 size_t startCountInner = mVertexBuffer[iSector].size();
682 for (int32_t
j = 0;
j <= (signed)
row.Grid().Ny();
j++) {
683 float z1 =
row.Grid().ZMin();
684 float z2 =
row.Grid().ZMax();
685 float x =
row.X() + mCfgH.xAdd;
686 float y =
row.Grid().YMin() + (float)
j /
row.Grid().StepYInv();
687 float zz1, zz2, yy1, yy2, xx1, xx2;
688 mParam->Sector2Global(tracker.ISector(),
x,
y,
z1, &xx1, &yy1, &zz1);
689 mParam->Sector2Global(tracker.ISector(),
x,
y,
z2, &xx2, &yy2, &zz2);
697 mVertexBuffer[iSector].emplace_back(xx1 * GL_SCALE_FACTOR, yy1 * GL_SCALE_FACTOR * mYFactor, zz1 * GL_SCALE_FACTOR);
698 mVertexBuffer[iSector].emplace_back(xx2 * GL_SCALE_FACTOR, yy2 * GL_SCALE_FACTOR * mYFactor, zz2 * GL_SCALE_FACTOR);
700 for (int32_t
j = 0;
j <= (signed)
row.Grid().Nz();
j++) {
701 float y1 =
row.Grid().YMin();
702 float y2 =
row.Grid().YMax();
703 float x =
row.X() + mCfgH.xAdd;
704 float z =
row.Grid().ZMin() + (float)
j /
row.Grid().StepZInv();
705 float zz1, zz2, yy1, yy2, xx1, xx2;
706 mParam->Sector2Global(tracker.ISector(),
x,
y1,
z, &xx1, &yy1, &zz1);
707 mParam->Sector2Global(tracker.ISector(),
x,
y2,
z, &xx2, &yy2, &zz2);
715 mVertexBuffer[iSector].emplace_back(xx1 * GL_SCALE_FACTOR, yy1 * GL_SCALE_FACTOR * mYFactor, zz1 * GL_SCALE_FACTOR);
716 mVertexBuffer[iSector].emplace_back(xx2 * GL_SCALE_FACTOR, yy2 * GL_SCALE_FACTOR * mYFactor, zz2 * GL_SCALE_FACTOR);
719 insertVertexList(tracker.ISector(), startCountInner, mVertexBuffer[iSector].size());
720 return (vboList(startCount, mVertexBufferStart[iSector].
size() - startCount, iSector));
723GPUDisplay::vboList GPUDisplay::DrawGridTRD(int32_t sector)
726 size_t startCount = mVertexBufferStart[sector].size();
727 size_t startCountInner = mVertexBuffer[sector].size();
728 auto* geo = trdGeometry();
730 int32_t trdsector = NSECTORS / 2 - 1 - sector;
731 float alpha = geo->GetAlpha() / 2.f + geo->GetAlpha() * trdsector;
732 if (trdsector >= 9) {
733 alpha -= 2 * CAMath::Pi();
737 int32_t iDet = geo->GetDetector(iLy, iStack, trdsector);
738 auto matrix = geo->GetClusterMatrix(iDet);
742 auto pp = geo->GetPadPlane(iDet);
743 for (int32_t
i = 0;
i < pp->GetNrows();
i++) {
748 xyzLoc1[0] = xyzLoc2[0] = geo->AnodePos();
749 xyzLoc1[1] = pp->GetCol0();
750 xyzLoc2[1] = pp->GetColEnd();
751 xyzLoc1[2] = xyzLoc2[2] = pp->GetRowPos(
i) - pp->GetRowPos(pp->GetNrows() / 2);
752 matrix->LocalToMaster(xyzLoc1, xyzGlb1);
753 matrix->LocalToMaster(xyzLoc2, xyzGlb2);
754 float x1Tmp = xyzGlb1[0];
755 xyzGlb1[0] = xyzGlb1[0] * cosf(
alpha) + xyzGlb1[1] * sinf(
alpha);
756 xyzGlb1[1] = -x1Tmp * sinf(
alpha) + xyzGlb1[1] * cosf(
alpha);
757 float x2Tmp = xyzGlb2[0];
758 xyzGlb2[0] = xyzGlb2[0] * cosf(
alpha) + xyzGlb2[1] * sinf(
alpha);
759 xyzGlb2[1] = -x2Tmp * sinf(
alpha) + xyzGlb2[1] * cosf(
alpha);
760 mVertexBuffer[sector].emplace_back(xyzGlb1[0] * GL_SCALE_FACTOR, xyzGlb1[1] * GL_SCALE_FACTOR * mYFactor, xyzGlb1[2] * GL_SCALE_FACTOR);
761 mVertexBuffer[sector].emplace_back(xyzGlb2[0] * GL_SCALE_FACTOR, xyzGlb2[1] * GL_SCALE_FACTOR * mYFactor, xyzGlb2[2] * GL_SCALE_FACTOR);
763 for (int32_t
j = 0;
j < pp->GetNcols(); ++
j) {
768 xyzLoc1[0] = xyzLoc2[0] = geo->AnodePos();
769 xyzLoc1[1] = xyzLoc2[1] = pp->GetColPos(
j) + pp->GetColSize(
j) / 2.f;
770 xyzLoc1[2] = pp->GetRow0() - pp->GetRowPos(pp->GetNrows() / 2);
771 xyzLoc2[2] = pp->GetRowEnd() - pp->GetRowPos(pp->GetNrows() / 2);
772 matrix->LocalToMaster(xyzLoc1, xyzGlb1);
773 matrix->LocalToMaster(xyzLoc2, xyzGlb2);
774 float x1Tmp = xyzGlb1[0];
775 xyzGlb1[0] = xyzGlb1[0] * cosf(
alpha) + xyzGlb1[1] * sinf(
alpha);
776 xyzGlb1[1] = -x1Tmp * sinf(
alpha) + xyzGlb1[1] * cosf(
alpha);
777 float x2Tmp = xyzGlb2[0];
778 xyzGlb2[0] = xyzGlb2[0] * cosf(
alpha) + xyzGlb2[1] * sinf(
alpha);
779 xyzGlb2[1] = -x2Tmp * sinf(
alpha) + xyzGlb2[1] * cosf(
alpha);
780 mVertexBuffer[sector].emplace_back(xyzGlb1[0] * GL_SCALE_FACTOR, xyzGlb1[1] * GL_SCALE_FACTOR * mYFactor, xyzGlb1[2] * GL_SCALE_FACTOR);
781 mVertexBuffer[sector].emplace_back(xyzGlb2[0] * GL_SCALE_FACTOR, xyzGlb2[1] * GL_SCALE_FACTOR * mYFactor, xyzGlb2[2] * GL_SCALE_FACTOR);
786 insertVertexList(sector, startCountInner, mVertexBuffer[sector].
size());
787 return (vboList(startCount, mVertexBufferStart[sector].
size() - startCount, sector));
790size_t GPUDisplay::DrawGLScene_updateVertexList()
793 for (int32_t
i = 0;
i < NSECTORS;
i++) {
794 mVertexBuffer[
i].clear();
795 mVertexBufferStart[
i].clear();
796 mVertexBufferCount[
i].clear();
799 for (int32_t
i = 0;
i < mCurrentClusters;
i++) {
800 mGlobalPos[
i].
w = tCLUSTER;
802 for (int32_t
i = 0;
i < mCurrentSpacePointsTRD;
i++) {
803 mGlobalPosTRD[
i].
w = tTRDCLUSTER;
806 for (int32_t iSector = 0; iSector < NSECTORS; iSector++) {
807 for (int32_t
i = 0;
i < N_POINTS_TYPE;
i++) {
808 mGlDLPoints[iSector][
i].resize(mNCollissions);
810 for (int32_t
i = 0;
i < N_FINAL_TYPE;
i++) {
811 mGlDLFinal[iSector].resize(mNCollissions);
814 if (timer.IsRunning()) {
815 GPUInfo(
"Display Time: Vertex Init:\t\t\t%6.0f us", timer.GetCurrentElapsedTime(
true) * 1e6);
818 int32_t numThreads = getNumThreads();
819 tbb::task_arena(numThreads).execute([&] {
821 tbb::parallel_for(0, NSECTORS, [&](int32_t iSector) {
822 GPUTPCTracker& tracker = (GPUTPCTracker&)sectorTracker(iSector);
823 tracker.SetPointersDataLinks(tracker.LinkTmpMemory());
824 mGlDLLines[iSector][tINITLINK] = DrawLinks(tracker, tINITLINK, true);
825 tracker.SetPointersDataLinks(mChain->rec()->Res(tracker.MemoryResLinks()).Ptr());
826 }, tbb::simple_partitioner());
827 if (timer.IsRunning()) {
828 GPUInfo(
"Display Time: Vertex Links:\t\t\t%6.0f us", timer.GetCurrentElapsedTime(
true) * 1e6);
831 tbb::parallel_for(0, NSECTORS, [&](int32_t iSector) {
834 mGlDLLines[iSector][tLINK] = DrawLinks(tracker, tLINK);
835 mGlDLLines[iSector][tSEED] = DrawSeeds(tracker);
836 mGlDLLines[iSector][tTRACKLET] = DrawTracklets(tracker);
837 mGlDLLines[iSector][tSECTORTRACK] = DrawTracks(tracker, 0);
838 mGlDLGrid[iSector] = DrawGrid(tracker);
839 if (iSector < NSECTORS / 2) {
840 mGlDLGridTRD[iSector] = DrawGridTRD(iSector);
842 }, tbb::simple_partitioner());
843 if (timer.IsRunning()) {
844 GPUInfo(
"Display Time: Vertex Seeds:\t\t\t%6.0f us", timer.GetCurrentElapsedTime(
true) * 1e6);
847 tbb::parallel_for(0, NSECTORS, [&](int32_t iSector) {
849 mGlDLLines[iSector][tEXTRAPOLATEDTRACK] = DrawTracks(tracker, 1);
850 }, tbb::simple_partitioner());
851 if (timer.IsRunning()) {
852 GPUInfo(
"Display Time: Vertex Sector Tracks:\t\t%6.0f us", timer.GetCurrentElapsedTime(
true) * 1e6);
855 tbb::parallel_for(0, numThreads, [&](int32_t iThread) {
856 mThreadTracks[iThread].resize(mNCollissions);
857 for (int32_t
i = 0;
i < mNCollissions;
i++) {
858 for (int32_t
j = 0;
j < NSECTORS;
j++) {
859 for (int32_t k = 0; k < 2; k++) {
860 mThreadTracks[iThread][
i][
j][k].clear();
864 }, tbb::simple_partitioner());
865 if (mConfig.showTPCTracksFromO2Format) {
866#ifdef GPUCA_TPC_GEOMETRY_O2
870 if (mIOPtrs->clustersNative) {
871 mIOPtrs->outputTracksTPCO2[i].getCluster(mIOPtrs->outputClusRefsTPCO2, 0, *mIOPtrs->clustersNative, sector, row);
876 col = mQA->GetMCLabelCol(mIOPtrs->outputTracksTPCO2MC[i]);
882 tbb::parallel_for<uint32_t>(0, mIOPtrs->nMergedTracks, [&](
auto i) {
883 const GPUTPCGMMergedTrack* track = &mIOPtrs->mergedTracks[i];
884 if (track->NClusters() == 0) {
887 if (mCfgH.hideRejectedTracks && !track->OK()) {
890 int32_t sector = mIOPtrs->mergedTrackHits[track->FirstClusterRef() + track->NClusters() - 1].sector;
893 const auto&
label = mQA->GetMCTrackLabel(
i);
894#ifdef GPUCA_TPC_GEOMETRY_O2
897 while (
label.isValid() &&
col < mOverlayTFClusters.size() && mOverlayTFClusters[
col][NSECTORS] <
label.track) {
905 for (uint32_t
col = 0;
col < mIOPtrs->nMCInfosTPCCol;
col++) {
906 tbb::parallel_for(mIOPtrs->mcInfosTPCCol[
col].first, mIOPtrs->mcInfosTPCCol[
col].first + mIOPtrs->mcInfosTPCCol[
col].num, [&](uint32_t
i) {
907 const GPUTPCMCInfo& mc = mIOPtrs->mcInfosTPC[i];
908 if (mc.charge == 0.f) {
915 float alpha = atan2f(mc.
y, mc.
x);
917 alpha += 2 * CAMath::Pi();
919 int32_t sector =
alpha / (2 * CAMath::Pi()) * 18;
926 if (timer.IsRunning()) {
927 GPUInfo(
"Display Time: Vertex Sort merged tracks:\t%6.0f us", timer.GetCurrentElapsedTime(
true) * 1e6);
931 prop.SetMaxSinPhi(.999);
932 prop.SetMaterialTPC();
933 prop.SetPolynomialField(&mParam->polynomialField);
935 tbb::parallel_for(0, NSECTORS, [&](int32_t iSector) {
937 for (int32_t iCol = 0; iCol < mNCollissions; iCol++) {
938 mThreadBuffers[numThread].clear();
939 for (int32_t iSet = 0; iSet < numThreads; iSet++) {
940 if (mConfig.showTPCTracksFromO2Format) {
941 DrawFinal<o2::tpc::TrackTPC>(iSector, iCol, &prop, mThreadTracks[iSet][iCol][iSector], mThreadBuffers[numThread]);
943 DrawFinal<GPUTPCGMMergedTrack>(iSector, iCol, &prop, mThreadTracks[iSet][iCol][iSector], mThreadBuffers[numThread]);
946 vboList*
list = &mGlDLFinal[iSector][iCol][0];
947 for (int32_t
i = 0;
i < N_FINAL_TYPE;
i++) {
948 size_t startCount = mVertexBufferStart[iSector].size();
949 for (uint32_t
j = 0;
j < mThreadBuffers[numThread].start[
i].size();
j++) {
950 mVertexBufferStart[iSector].emplace_back(mThreadBuffers[numThread].
start[
i][
j]);
951 mVertexBufferCount[iSector].emplace_back(mThreadBuffers[numThread].
count[
i][
j]);
953 list[
i] = vboList(startCount, mVertexBufferStart[iSector].
size() - startCount, iSector);
956 }, tbb::simple_partitioner());
957 if (timer.IsRunning()) {
958 GPUInfo(
"Display Time: Vertex Merged Tracks:\t\t%6.0f us", timer.GetCurrentElapsedTime(
true) * 1e6);
961 tbb::parallel_for(0, NSECTORS, [&](int32_t iSector) {
962 DrawClusters(iSector);
963 }, tbb::simple_partitioner());
964 if (timer.IsRunning()) {
965 GPUInfo(
"Display Time: Vertex Clusters:\t\t\t%6.0f us", timer.GetCurrentElapsedTime(
true) * 1e6);
971 mGlDLFinalITS = DrawFinalITS();
972 for (int32_t iSector = 0; iSector < NSECTORS; iSector++) {
973 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++) {
974 for (int32_t iCol = 0; iCol < mNCollissions; iCol++) {
975 mGlDLPoints[iSector][
i][iCol] = DrawSpacePointsITS(iSector,
i, iCol);
981 if (timer.IsRunning()) {
982 GPUInfo(
"Display Time: Vertex ITS:\t\t\t%6.0f us", timer.GetCurrentElapsedTime(
true) * 1e6);
985 for (int32_t iSector = 0; iSector < NSECTORS; iSector++) {
986 for (int32_t
i = N_POINTS_TYPE_TPC;
i < N_POINTS_TYPE_TPC + N_POINTS_TYPE_TRD;
i++) {
987 for (int32_t iCol = 0; iCol < mNCollissions; iCol++) {
988 mGlDLPoints[iSector][
i][iCol] = DrawSpacePointsTRD(iSector,
i, iCol);
992 if (timer.IsRunning()) {
993 GPUInfo(
"Display Time: Vertex TRD:\t\t\t%6.0f us", timer.GetCurrentElapsedTime(
true) * 1e6);
996 for (int32_t iSector = 0; iSector < NSECTORS; iSector++) {
997 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++) {
998 for (int32_t iCol = 0; iCol < mNCollissions; iCol++) {
999 mGlDLPoints[iSector][
i][iCol] = DrawSpacePointsTOF(iSector,
i, iCol);
1004 if (timer.IsRunning()) {
1005 GPUInfo(
"Display Time: Vertex TOF:\t\t\t%6.0f us", timer.GetCurrentElapsedTime(
true) * 1e6);
1008 mTracksArePropagated = mCfgL.propagateTracks != 0;
1009 mUpdateVertexLists =
false;
1010 size_t totalVertizes = 0;
1011 for (int32_t
i = 0;
i < NSECTORS;
i++) {
1012 totalVertizes += mVertexBuffer[
i].size();
1014 if (totalVertizes > 0xFFFFFFFF) {
1015 throw std::runtime_error(
"Display vertex count exceeds 32bit uint32_t counter");
1017 size_t needMultiVBOSize = mBackend->needMultiVBO();
1018 mUseMultiVBO = needMultiVBOSize && (totalVertizes *
sizeof(mVertexBuffer[0][0]) >= needMultiVBOSize);
1019 if (!mUseMultiVBO) {
1020 size_t totalYet = mVertexBuffer[0].size();
1021 mVertexBuffer[0].resize(totalVertizes);
1023 for (uint32_t
j = 0;
j < mVertexBufferStart[
i].size();
j++) {
1024 mVertexBufferStart[
i][
j] += totalYet;
1026 memcpy(&mVertexBuffer[0][totalYet], &mVertexBuffer[
i][0], mVertexBuffer[
i].
size() *
sizeof(mVertexBuffer[
i][0]));
1027 totalYet += mVertexBuffer[
i].size();
1028 mVertexBuffer[
i].clear();
1031 mBackend->loadDataToGPU(totalVertizes);
1033 mVertexBuffer[
i].clear();
1035 if (timer.IsRunning()) {
1036 GPUInfo(
"Display Time: Vertex Final:\t\t\t%6.0f us", timer.GetCurrentElapsedTime(
true) * 1e6);
1039 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.
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
uint8_t itsSharedClusterMap uint8_t
std::vector< InputSpec > select(char const *matcher="")
float float float float float z2
float float float float z1
if(!okForPhiMin(phi0, phi1))
S< o2::trd::GeometryFlat >::type * trdGeometry
S< TPCFastTransform >::type * fastTransform
S< CorrectionMapsHelper >::type * fastTransformHelper
GPUTPCTracker tpcTrackers[GPUCA_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