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. *
18 //***************************************************************************
21 #include "AliHLTTPCCATrackletSelector.h"
22 #include "AliHLTTPCCATrack.h"
23 #include "AliHLTTPCCATracker.h"
24 #include "AliHLTTPCCATrackParam.h"
25 #include "AliHLTTPCCATracklet.h"
26 #include "AliHLTTPCCAMath.h"
28 GPUd() void AliHLTTPCCATrackletSelector::Thread
29 ( int nBlocks, int nThreads, int iBlock, int iThread, int iSync,
30 AliHLTTPCCASharedMemory &s, AliHLTTPCCATracker &tracker )
32 // select best tracklets and kill clones
36 s.fNTracklets = *tracker.NTracklets();
37 s.fNThreadsTotal = nThreads * nBlocks;
38 s.fItr0 = nThreads * iBlock;
40 } else if ( iSync == 1 ) {
41 int nHits, nFirstTrackHit;
42 AliHLTTPCCAHitId trackHits[160 - HLTCA_GPU_TRACKLET_SELECTOR_HITS_REG_SIZE];
44 for ( int itr = s.fItr0 + iThread; itr < s.fNTracklets; itr += s.fNThreadsTotal ) {
46 #ifdef HLTCA_GPU_EMULATION_DEBUG_TRACKLET
47 if (itr == HLTCA_GPU_EMULATION_DEBUG_TRACKLET)
49 tracker.GPUParameters()->fGPUError = 1;
53 while (tracker.Tracklets()[itr].NHits() == 0)
55 itr += s.fNThreadsTotal;
56 if (itr >= s.fNTracklets) return;
59 AliHLTTPCCATracklet &tracklet = tracker.Tracklets()[itr];
60 const int tNHits = tracklet.NHits();
62 const int kMaxRowGap = 4;
63 const float kMaxShared = .1;
65 int firstRow = tracklet.FirstRow();
66 int lastRow = tracklet.LastRow();
70 if ( tNHits >= 10 && 1. / .5 >= CAMath::Abs( tracklet.Param().QPt() ) ) { //SG!!!
75 int w = ( kind << 29 ) + ( tNHits << 16 ) + itr;
77 //int w = (tNHits<<16)+itr;
78 //int nRows = tracker.Param().NRows();
79 //std::cout<<" store tracklet: "<<firstRow<<" "<<lastRow<<std::endl;
87 for (irow = firstRow; irow <= lastRow && lastRow - irow + nHits >= TRACKLET_SELECTOR_MIN_HITS; irow++ ) {
89 #ifdef EXTERN_ROW_HITS
90 int ih = tracker.TrackletRowHits()[irow * s.fNTracklets + itr];
92 int ih = tracklet.RowHit( irow );
95 const AliHLTTPCCARow &row = tracker.Row( irow );
96 bool own = ( tracker.HitWeight( row, ih ) <= w );
97 bool sharedOK = ( ( nShared < nHits * kMaxShared ) );
98 if ( own || sharedOK ) {//SG!!!
100 #if HLTCA_GPU_TRACKLET_SELECTOR_HITS_REG_SIZE != 0
101 if (nHits < HLTCA_GPU_TRACKLET_SELECTOR_HITS_REG_SIZE)
102 s.fHits[iThread][nHits].Set( irow, ih );
105 trackHits[nHits - HLTCA_GPU_TRACKLET_SELECTOR_HITS_REG_SIZE].Set( irow, ih );
107 if ( !own ) nShared++;
111 if ( gap > kMaxRowGap || irow == lastRow ) { // store
112 if ( nHits >= TRACKLET_SELECTOR_MIN_HITS ) { //SG!!!
113 int itrout = CAMath::AtomicAdd( tracker.NTracks(), 1 );
115 if (itrout >= HLTCA_GPU_MAX_TRACKS)
117 tracker.GPUParameters()->fGPUError = HLTCA_GPU_ERROR_TRACK_OVERFLOW;
118 CAMath::AtomicExch( tracker.NTracks(), 0 );
122 nFirstTrackHit = CAMath::AtomicAdd( tracker.NTrackHits(), nHits );
123 tracker.Tracks()[itrout].SetAlive(1);
124 tracker.Tracks()[itrout].SetParam(tracklet.Param());
125 tracker.Tracks()[itrout].SetFirstHitID(nFirstTrackHit);
126 tracker.Tracks()[itrout].SetNHits(nHits);
127 for ( int jh = 0; jh < nHits; jh++ ) {
128 #if HLTCA_GPU_TRACKLET_SELECTOR_HITS_REG_SIZE != 0
129 if (jh < HLTCA_GPU_TRACKLET_SELECTOR_HITS_REG_SIZE)
130 tracker.TrackHits()[nFirstTrackHit + jh] = s.fHits[iThread][jh];
133 tracker.TrackHits()[nFirstTrackHit + jh] = trackHits[jh - HLTCA_GPU_TRACKLET_SELECTOR_HITS_REG_SIZE];