Fit mathematics improved, obsollete GBTracker cleaned up
[u/mrichter/AliRoot.git] / HLT / TPCLib / tracking-ca / AliHLTTPCCATrackletSelector.cxx
CommitLineData
00d07bcd 1// @(#) $Id: AliHLTTPCCATrackletSelector.cxx 27042 2008-07-02 12:06:02Z richterm $
ce565086 2// **************************************************************************
00d07bcd 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. *
ce565086 17// *
00d07bcd 18//***************************************************************************
19
ce565086 20
00d07bcd 21#include "AliHLTTPCCATrackletSelector.h"
22#include "AliHLTTPCCATrack.h"
23#include "AliHLTTPCCATracker.h"
24#include "AliHLTTPCCATrackParam.h"
ce565086 25#include "AliHLTTPCCATracklet.h"
00d07bcd 26#include "AliHLTTPCCAMath.h"
27
28GPUd() void AliHLTTPCCATrackletSelector::Thread
29( Int_t nBlocks, Int_t nThreads, Int_t iBlock, Int_t iThread, Int_t iSync,
30 AliHLTTPCCASharedMemory &s, AliHLTTPCCATracker &tracker )
31{
32 // select best tracklets and kill clones
33
34 if( iSync==0 )
35 {
36 if( iThread==0 ){
37 if(iBlock==0){
ce565086 38 CAMath::AtomicExch(tracker.NTracks(),0);
39 CAMath::AtomicExch(tracker.NTrackHits(),0);
00d07bcd 40 }
4687b8fc 41 s.fNTracklets = *tracker.NTracklets();
00d07bcd 42 s.fNThreadsTotal = nThreads*nBlocks;
4687b8fc 43 s.fItr0 = nThreads*iBlock;
00d07bcd 44 }
45 }
46 else if( iSync==1 )
47 {
48 AliHLTTPCCATrack tout;
49 Int_t trackHits[160];
50
51 for( Int_t itr= s.fItr0 + iThread; itr<s.fNTracklets; itr+=s.fNThreadsTotal ){
ce565086 52
53 AliHLTTPCCATracklet &tracklet = tracker.Tracklets()[itr];
54
55 Int_t tNHits = tracklet.NHits();
00d07bcd 56 if( tNHits<=0 ) continue;
693d2443 57
58 const Int_t kMaxRowGap = 4;
ce565086 59 const Float_t kMaxShared = .1;
60
61 Int_t firstRow = tracklet.FirstRow();
62 Int_t lastRow = tracklet.LastRow();
693d2443 63
64 tout.SetNHits( 0 );
ce565086 65 Int_t kind = 0;
15d2e9cf 66 if(0){
67 if( tNHits>=10 && 1./.5 >= CAMath::Abs(tracklet.Param().QPt()) ){ //SG!!!
ce565086 68 kind = 1;
69 }
70 }
71
72 Int_t w = (kind<<29) + (tNHits<<16)+itr;
73
74 //Int_t w = (tNHits<<16)+itr;
693d2443 75 //Int_t nRows = tracker.Param().NRows();
325a2bc4 76 Int_t gap = 0;
ce565086 77 Int_t nShared = 0;
693d2443 78 //std::cout<<" store tracklet: "<<firstRow<<" "<<lastRow<<std::endl;
79 for( Int_t irow=firstRow; irow<=lastRow; irow++ ){
80 gap++;
ce565086 81 Int_t ih = tracklet.RowHit(irow);
693d2443 82 if( ih>=0 ){
83 Int_t ihTot = tracker.Row(irow).FirstHit()+ih;
ce565086 84 Bool_t own = ( tracker.HitWeights()[ihTot] <= w );
85 Bool_t sharedOK = ( (tout.NHits()<0) || (nShared<tout.NHits()*kMaxShared) );
86 if( own || sharedOK ){//SG!!!
693d2443 87 gap = 0;
88 Int_t th = AliHLTTPCCATracker::IRowIHit2ID(irow,ih);
89 trackHits[tout.NHits()] = th;
90 tout.SetNHits( tout.NHits() + 1 );
ce565086 91 if( !own ) nShared++;
693d2443 92 }
93 }
ce565086 94
693d2443 95 if( gap>kMaxRowGap || irow==lastRow ){ // store
96 if( tout.NHits()>=10 ){ //SG!!!
ce565086 97 Int_t itrout = CAMath::AtomicAdd(tracker.NTracks(),1);
98 tout.SetFirstHitID( CAMath::AtomicAdd( tracker.NTrackHits(), tout.NHits() ));
99 tout.SetParam( tracklet.Param() );
693d2443 100 tout.SetAlive( 1 );
101 tracker.Tracks()[itrout] = tout;
102 for( Int_t jh=0; jh<tout.NHits(); jh++ ){
103 tracker.TrackHits()[tout.FirstHitID() + jh] = trackHits[jh];
104 }
105 }
106 tout.SetNHits( 0 );
107 gap = 0;
ce565086 108 nShared = 0;
693d2443 109 }
00d07bcd 110 }
111 }
112 }
113}