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
37 CAMath::AtomicExch( tracker.NTracks(), 0 );
38 CAMath::AtomicExch( tracker.NTrackHits(), 0 );
40 s.fNTracklets = *tracker.NTracklets();
41 s.fNThreadsTotal = nThreads * nBlocks;
42 s.fItr0 = nThreads * iBlock;
44 } else if ( iSync == 1 ) {
45 AliHLTTPCCATrack tout;
48 for ( int itr = s.fItr0 + iThread; itr < s.fNTracklets; itr += s.fNThreadsTotal ) {
50 AliHLTTPCCATracklet &tracklet = tracker.Tracklets()[itr];
52 int tNHits = tracklet.NHits();
53 if ( tNHits <= 0 ) continue;
55 const int kMaxRowGap = 4;
56 const float kMaxShared = .1;
58 int firstRow = tracklet.FirstRow();
59 int lastRow = tracklet.LastRow();
64 if ( tNHits >= 10 && 1. / .5 >= CAMath::Abs( tracklet.Param().QPt() ) ) { //SG!!!
69 int w = ( kind << 29 ) + ( tNHits << 16 ) + itr;
71 //int w = (tNHits<<16)+itr;
72 //int nRows = tracker.Param().NRows();
75 //std::cout<<" store tracklet: "<<firstRow<<" "<<lastRow<<std::endl;
76 for ( int irow = firstRow; irow <= lastRow; irow++ ) {
78 int ih = tracklet.RowHit( irow );
80 int ihTot = tracker.Row( irow ).FirstHit() + ih;
81 bool own = ( tracker.HitWeights()[ihTot] <= w );
82 bool sharedOK = ( ( tout.NHits() < 0 ) || ( nShared < tout.NHits() * kMaxShared ) );
83 if ( own || sharedOK ) {//SG!!!
85 int th = AliHLTTPCCATracker::IRowIHit2ID( irow, ih );
86 trackHits[tout.NHits()] = th;
87 tout.SetNHits( tout.NHits() + 1 );
88 if ( !own ) nShared++;
92 if ( gap > kMaxRowGap || irow == lastRow ) { // store
93 if ( tout.NHits() >= 10 ) { //SG!!!
94 int itrout = CAMath::AtomicAdd( tracker.NTracks(), 1 );
95 tout.SetFirstHitID( CAMath::AtomicAdd( tracker.NTrackHits(), tout.NHits() ) );
96 tout.SetParam( tracklet.Param() );
98 tracker.Tracks()[itrout] = tout;
99 for ( int jh = 0; jh < tout.NHits(); jh++ ) {
100 tracker.TrackHits()[tout.FirstHitID() + jh] = trackHits[jh];