Skip to content

Commit a0256cf

Browse files
committed
GPU Display: Show ITS and TOF Clusters
1 parent ce3c49d commit a0256cf

9 files changed

Lines changed: 186 additions & 16 deletions

File tree

GPU/GPUTracking/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,8 +279,11 @@ if(ALIGPU_BUILD_TYPE STREQUAL "O2")
279279
PUBLIC_LINK_LIBRARIES O2::GPUCommon
280280
O2::GPUUtils
281281
O2::DataFormatsTPC
282+
O2::DataFormatsTOF
282283
O2::TPCBase
283284
O2::TRDBase
285+
O2::TOFBase
286+
O2::ITSBase
284287
O2::ITStracking
285288
O2::TPCFastTransformation
286289
O2::DetectorsRaw

GPU/GPUTracking/Definitions/GPUSettingsList.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,8 @@ AddOption(pointSize, float, 2.0f, "", 0, "Set point size")
183183
AddOption(lineWidth, float, 1.4f, "", 0, "Set line width")
184184
AddOption(drawTPC, bool, true, "", 0, "Enable drawing TPC data")
185185
AddOption(drawTRD, bool, true, "", 0, "Enabale drawing TRD data")
186+
AddOption(drawTOF, bool, true, "", 0, "Enabale drawing TOF data")
187+
AddOption(drawITS, bool, true, "", 0, "Enabale drawing ITS data")
186188
AddHelp("help", 'h')
187189
EndConfig()
188190

