1 // @(#) $Id: AliHLTTPCCATrackletSelector.cxx 27042 2008-07-02 12:06:02Z richterm $
2 //***************************************************************************
3 // This file is property of and copyright by the ALICE HLT Project *
4 // ALICE Experiment at CERN, All rights reserved. *
6 // Primary Authors: Sergey Gorbunov <sergey.gorbunov@kip.uni-heidelberg.de> *
7 // Ivan Kisel <kisel@kip.uni-heidelberg.de> *
8 // for The ALICE HLT Project. *
10 // Permission to use, copy, modify and distribute this software and its *
11 // documentation strictly for non-commercial purposes is hereby granted *
12 // without fee, provided that the above copyright notice appears in all *
13 // copies and that both the copyright notice and this permission notice *
14 // appear in the supporting documentation. The authors make no claims *
15 // about the suitability of this software for any purpose. It is *
16 // provided "as is" without express or implied warranty. *
17 //***************************************************************************
19 #include "AliHLTTPCCATrackletSelector.h"
20 #include "AliHLTTPCCATrack.h"
21 #include "AliHLTTPCCATracker.h"
22 #include "AliHLTTPCCATrackParam.h"
23 #include "AliHLTTPCCAMath.h"
25 GPUd() void AliHLTTPCCATrackletSelector::Thread
26 ( Int_t nBlocks, Int_t nThreads, Int_t iBlock, Int_t iThread, Int_t iSync,
27 AliHLTTPCCASharedMemory &s, AliHLTTPCCATracker &tracker )
29 // select best tracklets and kill clones
35 CAMath::atomicExch(&(tracker.NTracks()),0);
36 CAMath::atomicExch(tracker.TrackHits(),0);
38 s.fNTracklets = tracker.Tracklets()[0];
39 s.fNThreadsTotal = nThreads*nBlocks;
40 s.fItr0 = nThreads*iBlock;
41 //if( iBlock==0 ) tracker.StartHits()[0] = 0;//SG!!!
46 AliHLTTPCCATrack tout;
49 for( Int_t itr= s.fItr0 + iThread; itr<s.fNTracklets; itr+=s.fNThreadsTotal ){
50 Int_t *t = tracker.Tracklets() + 1 + itr*(5+ sizeof(AliHLTTPCCATrackParam)/4 + 160 );
52 if( tNHits<=0 ) continue;
54 CAMath::atomicAdd( tracker.StartHits(), 1);//SG!!!
56 Int_t *hitstore = t + 5+ sizeof(AliHLTTPCCATrackParam)/4 ;
57 Int_t w = (tNHits<<16)+itr;
58 Int_t nRows = tracker.Param().NRows();
60 for( Int_t irow=0; irow<nRows; irow++ ){
61 Int_t ih = hitstore[irow];
63 AliHLTTPCCARow &row = tracker.Rows()[irow];
64 Int_t ihTot = row.FirstHit()+ih;
65 if( tracker.HitIsUsed()[ihTot] > w ){
66 if( ++gap>6){ tout.NHits()=0; break; }
69 Int_t th = AliHLTTPCCATracker::IRowIHit2ID(irow,ih);
70 trackHits[tout.NHits()] = th;
73 if( tout.NHits()<10 ) continue;//SG!!!
74 Int_t itrout = CAMath::atomicAdd(&(tracker.NTracks()),1);
75 tout.FirstHitID() = CAMath::atomicAdd( tracker.TrackHits(), tout.NHits() ) + 1;
76 tout.Param() = *( (AliHLTTPCCATrackParam*)( t+5) );
78 tracker.Tracks()[itrout] = tout;
79 for( Int_t ih=0; ih<tout.NHits(); ih++ ){//SG
80 tracker.TrackHits()[tout.FirstHitID() + ih] = trackHits[ih];