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