When Pt is bad defined (ex. no field), the multiple scattering effect is calculated...
[u/mrichter/AliRoot.git] / HLT / TPCLib / tracking-ca / AliHLTTPCCAStartHitsSorter.cxx
CommitLineData
b22af1bf 1// @(#) $Id: AliHLTTPCCAStartHitsFinder.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: David Rohr <drohr@kip.uni-heidelberg.de> *
7// for The ALICE HLT Project. *
8// *
9// Permission to use, copy, modify and distribute this software and its *
10// documentation strictly for non-commercial purposes is hereby granted *
11// without fee, provided that the above copyright notice appears in all *
12// copies and that both the copyright notice and this permission notice *
13// appear in the supporting documentation. The authors make no claims *
14// about the suitability of this software for any purpose. It is *
15// provided "as is" without express or implied warranty. *
16// *
17//***************************************************************************
18
19#include "AliHLTTPCCAStartHitsSorter.h"
20#include "AliHLTTPCCATracker.h"
21
22GPUd() void AliHLTTPCCAStartHitsSorter::Thread
23( int nBlocks, int nThreads, int iBlock, int iThread, int iSync,
24 AliHLTTPCCASharedMemory &s, AliHLTTPCCATracker &tracker )
25{
26 //Sorts the Start Hits by Row Index and create RowBlock Data
27 if ( iSync == 0 ) {
28 if ( iThread == 0 ) {
29 const int gpuFixedBlockCount = tracker.GPUParametersConst()->fGPUFixedBlockCount;
30 const int tmpNRows = tracker.Param().NRows() - 6;
31 int nRows = iBlock == 29 ? (tmpNRows - (tmpNRows / 30) * 29) : (tmpNRows / 30);
32 int nStartRow = (tmpNRows / 30) * iBlock + 1;
33 int startOffset = 0;
34 int startOffset2 = 0;
35 int previousBlockEndTracklet = 0;
36 int nCurrentBlock = 0;
37
38 for (int ir = 1;ir < tracker.Param().NRows() - 5;ir++)
39 {
40 if (ir < nStartRow)
41 startOffset2 += tracker.RowStartHitCountOffset()[ir].x;
42
43 if (iBlock == nBlocks - 1 && nCurrentBlock < gpuFixedBlockCount)
44 {
45 startOffset += tracker.RowStartHitCountOffset()[ir].x;
46 for (int i = previousBlockEndTracklet + HLTCA_GPU_THREAD_COUNT - HLTCA_GPU_TRACKLET_CONSTRUCTOR_NMEMTHREDS;i <= startOffset;i += HLTCA_GPU_THREAD_COUNT - HLTCA_GPU_TRACKLET_CONSTRUCTOR_NMEMTHREDS)
47 {
48 if (previousBlockEndTracklet / (HLTCA_GPU_THREAD_COUNT - HLTCA_GPU_TRACKLET_CONSTRUCTOR_NMEMTHREDS) != i / (HLTCA_GPU_THREAD_COUNT - HLTCA_GPU_TRACKLET_CONSTRUCTOR_NMEMTHREDS))
49 {
50 tracker.BlockStartingTracklet()[nCurrentBlock].x = previousBlockEndTracklet;
51 tracker.BlockStartingTracklet()[nCurrentBlock++].y = HLTCA_GPU_THREAD_COUNT - HLTCA_GPU_TRACKLET_CONSTRUCTOR_NMEMTHREDS;
52 previousBlockEndTracklet += HLTCA_GPU_THREAD_COUNT - HLTCA_GPU_TRACKLET_CONSTRUCTOR_NMEMTHREDS;
53 if (nCurrentBlock == gpuFixedBlockCount)
54 {
55 break;
56 }
57 }
58 }
59 if ((ir + 1) % HLTCA_GPU_SCHED_ROW_STEP == 0 && nCurrentBlock < gpuFixedBlockCount)
60 {
61 if (previousBlockEndTracklet != startOffset)
62 {
63 tracker.BlockStartingTracklet()[nCurrentBlock].x = previousBlockEndTracklet;
64 tracker.BlockStartingTracklet()[nCurrentBlock++].y = startOffset - previousBlockEndTracklet;
65 previousBlockEndTracklet = startOffset;
66 }
67 }
68 if (nCurrentBlock == gpuFixedBlockCount)
69 {
70 tracker.GPUParameters()->fScheduleFirstDynamicTracklet = previousBlockEndTracklet;
71 }
72 }
73 }
74 if (iBlock == nBlocks - 1)
75 {
76 if (nCurrentBlock < gpuFixedBlockCount)
77 {
78 tracker.BlockStartingTracklet()[nCurrentBlock].x = previousBlockEndTracklet;
79 tracker.BlockStartingTracklet()[nCurrentBlock++].y = startOffset - previousBlockEndTracklet;
80 tracker.GPUParameters()->fScheduleFirstDynamicTracklet = startOffset;
81 }
82 for (int i = nCurrentBlock;i < HLTCA_GPU_BLOCK_COUNT;i++)
83 {
84 tracker.BlockStartingTracklet()[i].x = 0;
85 tracker.BlockStartingTracklet()[i].y = 0;
86 }
87 }
88 s.fStartOffset = startOffset2;
89 s.fNRows = nRows;
90 s.fStartRow = nStartRow;
91 }
92 } else if ( iSync == 1 ) {
93 int startOffset = s.fStartOffset;
94 for (int ir = 0;ir < s.fNRows;ir++)
95 {
96 AliHLTTPCCAHitId *const startHits = tracker.TrackletStartHits();
97 AliHLTTPCCAHitId *const tmpStartHits = tracker.TrackletTmpStartHits();
98 const int tmpLen = tracker.RowStartHitCountOffset()[ir + s.fStartRow].x; //Length of hits in row stored by StartHitsFinder
99 const int tmpOffset = tracker.RowStartHitCountOffset()[ir + s.fStartRow].y; //Offset of first hit in row of unsorted array by StartHitsFinder
100 if (iThread == 0)
101 tracker.RowStartHitCountOffset()[ir + s.fStartRow].z = startOffset; //Store New Offset Value of sorted array
102
103 for (int j = iThread;j < tmpLen;j += nThreads)
104 {
105 startHits[startOffset + j] = tmpStartHits[tmpOffset + j];
106 }
107 startOffset += tmpLen;
108 }
109 }
110}
111