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+ }
365392inline 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+
740797GPUDisplay::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 ));
0 commit comments