1 // @(#) $Id: AliHLTTPCCATrackletConstructor.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 "AliHLTTPCCATracker.h"
22 #include "AliHLTTPCCATrackParam.h"
23 #include "AliHLTTPCCATrackParam.h"
24 #include "AliHLTTPCCAGrid.h"
25 #include "AliHLTTPCCAHitArea.h"
26 #include "AliHLTTPCCAMath.h"
27 #include "AliHLTTPCCADef.h"
28 #include "AliHLTTPCCATracklet.h"
29 #include "AliHLTTPCCATrackletConstructor.h"
30 //#include "AliHLTTPCCAPerformance.h"
36 #include "AliHLTTPCCADisplay.h"
40 GPUd() void AliHLTTPCCATrackletConstructor::Step0
41 ( int nBlocks, int /*nThreads*/, int iBlock, int iThread,
42 AliHLTTPCCASharedMemory &s, AliHLTTPCCAThreadMemory &r, AliHLTTPCCATracker &tracker, AliHLTTPCCATrackParam &/*tParam*/ )
44 // reconstruction of tracklets, step 0
46 r.fIsMemThread = ( iThread < NMemThreads() );
48 int nTracks = *tracker.NTracklets();
49 int nTrPerBlock = nTracks / nBlocks + 1;
50 s.fNRows = tracker.Param().NRows();
51 s.fItr0 = nTrPerBlock * iBlock;
52 s.fItr1 = s.fItr0 + nTrPerBlock;
53 if ( s.fItr1 > nTracks ) s.fItr1 = nTracks;
58 s.fMinStartRow32[iThread] = 158;
59 s.fMaxStartRow32[iThread] = 0;
64 GPUd() void AliHLTTPCCATrackletConstructor::Step1
65 ( int /*nBlocks*/, int /*nThreads*/, int /*iBlock*/, int iThread,
66 AliHLTTPCCASharedMemory &s, AliHLTTPCCAThreadMemory &r, AliHLTTPCCATracker &tracker, AliHLTTPCCATrackParam &tParam )
68 // reconstruction of tracklets, step 1
70 r.fItr = s.fItr0 + ( iThread - NMemThreads() );
71 r.fGo = ( !r.fIsMemThread ) && ( r.fItr < s.fItr1 );
79 AliHLTTPCCATracklet &tracklet = tracker.Tracklets()[r.fItr];
81 unsigned int kThread = iThread % 32;//& 00000020;
82 if ( SAVE() ) for ( int i = 0; i < 160; i++ ) tracklet.SetRowHit( i, -1 );
84 AliHLTTPCCAHitId id = tracker.TrackletStartHits()[r.fItr];
85 r.fStartRow = id.RowIndex();
86 r.fEndRow = r.fStartRow;
87 r.fFirstRow = r.fStartRow;
88 r.fLastRow = r.fFirstRow;
89 r.fCurrIH = id.HitIndex();
91 CAMath::AtomicMin( &s.fMinStartRow32[kThread], r.fStartRow );
92 CAMath::AtomicMax( &s.fMaxStartRow32[kThread], r.fStartRow );
93 tParam.SetSinPhi( 0 );
96 tParam.SetSignCosPhi( 1 );
99 tParam.SetCov( 0, 1 );
100 tParam.SetCov( 1, 0 );
101 tParam.SetCov( 2, 1 );
102 tParam.SetCov( 3, 0 );
103 tParam.SetCov( 4, 0 );
104 tParam.SetCov( 5, 1 );
105 tParam.SetCov( 6, 0 );
106 tParam.SetCov( 7, 0 );
107 tParam.SetCov( 8, 0 );
108 tParam.SetCov( 9, 1 );
109 tParam.SetCov( 10, 0 );
110 tParam.SetCov( 11, 0 );
111 tParam.SetCov( 12, 0 );
112 tParam.SetCov( 13, 0 );
113 tParam.SetCov( 14, 10. );
117 GPUd() void AliHLTTPCCATrackletConstructor::Step2
118 ( int /*nBlocks*/, int nThreads, int /*iBlock*/, int iThread,
119 AliHLTTPCCASharedMemory &s, AliHLTTPCCAThreadMemory &/*r*/, AliHLTTPCCATracker &/*tracker*/, AliHLTTPCCATrackParam &/*tParam*/ )
121 // reconstruction of tracklets, step 2
123 if ( iThread == 0 ) {
124 //CAMath::AtomicMinGPU(&s.fMinRow, s.fMinRow32[iThread]);
125 int minStartRow = 158;
127 int n = ( nThreads > 32 ) ? 32 : nThreads;
128 for ( int i = 0; i < n; i++ ) {
129 if ( s.fMinStartRow32[i] < minStartRow ) minStartRow = s.fMinStartRow32[i];
130 if ( s.fMaxStartRow32[i] > maxStartRow ) maxStartRow = s.fMaxStartRow32[i];
132 s.fMinStartRow = minStartRow;
133 s.fMaxStartRow = maxStartRow;
137 GPUd() void AliHLTTPCCATrackletConstructor::ReadData
138 ( int iThread, AliHLTTPCCASharedMemory &s, AliHLTTPCCAThreadMemory &r, AliHLTTPCCATracker &tracker, int iRow )
140 // reconstruction of tracklets, read data step
142 if ( r.fIsMemThread ) {
143 const AliHLTTPCCARow &row = tracker.Row( iRow );
144 bool jr = !r.fCurrentData;
146 // copy hits, grid content and links
148 // FIXME: inefficient copy
149 const int numberOfHits = row.NHits();
150 ushort2 *sMem1 = reinterpret_cast<ushort2 *>( s.fData[jr] );
151 for ( int i = iThread; i < numberOfHits; i += NMemThreads() ) {
152 sMem1[i].x = tracker.HitDataY( row, i );
153 sMem1[i].y = tracker.HitDataZ( row, i );
155 short *sMem2 = reinterpret_cast<short *>( s.fData[jr] ) + 2 * numberOfHits;
156 for ( int i = iThread; i < numberOfHits; i += NMemThreads() ) {
157 sMem2[i] = tracker.HitLinkUpData( row, i );
160 unsigned short *sMem3 = reinterpret_cast<unsigned short *>( s.fData[jr] ) + 3 * numberOfHits;
161 const int n = row.FullSize(); // + grid content size
162 for ( int i = iThread; i < n; i += NMemThreads() ) {
163 sMem3[i] = tracker.FirstHitInBin( row, i );
169 GPUd() void AliHLTTPCCATrackletConstructor::StoreTracklet
170 ( int /*nBlocks*/, int /*nThreads*/, int /*iBlock*/, int /*iThread*/,
171 AliHLTTPCCASharedMemory &/*s*/, AliHLTTPCCAThreadMemory &r, AliHLTTPCCATracker &tracker, AliHLTTPCCATrackParam &tParam )
173 // reconstruction of tracklets, tracklet store step
175 if ( !r.fSave ) return;
177 //AliHLTTPCCAPerformance::Instance().HNHitsPerTrackCand()->Fill(r.fNHits);
181 //std::cout<<"tracklet to store: "<<r.fItr<<", nhits = "<<r.fNHits<<std::endl;
184 if ( r.fNHits < 5 ) {
190 if ( 1. / .5 < CAMath::Abs( tParam.QPt() ) ) { //SG!!!
198 const float *c = tParam.Cov();
199 for ( int i = 0; i < 15; i++ ) ok = ok && CAMath::Finite( c[i] );
200 for ( int i = 0; i < 5; i++ ) ok = ok && CAMath::Finite( tParam.Par()[i] );
201 ok = ok && ( tParam.X() > 50 );
203 if ( c[0] <= 0 || c[2] <= 0 || c[5] <= 0 || c[9] <= 0 || c[14] <= 0 ) ok = 0;
212 if ( !SAVE() ) return;
214 AliHLTTPCCATracklet &tracklet = tracker.Tracklets()[r.fItr];
216 tracklet.SetNHits( r.fNHits );
218 if ( r.fNHits > 0 ) {
221 std::cout << "store tracklet " << r.fItr << ", nhits = " << r.fNHits << std::endl;
222 if ( AliHLTTPCCADisplay::Instance().DrawTracklet( tParam, hitstore, kBlue, 1. ) ) {
223 AliHLTTPCCADisplay::Instance().Ask();
227 if ( CAMath::Abs( tParam.Par()[4] ) < 1.e-4 ) tParam.SetPar( 4, 1.e-4 );
228 tracklet.SetFirstRow( r.fFirstRow );
229 tracklet.SetLastRow( r.fLastRow );
230 tracklet.SetParam( tParam );
231 int w = ( r.fNHits << 16 ) + r.fItr;
232 for ( int iRow = 0; iRow < 160; iRow++ ) {
233 int ih = tracklet.RowHit( iRow );
235 tracker.MaximizeHitWeight( tracker.Row( iRow ), ih, w );
241 GPUd() void AliHLTTPCCATrackletConstructor::UpdateTracklet
242 ( int /*nBlocks*/, int /*nThreads*/, int /*iBlock*/, int /*iThread*/,
243 AliHLTTPCCASharedMemory &s, AliHLTTPCCAThreadMemory &r, AliHLTTPCCATracker &tracker, AliHLTTPCCATrackParam &tParam, int iRow )
245 // reconstruction of tracklets, tracklets update step
247 //std::cout<<"Update tracklet: "<<r.fItr<<" "<<r.fGo<<" "<<r.fStage<<" "<<iRow<<std::endl;
248 bool drawSearch = 0;//r.fItr==2;
249 bool drawFit = 0;//r.fItr==2;
250 bool drawFitted = drawFit ;//|| 1;//r.fItr==16;
252 if ( !r.fGo ) return;
254 const int kMaxRowGap = 4;
256 AliHLTTPCCATracklet &tracklet = tracker.Tracklets()[r.fItr];
258 const AliHLTTPCCARow &row = tracker.Row( iRow );
260 float y0 = row.Grid().YMin();
261 float stepY = row.HstepY();
262 float z0 = row.Grid().ZMin();
263 float stepZ = row.HstepZ();
264 float stepYi = row.HstepYi();
265 float stepZi = row.HstepZi();
267 if ( r.fStage == 0 ) { // fitting part
270 if ( iRow < r.fStartRow || r.fCurrIH < 0 ) break;
272 if ( ( iRow - r.fStartRow ) % 2 != 0 ) break; // SG!!! - jump over the row
274 uint4 *tmpint4 = s.fData[r.fCurrentData];
275 ushort2 hh = reinterpret_cast<ushort2*>( tmpint4 )[r.fCurrIH];
277 int oldIH = r.fCurrIH;
278 r.fCurrIH = reinterpret_cast<short*>( tmpint4 )[2 * row.NHits() + r.fCurrIH]; // read from linkup data
281 float y = y0 + hh.x * stepY;
282 float z = z0 + hh.y * stepZ;
283 if ( drawFit ) std::cout << " fit tracklet: new hit " << oldIH << ", xyz=" << x << " " << y << " " << z << std::endl;
285 if ( iRow == r.fStartRow ) {
292 if ( drawFit ) std::cout << " fit tracklet " << r.fItr << ", row " << iRow << " first row" << std::endl;
297 float dx = x - tParam.X();
298 float dy = y - r.fLastY;//tParam.Y();
299 float dz = z - r.fLastZ;//tParam.Z();
303 float ri = 1. / CAMath::Sqrt( dx * dx + dy * dy );
304 if ( iRow == r.fStartRow + 2 ) { //SG!!! important - thanks to Matthias
305 tParam.SetSinPhi( dy*ri );
306 tParam.SetSignCosPhi( dx );
307 tParam.SetDzDs( dz*ri );
308 //std::cout << "Init. errors... " << r.fItr << std::endl;
309 tracker.GetErrors2( iRow, tParam, err2Y, err2Z );
310 //std::cout << "Init. errors = " << err2Y << " " << err2Z << std::endl;
311 tParam.SetCov( 0, err2Y );
312 tParam.SetCov( 2, err2Z );
316 std::cout << " fit tracklet " << r.fItr << ", row " << iRow << " transporting.." << std::endl;
317 std::cout << " params before transport=" << std::endl;
321 float sinPhi, cosPhi;
322 if ( r.fNHits >= 10 && CAMath::Abs( tParam.SinPhi() ) < .99 ) {
323 sinPhi = tParam.SinPhi();
324 cosPhi = CAMath::Sqrt( 1 - sinPhi * sinPhi );
330 if ( drawFit ) std::cout << "sinPhi0 = " << sinPhi << ", cosPhi0 = " << cosPhi << std::endl;
332 if ( !tParam.TransportToX( x, sinPhi, cosPhi, tracker.Param().ConstBz(), -1 ) ) {
334 if ( drawFit ) std::cout << " tracklet " << r.fItr << ", row " << iRow << ": can not transport!!" << std::endl;
336 if ( SAVE() ) tracklet.SetRowHit( iRow, -1 );
339 //std::cout<<"mark1 "<<r.fItr<<std::endl;
341 tracker.GetErrors2( iRow, tParam.GetZ(), sinPhi, cosPhi, tParam.GetDzDs(), err2Y, err2Z );
342 //std::cout<<"mark2"<<std::endl;
346 std::cout << " params after transport=" << std::endl;
348 std::cout << "fit tracklet before filter: " << r.fItr << ", row " << iRow << " errs=" << err2Y << " " << err2Z << std::endl;
351 AliHLTTPCCADisplay::Instance().DrawTracklet( tParam, hitstore, kBlue, 2., 1 );
352 AliHLTTPCCADisplay::Instance().Ask();
355 if ( !tParam.Filter( y, z, err2Y, err2Z, .99 ) ) {
357 if ( drawFit ) std::cout << " tracklet " << r.fItr << ", row " << iRow << ": can not filter!!" << std::endl;
359 if ( SAVE() ) tracklet.SetRowHit( iRow, -1 );
363 if ( SAVE() ) tracklet.SetRowHit( iRow, oldIH );
366 std::cout << "fit tracklet after filter " << r.fItr << ", row " << iRow << std::endl;
370 AliHLTTPCCADisplay::Instance().DrawTracklet( tParam, hitstore, kGreen, 2. );
371 AliHLTTPCCADisplay::Instance().Ask();
380 if ( r.fCurrIH < 0 ) {
382 if ( drawFitted ) std::cout << "fitted tracklet " << r.fItr << ", nhits=" << r.fNHits << std::endl;
385 //AliHLTTPCCAPerformance::Instance().HNHitsPerSeed()->Fill(r.fNHits);
386 if ( r.fNHits < 3 ) { r.fNHits = 0; r.fGo = 0;}//SG!!!
387 if ( CAMath::Abs( tParam.SinPhi() ) > .999 ) {
389 if ( drawFitted ) std::cout << " fitted tracklet error: sinPhi=" << tParam.SinPhi() << std::endl;
391 r.fNHits = 0; r.fGo = 0;
393 //tParam.SetCosPhi( CAMath::Sqrt(1-tParam.SinPhi()*tParam.SinPhi()) );
397 std::cout << "fitted tracklet " << r.fItr << " miss=" << r.fNMissed << " go=" << r.fGo << std::endl;
400 AliHLTTPCCADisplay::Instance().DrawTracklet( tParam, hitstore, kBlue );
401 AliHLTTPCCADisplay::Instance().Ask();
405 } else { // forward/backward searching part
409 std::cout << "search tracklet " << r.fItr << " row " << iRow << " miss=" << r.fNMissed << " go=" << r.fGo << " stage=" << r.fStage << std::endl;
413 if ( r.fStage == 2 && ( ( iRow >= r.fEndRow ) ||
414 ( iRow >= r.fStartRow && ( iRow - r.fStartRow ) % 2 == 0 )
416 if ( r.fNMissed > kMaxRowGap ) {
426 std::cout << "tracklet " << r.fItr << " before transport to row " << iRow << " : " << std::endl;
430 if ( !tParam.TransportToX( x, tParam.SinPhi(), tParam.GetCosPhi(), tracker.Param().ConstBz(), .99 ) ) {
432 if ( drawSearch ) std::cout << " tracklet " << r.fItr << ", row " << iRow << ": can not transport!!" << std::endl;
436 if ( row.NHits() < 1 ) {
442 std::cout << "tracklet " << r.fItr << " after transport to row " << iRow << " : " << std::endl;
445 AliHLTTPCCADisplay::Instance().DrawTracklet( tParam, hitstore, kBlue, 2., 1 );
446 AliHLTTPCCADisplay::Instance().Ask();
449 uint4 *tmpint4 = s.fData[r.fCurrentData];
451 ushort2 *hits = reinterpret_cast<ushort2*>( tmpint4 );
453 float fY = tParam.GetY();
454 float fZ = tParam.GetZ();
457 { // search for the closest hit
458 const int fIndYmin = row.Grid().GetBinBounded( fY - 1.f, fZ - 1.f );
459 assert( fIndYmin >= 0 );
462 int fY0 = ( int ) ( ( fY - y0 ) * stepYi );
463 int fZ0 = ( int ) ( ( fZ - z0 ) * stepZi );
464 int ds0 = ( ( ( int )1 ) << 30 );
467 unsigned int fHitYfst = 1, fHitYlst = 0, fHitYfst1 = 1, fHitYlst1 = 0;
471 std::cout << " tracklet " << r.fItr << ", row " << iRow << ": grid N=" << row.Grid().N() << std::endl;
472 std::cout << " tracklet " << r.fItr << ", row " << iRow << ": minbin=" << fIndYmin << std::endl;
476 int nY = row.Grid().Ny();
478 unsigned short *sGridP = ( reinterpret_cast<unsigned short*>( tmpint4 ) ) + 3 * row.NHits();
479 fHitYfst = sGridP[fIndYmin];
480 fHitYlst = sGridP[fIndYmin+2];
481 fHitYfst1 = sGridP[fIndYmin+nY];
482 fHitYlst1 = sGridP[fIndYmin+nY+2];
483 assert( fHitYfst <= row.NHits() );
484 assert( fHitYlst <= row.NHits() );
485 assert( fHitYfst1 <= row.NHits() );
486 assert( fHitYlst1 <= row.NHits() );
489 std::cout << " Grid, row " << iRow << ": nHits=" << row.NHits() << ", grid n=" << row.Grid().N() << ", c[n]=" << sGridP[row.Grid().N()] << std::endl;
490 std::cout << "hit steps = " << stepY << " " << stepZ << std::endl;
491 std::cout << " Grid bins:" << std::endl;
492 for ( unsigned int i = 0; i < row.Grid().N(); i++ ) {
493 std::cout << " bin " << i << ": ";
494 for ( int j = sGridP[i]; j < sGridP[i+1]; j++ ) {
495 ushort2 hh = hits[j];
496 float y = y0 + hh.x * stepY;
497 float z = z0 + hh.y * stepZ;
498 std::cout << "[" << j << "|" << y << "," << z << "] ";
500 std::cout << std::endl;
504 if ( sGridP[row.Grid().N()] != row.NHits() ) {
506 std::cout << " grid, row " << iRow << ": nHits=" << row.NHits() << ", grid n=" << row.Grid().N() << ", c[n]=" << sGridP[row.Grid().N()] << std::endl;
513 std::cout << " tracklet " << r.fItr << ", row " << iRow << ", yz= " << fY << "," << fZ << ": search hits=" << fHitYfst << " " << fHitYlst << " / " << fHitYfst1 << " " << fHitYlst1 << std::endl;
514 std::cout << " hit search :" << std::endl;
517 for ( unsigned int fIh = fHitYfst; fIh < fHitYlst; fIh++ ) {
518 assert( fIh < row.NHits() );
519 ushort2 hh = hits[fIh];
520 int ddy = ( int )( hh.x ) - fY0;
521 int ddz = ( int )( hh.y ) - fZ0;
522 int dds = CAMath::Abs( ddy ) + CAMath::Abs( ddz );
525 std::cout << fIh << ": hityz= " << hh.x << " " << hh.y << "(" << hh.x*stepY << " " << hh.y*stepZ << "), trackyz=" << fY0 << " " << fZ0 << "(" << fY0*stepY << " " << fZ0*stepZ << "), dy,dz,ds= " << ddy << " " << ddz << " " << dds << "(" << ddy*stepY << " " << ddz*stepZ << std::endl;
534 for ( unsigned int fIh = fHitYfst1; fIh < fHitYlst1; fIh++ ) {
535 ushort2 hh = hits[fIh];
536 int ddy = ( int )( hh.x ) - fY0;
537 int ddz = ( int )( hh.y ) - fZ0;
538 int dds = CAMath::Abs( ddy ) + CAMath::Abs( ddz );
541 std::cout << fIh << ": hityz= " << hh.x << " " << hh.y << "(" << hh.x*stepY << " " << hh.y*stepZ << "), trackyz=" << fY0 << " " << fZ0 << "(" << fY0*stepY << " " << fZ0*stepZ << "), dy,dz,ds= " << ddy << " " << ddz << " " << dds << "(" << ddy*stepY << " " << ddz*stepZ << std::endl;
549 }// end of search for the closest hit
551 if ( best < 0 ) break;
554 std::cout << "hit search " << r.fItr << ", row " << iRow << " hit " << best << " found" << std::endl;
556 AliHLTTPCCADisplay::Instance().DrawSliceHit( iRow, best, kRed, 1. );
557 AliHLTTPCCADisplay::Instance().Ask();
558 AliHLTTPCCADisplay::Instance().DrawSliceHit( iRow, best, kWhite, 1 );
559 AliHLTTPCCADisplay::Instance().DrawSliceHit( iRow, best );
563 ushort2 hh = hits[best];
565 //std::cout<<"mark 3, "<<r.fItr<<std::endl;
567 tracker.GetErrors2( iRow, *( ( AliHLTTPCCATrackParam* )&tParam ), err2Y, err2Z );
568 //std::cout<<"mark 4"<<std::endl;
570 float y = y0 + hh.x * stepY;
571 float z = z0 + hh.y * stepZ;
575 const float kFactor = tracker.Param().HitPickUpFactor() * tracker.Param().HitPickUpFactor() * 3.5 * 3.5;
576 float sy2 = kFactor * ( tParam.GetErr2Y() + err2Y );
577 float sz2 = kFactor * ( tParam.GetErr2Z() + err2Z );
578 if ( sy2 > 2. ) sy2 = 2.;
579 if ( sz2 > 2. ) sz2 = 2.;
583 std::cout << "dy,sy= " << dy << " " << CAMath::Sqrt( sy2 ) << ", dz,sz= " << dz << " " << CAMath::Sqrt( sz2 ) << std::endl;
584 std::cout << "dy,dz= " << dy << " " << dz << ", sy,sz= " << CAMath::Sqrt( sy2 ) << " " << CAMath::Sqrt( sz2 ) << ", sy,sz= " << CAMath::Sqrt( kFactor*( tParam.GetErr2Y() + err2Y ) ) << " " << CAMath::Sqrt( kFactor*( tParam.GetErr2Z() + err2Z ) ) << std::endl;
587 if ( CAMath::FMulRZ( dy, dy ) > sy2 || CAMath::FMulRZ( dz, dz ) > sz2 ) {
591 std::cout << "found hit is out of the chi2 window\n " << std::endl;
597 //if( SAVE() ) hitstore[ iRow ] = best;
598 //std::cout<<"hit search before filter: "<<r.fItr<<", row "<<iRow<<std::endl;
599 //AliHLTTPCCADisplay::Instance().DrawTracklet(tParam, hitstore, kBlue);
600 //AliHLTTPCCADisplay::Instance().Ask();
602 if ( !tParam.Filter( y, z, err2Y, err2Z, .99 ) ) {
605 std::cout << "tracklet " << r.fItr << " at row " << iRow << " : can not filter!!!! " << std::endl;
610 if ( SAVE() ) tracklet.SetRowHit( iRow, best );
613 std::cout << "tracklet " << r.fItr << " after filter at row " << iRow << " : " << std::endl;
616 AliHLTTPCCADisplay::Instance().DrawTracklet( tParam, hitstore, kRed );
617 AliHLTTPCCADisplay::Instance().Ask();
622 if ( r.fStage == 1 ) r.fLastRow = iRow;
623 else r.fFirstRow = iRow;
630 GPUd() void AliHLTTPCCATrackletConstructor::Thread
631 ( int nBlocks, int nThreads, int iBlock, int iThread, int iSync,
632 AliHLTTPCCASharedMemory &s, AliHLTTPCCAThreadMemory &r, AliHLTTPCCATracker &tracker, AliHLTTPCCATrackParam &tParam )
635 // reconstruction of tracklets
637 Step0( nBlocks, nThreads, iBlock, iThread, s, r, tracker, tParam );
638 } else if ( iSync == 1 ) {
639 Step1( nBlocks, nThreads, iBlock, iThread, s, r, tracker, tParam );
640 } else if ( iSync == 2 ) {
641 Step2( nBlocks, nThreads, iBlock, iThread, s, r, tracker, tParam );
644 else if ( iSync == 3 )
648 ReadData( iThread, s, r, tracker, s.fMinStartRow );
651 } else if ( iSync == 3 + 159 + 1 ) {
653 int nextRow = s.fMaxStartRow - 1;
654 if ( nextRow < 0 ) nextRow = 0;
655 ReadData( iThread, s, r, tracker, nextRow );
660 const AliHLTTPCCARow &row = tracker.Row( r.fEndRow );
662 if ( !tParam.TransportToX( x, tracker.Param().ConstBz(), .999 ) ) r.fGo = 0;
666 else if ( iSync <= 3 + 159 + 1 + 159 ) {
668 if ( iSync <= 3 + 159 ) {
670 if ( iRow < s.fMinStartRow ) return;
672 if ( nextRow > 158 ) nextRow = 158;
674 iRow = 158 - ( iSync - 4 - 159 - 1 );
675 if ( iRow >= s.fMaxStartRow ) return;
677 if ( nextRow < 0 ) nextRow = 0;
680 if ( r.fIsMemThread ) {
681 ReadData( iThread, s, r, tracker, nextRow );
683 UpdateTracklet( nBlocks, nThreads, iBlock, iThread,
684 s, r, tracker, tParam, iRow );
686 r.fCurrentData = !r.fCurrentData;
689 else if ( iSync == 4 + 159*2 + 1 + 1 ) { //
690 StoreTracklet( nBlocks, nThreads, iBlock, iThread,
691 s, r, tracker, tParam );