]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/TPCLib/tracking-ca/AliHLTTPCCATracker.cxx
Remove compilser warnings
[u/mrichter/AliRoot.git] / HLT / TPCLib / tracking-ca / AliHLTTPCCATracker.cxx
CommitLineData
326c2d4b 1// @(#) $Id$
ce565086 2// **************************************************************************
fbb9b71b 3// This file is property of and copyright by the ALICE HLT Project *
d54804bf 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// *
d54804bf 18//***************************************************************************
326c2d4b 19
20#include "AliHLTTPCCATracker.h"
326c2d4b 21#include "AliHLTTPCCAOutTrack.h"
d54804bf 22#include "AliHLTTPCCAGrid.h"
23#include "AliHLTTPCCARow.h"
24#include "AliHLTTPCCATrack.h"
4687b8fc 25#include "AliHLTTPCCATracklet.h"
00d07bcd 26#include "AliHLTTPCCAMath.h"
27#include "AliHLTTPCCAHit.h"
326c2d4b 28
dc4788ec 29#include "TStopwatch.h"
00d07bcd 30#include "AliHLTTPCCAHitArea.h"
31#include "AliHLTTPCCANeighboursFinder.h"
32#include "AliHLTTPCCANeighboursCleaner.h"
33#include "AliHLTTPCCAStartHitsFinder.h"
34#include "AliHLTTPCCATrackletConstructor.h"
35#include "AliHLTTPCCATrackletSelector.h"
36#include "AliHLTTPCCAProcess.h"
00d07bcd 37#include "AliHLTTPCCAUsedHitsInitialiser.h"
63d8b79d 38#include "AliHLTTPCCASliceTrack.h"
39#include "AliHLTTPCCASliceOutput.h"
40#include "AliHLTTPCCADataCompressor.h"
00d07bcd 41
42#include "AliHLTTPCCATrackParam.h"
00d07bcd 43
44#if !defined(HLTCA_GPUCODE)
4687b8fc 45#include <iostream>
00d07bcd 46#endif
d54804bf 47
326c2d4b 48//#define DRAW
49
50#ifdef DRAW
fbb9b71b 51#include "AliHLTTPCCADisplay.h"
326c2d4b 52#endif //DRAW
53
ce565086 54#ifdef HLTCA_INTERNAL_PERFORMANCE
fbb9b71b 55#include "AliHLTTPCCAPerformance.h"
ce565086 56#endif
57
58
fbb9b71b 59ClassImp( AliHLTTPCCATracker )
326c2d4b 60
fbb9b71b 61#if !defined(HLTCA_GPUCODE)
326c2d4b 62
63AliHLTTPCCATracker::AliHLTTPCCATracker()
fbb9b71b 64 :
65 fParam(),
66 fNHitsTotal( 0 ),
67 fCommonMemory( 0 ),
68 fCommonMemorySize( 0 ),
69 fHitMemory( 0 ),
70 fHitMemorySize( 0 ),
71 fTrackMemory( 0 ),
72 fTrackMemorySize( 0 ),
73 fInputEvent( 0 ),
74 fInputEventSize( 0 ),
75 fRowData( 0 ),
76 fRowDataSize( 0 ),
77 fHitInputIDs( 0 ),
78 fHitWeights( 0 ),
79 fNTracklets( 0 ),
80 fTrackletStartHits( 0 ),
81 fTracklets( 0 ),
82 fNTracks( 0 ),
83 fTracks( 0 ),
84 fNTrackHits( 0 ),
85 fTrackHits( 0 ),
86 fOutput( 0 ),
87 fNOutTracks( 0 ),
88 fOutTracks( 0 ),
89 fNOutTrackHits( 0 ),
90 fOutTrackHits( 0 ),
91 fTmpHitInputIDs( 0 )
326c2d4b 92{
93 // constructor
326c2d4b 94}
95
96AliHLTTPCCATracker::AliHLTTPCCATracker( const AliHLTTPCCATracker& )
fbb9b71b 97 :
98 fParam(),
99 fNHitsTotal( 0 ),
100 fCommonMemory( 0 ),
101 fCommonMemorySize( 0 ),
102 fHitMemory( 0 ),
103 fHitMemorySize( 0 ),
104 fTrackMemory( 0 ),
105 fTrackMemorySize( 0 ),
106 fInputEvent( 0 ),
107 fInputEventSize( 0 ),
108 fRowData( 0 ),
109 fRowDataSize( 0 ),
110 fHitInputIDs( 0 ),
111 fHitWeights( 0 ),
112 fNTracklets( 0 ),
113 fTrackletStartHits( 0 ),
114 fTracklets( 0 ),
115 fNTracks( 0 ),
116 fTracks( 0 ),
117 fNTrackHits( 0 ),
118 fTrackHits( 0 ),
119 fOutput( 0 ),
120 fNOutTracks( 0 ),
121 fOutTracks( 0 ),
122 fNOutTrackHits( 0 ),
123 fOutTrackHits( 0 ),
124 fTmpHitInputIDs( 0 )
326c2d4b 125{
126 // dummy
127}
128
129AliHLTTPCCATracker &AliHLTTPCCATracker::operator=( const AliHLTTPCCATracker& )
130{
131 // dummy
4687b8fc 132 fCommonMemory = 0;
c259f7e4 133 fHitMemory = 0;
134 fTrackMemory = 0;
ce622827 135 return *this;
326c2d4b 136}
137
00d07bcd 138GPUd() AliHLTTPCCATracker::~AliHLTTPCCATracker()
326c2d4b 139{
140 // destructor
fbb9b71b 141 if ( fCommonMemory ) delete[] fCommonMemory;
142 if ( fHitMemory ) delete[] fHitMemory;
143 if ( fTrackMemory ) delete[] fTrackMemory;
144 if ( fTmpHitInputIDs ) delete[] fTmpHitInputIDs;
326c2d4b 145}
00d07bcd 146#endif
147
148
326c2d4b 149
150// ----------------------------------------------------------------------------------
ce565086 151GPUd() void AliHLTTPCCATracker::Initialize( const AliHLTTPCCAParam &param )
326c2d4b 152{
75192f26 153 // initialisation
00d07bcd 154 fParam = param;
4687b8fc 155 fParam.Update();
fbb9b71b 156 for ( int irow = 0; irow < fParam.NRows(); irow++ ) {
157 fRows[irow].SetX( fParam.RowX( irow ) );
158 fRows[irow].SetMaxY( CAMath::Tan( fParam.DAlpha() / 2. )*fRows[irow].X() );
326c2d4b 159 }
160 StartEvent();
161}
162
00d07bcd 163GPUd() void AliHLTTPCCATracker::StartEvent()
326c2d4b 164{
fbb9b71b 165 // start new event and fresh the memory
d54804bf 166
fbb9b71b 167 if ( !fCommonMemory ) {
c259f7e4 168 SetPointersCommon(); // just to calculate the size
fbb9b71b 169 fCommonMemory = reinterpret_cast<char*> ( new uint4 [ fCommonMemorySize/sizeof( uint4 ) + 100] );
c259f7e4 170 SetPointersCommon();// set pointers
4687b8fc 171 }
fbb9b71b 172
173 if ( fHitMemory ) delete[] fHitMemory;
c259f7e4 174 fHitMemory = 0;
fbb9b71b 175 if ( fTrackMemory ) delete[] fTrackMemory;
c259f7e4 176 fTrackMemory = 0;
177
178 fNHitsTotal = 0;
4687b8fc 179 *fNTracklets = 0;
180 *fNTracks = 0 ;
181 *fNTrackHits = 0;
182 *fNOutTracks = 0;
183 *fNOutTrackHits = 0;
fbb9b71b 184 if ( fTmpHitInputIDs ) delete[] fTmpHitInputIDs;
693d2443 185 fTmpHitInputIDs = 0;
326c2d4b 186}
187
c259f7e4 188
c259f7e4 189
190GPUhd() void AliHLTTPCCATracker::SetPointersCommon()
191{
192 // set all pointers to the event memory
193
fbb9b71b 194 ULong_t mem = ( ULong_t ) fCommonMemory;
195 unsigned int sI = sizeof( int );
196
c259f7e4 197 // set common memory
198
fbb9b71b 199 fNTracklets = ( int* ) mem;
200 mem += sI;
201 fNTracks = ( int* ) mem;
202 mem += sI;
203 fNTrackHits = ( int* ) mem;
204 mem += sI;
205 fNOutTracks = ( int* ) mem;
206 mem += sI;
207 fNOutTrackHits = ( int* ) mem;
208 mem += sI;
c259f7e4 209
210 // calculate the size
211
fbb9b71b 212 fCommonMemorySize = mem - ( ULong_t ) fCommonMemory;
c259f7e4 213}
214
215
fbb9b71b 216GPUhd() void AliHLTTPCCATracker::SetPointersHits( int MaxNHits )
c259f7e4 217{
218 // set all pointers to the event memory
219
fbb9b71b 220 int gridSizeTotal = 2 * ( 2 * MaxNHits + 10 * Param().NRows() );
c259f7e4 221 //gridSizeTotal *=100;//SG!!!
222
fbb9b71b 223 ULong_t mem = ( ULong_t ) fHitMemory;
224 unsigned int sI = sizeof( int );
225 unsigned int sF = sizeof( float );
226 unsigned int sS = sizeof( short );
227 unsigned int s4 = sizeof( uint4 );
228
c259f7e4 229 // set input event
230
fbb9b71b 231 mem = ( mem / s4 + 1 ) * s4;
232 fInputEvent = ( char* ) mem;
233 fInputEventSize = ( 1 + fParam.NRows() * 2 + 1 ) * sI + ( MaxNHits * 3 ) * sF;
234 mem += fInputEventSize;
c259f7e4 235
236 // set cluster data for TPC rows
237
fbb9b71b 238 mem = ( mem / s4 + 1 ) * s4;
239 fRowData = ( uint4* ) mem;
240 fRowDataSize = ( 2 * MaxNHits * sS + // yz
241 gridSizeTotal * sS + // grid
242 2 * MaxNHits * sS + // link up,link down
243 fParam.NRows() * s4 // row alignment
244 );
c259f7e4 245 mem += fRowDataSize;
246
247 // extra arrays for tpc clusters
c259f7e4 248
fbb9b71b 249 mem = ( mem / sI + 1 ) * sI;
c259f7e4 250
fbb9b71b 251 fHitInputIDs = ( int* ) mem;
252 mem += MaxNHits * sI;
c259f7e4 253
fbb9b71b 254 fTrackletStartHits = ( int* ) mem;
255 mem += MaxNHits * sI;
256
257 fHitWeights = ( int* ) mem;
258 mem += MaxNHits * sI;
c259f7e4 259
260 // arrays for track hits
261
fbb9b71b 262 fTrackHits = ( int* ) mem;
263 mem += 10 * MaxNHits * sI;//SG!!!
264
265 fOutTrackHits = ( int* ) mem;
266 mem += 10 * MaxNHits * sI; //SG!!!
c259f7e4 267
268 // calculate the size
269
fbb9b71b 270 fHitMemorySize = mem - ( ULong_t ) fHitMemory;
c259f7e4 271}
272
273
fbb9b71b 274GPUhd() void AliHLTTPCCATracker::SetPointersTracks( int MaxNTracks, int MaxNHits )
c259f7e4 275{
276 // set all pointers to the tracks memory
277
fbb9b71b 278 ULong_t mem = ( ULong_t ) fTrackMemory;
279
c259f7e4 280 // memory for tracklets
281
fbb9b71b 282 mem = ( mem / sizeof( AliHLTTPCCATracklet ) + 1 ) * sizeof( AliHLTTPCCATracklet );
283 fTracklets = ( AliHLTTPCCATracklet * ) mem;
284 mem += MaxNTracks * sizeof( AliHLTTPCCATracklet );
285
c259f7e4 286 // memory for selected tracks
fbb9b71b 287
288 mem = ( mem / sizeof( AliHLTTPCCATrack ) + 1 ) * sizeof( AliHLTTPCCATrack );
289 fTracks = ( AliHLTTPCCATrack* ) mem;
290 mem += MaxNTracks * sizeof( AliHLTTPCCATrack );
291
63d8b79d 292 // memory for output
293
fbb9b71b 294 mem = ( mem / sizeof( AliHLTTPCCASliceOutput ) + 1 ) * sizeof( AliHLTTPCCASliceOutput );
295 fOutput = ( AliHLTTPCCASliceOutput* ) mem;
296 mem += AliHLTTPCCASliceOutput::EstimateSize( MaxNTracks, MaxNHits );
297
c259f7e4 298 // memory for output tracks
299
fbb9b71b 300 mem = ( mem / sizeof( AliHLTTPCCAOutTrack ) + 1 ) * sizeof( AliHLTTPCCAOutTrack );
301
302 fOutTracks = ( AliHLTTPCCAOutTrack* ) mem;
303 mem += MaxNTracks * sizeof( AliHLTTPCCAOutTrack );
c259f7e4 304
305 // calculate the size
306
fbb9b71b 307 fTrackMemorySize = mem - ( ULong_t ) fTrackMemory;
c259f7e4 308}
309
326c2d4b 310
4687b8fc 311
fbb9b71b 312GPUd() void AliHLTTPCCATracker::ReadEvent( const int *RowFirstHit, const int *RowNHits, const float *X, const float *Y, const float *Z, int NHits )
326c2d4b 313{
00d07bcd 314 //* Read event
d54804bf 315
c259f7e4 316 StartEvent();
fbb9b71b 317
00d07bcd 318 fNHitsTotal = NHits;
fbb9b71b 319
4687b8fc 320 {
fbb9b71b 321 SetPointersHits( NHits ); // to calculate the size
322 fHitMemory = reinterpret_cast<char*> ( new uint4 [ fHitMemorySize/sizeof( uint4 ) + 100] );
323 SetPointersHits( NHits ); // set pointers for hits
4687b8fc 324 *fNTracklets = 0;
325 *fNTracks = 0 ;
326 *fNOutTracks = 0;
327 *fNOutTrackHits = 0;
328 }
329
fbb9b71b 330 reinterpret_cast<int*>( fInputEvent )[0] = fParam.NRows();
331 reinterpret_cast<int*>( fInputEvent )[1+fParam.NRows()*2] = NHits;
332 int *rowHeaders = reinterpret_cast<int*>( fInputEvent ) + 1;
333 float *hitsXYZ = reinterpret_cast<float*>( fInputEvent ) + 1 + fParam.NRows() * 2 + 1;
334 for ( int iRow = 0; iRow < fParam.NRows(); iRow++ ) {
4687b8fc 335 rowHeaders[iRow*2 ] = RowFirstHit[iRow];
336 rowHeaders[iRow*2+1] = RowNHits[iRow];
337 }
fbb9b71b 338 for ( int iHit = 0; iHit < NHits; iHit++ ) {
15d2e9cf 339 hitsXYZ[iHit*3 ] = X[iHit];
340 hitsXYZ[iHit*3+1] = Y[iHit];
341 hitsXYZ[iHit*3+2] = Z[iHit];
4687b8fc 342 }
693d2443 343
344 //SG cell finder - test code
345
fbb9b71b 346 if ( fTmpHitInputIDs ) delete[] fTmpHitInputIDs;
347 fTmpHitInputIDs = new int [NHits];
348 const float areaY = .5;
349 const float areaZ = .5;
350 int newRowNHitsTotal = 0;
351 bool *usedHits = new bool [NHits];
352 for ( int iHit = 0; iHit < NHits; iHit++ ) usedHits[iHit] = 0;
353 for ( int iRow = 0; iRow < fParam.NRows(); iRow++ ) {
693d2443 354 rowHeaders[iRow*2 ] = newRowNHitsTotal; // new first hit
355 rowHeaders[iRow*2+1] = 0; // new N hits
fbb9b71b 356 int newRowNHits = 0;
357 int oldRowFirstHit = RowFirstHit[iRow];
358 int oldRowLastHit = oldRowFirstHit + RowNHits[iRow];
359 for ( int iHit = oldRowFirstHit; iHit < oldRowLastHit; iHit++ ) {
360 if ( usedHits[iHit] ) continue;
361 float x0 = X[iHit];
362 float y0 = Y[iHit];
363 float z0 = Z[iHit];
364 float cx = x0;
365 float cy = y0;
366 float cz = z0;
367 int nclu = 1;
368 usedHits[iHit] = 1;
369 if ( 0 ) for ( int jHit = iHit + 1; jHit < oldRowLastHit; jHit++ ) {//SG!!!
370 //if( usedHits[jHit] ) continue;
371 float dy = Y[jHit] - y0;
372 float dz = Z[jHit] - z0;
373 if ( CAMath::Abs( dy ) < areaY && CAMath::Abs( dz ) < areaZ ) {
374 cx += X[jHit];
375 cy += Y[jHit];
376 cz += Z[jHit];
377 nclu++;
378 usedHits[jHit] = 1;
379 }
380 }
381 int id = newRowNHitsTotal + newRowNHits;
382 hitsXYZ[id*3+0 ] = cx / nclu;
383 hitsXYZ[id*3+1 ] = cy / nclu;
384 hitsXYZ[id*3+2 ] = cz / nclu;
693d2443 385 fTmpHitInputIDs[id] = iHit;
386 newRowNHits++;
387 }
388 rowHeaders[iRow*2+1] = newRowNHits;
fbb9b71b 389 newRowNHitsTotal += newRowNHits;
693d2443 390 }
391 fNHitsTotal = newRowNHitsTotal;
fbb9b71b 392 reinterpret_cast<int*>( fInputEvent )[1+fParam.NRows()*2] = newRowNHitsTotal;
693d2443 393
fbb9b71b 394 delete[] usedHits;
4687b8fc 395 SetupRowData();
396}
397
398
399GPUd() void AliHLTTPCCATracker::SetupRowData()
400{
401 //* Convert input hits, create grids, etc.
693d2443 402
fbb9b71b 403 fNHitsTotal = reinterpret_cast<int*>( fInputEvent )[1+fParam.NRows()*2];
404 int *rowHeaders = reinterpret_cast<int*>( fInputEvent ) + 1;
405 float *hitsXYZ = reinterpret_cast<float*>( fInputEvent ) + 1 + fParam.NRows() * 2 + 1;
406
407 for ( int iRow = 0; iRow < fParam.NRows(); iRow++ ) {
408
00d07bcd 409 AliHLTTPCCARow &row = fRows[iRow];
693d2443 410 row.SetFirstHit( rowHeaders[iRow*2] );
411 row.SetNHits( rowHeaders[iRow*2+1] );
fbb9b71b 412 float yMin = 1.e3, yMax = -1.e3, zMin = 1.e3, zMax = -1.e3;
413 int nGrid = row.NHits();
414 for ( int i = 0; i < row.NHits(); i++ ) {
415 int j = row.FirstHit() + i;
416 float y = hitsXYZ[j*3+1];
417 float z = hitsXYZ[j*3+2];
418 if ( yMax < y ) yMax = y;
419 if ( yMin > y ) yMin = y;
420 if ( zMax < z ) zMax = z;
421 if ( zMin > z ) zMin = z;
00d07bcd 422 }
fbb9b71b 423 if ( nGrid <= 0 ) {
00d07bcd 424 yMin = yMax = zMin = zMax = 0;
425 nGrid = 1;
426 }
427
693d2443 428 AliHLTTPCCAGrid grid;
429 grid.Create( yMin, yMax, zMin, zMax, nGrid );
fbb9b71b 430
431 float sy = ( CAMath::Abs( grid.StepYInv() ) > 1.e-4 ) ? 1. / grid.StepYInv() : 1;
432 float sz = ( CAMath::Abs( grid.StepZInv() ) > 1.e-4 ) ? 1. / grid.StepZInv() : 1;
433
00d07bcd 434 //cout<<"grid n = "<<row.Grid().N()<<" "<<sy<<" "<<sz<<" "<<yMin<<" "<<yMax<<" "<<zMin<<" "<<zMax<<endl;
fbb9b71b 435
436 bool recreate = 0;
437 if ( sy < 2. ) { recreate = 1; sy = 2; }
438 if ( sz < 2. ) { recreate = 1; sz = 2; }
c259f7e4 439 //recreate = 1;//SG!!!
440 //sy=2;
441 //sz=2;
fbb9b71b 442 if ( recreate ) grid.Create( yMin, yMax, zMin, zMax, sy, sz );
693d2443 443 row.SetGrid( grid );
ce565086 444 }
00d07bcd 445
fbb9b71b 446
e1f2d1c3 447 AliHLTTPCCAHit *ffHits = new AliHLTTPCCAHit[ fNHitsTotal ];
326c2d4b 448
fbb9b71b 449 int rowDataOffset = 0;
326c2d4b 450
fbb9b71b 451 for ( int iRow = 0; iRow < fParam.NRows(); iRow++ ) {
693d2443 452
00d07bcd 453 AliHLTTPCCARow &row = fRows[iRow];
693d2443 454 const AliHLTTPCCAGrid &grid = row.Grid();
d54804bf 455
fbb9b71b 456 int *c = new int [grid.N() + 3 + 10];
457 int *bins = new int [row.NHits()];
458 int *filled = new int [row.Grid().N() + 3 + 10 ];
459
460 for ( unsigned int bin = 0; bin < row.Grid().N() + 3; bin++ ) filled[bin] = 0;
d54804bf 461
fbb9b71b 462 for ( int i = 0; i < row.NHits(); i++ ) {
463 int j = row.FirstHit() + i;
464 int bin = row.Grid().GetBin( hitsXYZ[3*j+1], hitsXYZ[3*j+2] );
00d07bcd 465 bins[i] = bin;
466 filled[bin]++;
d54804bf 467 }
d54804bf 468
00d07bcd 469 {
fbb9b71b 470 int n = 0;
471 for ( unsigned int bin = 0; bin < row.Grid().N() + 3; bin++ ) {
472 c[bin] = n;
473 n += filled[bin];
00d07bcd 474 }
475 }
693d2443 476
fbb9b71b 477 for ( int i = 0; i < row.NHits(); i++ ) {
478 int bin = bins[i];
479 int ind = c[bin] + filled[bin] - 1;
ce565086 480
fbb9b71b 481 AliHLTTPCCAHit &h = ffHits[row.FirstHit()+ind];
693d2443 482 fHitInputIDs[row.FirstHit()+ind] = fTmpHitInputIDs[row.FirstHit()+i];
fbb9b71b 483 h.SetY( hitsXYZ[3*( row.FirstHit()+i )+1] );
484 h.SetZ( hitsXYZ[3*( row.FirstHit()+i )+2] );
00d07bcd 485 filled[bin]--;
486 }
d54804bf 487
00d07bcd 488 {
fbb9b71b 489 float y0 = row.Grid().YMin();
490 float stepY = ( row.Grid().YMax() - y0 ) * ( 1. / 65535. );
491 float z0 = row.Grid().ZMin();
492 float stepZ = ( row.Grid().ZMax() - z0 ) * ( 1. / 65535. );
493 if ( stepY < 1.e-4 ) stepY = 1.e-4;
494 if ( stepZ < 1.e-4 ) stepZ = 1.e-4;
495 float stepYi = 1. / stepY;
496 float stepZi = 1. / stepZ;
497
693d2443 498 row.SetHy0( y0 );
499 row.SetHz0( z0 );
500 row.SetHstepY( stepY );
501 row.SetHstepZ( stepZ );
502 row.SetHstepYi( stepYi );
503 row.SetHstepZi( stepZi );
fbb9b71b 504
693d2443 505 row.SetFullOffset( rowDataOffset );
fbb9b71b 506 ushort2 *p = ( ushort2* )( fRowData + row.FullOffset() );
507 for ( int ih = 0; ih < row.NHits(); ih++ ) {
508 int ihTot = row.FirstHit() + ih;
509 AliHLTTPCCAHit &hh = ffHits[ihTot];
510 float xx = ( ( hh.Y() - y0 ) * stepYi );
511 float yy = ( ( hh.Z() - z0 ) * stepZi );
512 if ( xx < 0 || yy < 0 || xx >= 65536 || yy >= 65536 ) {
513 std::cout << "!!!! hit packing error!!! " << xx << " " << yy << " " << std::endl;
514 }
515 p[ih].x = ( unsigned short ) xx;
516 p[ih].y = ( unsigned short ) yy;
d54804bf 517 }
fbb9b71b 518 int size = row.NHits() * sizeof( ushort2 );
00d07bcd 519
fbb9b71b 520 row.SetFullGridOffset( row.NHits()*2 );
521 unsigned short *p1 = ( ( unsigned short * )p ) + row.FullGridOffset();
00d07bcd 522
fbb9b71b 523 int n = grid.N();
524 for ( int i = 0; i < n; i++ ) {
525 p1[i] = c[i];
526 }
527 unsigned short a = c[n];
528 int nn = n + grid.Ny() + 3;
529 for ( int i = n; i < nn; i++ ) p1[i] = a;
00d07bcd 530
fbb9b71b 531 size += ( nn ) * sizeof( unsigned short );
693d2443 532 row.SetFullLinkOffset( row.NHits()*2 + nn );
fbb9b71b 533 size += row.NHits() * 2 * sizeof( short );
ce565086 534
fbb9b71b 535 if ( size % 16 ) size = size / sizeof( uint4 ) + 1;
536 else size = size / sizeof( uint4 );
693d2443 537 row.SetFullSize( size );
4687b8fc 538 //cout<<iRow<<", "<<row.fNHits<<"= "<<size*16<<"b: "<<row.fFullOffset<<" "<<row.fFullSize<<" "<<row.fFullGridOffset<<" "<<row.fFullLinkOffset<<std::endl;
00d07bcd 539
fbb9b71b 540 rowDataOffset += size;
e1f2d1c3 541 }
fbb9b71b 542 if ( c ) delete[] c;
543 if ( bins ) delete[] bins;
544 if ( filled ) delete[] filled;
e1f2d1c3 545 }
546 delete[] ffHits;
d54804bf 547}
548
326c2d4b 549
00d07bcd 550GPUh() void AliHLTTPCCATracker::Reconstruct()
551{
552 //* reconstruction of event
693d2443 553 //std::cout<<"Reconstruct slice "<<fParam.ISlice()<<", nHits="<<fNHitsTotal<<std::endl;
326c2d4b 554
00d07bcd 555 fTimers[0] = 0; // find neighbours
556 fTimers[1] = 0; // construct tracklets
557 fTimers[2] = 0; // fit tracklets
558 fTimers[3] = 0; // prolongation of tracklets
559 fTimers[4] = 0; // selection
560 fTimers[5] = 0; // write output
561 fTimers[6] = 0;
562 fTimers[7] = 0;
fbb9b71b 563
693d2443 564 //if( fParam.ISlice()<1 ) return; //SG!!!
00d07bcd 565
00d07bcd 566 TStopwatch timer0;
4687b8fc 567
693d2443 568 //SetupRowData();
fbb9b71b 569 if ( fNHitsTotal < 1 ) {
63d8b79d 570 {
fbb9b71b 571 SetPointersTracks( 1, 1 ); // to calculate the size
572 fTrackMemory = reinterpret_cast<char*> ( new uint4 [ fTrackMemorySize/sizeof( uint4 ) + 100] );
573 SetPointersTracks( 1, 1 ); // set pointers for tracks
574 fOutput->SetNTracks( 0 );
575 fOutput->SetNTrackClusters( 0 );
63d8b79d 576 }
693d2443 577
63d8b79d 578 return;
579 }
693d2443 580#ifdef DRAW
693d2443 581
fbb9b71b 582 AliHLTTPCCADisplay::Instance().ClearView();
693d2443 583 AliHLTTPCCADisplay::Instance().SetSliceView();
584 AliHLTTPCCADisplay::Instance().SetCurrentSlice( this );
fbb9b71b 585 AliHLTTPCCADisplay::Instance().DrawSlice( this, 1 );
586 if ( fNHitsTotal > 0 ) {
587 AliHLTTPCCADisplay::Instance().DrawSliceHits( kRed, .5 );
693d2443 588 AliHLTTPCCADisplay::Instance().Ask();
589 }
590#endif
591
00d07bcd 592 *fNTracks = 0;
4687b8fc 593 *fNTracklets = 0;
594
fbb9b71b 595#if !defined(HLTCA_GPUCODE)
596
00d07bcd 597 AliHLTTPCCAProcess<AliHLTTPCCANeighboursFinder>( Param().NRows(), 1, *this );
693d2443 598
fbb9b71b 599#ifdef HLTCA_INTERNAL_PERFORMANCE
600 //if( Param().ISlice()<=2 )
ce565086 601 //AliHLTTPCCAPerformance::Instance().LinkPerformance( Param().ISlice() );
602#endif
603
604
605#ifdef DRAW
fbb9b71b 606 if ( fNHitsTotal > 0 ) {
607 AliHLTTPCCADisplay::Instance().DrawSliceLinks( -1, -1, 1 );
ce565086 608 AliHLTTPCCADisplay::Instance().Ask();
609 }
610#endif
611
612
fbb9b71b 613 AliHLTTPCCAProcess<AliHLTTPCCANeighboursCleaner>( Param().NRows() - 2, 1, *this );
614 AliHLTTPCCAProcess<AliHLTTPCCAStartHitsFinder>( Param().NRows() - 4, 1, *this );
615
616 int nStartHits = *fNTracklets;
d54804bf 617
fbb9b71b 618 int nThreads = 128;
619 int nBlocks = fNHitsTotal / nThreads + 1;
620 if ( nBlocks < 12 ) {
621 nBlocks = 12;
622 nThreads = fNHitsTotal / 12 + 1;
623 if ( nThreads % 32 ) nThreads = ( nThreads / 32 + 1 ) * 32;
326c2d4b 624 }
fbb9b71b 625
00d07bcd 626 nThreads = fNHitsTotal;
627 nBlocks = 1;
dc4788ec 628
fbb9b71b 629 AliHLTTPCCAProcess<AliHLTTPCCAUsedHitsInitialiser>( nBlocks, nThreads, *this );
dc4788ec 630
c259f7e4 631
632 {
fbb9b71b 633 SetPointersTracks( nStartHits, fNHitsTotal ); // to calculate the size
634 fTrackMemory = reinterpret_cast<char*> ( new uint4 [ fTrackMemorySize/sizeof( uint4 ) + 100] );
635 SetPointersTracks( nStartHits, fNHitsTotal ); // set pointers for hits
c259f7e4 636 }
637
fbb9b71b 638 int nMemThreads = AliHLTTPCCATrackletConstructor::NMemThreads();
00d07bcd 639 nThreads = 256;//96;
fbb9b71b 640 nBlocks = nStartHits / nThreads + 1;
641 if ( nBlocks < 30 ) {
00d07bcd 642 nBlocks = 30;
fbb9b71b 643 nThreads = ( nStartHits ) / 30 + 1;
644 if ( nThreads % 32 ) nThreads = ( nThreads / 32 + 1 ) * 32;
00d07bcd 645 }
d54804bf 646
00d07bcd 647 nThreads = nStartHits;
648 nBlocks = 1;
d54804bf 649
fbb9b71b 650 AliHLTTPCCAProcess1<AliHLTTPCCATrackletConstructor>( nBlocks, nMemThreads + nThreads, *this );
d54804bf 651
ce565086 652 //std::cout<<"Slice "<<Param().ISlice()<<": NHits="<<fNHitsTotal<<", NTracklets="<<*NTracklets()<<std::endl;
653
fbb9b71b 654 {
00d07bcd 655 nThreads = 128;
fbb9b71b 656 nBlocks = nStartHits / nThreads + 1;
657 if ( nBlocks < 12 ) {
658 nBlocks = 12;
659 nThreads = nStartHits / 12 + 1;
660 nThreads = ( nThreads / 32 + 1 ) * 32;
00d07bcd 661 }
fbb9b71b 662
4687b8fc 663 *fNTrackHits = 0;
d54804bf 664
00d07bcd 665 nThreads = nStartHits;
666 nBlocks = 1;
d54804bf 667
d54804bf 668
fbb9b71b 669 AliHLTTPCCAProcess<AliHLTTPCCATrackletSelector>( nBlocks, nThreads, *this );
d54804bf 670
693d2443 671 //std::cout<<"Slice "<<Param().ISlice()<<": N start hits/tracklets/tracks = "<<nStartHits<<" "<<nStartHits<<" "<<*fNTracks<<std::endl;
fbb9b71b 672 }
c259f7e4 673
674 //std::cout<<"Memory used for slice "<<fParam.ISlice()<<" : "<<fCommonMemorySize/1024./1024.<<" + "<<fHitMemorySize/1024./1024.<<" + "<<fTrackMemorySize/1024./1024.<<" = "<<( fCommonMemorySize+fHitMemorySize+fTrackMemorySize )/1024./1024.<<" Mb "<<std::endl;
675
fbb9b71b 676
677 WriteOutput();
678
d54804bf 679
693d2443 680#endif
681
682#ifdef DRAW
fbb9b71b 683 {
684 AliHLTTPCCADisplay &disp = AliHLTTPCCADisplay::Instance();
685 AliHLTTPCCATracker &slice = *this;
686 std::cout << "N out tracks = " << *slice.NOutTracks() << std::endl;
687 //disp.Ask();
688 AliHLTTPCCADisplay::Instance().SetCurrentSlice( this );
689 AliHLTTPCCADisplay::Instance().DrawSlice( this, 1 );
690 disp.DrawSliceHits( -1, .5 );
691 for ( int itr = 0; itr < *slice.NOutTracks(); itr++ ) {
692 std::cout << "track N " << itr << ", nhits=" << slice.OutTracks()[itr].NHits() << std::endl;
693 disp.DrawSliceOutTrack( itr, kBlue );
694 //disp.Ask();
695 //int id = slice.OutTracks()[itr].OrigTrackID();
696 //AliHLTTPCCATrack &tr = Tracks()[id];
697 //for( int ih=0; ih<tr.NHits(); ih++ ){
698 //int ic = (fTrackHits[tr.FirstHitID()+ih]);
699 //std::cout<<ih<<" "<<ID2IRow(ic)<<" "<<ID2IHit(ic)<<std::endl;
700 //}
701 //disp.DrawSliceTrack( id, kBlue );
702 //disp.Ask();
703 }
704 disp.Ask();
705 }
d54804bf 706#endif
dc4788ec 707
fbb9b71b 708 timer0.Stop();
709 fTimers[0] = timer0.CpuTime() / 100.;
326c2d4b 710
fbb9b71b 711}
326c2d4b 712
d54804bf 713
714
d54804bf 715
00d07bcd 716GPUh() void AliHLTTPCCATracker::WriteOutput()
717{
d54804bf 718 // write output
eb30eb49 719
00d07bcd 720 TStopwatch timer;
63d8b79d 721
fbb9b71b 722 //cout<<"output: nTracks = "<<*fNTracks<<", nHitsTotal="<<fNHitsTotal<<std::endl;
723
63d8b79d 724
63d8b79d 725 fOutput->SetNTracks( *fNTracks );
726 fOutput->SetNTrackClusters( *fNTrackHits );
727 fOutput->SetPointers();
728
fbb9b71b 729 float *hitsXYZ = reinterpret_cast<float*>( fInputEvent ) + 1 + fParam.NRows() * 2 + 1;
730
731 int nStoredHits = 0;
15d2e9cf 732
fbb9b71b 733 for ( int iTr = 0; iTr < *fNTracks; iTr++ ) {
734 AliHLTTPCCATrack &iTrack = fTracks[iTr];
63d8b79d 735
63d8b79d 736 AliHLTTPCCASliceTrack out;
737 out.SetFirstClusterRef( nStoredHits );
fbb9b71b 738 out.SetNClusters( iTrack.NHits() );
63d8b79d 739 out.SetParam( iTrack.Param() );
740
741 fOutput->SetTrack( iTr, out );
742
fbb9b71b 743 int iID = iTrack.FirstHitID();
744 for ( int ith = 0; ith < iTrack.NHits(); ith++ ) {
745 int ic = ( fTrackHits[iID+ith] );
746 int iRow = ID2IRow( ic );
747 int ih = ID2IHit( ic );
748
749 const AliHLTTPCCARow &row = fRows[iRow];
15d2e9cf 750
fbb9b71b 751 //float y0 = row.Grid().YMin();
752 //float z0 = row.Grid().ZMin();
753 //float stepY = row.HstepY();
754 //float stepZ = row.HstepZ();
755 //float x = row.X();
63d8b79d 756
15d2e9cf 757 //const uint4 *tmpint4 = RowData() + row.FullOffset();
758 //const ushort2 *hits = reinterpret_cast<const ushort2*>(tmpint4);
759 //ushort2 hh = hits[ih];
fbb9b71b 760 //float y = y0 + hh.x*stepY;
761 //float z = z0 + hh.y*stepZ;
63d8b79d 762
fbb9b71b 763 int inpIDtot = fHitInputIDs[row.FirstHit()+ih];
764 int inpID = inpIDtot - row.FirstHit();
63d8b79d 765
15d2e9cf 766 float origX = hitsXYZ[inpIDtot*3+0];
767 float origY = hitsXYZ[inpIDtot*3+1];
768 float origZ = hitsXYZ[inpIDtot*3+2];
769
fbb9b71b 770 unsigned int hIDrc = AliHLTTPCCADataCompressor::IRowIClu2IDrc( iRow, inpID );
771 unsigned short hPackedYZ = 0;
63d8b79d 772 UChar_t hPackedAmp = 0;
fbb9b71b 773 float2 hUnpackedYZ = CAMath::MakeFloat2( origY, origZ );
15d2e9cf 774 float hUnpackedX = origX;
775
63d8b79d 776 fOutput->SetClusterIDrc( nStoredHits, hIDrc );
777 fOutput->SetClusterPackedYZ( nStoredHits, hPackedYZ );
fbb9b71b 778 fOutput->SetClusterPackedAmp( nStoredHits, hPackedAmp );
63d8b79d 779 fOutput->SetClusterUnpackedYZ( nStoredHits, hUnpackedYZ );
15d2e9cf 780 fOutput->SetClusterUnpackedX( nStoredHits, hUnpackedX );
63d8b79d 781 nStoredHits++;
782 }
783 }
fbb9b71b 784
785
786 // old stuff
63d8b79d 787
4687b8fc 788 *fNOutTrackHits = 0;
789 *fNOutTracks = 0;
790
4687b8fc 791
fbb9b71b 792 for ( int iTr = 0; iTr < *fNTracks; iTr++ ) {
4687b8fc 793
d54804bf 794 AliHLTTPCCATrack &iTrack = fTracks[iTr];
4687b8fc 795
796 //cout<<"iTr = "<<iTr<<", nHits="<<iTrack.NHits()<<std::endl;
693d2443 797
798 //if( !iTrack.Alive() ) continue;
fbb9b71b 799 if ( iTrack.NHits() < 3 ) continue;
4687b8fc 800 AliHLTTPCCAOutTrack &out = fOutTracks[*fNOutTracks];
693d2443 801 out.SetFirstHitRef( *fNOutTrackHits );
802 out.SetNHits( 0 );
fbb9b71b 803 out.SetOrigTrackID( iTr );
693d2443 804 out.SetStartPoint( iTrack.Param() );
fbb9b71b 805 out.SetEndPoint( iTrack.Param() );
806
807 int iID = iTrack.FirstHitID();
808 int nOutTrackHitsOld = *fNOutTrackHits;
809
810 for ( int ith = 0; ith < iTrack.NHits(); ith++ ) {
811 int ic = ( fTrackHits[iID+ith] );
812 const AliHLTTPCCARow &row = ID2Row( ic );
813 int ih = ID2IHit( ic );
814 fOutTrackHits[*fNOutTrackHits] = fHitInputIDs[row.FirstHit()+ih];
815 ( *fNOutTrackHits )++;
816 //cout<<"write i,row,hit,id="<<ith<<", "<<ID2IRow(ic)<<", "<<ih<<", "<<fHitInputIDs[row.FirstHit()+ih]<<std::endl;
817 if ( *fNOutTrackHits >= 10*fNHitsTotal ) {
818 std::cout << "fNOutTrackHits>fNHitsTotal" << std::endl;
819 //exit(0);
820 return;//SG!!!
eb30eb49 821 }
fbb9b71b 822 out.SetNHits( out.NHits() + 1 );
823 }
824 if ( out.NHits() >= 2 ) {
825 ( *fNOutTracks )++;
826 } else {
827 ( *fNOutTrackHits ) = nOutTrackHitsOld;
d54804bf 828 }
829 }
63d8b79d 830
831
00d07bcd 832 timer.Stop();
fbb9b71b 833 fTimers[5] += timer.CpuTime();
326c2d4b 834}
835
fbb9b71b 836GPUh() void AliHLTTPCCATracker::FitTrackFull( AliHLTTPCCATrack &/**/, float * /**/ ) const
837{
00d07bcd 838 // fit track with material
fbb9b71b 839#ifdef XXX
840 //* Fit the track
00d07bcd 841 FitTrack( iTrack, tt0 );
fbb9b71b 842 if ( iTrack.NHits() <= 3 ) return;
843
00d07bcd 844 AliHLTTPCCATrackParam &t = iTrack.Param();
845 AliHLTTPCCATrackParam t0 = t;
846
847 t.Chi2() = 0;
fbb9b71b 848 t.NDF() = -5;
849 bool first = 1;
850
851 int iID = iTrack.FirstHitID();
852 for ( int ih = 0; ih < iTrack.NHits(); ih++, iID++ ) {
853 int *ic = &( fTrackHits[iID] );
854 int iRow = ID2IRow( *ic );
855 AliHLTTPCCARow &row = fRows[iRow];
856 if ( !t0.TransportToX( row.X() ) ) continue;
857 float dy, dz;
858 AliHLTTPCCAHit &h = ID2Hit( *ic );
859
860 // check for wrong hits
861 if ( 0 ) {
00d07bcd 862 dy = t0.GetY() - h.Y();
863 dz = t0.GetZ() - h.Z();
fbb9b71b 864
00d07bcd 865 //if( dy*dy > 3.5*3.5*(/*t0.GetErr2Y() + */h.ErrY()*h.ErrY() ) ) continue;//SG!!!
fbb9b71b 866 //if( dz*dz > 3.5*3.5*(/*t0.GetErr2Z() + */h.ErrZ()*h.ErrZ() ) ) continue;
00d07bcd 867 }
326c2d4b 868
fbb9b71b 869 if ( !t.TransportToX( row.X() ) ) continue;
dc4788ec 870
00d07bcd 871 //* Update the track
fbb9b71b 872
873 if ( first ) {
874 t.Cov()[ 0] = .5 * .5;
00d07bcd 875 t.Cov()[ 1] = 0;
fbb9b71b 876 t.Cov()[ 2] = .5 * .5;
00d07bcd 877 t.Cov()[ 3] = 0;
878 t.Cov()[ 4] = 0;
fbb9b71b 879 t.Cov()[ 5] = .2 * .2;
00d07bcd 880 t.Cov()[ 6] = 0;
881 t.Cov()[ 7] = 0;
882 t.Cov()[ 8] = 0;
fbb9b71b 883 t.Cov()[ 9] = .2 * .2;
00d07bcd 884 t.Cov()[10] = 0;
885 t.Cov()[11] = 0;
886 t.Cov()[12] = 0;
887 t.Cov()[13] = 0;
fbb9b71b 888 t.Cov()[14] = .2 * .2;
00d07bcd 889 t.Chi2() = 0;
890 t.NDF() = -5;
891 }
fbb9b71b 892 float err2Y, err2Z;
00d07bcd 893 GetErrors2( iRow, t, err2Y, err2Z );
894
fbb9b71b 895 if ( !t.Filter2( h.Y(), h.Z(), err2Y, err2Z ) ) continue;
00d07bcd 896
fbb9b71b 897 first = 0;
898 }
00d07bcd 899 /*
fbb9b71b 900 float cosPhi = iTrack.Param().GetCosPhi();
00d07bcd 901 p0.Param().TransportToX(ID2Row( iTrack.PointID()[0] ).X());
fbb9b71b 902 p2.Param().TransportToX(ID2Row( iTrack.PointID()[1] ).X());
00d07bcd 903 if( p0.Param().GetCosPhi()*cosPhi<0 ){ // change direction
fbb9b71b 904 float *par = p0.Param().Par();
905 float *cov = p0.Param().Cov();
00d07bcd 906 par[2] = -par[2]; // sin phi
907 par[3] = -par[3]; // DzDs
908 par[4] = -par[4]; // kappa
909 cov[3] = -cov[3];
910 cov[4] = -cov[4];
911 cov[6] = -cov[6];
912 cov[7] = -cov[7];
913 cov[10] = -cov[10];
914 cov[11] = -cov[11];
915 p0.Param().CosPhi() = -p0.Param().GetCosPhi();
916 }
917 */
918#endif
919}
dc4788ec 920
fbb9b71b 921GPUh() void AliHLTTPCCATracker::FitTrack( AliHLTTPCCATrack &/*track*/, float */*t0[]*/ ) const
922{
923 //* Fit the track
00d07bcd 924#ifdef XXX
fbb9b71b 925 AliHLTTPCCAEndPoint &p2 = ID2Point( track.PointID()[1] );
926 AliHLTTPCCAHit &c0 = ID2Hit( fTrackHits[p0.TrackHitID()].HitID() );
927 AliHLTTPCCAHit &c1 = ID2Hit( fTrackHits[track.HitID()[1]].HitID() );
928 AliHLTTPCCAHit &c2 = ID2Hit( fTrackHits[p2.TrackHitID()].HitID() );
929 AliHLTTPCCARow &row0 = ID2Row( fTrackHits[p0.TrackHitID()].HitID() );
930 AliHLTTPCCARow &row1 = ID2Row( fTrackHits[track.HitID()[1]].HitID() );
931 AliHLTTPCCARow &row2 = ID2Row( fTrackHits[p2.TrackHitID()].HitID() );
932 float sp0[5] = {row0.X(), c0.Y(), c0.Z(), c0.ErrY(), c0.ErrZ() };
933 float sp1[5] = {row1.X(), c1.Y(), c1.Z(), c1.ErrY(), c1.ErrZ() };
934 float sp2[5] = {row2.X(), c2.Y(), c2.Z(), c2.ErrY(), c2.ErrZ() };
4687b8fc 935 //cout<<"Fit track, points ="<<sp0[0]<<" "<<sp0[1]<<" / "<<sp1[0]<<" "<<sp1[1]<<" / "<<sp2[0]<<" "<<sp2[1]<<std::endl;
fbb9b71b 936 if ( track.NHits() >= 3 ) {
937 p0.Param().ConstructXYZ3( sp0, sp1, sp2, p0.Param().CosPhi(), t0 );
938 p2.Param().ConstructXYZ3( sp2, sp1, sp0, p2.Param().CosPhi(), t0 );
d54804bf 939 //p2.Param() = p0.Param();
940 //p2.Param().TransportToX(row2.X());
941 //p2.Param().Par()[1] = -p2.Param().Par()[1];
942 //p2.Param().Par()[4] = -p2.Param().Par()[4];
943 } else {
944 p0.Param().X() = row0.X();
945 p0.Param().Y() = c0.Y();
946 p0.Param().Z() = c0.Z();
fbb9b71b 947 p0.Param().Err2Y() = c0.ErrY() * c0.ErrY();
948 p0.Param().Err2Z() = c0.ErrZ() * c0.ErrZ();
d54804bf 949 p2.Param().X() = row2.X();
950 p2.Param().Y() = c2.Y();
951 p2.Param().Z() = c2.Z();
fbb9b71b 952 p2.Param().Err2Y() = c2.ErrY() * c2.ErrY();
953 p2.Param().Err2Z() = c2.ErrZ() * c2.ErrZ();
326c2d4b 954 }
00d07bcd 955#endif
956}
957
958
959
fbb9b71b 960GPUd() void AliHLTTPCCATracker::GetErrors2( int iRow, float z, float sinPhi, float cosPhi, float DzDs, float &Err2Y, float &Err2Z ) const
693d2443 961{
962 //
963 // Use calibrated cluster error from OCDB
964 //
965
63d8b79d 966 fParam.GetClusterErrors2( iRow, z, sinPhi, cosPhi, DzDs, Err2Y, Err2Z );
693d2443 967}
968
fbb9b71b 969GPUd() void AliHLTTPCCATracker::GetErrors2( int iRow, const AliHLTTPCCATrackParam &t, float &Err2Y, float &Err2Z ) const
00d07bcd 970{
971 //
972 // Use calibrated cluster error from OCDB
973 //
974
15d2e9cf 975 fParam.GetClusterErrors2( iRow, t.GetZ(), t.SinPhi(), t.GetCosPhi(), t.DzDs(), Err2Y, Err2Z );
00d07bcd 976}
977
4687b8fc 978
fbb9b71b 979#if !defined(HLTCA_GPUCODE)
4687b8fc 980
fbb9b71b 981GPUh() void AliHLTTPCCATracker::WriteEvent( std::ostream &out )
00d07bcd 982{
4687b8fc 983 // write event to the file
fbb9b71b 984 for ( int iRow = 0; iRow < fParam.NRows(); iRow++ ) {
985 out << fRows[iRow].FirstHit() << " " << fRows[iRow].NHits() << std::endl;
986 }
987 out << fNHitsTotal << std::endl;
988
989 float *y = new float [fNHitsTotal];
990 float *z = new float [fNHitsTotal];
991
992 for ( int iRow = 0; iRow < fParam.NRows(); iRow++ ) {
693d2443 993 AliHLTTPCCARow &row = fRows[iRow];
fbb9b71b 994 float y0 = row.Grid().YMin();
995 float z0 = row.Grid().ZMin();
996 float stepY = row.HstepY();
997 float stepZ = row.HstepZ();
693d2443 998 const uint4* tmpint4 = RowData() + row.FullOffset();
fbb9b71b 999 const ushort2 *hits = reinterpret_cast<const ushort2*>( tmpint4 );
1000 for ( int ih = 0; ih < fRows[iRow].NHits(); ih++ ) {
1001 int ihTot = row.FirstHit() + ih;
1002 int id = fHitInputIDs[ihTot];
4687b8fc 1003 ushort2 hh = hits[ih];
fbb9b71b 1004 y[id] = y0 + hh.x * stepY;
1005 z[id] = z0 + hh.y * stepZ;
4687b8fc 1006 }
1007 }
fbb9b71b 1008 for ( int ih = 0; ih < fNHitsTotal; ih++ ) {
1009 out << y[ih] << " " << z[ih] << std::endl;
4687b8fc 1010 }
e1f2d1c3 1011 delete[] y;
1012 delete[] z;
4687b8fc 1013}
00d07bcd 1014
fbb9b71b 1015GPUh() void AliHLTTPCCATracker::ReadEvent( std::istream &in )
4687b8fc 1016{
fbb9b71b 1017 //* Read event from file
1018
1019 int *rowFirstHit = new int[ Param().NRows()];
1020 int *rowNHits = new int [ Param().NRows()];
4687b8fc 1021
fbb9b71b 1022 for ( int iRow = 0; iRow < Param().NRows(); iRow++ ) {
1023 in >> rowFirstHit[iRow] >> rowNHits[iRow];
4687b8fc 1024 }
fbb9b71b 1025 int nHits;
4687b8fc 1026 in >> nHits;
e1f2d1c3 1027
fbb9b71b 1028 float *y = new float[ nHits ];
1029 float *z = new float[ nHits ];
1030 for ( int ih = 0; ih < nHits; ih++ ) {
1031 in >> y[ih] >> z[ih];
4687b8fc 1032 }
15d2e9cf 1033 //ReadEvent( rowFirstHit, rowNHits, y, z, nHits );
fbb9b71b 1034 if ( rowFirstHit ) delete[] rowFirstHit;
1035 if ( rowNHits )delete[] rowNHits;
1036 if ( y )delete[] y;
1037 if ( z )delete[] z;
1038}
4687b8fc 1039
fbb9b71b 1040GPUh() void AliHLTTPCCATracker::WriteTracks( std::ostream &out )
4687b8fc 1041{
fbb9b71b 1042 //* Write tracks to file
1043
1044 out << fTimers[0] << std::endl;
1045 out << *fNOutTrackHits << std::endl;
1046 for ( int ih = 0; ih < *fNOutTrackHits; ih++ ) {
1047 out << fOutTrackHits[ih] << " ";
4687b8fc 1048 }
fbb9b71b 1049 out << std::endl;
1050
1051 out << *fNOutTracks << std::endl;
1052
1053 for ( int itr = 0; itr < *fNOutTracks; itr++ ) {
1054 AliHLTTPCCAOutTrack &t = fOutTracks[itr];
1055 AliHLTTPCCATrackParam p1 = t.StartPoint();
1056 AliHLTTPCCATrackParam p2 = t.EndPoint();
1057 out << t.NHits() << " ";
1058 out << t.FirstHitRef() << " ";
1059 out << t.OrigTrackID() << " ";
1060 out << std::endl;
1061 out << p1.X() << " ";
1062 out << p1.SignCosPhi() << " ";
1063 out << p1.Chi2() << " ";
1064 out << p1.NDF() << std::endl;
1065 for ( int i = 0; i < 5; i++ ) out << p1.Par()[i] << " ";
1066 out << std::endl;
1067 for ( int i = 0; i < 15; i++ ) out << p1.Cov()[i] << " ";
1068 out << std::endl;
1069 out << p2.X() << " ";
1070 out << p2.SignCosPhi() << " ";
1071 out << p2.Chi2() << " ";
1072 out << p2.NDF() << std::endl;
1073 for ( int i = 0; i < 5; i++ ) out << p2.Par()[i] << " ";
1074 out << std::endl;
1075 for ( int i = 0; i < 15; i++ ) out << p2.Cov()[i] << " ";
1076 out << std::endl;
4687b8fc 1077 }
1078}
1079
1080GPUh() void AliHLTTPCCATracker::ReadTracks( std::istream &in )
1081{
fbb9b71b 1082 //* Read tracks from file
1083 in >> fTimers[0];
1084 in >> *fNOutTrackHits;
4687b8fc 1085
fbb9b71b 1086 for ( int ih = 0; ih < *fNOutTrackHits; ih++ ) {
1087 in >> fOutTrackHits[ih];
4687b8fc 1088 }
fbb9b71b 1089 in >> *fNOutTracks;
4687b8fc 1090
fbb9b71b 1091 for ( int itr = 0; itr < *fNOutTracks; itr++ ) {
1092 AliHLTTPCCAOutTrack &t = fOutTracks[itr];
693d2443 1093 AliHLTTPCCATrackParam p1, p2;
fbb9b71b 1094 int i;
1095 float f;
1096 in >> i; t.SetNHits( i );
1097 in >> i; t.SetFirstHitRef( i );
1098 in >> i; t.SetOrigTrackID( i );
1099 in >> f; p1.SetX( f );
1100 in >> f; p1.SetSignCosPhi( f );
1101 in >> f; p1.SetChi2( f );
1102 in >> i; p1.SetNDF( i );
1103 for ( int j = 0; j < 5; j++ ) { in >> f; p1.SetPar( j, f ); }
1104 for ( int j = 0; j < 15; j++ ) { in >> f; p1.SetCov( j, f ); }
1105 in >> f; p2.SetX( f );
1106 in >> f; p2.SetSignCosPhi( f );
1107 in >> f; p2.SetChi2( f );
1108 in >> i; p2.SetNDF( i );
1109 for ( int j = 0; j < 5; j++ ) { in >> f; p2.SetPar( j, f ); }
1110 for ( int j = 0; j < 15; j++ ) { in >> f; p2.SetCov( j, f ); }
693d2443 1111 t.SetStartPoint( p1 );
1112 t.SetEndPoint( p2 );
4687b8fc 1113 }
326c2d4b 1114}
4687b8fc 1115#endif