GPU/GPUTracking/Standalone/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ include_directories(${GPUTRACKING_DIR}/TPCClusterFinder
151151
${O2_DIR}/DataFormats/common/include
152152
${O2_DIR}/DataFormats/Detectors/Common/include
153153
${O2_DIR}/DataFormats/Detectors/ITSMFT/ITS/include
154+
${O2_DIR}/DataFormats/Detectors/TOF/include
154155
${O2_DIR}/DataFormats/Detectors/TPC/include
155156
${O2_DIR}/DataFormats/Detectors/TRD/include
156157
${O2_DIR}/DataFormats/Headers/include
@@ -160,12 +161,15 @@ include_directories(${GPUTRACKING_DIR}/TPCClusterFinder
160161
${O2_DIR}/DataFormats/simulation/include
161162
${O2_DIR}/Detectors/Base/include
162163
${O2_DIR}/Detectors/Base/src
164+
${O2_DIR}/Detectors/ITSMFT/common/base/include
165+
${O2_DIR}/Detectors/ITSMFT/ITS/base/include
163166
${O2_DIR}/Detectors/ITSMFT/ITS/tracking/include
164167
${O2_DIR}/Detectors/ITSMFT/ITS/tracking/cuda/include
165168
${O2_DIR}/Detectors/ITSMFT/ITS/tracking/cuda/src
166169
${O2_DIR}/Detectors/ITSMFT/ITS/tracking/hip/include
167170
${O2_DIR}/Detectors/ITSMFT/ITS/tracking/hip/src
168171
${O2_DIR}/Detectors/Raw/include
172+
${O2_DIR}/Detectors/TOF/base/include
169173
${O2_DIR}/Detectors/TPC/base/include
170174
${O2_DIR}/Detectors/TRD/base/include
171175
${O2_DIR}/Detectors/TRD/base/src)

GPU/GPUTracking/display/GPUDisplay.cxx

Lines changed: 134 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@
5858

5959
#ifdef HAVE_O2HEADERS
6060
#include "DataFormatsTPC/TrackTPC.h"
61+
#include "DataFormatsTOF/Cluster.h"
62+
#include "TOFBase/Geo.h"
63+
#include "ITSBase/GeometryTGeo.h"
6164
#endif
6265

6366
#include "GPUDisplayShaders.h"
@@ -362,6 +365,30 @@ inline void GPUDisplay::SetColorTRD()
362365
}
363366
ActivateColor();
364367
}
368+
inline void GPUDisplay::SetColorITS()
369+
{
370+
if (mCfg.colorCollisions) {
371+
return;
372+
}
373+
if (mInvertColors) {
374+
mDrawColor = {1.00, 0.1, 0.1};
375+
} else {
376+
mDrawColor = {1.00, 0.3, 0.3};
377+
}
378+
ActivateColor();
379+
}
380+
inline void GPUDisplay::SetColorTOF()
381+
{
382+
if (mCfg.colorCollisions) {
383+
return;
384+
}
385+
if (mInvertColors) {
386+
mDrawColor = {0.1, 1.0, 0.1};
387+
} else {
388+
mDrawColor = {0.5, 1.0, 0.5};
389+
}
390+
ActivateColor();
391+
}
365392
inline void GPUDisplay::SetColorInitLinks()
366393
{
367394
if (mInvertColors) {
@@ -737,6 +764,36 @@ GPUDisplay::vboList GPUDisplay::DrawSpacePointsTRD(int iSlice, int select, int i
737764
return (vboList(startCount, mVertexBufferStart[iSlice].size() - startCount, iSlice));
738765
}
739766

767+
GPUDisplay::vboList GPUDisplay::DrawSpacePointsTOF(int iSlice, int select, int iCol)
768+
{
769+
size_t startCount = mVertexBufferStart[iSlice].size();
770+
size_t startCountInner = mVertexBuffer[iSlice].size();
771+
772+
if (iCol == 0 && iSlice == 0) {
773+
for (unsigned int i = 0; i < mIOPtrs->nTOFClusters; i++) {
774+
mVertexBuffer[iSlice].emplace_back(mGlobalPosTOF[i].x, mGlobalPosTOF[i].y, mProjectXY ? 0 : mGlobalPosTOF[i].z);
775+
}
776+
}
777+
778+
insertVertexList(iSlice, startCountInner, mVertexBuffer[iSlice].size());
779+
return (vboList(startCount, mVertexBufferStart[iSlice].size() - startCount, iSlice));
780+
}
781+
782+
GPUDisplay::vboList GPUDisplay::DrawSpacePointsITS(int iSlice, int select, int iCol)
783+
{
784+
size_t startCount = mVertexBufferStart[iSlice].size();
785+
size_t startCountInner = mVertexBuffer[iSlice].size();
786+
787+
if (iCol == 0 && iSlice == 0 && mIOPtrs->itsClusters) {
788+
for (unsigned int i = 0; i < mIOPtrs->nItsClusters; i++) {
789+
mVertexBuffer[iSlice].emplace_back(mGlobalPosITS[i].x, mGlobalPosITS[i].y, mProjectXY ? 0 : mGlobalPosITS[i].z);
790+
}
791+
}
792+
793+
insertVertexList(iSlice, startCountInner, mVertexBuffer[iSlice].size());
794+
return (vboList(startCount, mVertexBufferStart[iSlice].size() - startCount, iSlice));
795+
}
796+
740797
GPUDisplay::vboList GPUDisplay::DrawClusters(int iSlice, int select, int iCol)
741798
{
742799
size_t startCount = mVertexBufferStart[iSlice].size();
@@ -1330,6 +1387,21 @@ int GPUDisplay::DrawGLScene_internal(bool mixAnimation, float mAnimateTime)
13301387
mGlobalPosTRD = mGlobalPosPtrTRD.get();
13311388
mGlobalPosTRD2 = mGlobalPosPtrTRD2.get();
13321389
}
1390+
1391+
mCurrentClustersITS = mIOPtrs->itsClusters ? mIOPtrs->nItsClusters : 0;
1392+
if (mNMaxClustersITS < mCurrentClustersITS) {
1393+
mNMaxClustersITS = mCurrentClustersITS;
1394+
mGlobalPosPtrITS.reset(new float4[mNMaxClustersITS]);
1395+
mGlobalPosITS = mGlobalPosPtrITS.get();
1396+
}
1397+
1398+
mCurrentClustersTOF = mIOPtrs->nTOFClusters;
1399+
if (mNMaxClustersTOF < mCurrentClustersTOF) {
1400+
mNMaxClustersTOF = mCurrentClustersTOF;
1401+
mGlobalPosPtrTOF.reset(new float4[mNMaxClustersTOF]);
1402+
mGlobalPosTOF = mGlobalPosPtrTOF.get();
1403+
}
1404+
13331405
unsigned int nTpcMergedTracks = mConfig.showTPCTracksFromO2Format ? mIOPtrs->nOutputTracksTPCO2 : mIOPtrs->nMergedTracks;
13341406
if ((size_t)nTpcMergedTracks > mTRDTrackIds.size()) {
13351407
mTRDTrackIds.resize(nTpcMergedTracks);
@@ -1344,12 +1416,8 @@ int GPUDisplay::DrawGLScene_internal(bool mixAnimation, float mAnimateTime)
13441416
}
13451417

13461418
mMaxClusterZ = 0;
1347-
bool error = false;
13481419
GPUCA_OPENMP(parallel for num_threads(getNumThreads()) reduction(max : mMaxClusterZ))
13491420
for (int iSlice = 0; iSlice < NSLICES; iSlice++) {
1350-
if (error) {
1351-
continue;
1352-
}
13531421
int row = 0;
13541422
unsigned int nCls = mParam->par.earlyTpcTransform ? mIOPtrs->nClusterData[iSlice] : mIOPtrs->clustersNative->nClustersSector[iSlice];
13551423
for (unsigned int i = 0; i < nCls; i++) {
@@ -1365,9 +1433,7 @@ int GPUDisplay::DrawGLScene_internal(bool mixAnimation, float mAnimateTime)
13651433
}
13661434
}
13671435
if (cid >= mNMaxClusters) {
1368-
GPUError("Cluster Buffer Size exceeded (id %d max %d)", cid, mNMaxClusters);
1369-
error = true;
1370-
break;
1436+
throw std::runtime_error("Cluster Buffer Size exceeded");
13711437
}
13721438
float4* ptr = &mGlobalPos[cid];
13731439
if (mParam->par.earlyTpcTransform) {
@@ -1397,9 +1463,6 @@ int GPUDisplay::DrawGLScene_internal(bool mixAnimation, float mAnimateTime)
13971463
ptr->w = tCLUSTER;
13981464
}
13991465
}
1400-
if (error) {
1401-
return (1);
1402-
}
14031466

14041467
GPUCA_OPENMP(parallel for num_threads(getNumThreads()) reduction(max : mMaxClusterZ))
14051468
for (int i = 0; i < mCurrentSpacePointsTRD; i++) {
@@ -1425,6 +1488,41 @@ int GPUDisplay::DrawGLScene_internal(bool mixAnimation, float mAnimateTime)
14251488
ptr->w = tTRDCLUSTER;
14261489
}
14271490

1491+
GPUCA_OPENMP(parallel for num_threads(getNumThreads()) reduction(max : mMaxClusterZ))
1492+
for (int i = 0; i < mCurrentClustersTOF; i++) {
1493+
float4* ptr = &mGlobalPosTOF[i];
1494+
#ifdef HAVE_O2HEADERS
1495+
mParam->Slice2Global(mIOPtrs->tofClusters[i].getSector(), mIOPtrs->tofClusters[i].getX() + mXadd, mIOPtrs->tofClusters[i].getY(), mIOPtrs->tofClusters[i].getZ(), &ptr->x, &ptr->y, &ptr->z);
1496+
ptr->x /= GL_SCALE_FACTOR;
1497+
ptr->y /= GL_SCALE_FACTOR;
1498+
ptr->z /= GL_SCALE_FACTOR;
1499+
#endif
1500+
if (fabsf(ptr->z) > mMaxClusterZ) {
1501+
mMaxClusterZ = fabsf(ptr->z);
1502+
}
1503+
ptr->w = tTOFCLUSTER;
1504+
}
1505+
1506+
//GPUCA_OPENMP(parallel for num_threads(getNumThreads()) reduction(max : mMaxClusterZ))
1507+
for (int i = 0; i < mCurrentClustersITS; i++) {
1508+
float4* ptr = &mGlobalPosITS[i];
1509+
#ifdef HAVE_O2HEADERS
1510+
const auto& cl = mIOPtrs->itsClusters[i];
1511+
auto* itsGeo = o2::its::GeometryTGeo::Instance();
1512+
auto p = cl.getXYZGlo(*itsGeo);
1513+
ptr->x = p.X();
1514+
ptr->y = p.Y();
1515+
ptr->z = p.Z();
1516+
ptr->x /= GL_SCALE_FACTOR;
1517+
ptr->y /= GL_SCALE_FACTOR;
1518+
ptr->z /= GL_SCALE_FACTOR;
1519+
#endif
1520+
if (fabsf(ptr->z) > mMaxClusterZ) {
1521+
mMaxClusterZ = fabsf(ptr->z);
1522+
}
1523+
ptr->w = tITSCLUSTER;
1524+
}
1525+
14281526
mTimerFPS.ResetStart();
14291527
mFramesDoneFPS = 0;
14301528
mFPSScaleadjust = 0;
@@ -1913,6 +2011,24 @@ int GPUDisplay::DrawGLScene_internal(bool mixAnimation, float mAnimateTime)
19132011
}
19142012
}
19152013

