]>
Commit | Line | Data |
---|---|---|
a6c02c85 | 1 | // @(#) $Id$ |
4aa41877 | 2 | // Original: AliHLTTrackArray.cxx,v 1.21 2005/06/14 10:55:21 cvetan |
a6c02c85 | 3 | |
4fdaad1e | 4 | /************************************************************************** |
d53596be | 5 | * This file is property of and copyright by the ALICE HLT Project * |
6 | * ALICE Experiment at CERN, All rights reserved. * | |
4fdaad1e | 7 | * * |
d53596be | 8 | * Primary Authors: Uli Frankenfeld, maintained by * |
9 | * Matthias Richter <Matthias.Richter@ift.uib.no> * | |
10 | * for The ALICE HLT Project. * | |
4fdaad1e | 11 | * * |
12 | * Permission to use, copy, modify and distribute this software and its * | |
13 | * documentation strictly for non-commercial purposes is hereby granted * | |
14 | * without fee, provided that the above copyright notice appears in all * | |
15 | * copies and that both the copyright notice and this permission notice * | |
16 | * appear in the supporting documentation. The authors make no claims * | |
17 | * about the suitability of this software for any purpose. It is * | |
18 | * provided "as is" without express or implied warranty. * | |
19 | **************************************************************************/ | |
20 | ||
21 | /** @file AliHLTTPCTrackArray.cxx | |
22 | @author Uli Frankenfeld, maintained by Matthias Richter | |
23 | @date | |
24 | @brief Array of AliHLTTPCTracks */ | |
a6c02c85 | 25 | |
312160d3 | 26 | #include "AliLog.h" |
27 | #include "TClass.h" | |
a6c02c85 | 28 | #include "AliHLTTPCLogging.h" |
29 | #include "AliHLTTPCTrackArray.h" | |
5b538a2c | 30 | // Matthias 17.10.2007 the hough code has been disabled for the moment |
31 | //#define INCLUDE_TPC_HOUGH | |
a6c02c85 | 32 | #ifdef INCLUDE_TPC_HOUGH |
33 | #include "AliHLTTPCHoughTrack.h" | |
34 | #endif | |
35 | #include "AliHLTTPCModelTrack.h" | |
36 | #include "AliHLTTPCConfMapTrack.h" | |
37 | #include "AliHLTTPCTrackSegmentData.h" | |
38 | #include "AliHLTTPCTransform.h" | |
39 | #include "AliHLTTPCConfMapPoint.h" | |
40 | ||
a6c02c85 | 41 | #if __GNUC__ >= 3 |
42 | using namespace std; | |
43 | #endif | |
44 | ||
45 | ClassImp(AliHLTTPCTrackArray) | |
46 | ||
47 | AliHLTTPCTrackArray::AliHLTTPCTrackArray() | |
4fdaad1e | 48 | : |
2a083ac4 | 49 | fTrackType('t'), |
4fdaad1e | 50 | fSize(0), |
2a083ac4 | 51 | fIsPresent(NULL), |
4fdaad1e | 52 | fNAbsent(0), |
2a083ac4 | 53 | fTrack(NULL), |
54 | fNTracks(0) | |
a6c02c85 | 55 | { |
56 | //Default constructor | |
4fdaad1e | 57 | SetSize(); |
58 | } | |
59 | ||
60 | ||
a6c02c85 | 61 | AliHLTTPCTrackArray::AliHLTTPCTrackArray(Int_t ntrack) |
4fdaad1e | 62 | : |
2a083ac4 | 63 | fTrackType('t'), |
4fdaad1e | 64 | fSize(0), |
2a083ac4 | 65 | fIsPresent(NULL), |
4fdaad1e | 66 | fNAbsent(0), |
2a083ac4 | 67 | fTrack(NULL), |
68 | fNTracks(0) | |
a6c02c85 | 69 | { |
70 | //Constructor. | |
a6c02c85 | 71 | SetSize(ntrack); |
72 | } | |
73 | ||
74 | AliHLTTPCTrackArray::AliHLTTPCTrackArray(char* tracktype,Int_t ntrack) | |
4fdaad1e | 75 | : |
2a083ac4 | 76 | fTrackType('t'), |
4fdaad1e | 77 | fSize(0), |
2a083ac4 | 78 | fIsPresent(NULL), |
79 | fNAbsent(0), | |
80 | fTrack(NULL), | |
81 | fNTracks(0) | |
a6c02c85 | 82 | { |
83 | //Constructor. | |
a6c02c85 | 84 | if(strcmp(tracktype,"AliHLTTPCTrack")==0) fTrackType='t'; |
85 | if(strcmp(tracktype,"AliHLTTPCConfMapTrack")==0) fTrackType='c'; | |
86 | #ifdef INCLUDE_TPC_HOUGH | |
87 | if(strcmp(tracktype,"AliHLTTPCHoughTrack")==0) fTrackType='h'; | |
88 | #endif | |
89 | if(strcmp(tracktype,"AliHLTTPCModelTrack")==0) fTrackType='m'; | |
90 | SetSize(ntrack); | |
91 | } | |
92 | ||
93 | AliHLTTPCTrackArray::AliHLTTPCTrackArray(char* tracktype) | |
4fdaad1e | 94 | : |
2a083ac4 | 95 | fTrackType('t'), |
4fdaad1e | 96 | fSize(0), |
2a083ac4 | 97 | fIsPresent(NULL), |
98 | fNAbsent(0), | |
99 | fTrack(NULL), | |
100 | fNTracks(0) | |
a6c02c85 | 101 | { |
102 | //Constructor. | |
a6c02c85 | 103 | if(strcmp(tracktype,"AliHLTTPCTrack")==0) fTrackType='t'; |
104 | if(strcmp(tracktype,"AliHLTTPCConfMapTrack")==0) fTrackType='c'; | |
105 | #ifdef INCLUDE_TPC_HOUGH | |
106 | if(strcmp(tracktype,"AliHLTTPCHoughTrack")==0) fTrackType='h'; | |
107 | #endif | |
108 | if(strcmp(tracktype,"AliHLTTPCModelTrack")==0) fTrackType='m'; | |
109 | SetSize(); | |
110 | } | |
111 | ||
112 | AliHLTTPCTrackArray::~AliHLTTPCTrackArray() | |
113 | { | |
114 | //Destructor | |
115 | DeleteArray(); | |
116 | } | |
117 | ||
118 | ||
119 | AliHLTTPCTrack *AliHLTTPCTrackArray::NextTrack() | |
120 | { | |
121 | //next track in array | |
122 | if(fNTracks<fSize) return fTrack[fNTracks++]; | |
123 | SetSize(fSize+100); | |
124 | return fTrack[fNTracks++]; | |
125 | } | |
126 | ||
127 | void AliHLTTPCTrackArray::DeleteArray() | |
128 | { | |
129 | //delete array | |
130 | for(Int_t i=0; i<fSize;i++) | |
131 | delete fTrack[i]; | |
132 | delete[] fIsPresent; | |
133 | delete[] fTrack; | |
055fed30 | 134 | fSize=0; |
a6c02c85 | 135 | } |
136 | ||
137 | Bool_t AliHLTTPCTrackArray::SetSize(Int_t newsize) | |
138 | { | |
139 | //set size | |
140 | if(newsize<=fSize) return kFALSE; //shrink comes later!! | |
141 | if(!fSize){ | |
142 | fSize = newsize; | |
143 | fTrack = new AliHLTTPCTrack*[fSize]; | |
144 | fIsPresent = new Bool_t[fSize]; | |
145 | switch(fTrackType){ | |
146 | case 't': | |
147 | for(Int_t i=0;i<fSize;i++){ | |
148 | fTrack[i] = new AliHLTTPCTrack(); | |
149 | fIsPresent[i] = kTRUE; | |
150 | } | |
151 | break; | |
152 | case 'c': | |
153 | for(Int_t i=0;i<fSize;i++){ | |
154 | fTrack[i] = new AliHLTTPCConfMapTrack(); | |
155 | fIsPresent[i] = kTRUE; | |
156 | } | |
157 | break; | |
158 | #ifdef INCLUDE_TPC_HOUGH | |
159 | case 'h': | |
160 | for(Int_t i=0;i<fSize;i++){ | |
161 | fTrack[i] = new AliHLTTPCHoughTrack(); | |
162 | fIsPresent[i] = kTRUE; | |
163 | } | |
164 | break; | |
165 | #endif | |
166 | case 'm': | |
167 | for(Int_t i=0;i<fSize;i++){ | |
168 | fTrack[i] = new AliHLTTPCModelTrack(); | |
169 | fIsPresent[i] = kTRUE; | |
170 | } | |
171 | break; | |
172 | default: | |
173 | return kFALSE; | |
174 | } | |
175 | return kTRUE; | |
176 | } | |
177 | AliHLTTPCTrack **tmp = new AliHLTTPCTrack*[fSize]; | |
178 | Bool_t *pre = new Bool_t[fSize]; | |
179 | for(Int_t i=0; i<fSize;i++){ | |
180 | tmp[i] = fTrack[i]; | |
181 | pre[i] = fIsPresent[i]; | |
182 | } | |
183 | delete[] fTrack; | |
184 | delete[] fIsPresent; | |
185 | fTrack = new AliHLTTPCTrack*[newsize]; | |
186 | fIsPresent = new Bool_t[newsize]; | |
187 | for(Int_t i=0; i<fSize;i++){ | |
188 | fTrack[i] = tmp[i]; | |
189 | fIsPresent[i] = pre[i]; | |
190 | } | |
191 | delete[] tmp; | |
192 | delete[] pre; | |
193 | switch(fTrackType){ | |
194 | case 't': | |
195 | for(Int_t i=fSize;i<newsize;i++){ | |
196 | fTrack[i] = new AliHLTTPCTrack(); | |
197 | fIsPresent[i] = kTRUE; | |
198 | } | |
199 | break; | |
200 | case 'c': | |
201 | for(Int_t i=fSize;i<newsize;i++){ | |
202 | fTrack[i] = new AliHLTTPCConfMapTrack(); | |
203 | fIsPresent[i] = kTRUE; | |
204 | } | |
205 | break; | |
206 | #ifdef INCLUDE_TPC_HOUGH | |
207 | case 'h': | |
208 | for(Int_t i=fSize;i<newsize;i++){ | |
209 | fTrack[i] = new AliHLTTPCHoughTrack(); | |
210 | fIsPresent[i] = kTRUE; | |
211 | } | |
212 | break; | |
213 | #endif | |
214 | case 'm': | |
215 | for(Int_t i=fSize;i<newsize;i++){ | |
216 | fTrack[i] = new AliHLTTPCModelTrack(); | |
217 | fIsPresent[i] = kTRUE; | |
218 | } | |
219 | break; | |
220 | default: | |
221 | return kFALSE; | |
222 | } | |
223 | fSize = newsize; | |
224 | return kTRUE; | |
225 | } | |
226 | ||
227 | void AliHLTTPCTrackArray::Reset() | |
228 | { | |
229 | //reset | |
230 | fNTracks=0; | |
231 | fNAbsent=0; | |
232 | for(Int_t i=0; i<fSize;i++) | |
233 | fIsPresent[i] = kTRUE; | |
234 | } | |
235 | ||
236 | void AliHLTTPCTrackArray::Remove(Int_t track) | |
237 | { | |
238 | //remove track | |
239 | if(fIsPresent[track]){ | |
240 | fIsPresent[track]=kFALSE; | |
241 | fNAbsent++; | |
242 | } | |
243 | } | |
244 | ||
4fdaad1e | 245 | void AliHLTTPCTrackArray::FillTracks(Int_t ntracks, AliHLTTPCTrackSegmentData* tr,Int_t slice, Int_t bTransform) |
a6c02c85 | 246 | { |
247 | //Read tracks from shared memory (or memory) | |
248 | AliHLTTPCTrackSegmentData *trs = tr; | |
249 | for(Int_t i=0; i<ntracks; i++){ | |
250 | AliHLTTPCTrack *track = NextTrack(); | |
251 | track->SetPt(trs->fPt); | |
252 | track->SetPterr(trs->fPterr); | |
253 | Float_t psi[1]; | |
254 | psi[0]=trs->fPsi; | |
4fdaad1e | 255 | if (slice>=0 && bTransform!=0) { |
256 | AliHLTTPCTransform::Local2GlobalAngle(psi,slice); | |
257 | } | |
258 | //cout << "psi " << psi[0] << endl; | |
a6c02c85 | 259 | track->SetPsi(psi[0]); |
260 | track->SetTgl(trs->fTgl); | |
261 | track->SetPsierr(trs->fPsierr); | |
262 | track->SetTglerr(trs->fTglerr); | |
263 | track->SetNHits(trs->fNPoints); | |
264 | track->SetCharge(trs->fCharge); | |
265 | Float_t first[3]; | |
266 | first[0]=trs->fX;first[1]=trs->fY;first[2]=trs->fZ; | |
4fdaad1e | 267 | if (slice>=0 && bTransform!=0) { |
268 | AliHLTTPCTransform::Local2Global(first,slice); | |
269 | } | |
270 | //cout << "first point: " << first[0] << " " << first[1] << " " << first[3] << endl; | |
a6c02c85 | 271 | track->SetFirstPoint(first[0],first[1],first[2]); |
272 | Float_t last[3]; | |
273 | last[0]=trs->fLastX;last[1]=trs->fLastY;last[2]=trs->fLastZ; | |
4fdaad1e | 274 | if (slice>=0 && bTransform!=0) { |
275 | AliHLTTPCTransform::Local2Global(last,slice); | |
276 | } | |
277 | //cout << "last point: " << last[0] << " " << last[1] << " " << last[3] << endl; | |
a6c02c85 | 278 | track->SetLastPoint(last[0],last[1],last[2]); |
279 | track->SetHits( trs->fNPoints, trs->fPointIDs ); | |
4fdaad1e | 280 | |
d53596be | 281 | //if (slice>=0 && bTransform!=0) { |
4e57c862 | 282 | // Matthias Feb07: as everything is now in global coordinates, sector should |
283 | // be set to 0. But as the display does a check on the sector, we have to set | |
284 | // it to the slice no. I suspect, that the transformation is done twice. | |
285 | //track->SetSector(0); | |
286 | track->SetSector(slice); | |
d53596be | 287 | //} else { |
4fdaad1e | 288 | // the parameters are in local coordinates, set the sector no |
312160d3 | 289 | //#ifndef INCLUDE_TPC_HOUGH |
d53596be | 290 | //if (slice<0) track->SetSector(0); |
291 | //else track->SetSector(slice); | |
312160d3 | 292 | //#else |
4fdaad1e | 293 | // Matthias Feb 2007: this is some kind of legacy ... |
294 | // the INCLUDE_TPC_HOUGH has never been switched on in the new TPCLib | |
295 | // and this line was below in the corresponding block. As the slice | |
296 | // parameter is very useful but not available if the define is off | |
297 | // we distinguish the two cases here. Should be cleaned up. | |
312160d3 | 298 | // Matthias April 2007: update, try to integrate Cvetans Hough tracker |
299 | // so we need the support for the AliHLTTPCHoughTrack. I dont have the | |
300 | // full control of this code (should we use slice or trs->fSector?) | |
301 | // But the FillTracks method is never called from the hough code, so we | |
302 | // take 'slice' | |
303 | if (GetTrackType()=='h') { | |
304 | AliErrorClassStream() << "FillTracks was never used with AliHLTTPCHoughTrack:" | |
305 | << " CHECK THIS CODE!!!" << endl; | |
306 | } | |
307 | //track->SetSector(trs->fSector); | |
308 | //#endif // INCLUDE_TPC_HOUGH | |
d53596be | 309 | //} |
21b6a334 | 310 | |
311 | // this is currently a quick hack for straight lines of the first version | |
312 | // of the CA tracker. | |
313 | // we have to think about a more general way of treating straight and curved | |
314 | // tracks | |
315 | if ( trs->fPt == -9876.0 || trs->fPt == -1.0) { | |
316 | track->SetPhi0(atan2(first[1],first[0])); | |
317 | track->SetKappa(1.0); | |
318 | track->SetRadius(999999.0); | |
319 | } else { | |
4e57c862 | 320 | // Matthias Feb07: just tried to take this away, but this causes the tracks |
321 | // in the display not to be drawn. But we still have to tink about this. | |
322 | track->CalculateHelix(); | |
21b6a334 | 323 | } |
324 | ||
a6c02c85 | 325 | #ifdef INCLUDE_TPC_HOUGH |
326 | #ifdef ROWHOUGHPARAMS | |
327 | if(GetTrackType()=='h') { | |
328 | ((AliHLTTPCHoughTrack *)track)->SetWeight(trs->fWeight); | |
329 | ((AliHLTTPCHoughTrack *)track)->SetBinXY(trs->fBinX,trs->fBinY,trs->fBinXSize,trs->fBinYSize); | |
330 | } | |
331 | track->SetMCid(trs->fTrackID); | |
332 | track->SetRowRange(trs->fRowRange1,trs->fRowRange2); | |
a6c02c85 | 333 | track->SetPID(trs->fPID); |
334 | #endif | |
335 | #endif // INCLUDE_TPC_HOUGH | |
336 | UChar_t *tmpP = (UChar_t*)trs; | |
337 | tmpP += sizeof(AliHLTTPCTrackSegmentData)+trs->fNPoints*sizeof(UInt_t); | |
338 | trs = (AliHLTTPCTrackSegmentData*)tmpP; | |
339 | } | |
340 | } | |
341 | ||
342 | UInt_t AliHLTTPCTrackArray::GetOutSize() | |
343 | { | |
344 | //get size for IO | |
345 | UInt_t count = GetOutCount(); //use only present tracks | |
346 | UInt_t tHits = 0; | |
347 | for(Int_t i=0;i<fNTracks;i++){ //loop over all tracks | |
348 | AliHLTTPCTrack *track = GetCheckedTrack(i); //use only present tracks | |
349 | if(track) //use only present tracks | |
350 | tHits += track->GetNHits(); | |
351 | } | |
352 | ||
353 | //calculate size of track | |
354 | return count*sizeof(AliHLTTPCTrackSegmentData)+sizeof(UInt_t)*tHits; | |
355 | } | |
356 | ||
357 | UInt_t AliHLTTPCTrackArray::WriteTracks(UInt_t & ntracks,AliHLTTPCTrackSegmentData* tr) | |
358 | { | |
359 | //write tracks | |
360 | ntracks = GetOutCount(); | |
361 | return WriteTracks(tr); | |
362 | } | |
363 | ||
364 | UInt_t AliHLTTPCTrackArray::WriteTracks(AliHLTTPCTrackSegmentData* tr) | |
365 | { | |
366 | //if(GetTrackType()=='c') return WriteConfMapTracks(tr); | |
367 | AliHLTTPCTrackSegmentData *tP = tr; | |
368 | UInt_t *pP; | |
369 | UInt_t size = 0; | |
370 | for(Int_t i=0; i<fNTracks; i++){ //loop over all tracks | |
371 | AliHLTTPCTrack *track = GetCheckedTrack(i); //use only present tracks | |
372 | if(!track) continue; //use only present tracks | |
373 | tP->fX = track->GetFirstPointX(); | |
374 | tP->fY = track->GetFirstPointY(); | |
375 | tP->fZ = track->GetFirstPointZ(); | |
376 | tP->fPt = track->GetPt(); | |
377 | tP->fPterr = track->GetPterr(); | |
378 | tP->fLastX = track->GetLastPointX(); | |
379 | tP->fLastY = track->GetLastPointY(); | |
380 | tP->fLastZ = track->GetLastPointZ(); | |
381 | tP->fPsi = track->GetPsi(); | |
382 | tP->fTgl = track->GetTgl(); | |
383 | tP->fPsierr = track->GetPsierr(); | |
384 | tP->fTglerr = track->GetTglerr(); | |
385 | tP->fCharge = track->GetCharge(); | |
386 | tP->fNPoints = track->GetNHits(); | |
387 | #ifdef INCLUDE_TPC_HOUGH | |
388 | #ifdef ROWHOUGHPARAMS | |
389 | if(GetTrackType()=='h') { | |
390 | tP->fWeight = ((AliHLTTPCHoughTrack *)track)->GetWeight(); | |
391 | tP->fBinX = ((AliHLTTPCHoughTrack *)track)->GetBinX(); | |
392 | tP->fBinY = ((AliHLTTPCHoughTrack *)track)->GetBinY(); | |
393 | tP->fBinXSize = ((AliHLTTPCHoughTrack *)track)->GetSizeX(); | |
394 | tP->fBinYSize = ((AliHLTTPCHoughTrack *)track)->GetSizeY(); | |
395 | } | |
396 | tP->fTrackID = track->GetMCid(); | |
397 | tP->fRowRange1 = track->GetFirstRow(); | |
398 | tP->fRowRange2 = track->GetLastRow(); | |
399 | tP->fSector = track->GetSector(); | |
400 | tP->fPID = track->GetPID(); | |
401 | #endif | |
402 | #endif // INCLUDE_TPC_HOUGH | |
403 | pP = (UInt_t*)track->GetHitNumbers(); | |
404 | for (UInt_t j=0;j<tP->fNPoints;j++){ | |
405 | tP->fPointIDs[j] = pP[j]; | |
406 | } | |
407 | Byte_t *tmpP = (Byte_t *)tP; | |
408 | tmpP += sizeof(AliHLTTPCTrackSegmentData)+tP->fNPoints*sizeof(UInt_t); | |
409 | size += sizeof(AliHLTTPCTrackSegmentData)+tP->fNPoints*sizeof(UInt_t); | |
410 | tP = (AliHLTTPCTrackSegmentData*)tmpP; | |
738c049f | 411 | |
db16520a | 412 | // LOG(AliHLTTPCLog::kError,"AliHLTTPCTrackArray::WriteTracks","TRACKPARAMETER") <<ENDLOG; |
413 | // track->Rotate(0,kFALSE); | |
414 | // track->Print(); | |
738c049f | 415 | |
a6c02c85 | 416 | } |
417 | return size; | |
418 | } | |
419 | ||
420 | UInt_t AliHLTTPCTrackArray::WriteConfMapTracks(AliHLTTPCTrackSegmentData* tr) | |
421 | { | |
422 | // use first and last point objects | |
423 | AliHLTTPCTrackSegmentData *tP = tr; | |
424 | UInt_t *pP; | |
425 | UInt_t size = 0; | |
426 | for(Int_t i=0; i<fNTracks; i++){ //loop over all tracks | |
427 | AliHLTTPCConfMapTrack *track =(AliHLTTPCConfMapTrack *) GetCheckedTrack(i); //use only present tracks | |
428 | if(!track) continue; //use only present tracks | |
429 | AliHLTTPCConfMapPoint *hit = (AliHLTTPCConfMapPoint*)track->GetLastHit(); | |
430 | AliHLTTPCConfMapPoint *lastHit = (AliHLTTPCConfMapPoint*)track->GetFirstHit(); | |
431 | tP->fX = hit->GetX(); | |
432 | tP->fY = hit->GetY(); | |
433 | tP->fZ = hit->GetZ(); | |
434 | tP->fLastX = lastHit->GetX(); | |
435 | tP->fLastY = lastHit->GetY(); | |
436 | tP->fLastZ = lastHit->GetZ(); | |
437 | ||
438 | // tP->fX = track->GetFirstPointX(); | |
439 | // tP->fY = track->GetFirstPointY(); | |
440 | // tP->fZ = track->GetFirstPointZ(); | |
441 | tP->fPt = track->GetPt(); | |
442 | tP->fPterr = track->GetPterr(); | |
443 | // tP->fLastX = track->GetLastPointX(); | |
444 | // tP->fLastY = track->GetLastPointY(); | |
445 | // tP->fLastZ = track->GetLastPointZ(); | |
446 | tP->fPsi = track->GetPsi(); | |
447 | tP->fTgl = track->GetTgl(); | |
448 | tP->fPsierr = track->GetPsierr(); | |
449 | tP->fTglerr = track->GetTglerr(); | |
450 | tP->fCharge = track->GetCharge(); | |
451 | #ifdef INCLUDE_TPC_HOUGH | |
452 | #ifdef ROWHOUGHPARAMS | |
453 | tP->fTrackID = track->GetMCid(); | |
454 | tP->fRowRange1 = track->GetFirstRow(); | |
455 | tP->fRowRange2 = track->GetLastRow(); | |
456 | tP->fSector = track->GetSector(); | |
457 | tP->fPID = track->GetPID(); | |
458 | #endif | |
459 | #endif // INCLUDE_TPC_HOUGH | |
460 | tP->fNPoints = track->GetNHits(); | |
461 | pP = (UInt_t*)track->GetHitNumbers(); | |
462 | for (UInt_t j=0;j<tP->fNPoints;j++){ | |
463 | tP->fPointIDs[j] = pP[j]; | |
464 | } | |
465 | Byte_t *tmpP = (Byte_t *)tP; | |
466 | tmpP += sizeof(AliHLTTPCTrackSegmentData)+tP->fNPoints*sizeof(UInt_t); | |
467 | size +=sizeof(AliHLTTPCTrackSegmentData)+tP->fNPoints*sizeof(UInt_t); | |
468 | tP = (AliHLTTPCTrackSegmentData*)tmpP; | |
469 | } | |
470 | return size; | |
471 | } | |
472 | ||
473 | void AliHLTTPCTrackArray::AddLast(AliHLTTPCTrack *track) | |
474 | { | |
475 | //add track to last position | |
476 | AliHLTTPCTrack *tpt = NextTrack(); | |
3cde846d | 477 | tpt->Copy(track); |
a6c02c85 | 478 | |
479 | } | |
480 | ||
481 | void AliHLTTPCTrackArray::AddTracks(AliHLTTPCTrackArray *newtrack,Bool_t remove_old,Int_t slice) | |
482 | { | |
483 | //add tracks | |
484 | if(GetTrackType() != newtrack->GetTrackType() && GetTrackType()!='t') | |
485 | { | |
486 | LOG(AliHLTTPCLog::kError,"AliHLTTPCTrackArray::AddTracks","Track types") | |
487 | <<"Bad idea to add tracks of different types"<<ENDLOG; | |
488 | return; | |
489 | } | |
490 | if(fSize < fNTracks+newtrack->GetNPresent()) | |
491 | SetSize(fSize+newtrack->GetSize()); | |
492 | for(Int_t i =0;i<newtrack->GetNTracks();i++){ | |
493 | AliHLTTPCTrack *tpt = newtrack->GetCheckedTrack(i); | |
494 | if(!tpt) continue; | |
495 | if(remove_old) | |
496 | newtrack->Remove(i); | |
497 | AliHLTTPCTrack *track = NextTrack(); | |
3cde846d | 498 | track->Copy(tpt); |
a6c02c85 | 499 | if(slice>=0) |
500 | track->Rotate(slice); //Rotate track to global coordinates | |
501 | /* | |
502 | AliHLTTPCTrack *track; | |
503 | #ifdef INCLUDE_TPC_HOUGH | |
504 | if(GetTrackType()=='h') | |
505 | track = (AliHLTTPCHoughTrack*)NextTrack(); | |
506 | else | |
507 | #endif | |
508 | track = NextTrack(); | |
3cde846d | 509 | track->Copy(tpt); |
a6c02c85 | 510 | */ |
511 | } | |
512 | } | |
513 | ||
514 | void AliHLTTPCTrackArray::Compress() | |
515 | { | |
516 | //compress array | |
517 | if(GetNPresent()==GetNTracks()) return; | |
518 | AliHLTTPCTrack **tmp = new AliHLTTPCTrack *[fNTracks]; | |
519 | Int_t present=0; | |
520 | Int_t absent=GetNPresent(); | |
521 | for(Int_t i=0;i<GetNTracks();i++){ | |
522 | if(fIsPresent[i]) tmp[present++] = fTrack[i]; | |
523 | else tmp[absent++] = fTrack[i]; | |
524 | } | |
525 | for(Int_t i=0;i<GetNTracks();i++) | |
526 | fIsPresent[i]=kTRUE; | |
527 | ||
528 | //Copy pointers back | |
529 | for(Int_t i=0; i<GetNTracks();i++){ | |
530 | fTrack[i]=tmp[i]; | |
531 | } | |
532 | ||
533 | delete[] tmp; | |
534 | ||
535 | fNTracks = GetNPresent(); | |
536 | fNAbsent = 0; | |
537 | } | |
538 | ||
539 | void AliHLTTPCTrackArray::QSort() | |
540 | { | |
541 | // compress and sort | |
542 | Compress(); | |
543 | QSort(fTrack,0,fNTracks); | |
544 | } | |
545 | ||
546 | void AliHLTTPCTrackArray::QSort( AliHLTTPCTrack **a, Int_t first, Int_t last) | |
547 | { | |
548 | // Sort array of AliHLTTPCTrack pointers using a quicksort algorithm. | |
549 | // Uses TrackCompare() to compare objects. | |
550 | // Thanks to Root! | |
551 | ||
552 | static AliHLTTPCTrack *tmp; | |
553 | static int i; // "static" to save stack space | |
554 | int j; | |
555 | ||
556 | while (last - first > 1) { | |
557 | i = first; | |
558 | j = last; | |
559 | for (;;) { | |
560 | while (++i < last && TrackCompare(a[i], a[first]) < 0) | |
561 | ; | |
562 | while (--j > first && TrackCompare(a[j], a[first]) > 0) | |
563 | ; | |
564 | if (i >= j) | |
565 | break; | |
566 | ||
567 | tmp = a[i]; | |
568 | a[i] = a[j]; | |
569 | a[j] = tmp; | |
570 | } | |
571 | if (j == first) { | |
572 | ++first; | |
573 | continue; | |
574 | } | |
575 | tmp = a[first]; | |
576 | a[first] = a[j]; | |
577 | a[j] = tmp; | |
578 | if (j - first < last - (j + 1)) { | |
579 | QSort(a, first, j); | |
580 | first = j + 1; // QSort(j + 1, last); | |
581 | } else { | |
582 | QSort(a, j + 1, last); | |
583 | last = j; // QSort(first, j); | |
584 | } | |
585 | } | |
586 | } | |
587 | ||
588 | Int_t AliHLTTPCTrackArray::TrackCompare(AliHLTTPCTrack *a, AliHLTTPCTrack *b) const | |
589 | { | |
590 | // Compare the two tracks. | |
591 | ||
592 | return b->Compare(a); | |
593 | ||
594 | /* | |
595 | #ifdef INCLUDE_TPC_HOUGH | |
596 | if(fTrackType=='h') | |
597 | { | |
598 | AliHLTTPCHoughTrack *tra = (AliHLTTPCHoughTrack*)a; | |
599 | AliHLTTPCHoughTrack *trb = (AliHLTTPCHoughTrack*)b; | |
600 | if(tra->GetWeight() < trb->GetWeight()) return 1; | |
601 | if(tra->GetWeight() > trb->GetWeight()) return -1; | |
602 | } | |
603 | else | |
604 | #endif | |
605 | { | |
606 | if(a->GetNHits() < b->GetNHits()) return 1; | |
607 | if(a->GetNHits() > b->GetNHits()) return -1; | |
608 | } | |
609 | ||
610 | return 0; | |
611 | */ | |
612 | } | |
613 | ||
3cde846d | 614 | AliHLTTPCTrack* AliHLTTPCTrackArray::operator[](int index) |
615 | { | |
4fdaad1e | 616 | // access operator |
3cde846d | 617 | if (index<fNTracks) return fTrack[index]; |
618 | return NULL; | |
619 | } |