1414
1515#define GPUCA_CADEBUG 0
1616#define GPUCA_MERGE_LOOPER_MC 0
17+ // #define GPUCA_CADEBUG_ENABLED
1718
1819#include " GPUCommonDef.h"
1920
@@ -165,13 +166,30 @@ GPUTPCGMMerger::GPUTPCGMMerger()
165166
166167void GPUTPCGMMerger::CheckMergedTracks ()
167168{
169+ uint32_t nErr = 0 ;
168170 std::vector<bool > trkUsed (SectorTrackInfoLocalTotal ());
169171 for (int32_t i = 0 ; i < SectorTrackInfoLocalTotal (); i++) {
170172 trkUsed[i] = false ;
171173 }
172174
173175 for (int32_t itr = 0 ; itr < SectorTrackInfoLocalTotal (); itr++) {
174176 GPUTPCGMSectorTrack& track = mSectorTrackInfos [itr];
177+ if (track.PrevSegmentNeighbour () >= 0 && mSectorTrackInfos [track.PrevSegmentNeighbour ()].NextSegmentNeighbour () != itr) {
178+ GPUError (" Invalid reciprocal segment link: %d PrevSegmentNeighbour %d NextSegmentNeighbour %d" , itr, track.PrevSegmentNeighbour (), mSectorTrackInfos [track.PrevSegmentNeighbour ()].NextSegmentNeighbour ());
179+ nErr++;
180+ }
181+ if (track.NextSegmentNeighbour () >= 0 && mSectorTrackInfos [track.NextSegmentNeighbour ()].PrevSegmentNeighbour () != itr) {
182+ GPUError (" Invalid reciprocal segment link: %d NextSegmentNeighbour %d PrevSegmentNeighbour %d" , itr, track.NextSegmentNeighbour (), mSectorTrackInfos [track.NextSegmentNeighbour ()].PrevSegmentNeighbour ());
183+ nErr++;
184+ }
185+ if (track.PrevNeighbour () >= 0 && mSectorTrackInfos [track.PrevNeighbour ()].NextNeighbour () != itr) {
186+ GPUError (" Invalid reciprocal link: %d PrevNeighbour %d NextNeighbour %d" , itr, track.PrevNeighbour (), mSectorTrackInfos [track.PrevNeighbour ()].NextNeighbour ());
187+ nErr++;
188+ }
189+ if (track.NextNeighbour () >= 0 && mSectorTrackInfos [track.NextNeighbour ()].PrevNeighbour () != itr) {
190+ GPUError (" Invalid reciprocal link: %d NextNeighbour %d PrevNeighbour %d" , itr, track.NextNeighbour (), mSectorTrackInfos [track.NextNeighbour ()].PrevNeighbour ());
191+ nErr++;
192+ }
175193 if (track.PrevSegmentNeighbour () >= 0 ) {
176194 continue ;
177195 }
@@ -183,6 +201,7 @@ void GPUTPCGMMerger::CheckMergedTracks()
183201 int32_t iTrk = tr - mSectorTrackInfos ;
184202 if (trkUsed[iTrk]) {
185203 GPUError (" FAILURE: double use" );
204+ nErr++;
186205 }
187206 trkUsed[iTrk] = true ;
188207
@@ -206,8 +225,12 @@ void GPUTPCGMMerger::CheckMergedTracks()
206225 for (int32_t i = 0 ; i < SectorTrackInfoLocalTotal (); i++) {
207226 if (trkUsed[i] == false ) {
208227 GPUError (" FAILURE: trk missed" );
228+ nErr++;
209229 }
210230 }
231+ if (nErr == 0 ) {
232+ GPUInfo (" Merged Track Graph OK" );
233+ }
211234}
212235
213236template <class T >
@@ -1419,6 +1442,7 @@ struct GPUTPCGMMerger_CompareClusterIds {
14191442
14201443GPUd () void GPUTPCGMMerger::CollectMergedTracks(int32_t nBlocks, int32_t nThreads, int32_t iBlock, int32_t iThread)
14211444{
1445+ // if (iThread == 0 && iBlock == 0) { CheckMergedTracks(); } return; // (if GPUCA_CADEBUG_ENABLED)
14221446 static constexpr int32_t kMaxParts = 16 ;
14231447 static constexpr int32_t kMaxClusters = GPUCA_MERGER_MAX_TRACK_CLUSTERS;
14241448
0 commit comments