2014+
for (int iSlice = 0; iSlice < NSLICES; iSlice++) {
2015+
for (int i = N_POINTS_TYPE_TPC + N_POINTS_TYPE_TRD; i < N_POINTS_TYPE_TPC + N_POINTS_TYPE_TRD + N_POINTS_TYPE_TOF; i++) {
2016+
for (int iCol = 0; iCol < mNCollissions; iCol++) {
2017+
mGlDLPoints[iSlice][i][iCol] = DrawSpacePointsTOF(iSlice, i, iCol);
2018+
}
2019+
}
2020+
break; // TODO: Only slice 0 filled for now
2021+
}
2022+
2023+
for (int iSlice = 0; iSlice < NSLICES; iSlice++) {
2024+
for (int 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++) {
2025+
for (int iCol = 0; iCol < mNCollissions; iCol++) {
2026+
mGlDLPoints[iSlice][i][iCol] = DrawSpacePointsITS(iSlice, i, iCol);
2027+
}
2028+
}
2029+
break; // TODO: Only slice 0 filled for now
2030+
}
2031+
19162032
mGlDLrecent = 1;
19172033
size_t totalVertizes = 0;
19182034
for (int i = 0; i < NSLICES; i++) {
@@ -2026,6 +2142,14 @@ int GPUDisplay::DrawGLScene_internal(bool mixAnimation, float mAnimateTime)
20262142
LOOP_SLICE LOOP_COLLISION_COL(drawVertices(mGlDLPoints[iSlice][tTRDATTACHED][iCol], GL_LINES));
20272143
}
20282144
}
2145+
if (mCfg.drawTOF) {
2146+
SetColorTOF();
2147+
LOOP_SLICE LOOP_COLLISION_COL(drawVertices(mGlDLPoints[0][tTOFCLUSTER][0], GL_POINTS));
2148+
}
2149+
if (mCfg.drawITS) {
2150+
SetColorITS();
2151+
LOOP_SLICE LOOP_COLLISION_COL(drawVertices(mGlDLPoints[0][tITSCLUSTER][0], GL_POINTS));
2152+
}
20292153
if (mCfg.drawTPC) {
20302154
SetColorClusters();
20312155
LOOP_SLICE LOOP_COLLISION_COL(drawVertices(mGlDLPoints[iSlice][tCLUSTER][iCol], GL_POINTS));

GPU/GPUTracking/display/GPUDisplay.h

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,11 @@ class GPUDisplay
105105
private:
106106
static constexpr int NSLICES = GPUChainTracking::NSLICES;
107107

108-
static constexpr const int N_POINTS_TYPE = 11;
108+
static constexpr const int N_POINTS_TYPE = 13;
109109
static constexpr const int N_POINTS_TYPE_TPC = 9;
110110
static constexpr const int N_POINTS_TYPE_TRD = 2;
111+
static constexpr const int N_POINTS_TYPE_TOF = 1;
112+
static constexpr const int N_POINTS_TYPE_ITS = 1;
111113
static constexpr const int N_LINES_TYPE = 7;
112114
static constexpr const int N_FINAL_TYPE = 4;
113115
static constexpr int TRACK_TYPE_ID_LIMIT = 100;
@@ -121,7 +123,9 @@ class GPUDisplay
121123
tFINALTRACK = 7,
122124
tMARKED = 8,
123125
tTRDCLUSTER = 9,
124-
tTRDATTACHED = 10 };
126+
tTRDATTACHED = 10,
127+
tTOFCLUSTER = 11,
128+
tITSCLUSTER = 12 };
125129
enum LineTypes { RESERVED = 0 /*1 -- 6 = INITLINK to GLOBALTRACK*/ };
126130

