]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/TPCLib/tracking-ca/AliHLTTPCCATracker.cxx
bug fix: reconstruction crash when the output buffer size exceed
[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 "AliHLTTPCCARow.h"
23#include "AliHLTTPCCATrack.h"
4687b8fc 24#include "AliHLTTPCCATracklet.h"
00d07bcd 25#include "AliHLTTPCCAMath.h"
4acc2401 26#include "MemoryAssignmentHelpers.h"
326c2d4b 27
dc4788ec 28#include "TStopwatch.h"
00d07bcd 29#include "AliHLTTPCCAHitArea.h"
30#include "AliHLTTPCCANeighboursFinder.h"
31#include "AliHLTTPCCANeighboursCleaner.h"
32#include "AliHLTTPCCAStartHitsFinder.h"
33#include "AliHLTTPCCATrackletConstructor.h"
34#include "AliHLTTPCCATrackletSelector.h"
35#include "AliHLTTPCCAProcess.h"
63d8b79d 36#include "AliHLTTPCCASliceTrack.h"
37#include "AliHLTTPCCASliceOutput.h"
4acc2401 38#include "AliHLTTPCCAClusterData.h"
00d07bcd 39
40#include "AliHLTTPCCATrackParam.h"
00d07bcd 41
b22af1bf 42#include "AliHLTTPCCAGPUConfig.h"
b22af1bf 43
00d07bcd 44#if !defined(HLTCA_GPUCODE)
4687b8fc 45#include <iostream>
a59a784e 46#include <iomanip>
b22af1bf 47#include <string.h>
00d07bcd 48#endif
d54804bf 49
6de2bc40 50//#define DRAW1
326c2d4b 51
6de2bc40 52#ifdef DRAW1
fbb9b71b 53#include "AliHLTTPCCADisplay.h"
31649d4b 54#endif //DRAW1
326c2d4b 55
ce565086 56#ifdef HLTCA_INTERNAL_PERFORMANCE
a59a784e 57//#include "AliHLTTPCCAPerformance.h"
ce565086 58#endif
59
b22af1bf 60#ifdef HLTCA_STANDALONE
61#include "AliHLTTPCCAStandaloneFramework.h"
62#endif
ce565086 63
fbb9b71b 64ClassImp( AliHLTTPCCATracker )
326c2d4b 65
b22af1bf 66
67#if !defined(HLTCA_GPUCODE)
68
69AliHLTTPCCATracker::~AliHLTTPCCATracker()
326c2d4b 70{
71 // destructor
7be9b0d7 72 if (!fIsGPUTracker)
73 {
b22af1bf 74 if (fCommonMem) delete fCommonMem;
75 if (fHitMemory) delete[] fHitMemory;
76 if (fTrackletMemory) delete[] fTrackletMemory;
77 if (fTrackMemory) delete[] fTrackMemory;
78 fCommonMem = NULL;
79 fHitMemory = fTrackMemory = NULL;
7be9b0d7 80 }
326c2d4b 81}
00d07bcd 82
326c2d4b 83// ----------------------------------------------------------------------------------
7be9b0d7 84void AliHLTTPCCATracker::Initialize( const AliHLTTPCCAParam &param )
326c2d4b 85{
75192f26 86 // initialisation
00d07bcd 87 fParam = param;
4687b8fc 88 fParam.Update();
4acc2401 89 fData.InitializeRows( fParam );
90
326c2d4b 91 StartEvent();
92}
93
7be9b0d7 94void AliHLTTPCCATracker::StartEvent()
326c2d4b 95{
fbb9b71b 96 // start new event and fresh the memory
d54804bf 97
4acc2401 98 SetupCommonMemory();
4acc2401 99}
100
7be9b0d7 101void AliHLTTPCCATracker::SetGPUTracker()
102{
8566066c 103 //Make this a GPU Tracker
7be9b0d7 104 fIsGPUTracker = true;
b22af1bf 105 fData.SetGpuSliceData();
7be9b0d7 106}
107
8566066c 108char* AliHLTTPCCATracker::SetGPUTrackerCommonMemory(char* const pGPUMemory)
7be9b0d7 109{
8566066c 110 //Set up common Memory Pointer for GPU Tracker
a59a784e 111 fCommonMem = (commonMemoryStruct*) pGPUMemory;
112 return(pGPUMemory + sizeof(commonMemoryStruct));
7be9b0d7 113}
114
115
b22af1bf 116char* AliHLTTPCCATracker::SetGPUTrackerHitsMemory(char* pGPUMemory, int MaxNHits)
7be9b0d7 117{
8566066c 118 //Set up Hits Memory Pointers for GPU Tracker
7be9b0d7 119 fHitMemory = (char*) pGPUMemory;
120 SetPointersHits(MaxNHits);
b22af1bf 121 pGPUMemory += fHitMemorySize;
122 AssignMemory(fTrackletTmpStartHits, pGPUMemory, NHitsTotal());
123 AssignMemory(fRowStartHitCountOffset, pGPUMemory, Param().NRows());
124
125 return(pGPUMemory);
7be9b0d7 126}
127
b22af1bf 128char* AliHLTTPCCATracker::SetGPUTrackerTrackletsMemory(char* pGPUMemory, int MaxNTracks)
129{
8566066c 130 //Set up Tracklet Memory Pointers for GPU Tracker
b22af1bf 131 fTrackletMemory = (char*) pGPUMemory;
132 SetPointersTracklets(MaxNTracks);
133 pGPUMemory += fTrackletMemorySize;
134 AssignMemory(fGPUTrackletTemp, pGPUMemory, MaxNTracks);
135 AssignMemory(fRowBlockTracklets, pGPUMemory, MaxNTracks * 2 * (Param().NRows() / HLTCA_GPU_SCHED_ROW_STEP + 1));
136 AssignMemory(fRowBlockPos, pGPUMemory, 2 * (Param().NRows() / HLTCA_GPU_SCHED_ROW_STEP + 1));
137 AssignMemory(fBlockStartingTracklet, pGPUMemory, HLTCA_GPU_BLOCK_COUNT);
138
139 return(pGPUMemory);
140}
7be9b0d7 141
142char* AliHLTTPCCATracker::SetGPUTrackerTracksMemory(char* pGPUMemory, int MaxNTracks, int MaxNHits )
143{
8566066c 144 //Set up Tracks Memory Pointer for GPU Tracker
7be9b0d7 145 fTrackMemory = (char*) pGPUMemory;
146 SetPointersTracks(MaxNTracks, MaxNHits);
b22af1bf 147 pGPUMemory += fTrackMemorySize;
148
149 return(pGPUMemory);
7be9b0d7 150}
151
b22af1bf 152void AliHLTTPCCATracker::DumpSliceData(std::ostream &out)
7be9b0d7 153{
8566066c 154 //Dump Slice Input Data to File
155 out << "Slice Data:" << std::endl;
7be9b0d7 156 for (int i = 0;i < Param().NRows();i++)
157 {
8566066c 158 out << "Row: " << i << std::endl;
7be9b0d7 159 for (int j = 0;j < Row(i).NHits();j++)
160 {
b22af1bf 161 if (j && j % 16 == 0) out << std::endl;
162 out << j << '-' << Data().HitDataY(Row(i), j) << '-' << Data().HitDataZ(Row(i), j) << ", ";
7be9b0d7 163 }
8566066c 164 out << std::endl;
7be9b0d7 165 }
166}
167
b22af1bf 168void AliHLTTPCCATracker::DumpLinks(std::ostream &out)
7be9b0d7 169{
8566066c 170 //Dump Links (after Neighbours Finder / Cleaner) to file
171 out << "Hit Links:" << std::endl;
b22af1bf 172 for (int i = 0;i < Param().NRows();i++)
7be9b0d7 173 {
8566066c 174 out << "Row: " << i << std::endl;
b22af1bf 175 for (int j = 0;j < Row(i).NHits();j++)
7be9b0d7 176 {
8566066c 177 if (j && j % 32 == 0) out << std::endl;
b22af1bf 178 out << HitLinkUpData(Row(i), j) << "/" << HitLinkDownData(Row(i), j) << ", ";
7be9b0d7 179 }
8566066c 180 out << std::endl;
7be9b0d7 181 }
7be9b0d7 182}
183
b22af1bf 184void AliHLTTPCCATracker::DumpHitWeights(std::ostream &out)
7be9b0d7 185{
8566066c 186 //dump hit weights to file
187 out << "Hit Weights:" << std::endl;
b22af1bf 188 for (int i = 0;i < Param().NRows();i++)
189 {
8566066c 190 out << "Row: " << i << ":" << std::endl;
b22af1bf 191 for (int j = 0;j < Row(i).NHits();j++)
7be9b0d7 192 {
8566066c 193 if (j && j % 32 == 0) out << std::endl;
b22af1bf 194 out << HitWeight(Row(i), j) << ", ";
7be9b0d7 195 }
8566066c 196 out << std::endl;
b22af1bf 197 }
198}
199
a59a784e 200int AliHLTTPCCATracker::StarthitSortComparison(const void*a, const void* b)
b22af1bf 201{
8566066c 202 //qsort helper function to sort start hits
b22af1bf 203 AliHLTTPCCAHitId* aa = (AliHLTTPCCAHitId*) a;
204 AliHLTTPCCAHitId* bb = (AliHLTTPCCAHitId*) b;
205
206 if (aa->RowIndex() != bb->RowIndex()) return(aa->RowIndex() - bb->RowIndex());
207 return(aa->HitIndex() - bb->HitIndex());
7be9b0d7 208}
209
b22af1bf 210void AliHLTTPCCATracker::DumpStartHits(std::ostream &out)
7be9b0d7 211{
8566066c 212 //sort start hits and dump to file
213 out << "Start Hits: (" << *NTracklets() << ")" << std::endl;
b22af1bf 214#ifdef HLTCA_GPU_SORT_DUMPDATA
a59a784e 215 qsort(TrackletStartHits(), *NTracklets(), sizeof(AliHLTTPCCAHitId), StarthitSortComparison);
b22af1bf 216#endif
217 for (int i = 0;i < *NTracklets();i++)
7be9b0d7 218 {
8566066c 219 out << TrackletStartHit(i).RowIndex() << "-" << TrackletStartHit(i).HitIndex() << std::endl;
7be9b0d7 220 }
8566066c 221 out << std::endl;
b22af1bf 222}
223
224void AliHLTTPCCATracker::DumpTrackHits(std::ostream &out)
225{
8566066c 226 //dump tracks to file
227 out << "Tracks: (" << *NTracks() << ")" << std::endl;
b22af1bf 228#ifdef HLTCA_GPU_SORT_DUMPDATA
229 for (int k = 0;k < Param().NRows();k++)
7be9b0d7 230 {
b22af1bf 231 for (int l = 0;l < Row(k).NHits();l++)
7be9b0d7 232 {
b22af1bf 233#endif
234 for (int j = 0;j < *NTracks();j++)
235 {
236 if (Tracks()[j].NHits() == 0 || !Tracks()[j].Alive()) continue;
237#ifdef HLTCA_GPU_SORT_DUMPDATA
238 if (TrackHits()[Tracks()[j].FirstHitID()].RowIndex() == k && TrackHits()[Tracks()[j].FirstHitID()].HitIndex() == l)
239 {
240#endif
241 for (int i = 0;i < Tracks()[j].NHits();i++)
242 {
243 out << TrackHits()[Tracks()[j].FirstHitID() + i].RowIndex() << "-" << TrackHits()[Tracks()[j].FirstHitID() + i].HitIndex() << ", ";
244 }
8566066c 245 out << "(Track: " << j << ")" << std::endl;
b22af1bf 246#ifdef HLTCA_GPU_SORT_DUMPDATA
247 }
248 }
249#endif
250 }
251#ifdef HLTCA_GPU_SORT_DUMPDATA
7be9b0d7 252 }
b22af1bf 253#endif
7be9b0d7 254}
255
256void AliHLTTPCCATracker::DumpTrackletHits(std::ostream &out)
257{
8566066c 258 //dump tracklets to file
259 out << "Tracklets: (" << *NTracklets() << ")" << std::endl;
b22af1bf 260#ifdef HLTCA_GPU_SORT_DUMPDATA
261 AliHLTTPCCAHitId* tmpIds = new AliHLTTPCCAHitId[*NTracklets()];
262 AliHLTTPCCATracklet* tmpTracklets = new AliHLTTPCCATracklet[*NTracklets()];
263 memcpy(tmpIds, TrackletStartHits(), *NTracklets() * sizeof(AliHLTTPCCAHitId));
264 memcpy(tmpTracklets, Tracklets(), *NTracklets() * sizeof(AliHLTTPCCATracklet));
265#ifdef EXTERN_ROW_HITS
266 int* tmpHits = new int[*NTracklets() * Param().NRows()];
267 memcpy(tmpHits, TrackletRowHits(), *NTracklets() * Param().NRows() * sizeof(int));
268#endif
a59a784e 269 qsort(TrackletStartHits(), *NTracklets(), sizeof(AliHLTTPCCAHitId), StarthitSortComparison);
b22af1bf 270 for (int i = 0;i < *NTracklets();i++)
7be9b0d7 271 {
272 for (int j = 0;j < *NTracklets();j++)
273 {
b22af1bf 274 if (tmpIds[i].RowIndex() == TrackletStartHit(j).RowIndex() && tmpIds[i].HitIndex() == TrackletStartHit(j).HitIndex())
7be9b0d7 275 {
b22af1bf 276 memcpy(&Tracklets()[j], &tmpTracklets[i], sizeof(AliHLTTPCCATracklet));
277#ifdef EXTERN_ROW_HITS
278 if (tmpTracklets[i].NHits())
7be9b0d7 279 {
b22af1bf 280 for (int k = tmpTracklets[i].FirstRow();k <= tmpTracklets[i].LastRow();k++)
281 {
282 fTrackletRowHits[k * *NTracklets() + j] = tmpHits[k * *NTracklets() + i];
283 }
7be9b0d7 284 }
b22af1bf 285#endif
286 break;
287 }
288 }
289 }
290 delete[] tmpIds;
291 delete[] tmpTracklets;
292#ifdef EXTERN_ROW_HITS
293 delete[] tmpHits;
294#endif
295#endif
296 for (int j = 0;j < *NTracklets();j++)
297 {
8566066c 298 out << "Tracklet " << j << " (Hits: " << std::setw(3) << Tracklets()[j].NHits() << ", Start: " << std::setw(3) << TrackletStartHit(j).RowIndex() << "-" << std::setw(3) << TrackletStartHit(j).HitIndex() << ") ";
b22af1bf 299 if (Tracklets()[j].NHits() == 0);
300 else if (Tracklets()[j].LastRow() > Tracklets()[j].FirstRow() && (Tracklets()[j].FirstRow() >= Param().NRows() || Tracklets()[j].LastRow() >= Param().NRows()))
301 {
302#ifdef HLTCA_STANDALONE
303 printf("\nError: First %d Last %d Num %d", Tracklets()[j].FirstRow(), Tracklets()[j].LastRow(), Tracklets()[j].NHits());
304#endif
305 }
306 else if (Tracklets()[j].NHits() && Tracklets()[j].LastRow() > Tracklets()[j].FirstRow())
307 {
308 for (int i = Tracklets()[j].FirstRow();i <= Tracklets()[j].LastRow();i++)
309 {
310 //if (Tracklets()[j].RowHit(i) != -1)
311#ifdef EXTERN_ROW_HITS
312 out << i << "-" << fTrackletRowHits[i * fCommonMem->fNTracklets + j] << ", ";
313#else
314 out << i << "-" << Tracklets()[j].RowHit(i) << ", ";
315#endif
7be9b0d7 316 }
317 }
8566066c 318 out << std::endl;
7be9b0d7 319 }
320}
321
322
b22af1bf 323void AliHLTTPCCATracker::SetupCommonMemory()
4acc2401 324{
6de2bc40 325 // set up common memory
326
7be9b0d7 327 if (!fIsGPUTracker)
328 {
b22af1bf 329 if ( !fCommonMem ) {
7be9b0d7 330 // the 1600 extra bytes are not used unless fCommonMemorySize increases with a later event
b22af1bf 331 //fCommonMemory = reinterpret_cast<char*> ( new uint4 [ fCommonMemorySize/sizeof( uint4 ) + 100] );
332 fCommonMem = new commonMemoryStruct;
7be9b0d7 333 }
fbb9b71b 334
b22af1bf 335 if (fHitMemory) delete[] fHitMemory;
336 if (fTrackletMemory) delete[] fTrackletMemory;
337 if (fTrackMemory) delete[] fTrackMemory;
7be9b0d7 338 }
c259f7e4 339
b22af1bf 340 fHitMemory = fTrackletMemory = fTrackMemory = 0;
341
4acc2401 342 fData.Clear();
b22af1bf 343 fCommonMem->fNTracklets = 0;
344 fCommonMem->fNTracks = 0 ;
345 fCommonMem->fNTrackHits = 0;
326c2d4b 346}
347
7be9b0d7 348void AliHLTTPCCATracker::ReadEvent( AliHLTTPCCAClusterData *clusterData )
349{
350 // read event
351
352 fClusterData = clusterData;
353
354 StartEvent();
355
356 //* Convert input hits, create grids, etc.
357 fData.InitFromClusterData( *clusterData );
7be9b0d7 358 {
b22af1bf 359 if (!fIsGPUTracker)
360 {
361 SetPointersHits( fData.NumberOfHits() ); // to calculate the size
362 fHitMemory = reinterpret_cast<char*> ( new uint4 [ fHitMemorySize/sizeof( uint4 ) + 100] );
363 }
7be9b0d7 364 SetPointersHits( fData.NumberOfHits() ); // set pointers for hits
7be9b0d7 365 }
366}
367
fbb9b71b 368GPUhd() void AliHLTTPCCATracker::SetPointersHits( int MaxNHits )
c259f7e4 369{
370 // set all pointers to the event memory
371
4acc2401 372 char *mem = fHitMemory;
c259f7e4 373
374 // extra arrays for tpc clusters
c259f7e4 375
b22af1bf 376#ifdef HLTCA_GPU_SORT_STARTHITS_2
377 AssignMemory( fTrackletStartHits, mem, MaxNHits + 32);
378#else
379 AssignMemory( fTrackletStartHits, mem, MaxNHits);
380#endif
381
382 // calculate the size
c259f7e4 383
b22af1bf 384 fHitMemorySize = mem - fHitMemory;
385}
c259f7e4 386
b22af1bf 387GPUhd() void AliHLTTPCCATracker::SetPointersTracklets( int MaxNTracklets )
388{
389 // set all pointers to the tracklets memory
390 char *mem = fTrackletMemory;
fbb9b71b 391
b22af1bf 392 // memory for tracklets
c259f7e4 393
b22af1bf 394 AssignMemory( fTracklets, mem, MaxNTracklets );
395#ifdef EXTERN_ROW_HITS
396 AssignMemory( fTrackletRowHits, mem, MaxNTracklets * Param().NRows());
397#endif
c259f7e4 398
b22af1bf 399 fTrackletMemorySize = mem - fTrackletMemory;
c259f7e4 400}
401
402
fbb9b71b 403GPUhd() void AliHLTTPCCATracker::SetPointersTracks( int MaxNTracks, int MaxNHits )
c259f7e4 404{
405 // set all pointers to the tracks memory
4acc2401 406 char *mem = fTrackMemory;
fbb9b71b 407
c259f7e4 408 // memory for selected tracks
fbb9b71b 409
4acc2401 410 AssignMemory( fTracks, mem, MaxNTracks );
b22af1bf 411 AssignMemory( fTrackHits, mem, 2 * MaxNHits );
c259f7e4 412
413 // calculate the size
414
4acc2401 415 fTrackMemorySize = mem - fTrackMemory;
c259f7e4 416}
417
a59a784e 418GPUh() int AliHLTTPCCATracker::CheckEmptySlice() const
7be9b0d7 419{
8566066c 420 //Check if the Slice is empty, if so set the output apropriate and tell the reconstuct procesdure to terminate
7be9b0d7 421 if ( NHitsTotal() < 1 ) {
422 {
a59a784e 423 AliHLTTPCCASliceOutput::Allocate(*fOutput, 0, 0, fOutputControl);
424 AliHLTTPCCASliceOutput* useOutput = *fOutput;
90da1ad5 425 if (useOutput == NULL) return(1);
98512261 426 useOutput->SetNTracks( 0 );
427 useOutput->SetNTrackClusters( 0 );
a59a784e 428 useOutput->SetNOutTracks(0);
429 useOutput->SetNOutTrackHits(0);
7be9b0d7 430 }
326c2d4b 431
7be9b0d7 432 return 1;
433 }
434 return 0;
435}
436
437void AliHLTTPCCATracker::RunNeighboursFinder()
326c2d4b 438{
8566066c 439 //Run the CPU Neighbours Finder
7be9b0d7 440 AliHLTTPCCAProcess<AliHLTTPCCANeighboursFinder>( Param().NRows(), 1, *this );
441}
6de2bc40 442
7be9b0d7 443void AliHLTTPCCATracker::RunNeighboursCleaner()
444{
8566066c 445 //Run the CPU Neighbours Cleaner
7be9b0d7 446 AliHLTTPCCAProcess<AliHLTTPCCANeighboursCleaner>( Param().NRows() - 2, 1, *this );
447}
d54804bf 448
7be9b0d7 449void AliHLTTPCCATracker::RunStartHitsFinder()
450{
8566066c 451 //Run the CPU Start Hits Finder
7be9b0d7 452 AliHLTTPCCAProcess<AliHLTTPCCAStartHitsFinder>( Param().NRows() - 4, 1, *this );
453}
fbb9b71b 454
7be9b0d7 455void AliHLTTPCCATracker::RunTrackletConstructor()
456{
8566066c 457 //Run CPU Tracklet Constructor
a59a784e 458 AliHLTTPCCATrackletConstructor::AliHLTTPCCATrackletConstructorNewCPU(*this);
7be9b0d7 459}
fbb9b71b 460
7be9b0d7 461void AliHLTTPCCATracker::RunTrackletSelector()
462{
8566066c 463 //Run CPU Tracklet Selector
b22af1bf 464 AliHLTTPCCAProcess<AliHLTTPCCATrackletSelector>( 1, fCommonMem->fNTracklets, *this );
d54804bf 465}
466
b22af1bf 467#ifdef HLTCA_STANDALONE
468void AliHLTTPCCATracker::StandalonePerfTime(int i)
469{
8566066c 470 //Query Performance Timer for Standalone Version of Tracker
b22af1bf 471 if (fGPUDebugLevel >= 1)
472 {
a59a784e 473 AliHLTTPCCAStandaloneFramework::StandaloneQueryTime(&fPerfTimers[i]);
b22af1bf 474 }
475}
476#else
477void AliHLTTPCCATracker::StandalonePerfTime(int /*i*/) {}
478#endif
479
00d07bcd 480GPUh() void AliHLTTPCCATracker::Reconstruct()
481{
482 //* reconstruction of event
4acc2401 483 //std::cout<<"Reconstruct slice "<<fParam.ISlice()<<", nHits="<<NHitsTotal()<<std::endl;
326c2d4b 484
00d07bcd 485 fTimers[0] = 0; // find neighbours
486 fTimers[1] = 0; // construct tracklets
487 fTimers[2] = 0; // fit tracklets
488 fTimers[3] = 0; // prolongation of tracklets
489 fTimers[4] = 0; // selection
490 fTimers[5] = 0; // write output
491 fTimers[6] = 0;
492 fTimers[7] = 0;
fbb9b71b 493
693d2443 494 //if( fParam.ISlice()<1 ) return; //SG!!!
00d07bcd 495
00d07bcd 496 TStopwatch timer0;
b22af1bf 497
498 StandalonePerfTime(0);
499
7be9b0d7 500 if (CheckEmptySlice()) return;
4687b8fc 501
6de2bc40 502#ifdef DRAW1
f0fb467d 503 //if( fParam.ISlice()==2 || fParam.ISlice()==3)
504 {
fbb9b71b 505 AliHLTTPCCADisplay::Instance().ClearView();
693d2443 506 AliHLTTPCCADisplay::Instance().SetSliceView();
507 AliHLTTPCCADisplay::Instance().SetCurrentSlice( this );
fbb9b71b 508 AliHLTTPCCADisplay::Instance().DrawSlice( this, 1 );
4acc2401 509 if ( NHitsTotal() > 0 ) {
fbb9b71b 510 AliHLTTPCCADisplay::Instance().DrawSliceHits( kRed, .5 );
693d2443 511 AliHLTTPCCADisplay::Instance().Ask();
512 }
f0fb467d 513 }
31649d4b 514#endif //DRAW1
693d2443 515
b22af1bf 516 fCommonMem->fNTracklets = fCommonMem->fNTracks = fCommonMem->fNTrackHits = 0;
4687b8fc 517
fbb9b71b 518#if !defined(HLTCA_GPUCODE)
519
31649d4b 520 if (fGPUDebugLevel >= 6)
7be9b0d7 521 {
31649d4b 522 *fGPUDebugOut << std::endl << std::endl << "Slice: " << Param().ISlice() << std::endl;
523 *fGPUDebugOut << "Slice Data:" << std::endl;
b22af1bf 524 DumpSliceData(*fGPUDebugOut);
31649d4b 525 }
b22af1bf 526
527 StandalonePerfTime(1);
693d2443 528
7be9b0d7 529 RunNeighboursFinder();
530
b22af1bf 531 StandalonePerfTime(2);
532
533 if (fGPUDebugLevel >= 6) DumpLinks(*fGPUDebugOut);
534
fbb9b71b 535#ifdef HLTCA_INTERNAL_PERFORMANCE
536 //if( Param().ISlice()<=2 )
ce565086 537 //AliHLTTPCCAPerformance::Instance().LinkPerformance( Param().ISlice() );
538#endif
539
540
f0fb467d 541#ifdef DRAW1
4acc2401 542 if ( NHitsTotal() > 0 ) {
fbb9b71b 543 AliHLTTPCCADisplay::Instance().DrawSliceLinks( -1, -1, 1 );
ce565086 544 AliHLTTPCCADisplay::Instance().Ask();
545 }
31649d4b 546#endif //DRAW1
ce565086 547
7be9b0d7 548 RunNeighboursCleaner();
ce565086 549
b22af1bf 550 StandalonePerfTime(3);
551
552 if (fGPUDebugLevel >= 6) DumpLinks(*fGPUDebugOut);
fbb9b71b 553
7be9b0d7 554 RunStartHitsFinder();
c259f7e4 555
b22af1bf 556 StandalonePerfTime(4);
557 StandalonePerfTime(5);
d54804bf 558
b22af1bf 559 if (fGPUDebugLevel >= 6) DumpStartHits(*fGPUDebugOut);
560
7be9b0d7 561 fData.ClearHitWeights();
d54804bf 562
b22af1bf 563 SetPointersTracklets( fCommonMem->fNTracklets * 2 ); // to calculate the size
564 fTrackletMemory = reinterpret_cast<char*> ( new uint4 [ fTrackletMemorySize/sizeof( uint4 ) + 100] );
565 SetPointersTracklets( fCommonMem->fNTracklets * 2 ); // set pointers for hits
566
567 SetPointersTracks( fCommonMem->fNTracklets * 2, NHitsTotal() ); // to calculate the size
7be9b0d7 568 fTrackMemory = reinterpret_cast<char*> ( new uint4 [ fTrackMemorySize/sizeof( uint4 ) + 100] );
b22af1bf 569 SetPointersTracks( fCommonMem->fNTracklets * 2, NHitsTotal() ); // set pointers for hits
570
571 StandalonePerfTime(6);
572 StandalonePerfTime(7);
d54804bf 573
7be9b0d7 574 RunTrackletConstructor();
ce565086 575
b22af1bf 576 StandalonePerfTime(8);
577
578 if (fGPUDebugLevel >= 6) DumpTrackletHits(*fGPUDebugOut);
579 if (fGPUDebugLevel >= 6) DumpHitWeights(*fGPUDebugOut);
d54804bf 580
7be9b0d7 581 //std::cout<<"Slice "<<Param().ISlice()<<": NHits="<<NHitsTotal()<<", NTracklets="<<*NTracklets()<<std::endl;
d54804bf 582
7be9b0d7 583 RunTrackletSelector();
d54804bf 584
b22af1bf 585 StandalonePerfTime(9);
586
7be9b0d7 587 //std::cout<<"Slice "<<Param().ISlice()<<": N start hits/tracklets/tracks = "<<nStartHits<<" "<<nStartHits<<" "<<*fNTracks<<std::endl;
d54804bf 588
b22af1bf 589 if (fGPUDebugLevel >= 6) DumpTrackHits(*fGPUDebugOut);
c259f7e4 590
591 //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;
592
fbb9b71b 593 WriteOutput();
594
b22af1bf 595 StandalonePerfTime(10);
596
693d2443 597#endif
598
f0fb467d 599#ifdef DRAW1
fbb9b71b 600 {
601 AliHLTTPCCADisplay &disp = AliHLTTPCCADisplay::Instance();
602 AliHLTTPCCATracker &slice = *this;
b22af1bf 603 std::cout << "N out tracks = " << slice.NOutTracks() << std::endl;
f0fb467d 604 AliHLTTPCCADisplay::Instance().SetSliceView();
fbb9b71b 605 AliHLTTPCCADisplay::Instance().SetCurrentSlice( this );
606 AliHLTTPCCADisplay::Instance().DrawSlice( this, 1 );
f0fb467d 607 disp.DrawSliceHits( kRed, .5 );
608 disp.Ask();
b22af1bf 609 for ( int itr = 0; itr < slice.NOutTracks(); itr++ ) {
fbb9b71b 610 std::cout << "track N " << itr << ", nhits=" << slice.OutTracks()[itr].NHits() << std::endl;
f0fb467d 611 disp.DrawSliceOutTrack( itr, kBlue );
fbb9b71b 612 //disp.Ask();
613 //int id = slice.OutTracks()[itr].OrigTrackID();
614 //AliHLTTPCCATrack &tr = Tracks()[id];
615 //for( int ih=0; ih<tr.NHits(); ih++ ){
616 //int ic = (fTrackHits[tr.FirstHitID()+ih]);
617 //std::cout<<ih<<" "<<ID2IRow(ic)<<" "<<ID2IHit(ic)<<std::endl;
618 //}
619 //disp.DrawSliceTrack( id, kBlue );
620 //disp.Ask();
621 }
622 disp.Ask();
623 }
31649d4b 624#endif //DRAW1
dc4788ec 625
fbb9b71b 626 timer0.Stop();
627 fTimers[0] = timer0.CpuTime() / 100.;
326c2d4b 628
fbb9b71b 629}
326c2d4b 630
00d07bcd 631GPUh() void AliHLTTPCCATracker::WriteOutput()
632{
d54804bf 633 // write output
eb30eb49 634
00d07bcd 635 TStopwatch timer;
63d8b79d 636
4acc2401 637 //cout<<"output: nTracks = "<<*fNTracks<<", nHitsTotal="<<NHitsTotal()<<std::endl;
63d8b79d 638
d4594e7d 639 if (fOutputControl == NULL) fOutputControl = new AliHLTTPCCASliceOutput::outputControlStruct;
640 AliHLTTPCCASliceOutput::Allocate(*fOutput, fCommonMem->fNTracks, fCommonMem->fNTrackHits, fOutputControl);
98512261 641 AliHLTTPCCASliceOutput* useOutput = *fOutput;
d4594e7d 642 if (useOutput == NULL) return;
98512261 643
d4594e7d 644 if (fOutputControl->fDefaultOutput)
645 {
646 useOutput->SetNTracks( fCommonMem->fNTracks );
647 useOutput->SetNTrackClusters( fCommonMem->fNTrackHits );
648
649 int nStoredHits = 0;
650
651 for ( int iTr = 0; iTr < fCommonMem->fNTracks; iTr++ ) {
652 AliHLTTPCCATrack &iTrack = fTracks[iTr];
653
654 AliHLTTPCCASliceTrack out;
655 out.SetFirstClusterRef( nStoredHits );
656 out.SetNClusters( iTrack.NHits() );
657 out.SetParam( iTrack.Param() );
658
659 useOutput->SetTrack( iTr, out );
660
661 int iID = iTrack.FirstHitID();
662 for ( int ith = 0; ith < iTrack.NHits(); ith++ ) {
663 const AliHLTTPCCAHitId &ic = fTrackHits[iID + ith];
664 int iRow = ic.RowIndex();
665 int ih = ic.HitIndex();
666
667 const AliHLTTPCCARow &row = fData.Row( iRow );
668
669 //float y0 = row.Grid().YMin();
670 //float z0 = row.Grid().ZMin();
671 //float stepY = row.HstepY();
672 //float stepZ = row.HstepZ();
673 //float x = row.X();
674
675 //const uint4 *tmpint4 = RowData() + row.FullOffset();
676 //const ushort2 *hits = reinterpret_cast<const ushort2*>(tmpint4);
677 //ushort2 hh = hits[ih];
678 //float y = y0 + hh.x*stepY;
679 //float z = z0 + hh.y*stepZ;
680
681 int clusterIndex = fData.ClusterDataIndex( row, ih );
682 int clusterRowIndex = clusterIndex - fClusterData->RowOffset( iRow );
683
684 if ( clusterIndex < 0 || clusterIndex >= fClusterData->NumberOfClusters() ) {
685 //std::cout << inpIDtot << ", " << fClusterData->NumberOfClusters()
686 //<< "; " << inpID << ", " << fClusterData->NumberOfClusters( iRow ) << std::endl;
687 //abort();
688 continue;
689 }
690 if ( clusterRowIndex < 0 || clusterRowIndex >= fClusterData->NumberOfClusters( iRow ) ) {
691 //std::cout << inpIDtot << ", " << fClusterData->NumberOfClusters()
692 //<< "; " << inpID << ", " << fClusterData->NumberOfClusters( iRow ) << std::endl;
693 //abort();
694 continue;
695 }
696
697 float origX = fClusterData->X( clusterIndex );
698 float origY = fClusterData->Y( clusterIndex );
699 float origZ = fClusterData->Z( clusterIndex );
700
701
702 int id = fClusterData->Id( clusterIndex );
703
d4594e7d 704 float2 hUnpackedYZ;
705 hUnpackedYZ.x = origY;
706 hUnpackedYZ.y = origZ;
707 float hUnpackedX = origX;
708
709 useOutput->SetClusterId( nStoredHits, id );
710 useOutput->SetClusterRow( nStoredHits, ( unsigned char ) iRow );
d4594e7d 711 useOutput->SetClusterUnpackedYZ( nStoredHits, hUnpackedYZ );
712 useOutput->SetClusterUnpackedX( nStoredHits, hUnpackedX );
713 nStoredHits++;
714 }
715 }
63d8b79d 716 }
fbb9b71b 717
718
719 // old stuff
d4594e7d 720 if (fOutputControl->fObsoleteOutput)
721 {
722 useOutput->SetNOutTrackHits(0);
723 useOutput->SetNOutTracks(0);
724
725
726 for ( int iTr = 0; iTr < fCommonMem->fNTracks; iTr++ ) {
727
728 const AliHLTTPCCATrack &iTrack = fTracks[iTr];
729
730 //std::cout<<"iTr = "<<iTr<<", nHits="<<iTrack.NHits()<<std::endl;
731
732 //if( !iTrack.Alive() ) continue;
733 if ( iTrack.NHits() < 3 ) continue;
734 AliHLTTPCCAOutTrack &out = useOutput->OutTracks()[useOutput->NOutTracks()];
735 out.SetFirstHitRef( useOutput->NOutTrackHits() );
736 out.SetNHits( 0 );
737 out.SetOrigTrackID( iTr );
73a33d2e 738 AliHLTTPCCATrackParam tmpParam;
739 tmpParam.InitParam();
740 tmpParam.SetParam(iTrack.Param());
741 out.SetStartPoint( tmpParam );
742 out.SetEndPoint( tmpParam );
d4594e7d 743
744 int iID = iTrack.FirstHitID();
745 int nOutTrackHitsOld = useOutput->NOutTrackHits();
746
747 for ( int ith = 0; ith < iTrack.NHits(); ith++ ) {
748 const AliHLTTPCCAHitId &ic = fTrackHits[iID + ith];
749 const AliHLTTPCCARow &row = Row( ic );
750 int ih = ic.HitIndex();
751 useOutput->SetOutTrackHit(useOutput->NOutTrackHits(), HitInputID( row, ih ));
752 useOutput->SetNOutTrackHits(useOutput->NOutTrackHits() + 1 );
753 //std::cout<<"write i,row,hit,id="<<ith<<", "<<ID2IRow(ic)<<", "<<ih<<", "<<HitInputID( row, ih )<<std::endl;
754 if ( useOutput->NOutTrackHits() >= 10*NHitsTotal() ) {
755 std::cout << "fNOutTrackHits>NHitsTotal()" << std::endl;
756 //exit(0);
757 return;//SG!!!
758 }
759 out.SetNHits( out.NHits() + 1 );
760 }
761 if ( out.NHits() >= 2 ) {
762 useOutput->SetNOutTracks(useOutput->NOutTracks() + 1);
763 } else {
764 useOutput->SetNOutTrackHits(nOutTrackHitsOld);
765 }
766 }
d54804bf 767 }
63d8b79d 768
00d07bcd 769 timer.Stop();
fbb9b71b 770 fTimers[5] += timer.CpuTime();
326c2d4b 771}
772
7be9b0d7 773#endif
774
4acc2401 775GPUh() void AliHLTTPCCATracker::FitTrackFull( const AliHLTTPCCATrack &/**/, float * /**/ ) const
fbb9b71b 776{
00d07bcd 777 // fit track with material
fbb9b71b 778#ifdef XXX
779 //* Fit the track
00d07bcd 780 FitTrack( iTrack, tt0 );
fbb9b71b 781 if ( iTrack.NHits() <= 3 ) return;
782
00d07bcd 783 AliHLTTPCCATrackParam &t = iTrack.Param();
784 AliHLTTPCCATrackParam t0 = t;
785
786 t.Chi2() = 0;
fbb9b71b 787 t.NDF() = -5;
788 bool first = 1;
789
790 int iID = iTrack.FirstHitID();
791 for ( int ih = 0; ih < iTrack.NHits(); ih++, iID++ ) {
4acc2401 792 const AliHLTTPCCAHitId &ic = fTrackHits[iID];
793 int iRow = ic.rowIndex();
794 const AliHLTTPCCARow &row = fData.Row( iRow );
fbb9b71b 795 if ( !t0.TransportToX( row.X() ) ) continue;
796 float dy, dz;
4acc2401 797 const AliHLTTPCCAHit &h = ic.hitIndex();
fbb9b71b 798
799 // check for wrong hits
800 if ( 0 ) {
00d07bcd 801 dy = t0.GetY() - h.Y();
802 dz = t0.GetZ() - h.Z();
fbb9b71b 803
00d07bcd 804 //if( dy*dy > 3.5*3.5*(/*t0.GetErr2Y() + */h.ErrY()*h.ErrY() ) ) continue;//SG!!!
fbb9b71b 805 //if( dz*dz > 3.5*3.5*(/*t0.GetErr2Z() + */h.ErrZ()*h.ErrZ() ) ) continue;
00d07bcd 806 }
326c2d4b 807
fbb9b71b 808 if ( !t.TransportToX( row.X() ) ) continue;
dc4788ec 809
00d07bcd 810 //* Update the track
fbb9b71b 811
812 if ( first ) {
813 t.Cov()[ 0] = .5 * .5;
00d07bcd 814 t.Cov()[ 1] = 0;
fbb9b71b 815 t.Cov()[ 2] = .5 * .5;
00d07bcd 816 t.Cov()[ 3] = 0;
817 t.Cov()[ 4] = 0;
fbb9b71b 818 t.Cov()[ 5] = .2 * .2;
00d07bcd 819 t.Cov()[ 6] = 0;
820 t.Cov()[ 7] = 0;
821 t.Cov()[ 8] = 0;
fbb9b71b 822 t.Cov()[ 9] = .2 * .2;
00d07bcd 823 t.Cov()[10] = 0;
824 t.Cov()[11] = 0;
825 t.Cov()[12] = 0;
826 t.Cov()[13] = 0;
fbb9b71b 827 t.Cov()[14] = .2 * .2;
00d07bcd 828 t.Chi2() = 0;
829 t.NDF() = -5;
830 }
fbb9b71b 831 float err2Y, err2Z;
00d07bcd 832 GetErrors2( iRow, t, err2Y, err2Z );
833
fbb9b71b 834 if ( !t.Filter2( h.Y(), h.Z(), err2Y, err2Z ) ) continue;
00d07bcd 835
fbb9b71b 836 first = 0;
837 }
00d07bcd 838 /*
fbb9b71b 839 float cosPhi = iTrack.Param().GetCosPhi();
00d07bcd 840 p0.Param().TransportToX(ID2Row( iTrack.PointID()[0] ).X());
fbb9b71b 841 p2.Param().TransportToX(ID2Row( iTrack.PointID()[1] ).X());
00d07bcd 842 if( p0.Param().GetCosPhi()*cosPhi<0 ){ // change direction
fbb9b71b 843 float *par = p0.Param().Par();
844 float *cov = p0.Param().Cov();
00d07bcd 845 par[2] = -par[2]; // sin phi
846 par[3] = -par[3]; // DzDs
847 par[4] = -par[4]; // kappa
848 cov[3] = -cov[3];
849 cov[4] = -cov[4];
850 cov[6] = -cov[6];
851 cov[7] = -cov[7];
852 cov[10] = -cov[10];
853 cov[11] = -cov[11];
854 p0.Param().CosPhi() = -p0.Param().GetCosPhi();
855 }
856 */
857#endif
858}
dc4788ec 859
4acc2401 860GPUh() void AliHLTTPCCATracker::FitTrack( const AliHLTTPCCATrack &/*track*/, float * /*t0[]*/ ) const
fbb9b71b 861{
862 //* Fit the track
00d07bcd 863#ifdef XXX
fbb9b71b 864 AliHLTTPCCAEndPoint &p2 = ID2Point( track.PointID()[1] );
4acc2401 865 const AliHLTTPCCAHit &c0 = ID2Hit( fTrackHits[p0.TrackHitID()].HitID() );
866 const AliHLTTPCCAHit &c1 = ID2Hit( fTrackHits[track.HitID()[1]].HitID() );
867 const AliHLTTPCCAHit &c2 = ID2Hit( fTrackHits[p2.TrackHitID()].HitID() );
868 const AliHLTTPCCARow &row0 = ID2Row( fTrackHits[p0.TrackHitID()].HitID() );
869 const AliHLTTPCCARow &row1 = ID2Row( fTrackHits[track.HitID()[1]].HitID() );
870 const AliHLTTPCCARow &row2 = ID2Row( fTrackHits[p2.TrackHitID()].HitID() );
fbb9b71b 871 float sp0[5] = {row0.X(), c0.Y(), c0.Z(), c0.ErrY(), c0.ErrZ() };
872 float sp1[5] = {row1.X(), c1.Y(), c1.Z(), c1.ErrY(), c1.ErrZ() };
873 float sp2[5] = {row2.X(), c2.Y(), c2.Z(), c2.ErrY(), c2.ErrZ() };
4acc2401 874 //std::cout<<"Fit track, points ="<<sp0[0]<<" "<<sp0[1]<<" / "<<sp1[0]<<" "<<sp1[1]<<" / "<<sp2[0]<<" "<<sp2[1]<<std::endl;
fbb9b71b 875 if ( track.NHits() >= 3 ) {
876 p0.Param().ConstructXYZ3( sp0, sp1, sp2, p0.Param().CosPhi(), t0 );
877 p2.Param().ConstructXYZ3( sp2, sp1, sp0, p2.Param().CosPhi(), t0 );
d54804bf 878 //p2.Param() = p0.Param();
879 //p2.Param().TransportToX(row2.X());
880 //p2.Param().Par()[1] = -p2.Param().Par()[1];
881 //p2.Param().Par()[4] = -p2.Param().Par()[4];
882 } else {
883 p0.Param().X() = row0.X();
884 p0.Param().Y() = c0.Y();
885 p0.Param().Z() = c0.Z();
fbb9b71b 886 p0.Param().Err2Y() = c0.ErrY() * c0.ErrY();
887 p0.Param().Err2Z() = c0.ErrZ() * c0.ErrZ();
d54804bf 888 p2.Param().X() = row2.X();
889 p2.Param().Y() = c2.Y();
890 p2.Param().Z() = c2.Z();
fbb9b71b 891 p2.Param().Err2Y() = c2.ErrY() * c2.ErrY();
892 p2.Param().Err2Z() = c2.ErrZ() * c2.ErrZ();
326c2d4b 893 }
00d07bcd 894#endif
895}
896
897
fbb9b71b 898GPUd() void AliHLTTPCCATracker::GetErrors2( int iRow, float z, float sinPhi, float cosPhi, float DzDs, float &Err2Y, float &Err2Z ) const
693d2443 899{
900 //
901 // Use calibrated cluster error from OCDB
902 //
903
63d8b79d 904 fParam.GetClusterErrors2( iRow, z, sinPhi, cosPhi, DzDs, Err2Y, Err2Z );
f0fb467d 905 Err2Y*=fParam.ClusterError2CorrectionY();
906 Err2Z*=fParam.ClusterError2CorrectionZ();
693d2443 907}
908
fbb9b71b 909GPUd() void AliHLTTPCCATracker::GetErrors2( int iRow, const AliHLTTPCCATrackParam &t, float &Err2Y, float &Err2Z ) const
00d07bcd 910{
911 //
912 // Use calibrated cluster error from OCDB
913 //
914
15d2e9cf 915 fParam.GetClusterErrors2( iRow, t.GetZ(), t.SinPhi(), t.GetCosPhi(), t.DzDs(), Err2Y, Err2Z );
00d07bcd 916}
917
4687b8fc 918
fbb9b71b 919#if !defined(HLTCA_GPUCODE)
4687b8fc 920
fbb9b71b 921GPUh() void AliHLTTPCCATracker::WriteEvent( std::ostream &out )
00d07bcd 922{
4687b8fc 923 // write event to the file
fbb9b71b 924 for ( int iRow = 0; iRow < fParam.NRows(); iRow++ ) {
4acc2401 925 out << fData.Row( iRow ).HitNumberOffset() << " " << fData.Row( iRow ).NHits() << std::endl;
fbb9b71b 926 }
4acc2401 927 out << NHitsTotal() << std::endl;
fbb9b71b 928
4acc2401 929 AliHLTResizableArray<float> y( NHitsTotal() ), z( NHitsTotal() );
fbb9b71b 930
931 for ( int iRow = 0; iRow < fParam.NRows(); iRow++ ) {
4acc2401 932 const AliHLTTPCCARow &row = Row( iRow );
fbb9b71b 933 float y0 = row.Grid().YMin();
934 float z0 = row.Grid().ZMin();
935 float stepY = row.HstepY();
936 float stepZ = row.HstepZ();
4acc2401 937 for ( int ih = 0; ih < fData.Row( iRow ).NHits(); ih++ ) {
938 int id = HitInputID( row, ih );
939 y[id] = y0 + HitDataY( row, ih ) * stepY;
940 z[id] = z0 + HitDataZ( row, ih ) * stepZ;
4687b8fc 941 }
942 }
4acc2401 943 for ( int ih = 0; ih < NHitsTotal(); ih++ ) {
fbb9b71b 944 out << y[ih] << " " << z[ih] << std::endl;
4687b8fc 945 }
fbb9b71b 946}
4687b8fc 947
fbb9b71b 948GPUh() void AliHLTTPCCATracker::WriteTracks( std::ostream &out )
4687b8fc 949{
fbb9b71b 950 //* Write tracks to file
98512261 951 AliHLTTPCCASliceOutput* useOutput = *fOutput;
fbb9b71b 952
953 out << fTimers[0] << std::endl;
98512261 954 out << useOutput->NOutTrackHits() << std::endl;
955 for ( int ih = 0; ih < useOutput->NOutTrackHits(); ih++ ) {
956 out << useOutput->OutTrackHit(ih) << " ";
4687b8fc 957 }
fbb9b71b 958 out << std::endl;
959
98512261 960 out << useOutput->NOutTracks() << std::endl;
fbb9b71b 961
98512261 962 for ( int itr = 0; itr < useOutput->NOutTracks(); itr++ ) {
963 const AliHLTTPCCAOutTrack &t = useOutput->OutTrack(itr);
fbb9b71b 964 AliHLTTPCCATrackParam p1 = t.StartPoint();
965 AliHLTTPCCATrackParam p2 = t.EndPoint();
966 out << t.NHits() << " ";
967 out << t.FirstHitRef() << " ";
968 out << t.OrigTrackID() << " ";
969 out << std::endl;
970 out << p1.X() << " ";
971 out << p1.SignCosPhi() << " ";
972 out << p1.Chi2() << " ";
973 out << p1.NDF() << std::endl;
974 for ( int i = 0; i < 5; i++ ) out << p1.Par()[i] << " ";
975 out << std::endl;
976 for ( int i = 0; i < 15; i++ ) out << p1.Cov()[i] << " ";
977 out << std::endl;
978 out << p2.X() << " ";
979 out << p2.SignCosPhi() << " ";
980 out << p2.Chi2() << " ";
981 out << p2.NDF() << std::endl;
982 for ( int i = 0; i < 5; i++ ) out << p2.Par()[i] << " ";
983 out << std::endl;
984 for ( int i = 0; i < 15; i++ ) out << p2.Cov()[i] << " ";
985 out << std::endl;
4687b8fc 986 }
987}
988
989GPUh() void AliHLTTPCCATracker::ReadTracks( std::istream &in )
990{
fbb9b71b 991 //* Read tracks from file
d4594e7d 992 AliHLTTPCCASliceOutput::Allocate(*fOutput, 4096, 16384, fOutputControl);//Just some max values
98512261 993 AliHLTTPCCASliceOutput* useOutput = *fOutput;
994
995 int tmpval;
fbb9b71b 996 in >> fTimers[0];
b22af1bf 997 in >> tmpval;
98512261 998 useOutput->SetNOutTrackHits(tmpval);
4687b8fc 999
98512261 1000 for ( int ih = 0; ih < useOutput->NOutTrackHits(); ih++ ) {
b22af1bf 1001 in >> tmpval;
98512261 1002 useOutput->SetOutTrackHit(ih, tmpval);
4687b8fc 1003 }
b22af1bf 1004 in >> tmpval;
98512261 1005 useOutput->SetNOutTracks(tmpval);
4687b8fc 1006
98512261 1007 for ( int itr = 0; itr < useOutput->NOutTracks(); itr++ ) {
1008 AliHLTTPCCAOutTrack &t = useOutput->OutTracks()[itr];
693d2443 1009 AliHLTTPCCATrackParam p1, p2;
fbb9b71b 1010 int i;
1011 float f;
1012 in >> i; t.SetNHits( i );
1013 in >> i; t.SetFirstHitRef( i );
1014 in >> i; t.SetOrigTrackID( i );
1015 in >> f; p1.SetX( f );
1016 in >> f; p1.SetSignCosPhi( f );
1017 in >> f; p1.SetChi2( f );
1018 in >> i; p1.SetNDF( i );
1019 for ( int j = 0; j < 5; j++ ) { in >> f; p1.SetPar( j, f ); }
1020 for ( int j = 0; j < 15; j++ ) { in >> f; p1.SetCov( j, f ); }
1021 in >> f; p2.SetX( f );
1022 in >> f; p2.SetSignCosPhi( f );
1023 in >> f; p2.SetChi2( f );
1024 in >> i; p2.SetNDF( i );
1025 for ( int j = 0; j < 5; j++ ) { in >> f; p2.SetPar( j, f ); }
1026 for ( int j = 0; j < 15; j++ ) { in >> f; p2.SetCov( j, f ); }
693d2443 1027 t.SetStartPoint( p1 );
1028 t.SetEndPoint( p2 );
4687b8fc 1029 }
326c2d4b 1030}
4687b8fc 1031#endif