]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/TPCLib/tracking-ca/AliHLTTPCCATrackletSelector.cxx
cosmetical changes
[u/mrichter/AliRoot.git] / HLT / TPCLib / tracking-ca / AliHLTTPCCATrackletSelector.cxx
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.                           *
5 //                                                                          *
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.                              *
9 //                                                                          *
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 //                                                                          *
18 //***************************************************************************
19
20
21 #include "AliHLTTPCCATrackletSelector.h"
22 #include "AliHLTTPCCATrack.h"
23 #include "AliHLTTPCCATracker.h"
24 #include "AliHLTTPCCATrackParam.h"
25 #include "AliHLTTPCCATracklet.h"
26 #include "AliHLTTPCCAMath.h"
27
28 GPUd() void AliHLTTPCCATrackletSelector::Thread
29 ( int nBlocks, int nThreads, int iBlock, int iThread, int iSync,
30   AliHLTTPCCASharedMemory &s, AliHLTTPCCATracker &tracker )
31 {
32   // select best tracklets and kill clones
33
34   if ( iSync == 0 ) {
35     if ( iThread == 0 ) {
36       if ( iBlock == 0 ) {
37         CAMath::AtomicExch( tracker.NTracks(), 0 );
38         CAMath::AtomicExch( tracker.NTrackHits(), 0 );
39       }
40       s.fNTracklets = *tracker.NTracklets();
41       s.fNThreadsTotal = nThreads * nBlocks;
42       s.fItr0 = nThreads * iBlock;
43     }
44   } else if ( iSync == 1 ) {
45     AliHLTTPCCATrack tout;
46     int trackHits[160];
47
48     for ( int itr = s.fItr0 + iThread; itr < s.fNTracklets; itr += s.fNThreadsTotal ) {
49
50       AliHLTTPCCATracklet &tracklet = tracker.Tracklets()[itr];
51
52       int tNHits = tracklet.NHits();
53       if ( tNHits <= 0 ) continue;
54
55       const int kMaxRowGap = 4;
56       const float kMaxShared = .1;
57
58       int firstRow = tracklet.FirstRow();
59       int lastRow = tracklet.LastRow();
60
61       tout.SetNHits( 0 );
62       int kind = 0;
63       if ( 0 ) {
64         if ( tNHits >= 10 && 1. / .5 >= CAMath::Abs( tracklet.Param().QPt() ) ) { //SG!!!
65           kind = 1;
66         }
67       }
68
69       int w = ( kind << 29 ) + ( tNHits << 16 ) + itr;
70
71       //int w = (tNHits<<16)+itr;
72       //int nRows = tracker.Param().NRows();
73       int gap = 0;
74       int nShared = 0;
75       //std::cout<<" store tracklet: "<<firstRow<<" "<<lastRow<<std::endl;
76       for ( int irow = firstRow; irow <= lastRow; irow++ ) {
77         gap++;
78         int ih = tracklet.RowHit( irow );
79         if ( ih >= 0 ) {
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!!!
84             gap = 0;
85             int th = AliHLTTPCCATracker::IRowIHit2ID( irow, ih );
86             trackHits[tout.NHits()] = th;
87             tout.SetNHits( tout.NHits() + 1 );
88             if ( !own ) nShared++;
89           }
90         }
91
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() );
97             tout.SetAlive( 1 );
98             tracker.Tracks()[itrout] = tout;
99             for ( int jh = 0; jh < tout.NHits(); jh++ ) {
100               tracker.TrackHits()[tout.FirstHitID() + jh] = trackHits[jh];
101             }
102           }
103           tout.SetNHits( 0 );
104           gap = 0;
105           nShared = 0;
106         }
107       }
108     }
109   }
110 }