127131
typedef std::tuple<GLsizei, GLsizei, int> vboList;
@@ -210,6 +214,8 @@ class GPUDisplay
210214
void showInfo(const char* info);
211215
void ActivateColor();
212216
void SetColorTRD();
217+
void SetColorTOF();
218+
void SetColorITS();
213219
void SetColorClusters();
214220
void SetColorInitLinks();
215221
void SetColorLinks();
@@ -234,7 +240,8 @@ class GPUDisplay
234240
void drawPointLinestrip(int iSlice, int cid, int id, int id_limit = TRACK_TYPE_ID_LIMIT);
235241
vboList DrawClusters(int iSlice, int select, int iCol);
236242
vboList DrawSpacePointsTRD(int iSlice, int select, int iCol);
237-
vboList DrawSpacePointsTRD(const GPUTPCTracker& tracker, int select, int iCol);
243+
vboList DrawSpacePointsTOF(int iSlice, int select, int iCol);
244+
vboList DrawSpacePointsITS(int iSlice, int select, int iCol);
238245
vboList DrawLinks(const GPUTPCTracker& tracker, int id, bool dodown = false);
239246
vboList DrawSeeds(const GPUTPCTracker& tracker);
240247
vboList DrawTracklets(const GPUTPCTracker& tracker);
@@ -330,13 +337,21 @@ class GPUDisplay
330337
std::unique_ptr<float4[]> mGlobalPosPtr;
331338
std::unique_ptr<float4[]> mGlobalPosPtrTRD;
332339
std::unique_ptr<float4[]> mGlobalPosPtrTRD2;
340+
std::unique_ptr<float4[]> mGlobalPosPtrITS;
341+
std::unique_ptr<float4[]> mGlobalPosPtrTOF;
333342
float4* mGlobalPos;
334343
float4* mGlobalPosTRD;
335344
float4* mGlobalPosTRD2;
345+
float4* mGlobalPosITS;
346+
float4* mGlobalPosTOF;
336347
int mNMaxClusters = 0;
337348
int mNMaxSpacePointsTRD = 0;
349+
int mNMaxClustersITS = 0;
350+
int mNMaxClustersTOF = 0;
338351
int mCurrentClusters = 0;
339352
int mCurrentSpacePointsTRD = 0;
353+
int mCurrentClustersITS = 0;
354+
int mCurrentClustersTOF = 0;
340355
std::vector<int> mTRDTrackIds;
341356

