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