]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - HLT/TPCLib/tracking-ca/AliHLTTPCCANeighboursCleaner.cxx
bug fix: reconstruction crash when the output buffer size exceed
[u/mrichter/AliRoot.git] / HLT / TPCLib / tracking-ca / AliHLTTPCCANeighboursCleaner.cxx
index febd74794cc40c467b852a6dd3ca74019d34c4b8..920d6651eeb636ff9da0d9262a34d015b317672e 100644 (file)
@@ -1,6 +1,6 @@
 // @(#) $Id: AliHLTTPCCANeighboursCleaner.cxx 27042 2008-07-02 12:06:02Z richterm $
 // **************************************************************************
-// This file is property of and copyright by the ALICE HLT Project          * 
+// This file is property of and copyright by the ALICE HLT Project          *
 // ALICE Experiment at CERN, All rights reserved.                           *
 //                                                                          *
 // Primary Authors: Sergey Gorbunov <sergey.gorbunov@kip.uni-heidelberg.de> *
 #include "AliHLTTPCCAMath.h"
 #include "AliHLTTPCCATracker.h"
 
-GPUd() void AliHLTTPCCANeighboursCleaner::Thread 
-( Int_t /*nBlocks*/, Int_t nThreads, Int_t iBlock, Int_t iThread, Int_t iSync,
+GPUd() void AliHLTTPCCANeighboursCleaner::Thread
+( int /*nBlocks*/, int nThreads, int iBlock, int iThread, int iSync,
   AliHLTTPCCASharedMemory &s, AliHLTTPCCATracker &tracker )
 {
   // *
   // * kill link to the neighbour if the neighbour is not pointed to the cluster
   // *
 
-  if( iSync==0 )
-    {
-      if( iThread==0 ){
-       s.fNRows = tracker.Param().NRows();
-       s.fIRow = iBlock+2;
-       if( s.fIRow <= s.fNRows-3 ){
-         s.fIRowUp = s.fIRow+2;
-         s.fIRowDn = s.fIRow-2;          
-         s.fFirstHit = tracker.Row(s.fIRow).FirstHit(); 
-         const AliHLTTPCCARow &row = tracker.Row(s.fIRow);
-         const AliHLTTPCCARow &rowUp = tracker.Row(s.fIRowUp);
-         const AliHLTTPCCARow &rowDn = tracker.Row(s.fIRowDn);
-         s.fHitLinkUp = ((Short_t*)(tracker.RowData() + row.FullOffset())) + row.FullLinkOffset();
-         s.fHitLinkDn = s.fHitLinkUp + row.NHits();
-         s.fDnHitLinkUp = ((Short_t*)(tracker.RowData() + rowDn.FullOffset())) + rowDn.FullLinkOffset();
-         s.fUpHitLinkDn = ((Short_t*)(tracker.RowData() + rowUp.FullOffset())) + rowUp.FullLinkOffset() + rowUp.NHits();
-
-         s.fNHits = tracker.Row(s.fIRow).NHits();
-       }
+  if ( iSync == 0 ) {
+    if ( iThread == 0 ) {
+      s.fNRows = tracker.Param().NRows();
+      s.fIRow = iBlock + 2;
+      if ( s.fIRow <= s.fNRows - 3 ) {
+        s.fIRowUp = s.fIRow + 2;
+        s.fIRowDn = s.fIRow - 2;
+        s.fNHits = tracker.Row( s.fIRow ).NHits();
       }
-    } 
-  else if( iSync==1 )
-    {
-      if( s.fIRow <= s.fNRows-3 ){
+    }
+  } else if ( iSync == 1 ) {
+    if ( s.fIRow <= s.fNRows - 3 ) {
+      const AliHLTTPCCARow &row = tracker.Row( s.fIRow );
+      const AliHLTTPCCARow &rowUp = tracker.Row( s.fIRowUp );
+      const AliHLTTPCCARow &rowDn = tracker.Row( s.fIRowDn );
 
-       for( Int_t ih=iThread; ih<s.fNHits; ih+=nThreads ){
-         Int_t up = s.fHitLinkUp[ih];
-         if( up>=0 ){
-           Short_t upDn = s.fUpHitLinkDn[up];
-           if( (upDn!=ih) ) s.fHitLinkUp[ih]= -1;
-         }       
-         Int_t dn = s.fHitLinkDn[ih];
-         if( dn>=0 ){
-           Short_t dnUp = s.fDnHitLinkUp[dn];
-           if( dnUp!=ih ) s.fHitLinkDn[ih]= -1;
-         }
-       }
+      // - look at up link, if it's valid but the down link in the row above doesn't link to us remove
+      //   the link
+      // - look at down link, if it's valid but the up link in the row below doesn't link to us remove
+      //   the link
+      for ( int ih = iThread; ih < s.fNHits; ih += nThreads ) {
+        int up = tracker.HitLinkUpData( row, ih );
+        if ( up >= 0 ) {
+          short upDn = tracker.HitLinkDownData( rowUp, up );
+          if ( ( upDn != ih ) ) tracker.SetHitLinkUpData( row, ih, -1 );
+        }
+        int dn = tracker.HitLinkDownData( row, ih );
+        if ( dn >= 0 ) {
+          short dnUp = tracker.HitLinkUpData( rowDn, dn );
+          if ( dnUp != ih ) tracker.SetHitLinkDownData( row, ih, -1 );
+        }
       }
     }
+  }
 }