342357
int mGlDLrecent = 0;

GPU/GPUTracking/display/GPUDisplayKeys.cxx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ const char* HelpText[] = {
6060
"[ALT] / [CTRL] / [m] Focus camera on origin / orient y-axis upwards (combine with [SHIFT] to lock) / Cycle through modes",
6161
"[RCTRL] / [RALT] Rotate model instead of camera / rotate TPC around beamline",
6262
"[1] ... [8] / [N] Enable display of clusters, preseeds, seeds, starthits, tracklets, tracks, global tracks, merged tracks / Show assigned clusters in colors"
63-
"[F1] / [F2] Enable / disable drawing of TPC / TRD"
63+
"[F1] / [F2] / [F3] / [F4] Enable / disable drawing of TPC / TRD / TOF / ITS"
6464
// FREE: none
6565
// Test setting: ^ --> mHideUnmatchedClusters
6666
};
@@ -324,6 +324,10 @@ void GPUDisplay::HandleKeyRelease(unsigned char key)
324324
mCfg.drawTPC ^= 1;
325325
} else if (key == mBackend->KEY_F2) {
326326
mCfg.drawTRD ^= 1;
327+
} else if (key == mBackend->KEY_F3) {
328+
mCfg.drawTOF ^= 1;
329+
} else if (key == mBackend->KEY_F4) {
330+
mCfg.drawITS ^= 1;
327331
} else if (key == 't') {
328332
GPUInfo("Taking screenshot");
329333
static int nScreenshot = 1;

GPU/Workflow/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ if(ALIGPU_BUILD_TYPE STREQUAL "O2"
5353
O2::DataFormatsGlobalTracking
5454
O2::TPCFastTransformation
5555
O2::TRDBase
56+
O2::TOFBase
5657
O2::TPCReconstruction
5758
O2::GlobalTrackingWorkflowHelpers)
5859
target_include_directories(${targetName} PUBLIC "include")

GPU/Workflow/include/GPUWorkflow/O2GPUDPLDisplay.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ namespace o2::globaltracking
2323
{
2424
struct DataRequest;
2525
}
26+
namespace o2::itsmft
27+
{
28+
class TopologyDictionary;
29+
}
2630

2731
namespace o2::gpu
2832
{
@@ -47,6 +51,7 @@ class O2GPUDPLDisplaySpec : public o2::framework::Task
4751
std::unique_ptr<GPUO2InterfaceConfiguration> mConfig;
4852
std::unique_ptr<TPCFastTransform> mFastTransform;
4953
std::unique_ptr<o2::trd::GeometryFlat> mTrdGeo;
54+
std::unique_ptr<o2::itsmft::TopologyDictionary> mITSDict;
5055
std::shared_ptr<o2::globaltracking::DataRequest> mDataRequest;
5156
};
5257

0 commit comments

Comments
 (0)