23 #include "AliHLTTPCCATracker.h"
24 #include "AliHLTTPCCAOutTrack.h"
25 #include "AliHLTTPCCAGrid.h"
26 #include "AliHLTTPCCARow.h"
27 #include "AliHLTTPCCATrack.h"
28 #include "AliHLTTPCCATrackletVector.h"
29 #include "AliHLTTPCCAMath.h"
30 #include "AliHLTTPCCAHit.h"
31 #include "Reconstructor.h"
32 #include "MemoryAssignmentHelpers.h"
34 #include "Stopwatch.h"
35 #include "AliHLTTPCCASliceOutput.h"
36 #include "AliHLTTPCCADataCompressor.h"
37 #include "AliHLTTPCCAClusterData.h"
39 #include "AliHLTTPCCATrackParam.h"
43 #ifdef HLTCA_INTERNAL_PERFORMANCE
44 #include "AliHLTTPCCAPerformance.h"
49 AliHLTTPCCATracker::AliHLTTPCCATracker()
51 #ifdef DO_TPCCATRACKER_EFF_PERFORMANCE
61 fTrackMemorySize( 0 ),
62 fTrackletStartHits( 0 ),
73 AliHLTTPCCATracker::~AliHLTTPCCATracker()
76 #ifdef DO_TPCCATRACKER_EFF_PERFORMANCE
77 if (fOutTracks1)
delete[] fOutTracks1;
79 if (fHitMemory)
delete[] fHitMemory;
80 if (fTrackMemory)
delete[] fTrackMemory;
91 fData.InitializeRows( fParam );
96 void AliHLTTPCCATracker::StartEvent()
104 void AliHLTTPCCATracker::SetupCommonMemory()
107 if (fHitMemory)
delete[] fHitMemory;
110 if (fTrackMemory)
delete[] fTrackMemory;
118 void AliHLTTPCCATracker::RecalculateHitsSize(
int MaxNHits )
121 fHitMemorySize += RequiredMemory( fTrackletStartHits, MaxNHits );
124 void AliHLTTPCCATracker::SetPointersHits(
int MaxNHits )
126 assert( fHitMemory );
127 assert( fHitMemorySize > 0 );
131 char *mem = fHitMemory;
135 AssignMemory( fTrackletStartHits, mem, MaxNHits );
138 assert( fHitMemorySize >= mem - fHitMemory );
141 void AliHLTTPCCATracker::RecalculateTrackMemorySize(
int MaxNTracks,
int MaxNHits )
143 debugWO() <<
"RecalculateTrackMemorySize( " << MaxNTracks <<
", " << MaxNHits <<
")" << endl;
144 fTrackMemorySize = 0;
145 fTrackMemorySize +=
sizeof(
void * );
147 fTrackMemorySize += AliHLTTPCCASliceOutput::EstimateSize( MaxNTracks, MaxNHits );
150 void AliHLTTPCCATracker::SetPointersTracks(
int MaxNTracks,
int MaxNHits )
152 debugWO() <<
"SetPointersTracks( " << MaxNTracks <<
", " << MaxNHits <<
")" << endl;
153 assert( fTrackMemory );
154 assert( fTrackMemorySize > 0 );
158 char *mem = fTrackMemory;
162 AlignTo<sizeof( void * )>( mem );
165 mem += AliHLTTPCCASliceOutput::EstimateSize( MaxNTracks, MaxNHits );
168 assert( fTrackMemorySize >= mem - fTrackMemory );
174 fClusterData = clusterData;
183 fHitMemory =
new char[fHitMemorySize + 1600];
189 void AliHLTTPCCATracker::Reconstruct()
192 tbb::task::spawn_root_and_wait( *
new( tbb::task::allocate_root() ) Reconstructor(
this ) );
194 Reconstructor R(
this);
199 void AliHLTTPCCATracker::WriteOutput()
209 debugWO() <<
"numberOfTracks = " << fNumberOfTracks << std::endl;
210 fOutput->SetNTracks( fNumberOfTracks );
211 fOutput->SetNTrackClusters( fNTrackHits );
212 fOutput->SetPointers();
214 debugWO() <<
"WriteOutput| "
215 << fNumberOfTracks <<
" tracks found, "
216 << fTrackletVectors.Size() <<
" TrackletVectors, "
217 << fNTrackHits <<
" track hits "
220 int hitStoreIndex = 0;
223 const int tracksSize = fTracks.size();
224 for (
int trackIndex = 0; trackIndex < tracksSize; ++trackIndex ) {
227 const short numberOfHits = track.NumberOfHits();
228 if ( numberOfHits <= 0 ) {
230 if (fTracks[trackIndex])
delete fTracks[trackIndex];
236 hitStoreIndex = nStoredHits;
237 out.SetFirstClusterRef( nStoredHits );
238 nStoredHits += numberOfHits;
239 out.SetNClusters( numberOfHits );
240 out.SetParam( track.Param() );
241 fOutput->SetTrack( iTr, out );
245 for (
int hitIdIndex = 0; hitIdIndex < numberOfHits; ++hitIdIndex ) {
246 const HitId &hitId = track.HitId( hitIdIndex );
247 const short rowIndex = hitId.RowIndex();
248 const unsigned short hitIndex = hitId.HitIndex();
251 const int inpIdOffset = fClusterData->
RowOffset( rowIndex );
253 const int inpId = inpIdtot - inpIdOffset;
255 const float origX = fClusterData->
X( inpIdtot );
256 const float origY = fClusterData->
Y( inpIdtot );
257 const float origZ = fClusterData->
Z( inpIdtot );
259 const DataCompressor::RowCluster rc( rowIndex, inpId );
260 unsigned short hPackedYZ = 0;
261 UChar_t hPackedAmp = 0;
263 hUnpackedYZ.x = origY;
264 hUnpackedYZ.y = origZ;
265 float hUnpackedX = origX;
267 fOutput->SetClusterIDrc( hitStoreIndex, rc );
268 fOutput->SetClusterPackedYZ( hitStoreIndex, hPackedYZ );
269 fOutput->SetClusterPackedAmp( hitStoreIndex, hPackedAmp );
270 fOutput->SetClusterUnpackedYZ( hitStoreIndex, hUnpackedYZ );
271 fOutput->SetClusterUnpackedX( hitStoreIndex, hUnpackedX );
274 if (fTracks[trackIndex])
delete fTracks[trackIndex];
277 fOutput->SortTracks();
280 fTimers[5] += timer.RealTime();
285 void AliHLTTPCCATracker::GetErrors2(
int iRow,
const AliHLTTPCCATrackParam &t,
float *Err2Y,
float *Err2Z )
const
294 void AliHLTTPCCATracker::WriteTracks( std::ostream &out )
298 out << fTimers[0] << std::endl;
300 out << fNOutTrackHits << std::endl;
301 for (
int hitIndex = 0; hitIndex < fNOutTrackHits; ++hitIndex ) {
302 out << fOutTrackHits[hitIndex] <<
" ";
306 out << fNOutTracks << std::endl;
308 for (
int itr = 0; itr < fNOutTracks; itr++ ) {
309 out << fOutTracks[itr];
311 #endif //DO_TPCCATRACKER_EFF_PERFORMANCE
314 void AliHLTTPCCATracker::ReadTracks( std::istream &in )
319 in >> fNOutTrackHits;
321 for (
int hitIndex = 0; hitIndex < fNOutTrackHits; ++hitIndex ) {
322 in >> fOutTrackHits[hitIndex];
326 for (
int itr = 0; itr < fNOutTracks; itr++ ) {
327 in >> fOutTracks[itr];
329 #endif //DO_TPCCATRACKER_EFF_PERFORMANCE
332 #include "BinaryStoreHelper.h"
334 void AliHLTTPCCATracker::StoreToFile( FILE *f )
const
336 fParam.StoreToFile( f );
337 fData.StoreToFile( f );
339 BinaryStoreWrite( fTimers, 10, f );
348 BinaryStoreWrite( fNTracklets, f );
355 BinaryStoreWrite( fNOutTracks, f );
357 BinaryStoreWrite( fNOutTrackHits, f );
359 #endif //DO_TPCCATRACKER_EFF_PERFORMANCE
362 void AliHLTTPCCATracker::RestoreFromFile( FILE *f )
364 fParam.RestoreFromFile( f );
365 fData.RestoreFromFile( f );
367 BinaryStoreRead( fTimers, 10, f );
370 BinaryStoreRead( alignment, f );
379 BinaryStoreRead( fNTracklets, f );
386 BinaryStoreRead( fNOutTracks , f );
388 BinaryStoreRead( fNOutTrackHits, f );
390 #endif //DO_TPCCATRACKER_EFF_PERFORMANCE
int RowOffset(unsigned int rowIndex) const
void InitFromClusterData(const AliHLTTPCCAClusterData &data)
const AliHLTTPCCARow & Row(int rowIndex) const
int ClusterDataIndex(const AliHLTTPCCARow &row, int hitIndex) const
void GetClusterErrors2(int iRow, const AliHLTTPCCATrackParam &t, float &Err2Y, float &Err2Z) const
mvz start 20.01.2010