]>
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 | ||
febeb705 | 245 | int AliHLTTPCTrackArray::FillTracks(Int_t ntracks, AliHLTTPCTrackSegmentData* tr, Int_t slice, Int_t bTransform) |
a6c02c85 | 246 | { |
247 | //Read tracks from shared memory (or memory) | |
febeb705 | 248 | return FillTracksChecked(tr, ntracks, 0, slice, bTransform); |
249 | } | |
250 | ||
251 | int AliHLTTPCTrackArray::FillTracksChecked(AliHLTTPCTrackSegmentData* tr, Int_t ntracks, unsigned int sizeInByte, Int_t slice, Int_t bTransform) | |
252 | { | |
253 | //Read tracks from shared memory (or memory) | |
254 | int iResult=0; | |
a6c02c85 | 255 | AliHLTTPCTrackSegmentData *trs = tr; |
256 | for(Int_t i=0; i<ntracks; i++){ | |
febeb705 | 257 | if (sizeInByte>0 && |
258 | (((AliHLTUInt8_t*)trs)+sizeof(AliHLTTPCTrackSegmentData)>((AliHLTUInt8_t*)tr)+sizeInByte || | |
259 | ((AliHLTUInt8_t*)trs)+sizeof(AliHLTTPCTrackSegmentData)+trs->fNPoints*sizeof(UInt_t)>((AliHLTUInt8_t*)tr)+sizeInByte)) { | |
260 | iResult=-EDOM; | |
261 | break; | |
262 | } | |
a6c02c85 | 263 | AliHLTTPCTrack *track = NextTrack(); |
264 | track->SetPt(trs->fPt); | |
265 | track->SetPterr(trs->fPterr); | |
266 | Float_t psi[1]; | |
267 | psi[0]=trs->fPsi; | |
4fdaad1e | 268 | if (slice>=0 && bTransform!=0) { |
269 | AliHLTTPCTransform::Local2GlobalAngle(psi,slice); | |
270 | } | |
271 | //cout << "psi " << psi[0] << endl; | |
a6c02c85 | 272 | track->SetPsi(psi[0]); |
273 | track->SetTgl(trs->fTgl); | |
274 | track->SetPsierr(trs->fPsierr); | |
275 | track->SetTglerr(trs->fTglerr); | |
1ee9dca4 | 276 | track->SetY0err(trs->fY0err); |
277 | track->SetZ0err(trs->fZ0err); | |
a6c02c85 | 278 | track->SetNHits(trs->fNPoints); |
279 | track->SetCharge(trs->fCharge); | |
280 | Float_t first[3]; | |
281 | first[0]=trs->fX;first[1]=trs->fY;first[2]=trs->fZ; | |
4fdaad1e | 282 | if (slice>=0 && bTransform!=0) { |
283 | AliHLTTPCTransform::Local2Global(first,slice); | |
284 | } | |
285 | //cout << "first point: " << first[0] << " " << first[1] << " " << first[3] << endl; | |
a6c02c85 | 286 | track->SetFirstPoint(first[0],first[1],first[2]); |
287 | Float_t last[3]; | |
288 | last[0]=trs->fLastX;last[1]=trs->fLastY;last[2]=trs->fLastZ; | |
4fdaad1e | 289 | if (slice>=0 && bTransform!=0) { |
290 | AliHLTTPCTransform::Local2Global(last,slice); | |
291 | } | |
292 | //cout << "last point: " << last[0] << " " << last[1] << " " << last[3] << endl; | |
a6c02c85 | 293 | track->SetLastPoint(last[0],last[1],last[2]); |
294 | track->SetHits( trs->fNPoints, trs->fPointIDs ); | |
4fdaad1e | 295 | |
d53596be | 296 | //if (slice>=0 && bTransform!=0) { |
4e57c862 | 297 | // Matthias Feb07: as everything is now in global coordinates, sector should |
298 | // be set to 0. But as the display does a check on the sector, we have to set | |
299 | // it to the slice no. I suspect, that the transformation is done twice. | |
300 | //track->SetSector(0); | |
301 | track->SetSector(slice); | |
d53596be | 302 | //} else { |
4fdaad1e | 303 | // the parameters are in local coordinates, set the sector no |
312160d3 | 304 | //#ifndef INCLUDE_TPC_HOUGH |
d53596be | 305 | //if (slice<0) track->SetSector(0); |
306 | //else track->SetSector(slice); | |
312160d3 | 307 | //#else |
4fdaad1e | 308 | // Matthias Feb 2007: this is some kind of legacy ... |
309 | // the INCLUDE_TPC_HOUGH has never been switched on in the new TPCLib | |
310 | // and this line was below in the corresponding block. As the slice | |
311 | // parameter is very useful but not available if the define is off | |
312 | // we distinguish the two cases here. Should be cleaned up. | |
312160d3 | 313 | // Matthias April 2007: update, try to integrate Cvetans Hough tracker |
314 | // so we need the support for the AliHLTTPCHoughTrack. I dont have the | |
315 | // full control of this code (should we use slice or trs->fSector?) | |
316 | // But the FillTracks method is never called from the hough code, so we | |
317 | // take 'slice' | |
318 | if (GetTrackType()=='h') { | |
319 | AliErrorClassStream() << "FillTracks was never used with AliHLTTPCHoughTrack:" | |
320 | << " CHECK THIS CODE!!!" << endl; | |
321 | } | |
322 | //track->SetSector(trs->fSector); | |
323 | //#endif // INCLUDE_TPC_HOUGH | |
d53596be | 324 | //} |
21b6a334 | 325 | |
326 | // this is currently a quick hack for straight lines of the first version | |
327 | // of the CA tracker. | |
328 | // we have to think about a more general way of treating straight and curved | |
329 | // tracks | |
330 | if ( trs->fPt == -9876.0 || trs->fPt == -1.0) { | |
331 | track->SetPhi0(atan2(first[1],first[0])); | |
332 | track->SetKappa(1.0); | |
333 | track->SetRadius(999999.0); | |
334 | } else { | |
4e57c862 | 335 | // Matthias Feb07: just tried to take this away, but this causes the tracks |
336 | // in the display not to be drawn. But we still have to tink about this. | |
337 | track->CalculateHelix(); | |
21b6a334 | 338 | } |
339 | ||
a6c02c85 | 340 | #ifdef INCLUDE_TPC_HOUGH |
341 | #ifdef ROWHOUGHPARAMS | |
342 | if(GetTrackType()=='h') { | |
343 | ((AliHLTTPCHoughTrack *)track)->SetWeight(trs->fWeight); | |
344 | ((AliHLTTPCHoughTrack *)track)->SetBinXY(trs->fBinX,trs->fBinY,trs->fBinXSize,trs->fBinYSize); | |
345 | } | |
346 | track->SetMCid(trs->fTrackID); | |
347 | track->SetRowRange(trs->fRowRange1,trs->fRowRange2); | |
a6c02c85 | 348 | track->SetPID(trs->fPID); |
349 | #endif | |
350 | #endif // INCLUDE_TPC_HOUGH | |
351 | UChar_t *tmpP = (UChar_t*)trs; | |
352 | tmpP += sizeof(AliHLTTPCTrackSegmentData)+trs->fNPoints*sizeof(UInt_t); | |
353 | trs = (AliHLTTPCTrackSegmentData*)tmpP; | |
354 | } | |
febeb705 | 355 | |
356 | if (iResult==-EDOM) { | |
357 | // try to recover the version 1 struct | |
358 | Reset(); | |
359 | if ((iResult=FillTracksVersion1((AliHLTTPCTrackSegmentDataV1*)tr, ntracks, sizeInByte, slice, bTransform))>=0) { | |
360 | LOG(AliHLTTPCLog::kWarning,"AliHLTTPCTrackArray::FillTracks","") << "version 1 track array recoverd (deprecated since r27415)" << ENDLOG; | |
361 | } | |
362 | } | |
363 | if (iResult==-EDOM) { | |
364 | Reset(); | |
365 | LOG(AliHLTTPCLog::kError,"AliHLTTPCTrackArray::FillTracks","") << "corrupted input data array" << ENDLOG; | |
366 | } | |
367 | ||
368 | return iResult; | |
369 | } | |
370 | ||
371 | int AliHLTTPCTrackArray::FillTracksVersion1(AliHLTTPCTrackSegmentDataV1* tr, Int_t ntracks, unsigned int sizeInByte, Int_t slice, Int_t bTransform) | |
372 | { | |
373 | //Read tracks from shared memory (or memory) | |
374 | int iResult=0; | |
375 | AliHLTTPCTrackSegmentDataV1 *trs = tr; | |
376 | for(Int_t i=0; i<ntracks; i++){ | |
377 | if (sizeInByte>0 && | |
378 | (((AliHLTUInt8_t*)trs)+sizeof(AliHLTTPCTrackSegmentDataV1)>((AliHLTUInt8_t*)tr)+sizeInByte || | |
379 | ((AliHLTUInt8_t*)trs)+sizeof(AliHLTTPCTrackSegmentDataV1)+trs->fNPoints*sizeof(UInt_t)>((AliHLTUInt8_t*)tr)+sizeInByte)) { | |
380 | iResult=-EDOM; | |
381 | break; | |
382 | } | |
383 | AliHLTTPCTrack *track = NextTrack(); | |
384 | track->SetPt(trs->fPt); | |
385 | track->SetPterr(trs->fPterr); | |
386 | Float_t psi[1]; | |
387 | psi[0]=trs->fPsi; | |
388 | if (slice>=0 && bTransform!=0) { | |
389 | AliHLTTPCTransform::Local2GlobalAngle(psi,slice); | |
390 | } | |
391 | track->SetPsi(psi[0]); | |
392 | track->SetTgl(trs->fTgl); | |
393 | track->SetPsierr(trs->fPsierr); | |
394 | track->SetTglerr(trs->fTglerr); | |
395 | track->SetNHits(trs->fNPoints); | |
396 | track->SetCharge(trs->fCharge); | |
397 | Float_t first[3]; | |
398 | first[0]=trs->fX;first[1]=trs->fY;first[2]=trs->fZ; | |
399 | if (slice>=0 && bTransform!=0) { | |
400 | AliHLTTPCTransform::Local2Global(first,slice); | |
401 | } | |
402 | track->SetFirstPoint(first[0],first[1],first[2]); | |
403 | Float_t last[3]; | |
404 | last[0]=trs->fLastX;last[1]=trs->fLastY;last[2]=trs->fLastZ; | |
405 | if (slice>=0 && bTransform!=0) { | |
406 | AliHLTTPCTransform::Local2Global(last,slice); | |
407 | } | |
408 | track->SetLastPoint(last[0],last[1],last[2]); | |
409 | track->SetHits( trs->fNPoints, trs->fPointIDs ); | |
410 | ||
411 | track->SetSector(slice); | |
412 | if ( trs->fPt == -9876.0 || trs->fPt == -1.0) { | |
413 | track->SetPhi0(atan2(first[1],first[0])); | |
414 | track->SetKappa(1.0); | |
415 | track->SetRadius(999999.0); | |
416 | } else { | |
417 | track->CalculateHelix(); | |
418 | } | |
419 | ||
420 | UChar_t *tmpP = (UChar_t*)trs; | |
421 | tmpP += sizeof(AliHLTTPCTrackSegmentDataV1)+trs->fNPoints*sizeof(UInt_t); | |
422 | trs = (AliHLTTPCTrackSegmentDataV1*)tmpP; | |
423 | } | |
424 | return iResult; | |
a6c02c85 | 425 | } |
426 | ||
427 | UInt_t AliHLTTPCTrackArray::GetOutSize() | |
428 | { | |
429 | //get size for IO | |
430 | UInt_t count = GetOutCount(); //use only present tracks | |
431 | UInt_t tHits = 0; | |
432 | for(Int_t i=0;i<fNTracks;i++){ //loop over all tracks | |
433 | AliHLTTPCTrack *track = GetCheckedTrack(i); //use only present tracks | |
434 | if(track) //use only present tracks | |
435 | tHits += track->GetNHits(); | |
436 | } | |
437 | ||
438 | //calculate size of track | |
439 | return count*sizeof(AliHLTTPCTrackSegmentData)+sizeof(UInt_t)*tHits; | |
440 | } | |
441 | ||
442 | UInt_t AliHLTTPCTrackArray::WriteTracks(UInt_t & ntracks,AliHLTTPCTrackSegmentData* tr) | |
443 | { | |
444 | //write tracks | |
445 | ntracks = GetOutCount(); | |
446 | return WriteTracks(tr); | |
447 | } | |
448 | ||
449 | UInt_t AliHLTTPCTrackArray::WriteTracks(AliHLTTPCTrackSegmentData* tr) | |
450 | { | |
451 | //if(GetTrackType()=='c') return WriteConfMapTracks(tr); | |
452 | AliHLTTPCTrackSegmentData *tP = tr; | |
453 | UInt_t *pP; | |
454 | UInt_t size = 0; | |
455 | for(Int_t i=0; i<fNTracks; i++){ //loop over all tracks | |
456 | AliHLTTPCTrack *track = GetCheckedTrack(i); //use only present tracks | |
457 | if(!track) continue; //use only present tracks | |
458 | tP->fX = track->GetFirstPointX(); | |
459 | tP->fY = track->GetFirstPointY(); | |
460 | tP->fZ = track->GetFirstPointZ(); | |
461 | tP->fPt = track->GetPt(); | |
462 | tP->fPterr = track->GetPterr(); | |
463 | tP->fLastX = track->GetLastPointX(); | |
464 | tP->fLastY = track->GetLastPointY(); | |
465 | tP->fLastZ = track->GetLastPointZ(); | |
466 | tP->fPsi = track->GetPsi(); | |
467 | tP->fTgl = track->GetTgl(); | |
468 | tP->fPsierr = track->GetPsierr(); | |
469 | tP->fTglerr = track->GetTglerr(); | |
1ee9dca4 | 470 | tP->fY0err = track->GetY0err(); |
471 | tP->fZ0err = track->GetZ0err(); | |
a6c02c85 | 472 | tP->fCharge = track->GetCharge(); |
473 | tP->fNPoints = track->GetNHits(); | |
474 | #ifdef INCLUDE_TPC_HOUGH | |
475 | #ifdef ROWHOUGHPARAMS | |
476 | if(GetTrackType()=='h') { | |
477 | tP->fWeight = ((AliHLTTPCHoughTrack *)track)->GetWeight(); | |
478 | tP->fBinX = ((AliHLTTPCHoughTrack *)track)->GetBinX(); | |
479 | tP->fBinY = ((AliHLTTPCHoughTrack *)track)->GetBinY(); | |
480 | tP->fBinXSize = ((AliHLTTPCHoughTrack *)track)->GetSizeX(); | |
481 | tP->fBinYSize = ((AliHLTTPCHoughTrack *)track)->GetSizeY(); | |
482 | } | |
483 | tP->fTrackID = track->GetMCid(); | |
484 | tP->fRowRange1 = track->GetFirstRow(); | |
485 | tP->fRowRange2 = track->GetLastRow(); | |
486 | tP->fSector = track->GetSector(); | |
487 | tP->fPID = track->GetPID(); | |
488 | #endif | |
489 | #endif // INCLUDE_TPC_HOUGH | |
490 | pP = (UInt_t*)track->GetHitNumbers(); | |
491 | for (UInt_t j=0;j<tP->fNPoints;j++){ | |
492 | tP->fPointIDs[j] = pP[j]; | |
493 | } | |
494 | Byte_t *tmpP = (Byte_t *)tP; | |
495 | tmpP += sizeof(AliHLTTPCTrackSegmentData)+tP->fNPoints*sizeof(UInt_t); | |
496 | size += sizeof(AliHLTTPCTrackSegmentData)+tP->fNPoints*sizeof(UInt_t); | |
497 | tP = (AliHLTTPCTrackSegmentData*)tmpP; | |
738c049f | 498 | |
db16520a | 499 | // LOG(AliHLTTPCLog::kError,"AliHLTTPCTrackArray::WriteTracks","TRACKPARAMETER") <<ENDLOG; |
500 | // track->Rotate(0,kFALSE); | |
501 | // track->Print(); | |
738c049f | 502 | |
a6c02c85 | 503 | } |
504 | return size; | |
505 | } | |
506 | ||
507 | UInt_t AliHLTTPCTrackArray::WriteConfMapTracks(AliHLTTPCTrackSegmentData* tr) | |
508 | { | |
509 | // use first and last point objects | |
510 | AliHLTTPCTrackSegmentData *tP = tr; | |
511 | UInt_t *pP; | |
512 | UInt_t size = 0; | |
513 | for(Int_t i=0; i<fNTracks; i++){ //loop over all tracks | |
514 | AliHLTTPCConfMapTrack *track =(AliHLTTPCConfMapTrack *) GetCheckedTrack(i); //use only present tracks | |
515 | if(!track) continue; //use only present tracks | |
516 | AliHLTTPCConfMapPoint *hit = (AliHLTTPCConfMapPoint*)track->GetLastHit(); | |
517 | AliHLTTPCConfMapPoint *lastHit = (AliHLTTPCConfMapPoint*)track->GetFirstHit(); | |
518 | tP->fX = hit->GetX(); | |
519 | tP->fY = hit->GetY(); | |
520 | tP->fZ = hit->GetZ(); | |
521 | tP->fLastX = lastHit->GetX(); | |
522 | tP->fLastY = lastHit->GetY(); | |
523 | tP->fLastZ = lastHit->GetZ(); | |
524 | ||
525 | // tP->fX = track->GetFirstPointX(); | |
526 | // tP->fY = track->GetFirstPointY(); | |
527 | // tP->fZ = track->GetFirstPointZ(); | |
528 | tP->fPt = track->GetPt(); | |
529 | tP->fPterr = track->GetPterr(); | |
530 | // tP->fLastX = track->GetLastPointX(); | |
531 | // tP->fLastY = track->GetLastPointY(); | |
532 | // tP->fLastZ = track->GetLastPointZ(); | |
533 | tP->fPsi = track->GetPsi(); | |
534 | tP->fTgl = track->GetTgl(); | |
535 | tP->fPsierr = track->GetPsierr(); | |
536 | tP->fTglerr = track->GetTglerr(); | |
1ee9dca4 | 537 | tP->fY0err = track->GetY0err(); |
538 | tP->fZ0err = track->GetZ0err(); | |
a6c02c85 | 539 | tP->fCharge = track->GetCharge(); |
540 | #ifdef INCLUDE_TPC_HOUGH | |
541 | #ifdef ROWHOUGHPARAMS | |
542 | tP->fTrackID = track->GetMCid(); | |
543 | tP->fRowRange1 = track->GetFirstRow(); | |
544 | tP->fRowRange2 = track->GetLastRow(); | |
545 | tP->fSector = track->GetSector(); | |
546 | tP->fPID = track->GetPID(); | |
547 | #endif | |
548 | #endif // INCLUDE_TPC_HOUGH | |
549 | tP->fNPoints = track->GetNHits(); | |
550 | pP = (UInt_t*)track->GetHitNumbers(); | |
551 | for (UInt_t j=0;j<tP->fNPoints;j++){ | |
552 | tP->fPointIDs[j] = pP[j]; | |
553 | } | |
554 | Byte_t *tmpP = (Byte_t *)tP; | |
555 | tmpP += sizeof(AliHLTTPCTrackSegmentData)+tP->fNPoints*sizeof(UInt_t); | |
556 | size +=sizeof(AliHLTTPCTrackSegmentData)+tP->fNPoints*sizeof(UInt_t); | |
557 | tP = (AliHLTTPCTrackSegmentData*)tmpP; | |
558 | } | |
559 | return size; | |
560 | } | |
561 | ||
562 | void AliHLTTPCTrackArray::AddLast(AliHLTTPCTrack *track) | |
563 | { | |
564 | //add track to last position | |
565 | AliHLTTPCTrack *tpt = NextTrack(); | |
3cde846d | 566 | tpt->Copy(track); |
a6c02c85 | 567 | |
568 | } | |
569 | ||
570 | void AliHLTTPCTrackArray::AddTracks(AliHLTTPCTrackArray *newtrack,Bool_t remove_old,Int_t slice) | |
571 | { | |
572 | //add tracks | |
573 | if(GetTrackType() != newtrack->GetTrackType() && GetTrackType()!='t') | |
574 | { | |
575 | LOG(AliHLTTPCLog::kError,"AliHLTTPCTrackArray::AddTracks","Track types") | |
576 | <<"Bad idea to add tracks of different types"<<ENDLOG; | |
577 | return; | |
578 | } | |
579 | if(fSize < fNTracks+newtrack->GetNPresent()) | |
580 | SetSize(fSize+newtrack->GetSize()); | |
581 | for(Int_t i =0;i<newtrack->GetNTracks();i++){ | |
582 | AliHLTTPCTrack *tpt = newtrack->GetCheckedTrack(i); | |
583 | if(!tpt) continue; | |
584 | if(remove_old) | |
585 | newtrack->Remove(i); | |
586 | AliHLTTPCTrack *track = NextTrack(); | |
3cde846d | 587 | track->Copy(tpt); |
a6c02c85 | 588 | if(slice>=0) |
589 | track->Rotate(slice); //Rotate track to global coordinates | |
590 | /* | |
591 | AliHLTTPCTrack *track; | |
592 | #ifdef INCLUDE_TPC_HOUGH | |
593 | if(GetTrackType()=='h') | |
594 | track = (AliHLTTPCHoughTrack*)NextTrack(); | |
595 | else | |
596 | #endif | |
597 | track = NextTrack(); | |
3cde846d | 598 | track->Copy(tpt); |
a6c02c85 | 599 | */ |
600 | } | |
601 | } | |
602 | ||
603 | void AliHLTTPCTrackArray::Compress() | |
604 | { | |
605 | //compress array | |
606 | if(GetNPresent()==GetNTracks()) return; | |
607 | AliHLTTPCTrack **tmp = new AliHLTTPCTrack *[fNTracks]; | |
608 | Int_t present=0; | |
609 | Int_t absent=GetNPresent(); | |
610 | for(Int_t i=0;i<GetNTracks();i++){ | |
611 | if(fIsPresent[i]) tmp[present++] = fTrack[i]; | |
612 | else tmp[absent++] = fTrack[i]; | |
613 | } | |
614 | for(Int_t i=0;i<GetNTracks();i++) | |
615 | fIsPresent[i]=kTRUE; | |
616 | ||
617 | //Copy pointers back | |
618 | for(Int_t i=0; i<GetNTracks();i++){ | |
619 | fTrack[i]=tmp[i]; | |
620 | } | |
621 | ||
622 | delete[] tmp; | |
623 | ||
624 | fNTracks = GetNPresent(); | |
625 | fNAbsent = 0; | |
626 | } | |
627 | ||
628 | void AliHLTTPCTrackArray::QSort() | |
629 | { | |
630 | // compress and sort | |
631 | Compress(); | |
632 | QSort(fTrack,0,fNTracks); | |
633 | } | |
634 | ||
635 | void AliHLTTPCTrackArray::QSort( AliHLTTPCTrack **a, Int_t first, Int_t last) | |
636 | { | |
637 | // Sort array of AliHLTTPCTrack pointers using a quicksort algorithm. | |
638 | // Uses TrackCompare() to compare objects. | |
639 | // Thanks to Root! | |
640 | ||
641 | static AliHLTTPCTrack *tmp; | |
642 | static int i; // "static" to save stack space | |
643 | int j; | |
644 | ||
645 | while (last - first > 1) { | |
646 | i = first; | |
647 | j = last; | |
648 | for (;;) { | |
649 | while (++i < last && TrackCompare(a[i], a[first]) < 0) | |
650 | ; | |
651 | while (--j > first && TrackCompare(a[j], a[first]) > 0) | |
652 | ; | |
653 | if (i >= j) | |
654 | break; | |
655 | ||
656 | tmp = a[i]; | |
657 | a[i] = a[j]; | |
658 | a[j] = tmp; | |
659 | } | |
660 | if (j == first) { | |
661 | ++first; | |
662 | continue; | |
663 | } | |
664 | tmp = a[first]; | |
665 | a[first] = a[j]; | |
666 | a[j] = tmp; | |
667 | if (j - first < last - (j + 1)) { | |
668 | QSort(a, first, j); | |
669 | first = j + 1; // QSort(j + 1, last); | |
670 | } else { | |
671 | QSort(a, j + 1, last); | |
672 | last = j; // QSort(first, j); | |
673 | } | |
674 | } | |
675 | } | |
676 | ||
677 | Int_t AliHLTTPCTrackArray::TrackCompare(AliHLTTPCTrack *a, AliHLTTPCTrack *b) const | |
678 | { | |
679 | // Compare the two tracks. | |
680 | ||
681 | return b->Compare(a); | |
682 | ||
683 | /* | |
684 | #ifdef INCLUDE_TPC_HOUGH | |
685 | if(fTrackType=='h') | |
686 | { | |
687 | AliHLTTPCHoughTrack *tra = (AliHLTTPCHoughTrack*)a; | |
688 | AliHLTTPCHoughTrack *trb = (AliHLTTPCHoughTrack*)b; | |
689 | if(tra->GetWeight() < trb->GetWeight()) return 1; | |
690 | if(tra->GetWeight() > trb->GetWeight()) return -1; | |
691 | } | |
692 | else | |
693 | #endif | |
694 | { | |
695 | if(a->GetNHits() < b->GetNHits()) return 1; | |
696 | if(a->GetNHits() > b->GetNHits()) return -1; | |
697 | } | |
698 | ||
699 | return 0; | |
700 | */ | |
701 | } | |
702 | ||
3cde846d | 703 | AliHLTTPCTrack* AliHLTTPCTrackArray::operator[](int index) |
704 | { | |
4fdaad1e | 705 | // access operator |
3cde846d | 706 | if (index<fNTracks) return fTrack[index]; |
707 | return NULL; | |
708 | } |