]>
Commit | Line | Data |
---|---|---|
d54804bf | 1 | // $Id$ |
2 | //*************************************************************************** | |
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. * | |
17 | //*************************************************************************** | |
18 | ||
19 | #include "AliHLTTPCCAGBTracker.h" | |
20 | #include "AliHLTTPCCAGBHit.h" | |
21 | #include "AliHLTTPCCAOutTrack.h" | |
22 | #include "AliHLTTPCCATracker.h" | |
23 | #include "AliHLTTPCCAGBTrack.h" | |
00d07bcd | 24 | #include "AliHLTTPCCATrackParam.h" |
d54804bf | 25 | |
00d07bcd | 26 | #include "AliHLTTPCCAMath.h" |
d54804bf | 27 | #include "TStopwatch.h" |
00d07bcd | 28 | #include <iostream.h> |
d54804bf | 29 | |
30 | //#define DRAW | |
31 | ||
32 | #ifdef DRAW | |
33 | #include "AliHLTTPCCADisplay.h" | |
34 | #include "TApplication.h" | |
35 | #endif //DRAW | |
36 | ||
d54804bf | 37 | |
38 | AliHLTTPCCAGBTracker::AliHLTTPCCAGBTracker() | |
00d07bcd | 39 | : |
d54804bf | 40 | fSlices(0), |
41 | fNSlices(0), | |
42 | fHits(0), | |
43 | fNHits(0), | |
44 | fTrackHits(0), | |
45 | fTracks(0), | |
46 | fNTracks(0), | |
47 | fSliceTrackInfos(0), | |
eb30eb49 | 48 | fTime(0), |
d54804bf | 49 | fStatNEvents(0) |
50 | { | |
51 | //* constructor | |
eb30eb49 | 52 | for( Int_t i=0; i<20; i++ ) fStatTime[i] = 0; |
d54804bf | 53 | } |
54 | ||
55 | AliHLTTPCCAGBTracker::AliHLTTPCCAGBTracker(const AliHLTTPCCAGBTracker&) | |
00d07bcd | 56 | : |
d54804bf | 57 | fSlices(0), |
58 | fNSlices(0), | |
59 | fHits(0), | |
60 | fNHits(0), | |
61 | fTrackHits(0), | |
62 | fTracks(0), | |
63 | fNTracks(0), | |
64 | fSliceTrackInfos(0), | |
eb30eb49 | 65 | fTime(0), |
d54804bf | 66 | fStatNEvents(0) |
67 | { | |
68 | //* dummy | |
69 | } | |
70 | ||
71 | AliHLTTPCCAGBTracker &AliHLTTPCCAGBTracker::operator=(const AliHLTTPCCAGBTracker&) | |
72 | { | |
73 | //* dummy | |
74 | return *this; | |
75 | } | |
76 | ||
77 | AliHLTTPCCAGBTracker::~AliHLTTPCCAGBTracker() | |
78 | { | |
79 | //* destructor | |
80 | StartEvent(); | |
81 | if( fSliceTrackInfos ) delete[] fSliceTrackInfos; | |
82 | fSliceTrackInfos = 0; | |
83 | if( fSlices ) delete[] fSlices; | |
84 | fSlices=0; | |
85 | } | |
86 | ||
87 | void AliHLTTPCCAGBTracker::SetNSlices( Int_t N ) | |
88 | { | |
89 | //* set N of slices | |
90 | StartEvent(); | |
91 | fNSlices = N; | |
92 | if( fSliceTrackInfos ) delete[] fSliceTrackInfos; | |
93 | fSliceTrackInfos = 0; | |
94 | if( fSlices ) delete[] fSlices; | |
95 | fSlices=0; | |
96 | fSlices = new AliHLTTPCCATracker[N]; | |
97 | fSliceTrackInfos = new AliHLTTPCCAGBSliceTrackInfo *[N]; | |
98 | for( Int_t iSlice=0; iSlice<fNSlices; iSlice++ ){ | |
99 | fSliceTrackInfos[iSlice] = 0; | |
100 | } | |
101 | } | |
102 | ||
103 | void AliHLTTPCCAGBTracker::StartEvent() | |
104 | { | |
105 | //* clean up track and hit arrays | |
106 | ||
107 | if( fSliceTrackInfos ){ | |
108 | for( Int_t iSlice=0; iSlice<fNSlices; iSlice++ ){ | |
109 | if( fSliceTrackInfos[iSlice] ) delete[] fSliceTrackInfos[iSlice]; | |
110 | fSliceTrackInfos[iSlice] = 0; | |
111 | } | |
112 | } | |
113 | if( fTrackHits ) delete[] fTrackHits; | |
114 | fTrackHits = 0; | |
115 | if( fTracks ) delete[] fTracks; | |
116 | fTracks = 0; | |
117 | if( fHits ) delete[] fHits; | |
118 | fHits=0; | |
119 | fNHits = 0; | |
120 | fNTracks = 0; | |
121 | for( int i=0; i<fNSlices; i++) fSlices[i].StartEvent(); | |
122 | } | |
123 | ||
124 | ||
125 | void AliHLTTPCCAGBTracker::SetNHits( Int_t nHits ) | |
126 | { | |
127 | //* set the number of hits | |
128 | if( fHits ) delete[] fHits; | |
129 | fHits = 0; | |
130 | fHits = new AliHLTTPCCAGBHit[ nHits ]; | |
131 | fNHits = 0; | |
132 | } | |
133 | ||
eb30eb49 | 134 | void AliHLTTPCCAGBTracker::ReadHit( Float_t x, Float_t y, Float_t z, |
135 | Float_t errY, Float_t errZ, Float_t amp, | |
d54804bf | 136 | Int_t ID, Int_t iSlice, Int_t iRow ) |
137 | { | |
138 | //* read the hit to local array | |
139 | AliHLTTPCCAGBHit &hit = fHits[fNHits]; | |
140 | hit.X() = x; | |
141 | hit.Y() = y; | |
142 | hit.Z() = z; | |
143 | hit.ErrX() = 1.e-4;//fSlices[iSlice].Param().ErrX(); | |
144 | hit.ErrY() = errY; | |
145 | hit.ErrZ() = errZ; | |
eb30eb49 | 146 | hit.Amp() = amp; |
d54804bf | 147 | hit.ID() = ID; |
148 | hit.ISlice()=iSlice; | |
149 | hit.IRow() = iRow; | |
150 | hit.IsUsed() = 0; | |
d54804bf | 151 | fNHits++; |
152 | } | |
153 | ||
154 | void AliHLTTPCCAGBTracker::FindTracks() | |
155 | { | |
156 | //* main tracking routine | |
eb30eb49 | 157 | fTime = 0; |
00d07bcd | 158 | fStatNEvents++; |
d54804bf | 159 | #ifdef DRAW |
160 | if( fStatNEvents<=1 ){ | |
161 | if( !gApplication ){ | |
162 | TApplication *myapp = new TApplication("myapp",0,0); | |
163 | } | |
164 | AliHLTTPCCADisplay::Instance().Init(); | |
165 | } | |
166 | AliHLTTPCCADisplay::Instance().SetSliceView(); | |
167 | //AliHLTTPCCADisplay::Instance().SetTPCView(); | |
168 | //AliHLTTPCCADisplay::Instance().DrawTPC(); | |
00d07bcd | 169 | #endif //DRAW |
d54804bf | 170 | |
171 | if( fNHits<=0 ) return; | |
172 | ||
00d07bcd | 173 | std::sort(fHits,fHits+fNHits, AliHLTTPCCAGBHit::Compare ); |
d54804bf | 174 | |
175 | // Read hits, row by row | |
176 | ||
d54804bf | 177 | int nHitsTotal = fNHits; |
00d07bcd | 178 | Float_t *hitY = new Float_t [nHitsTotal]; |
179 | Float_t *hitZ = new Float_t [nHitsTotal]; | |
180 | ||
181 | Int_t sliceNHits[fNSlices]; | |
182 | Int_t rowNHits[fNSlices][200]; | |
d54804bf | 183 | |
00d07bcd | 184 | for( Int_t is=0; is<fNSlices; is++ ){ |
185 | sliceNHits[is] = 0; | |
186 | for( Int_t ir=0; ir<200; ir++ ) rowNHits[is][ir] = 0; | |
187 | } | |
188 | ||
d54804bf | 189 | for( int ih=0; ih<nHitsTotal; ih++){ |
00d07bcd | 190 | AliHLTTPCCAGBHit &h = fHits[ih]; |
191 | sliceNHits[h.ISlice()]++; | |
192 | rowNHits[h.ISlice()][h.IRow()]++; | |
193 | } | |
194 | ||
195 | Int_t firstSliceHit = 0; | |
196 | for( Int_t is=0; is<fNSlices; is++ ){ | |
197 | fFirstSliceHit[is] = firstSliceHit; | |
198 | Int_t rowFirstHits[200]; | |
199 | Int_t firstRowHit = 0; | |
200 | for( Int_t ir=0; ir<200; ir++ ){ | |
201 | rowFirstHits[ir] = firstRowHit; | |
202 | for( Int_t ih=0; ih<rowNHits[is][ir]; ih++){ | |
203 | AliHLTTPCCAGBHit &h = fHits[firstSliceHit + firstRowHit + ih]; | |
204 | hitY[firstRowHit + ih] = h.Y(); | |
205 | hitZ[firstRowHit + ih] = h.Z(); | |
d54804bf | 206 | } |
00d07bcd | 207 | firstRowHit+=rowNHits[is][ir]; |
d54804bf | 208 | } |
00d07bcd | 209 | //if( is==24 ){//SG!!! |
210 | fSlices[is].ReadEvent( rowFirstHits, rowNHits[is], hitY, hitZ, sliceNHits[is] ); | |
211 | //} | |
212 | firstSliceHit+=sliceNHits[is]; | |
d54804bf | 213 | } |
d54804bf | 214 | |
00d07bcd | 215 | |
216 | delete[] hitY; | |
217 | delete[] hitZ; | |
218 | ||
219 | TStopwatch timer1; | |
220 | TStopwatch timer2; | |
221 | //cout<<"Start CA reconstruction"<<endl; | |
d54804bf | 222 | for( int iSlice=0; iSlice<fNSlices; iSlice++ ){ |
223 | TStopwatch timer; | |
224 | AliHLTTPCCATracker &slice = fSlices[iSlice]; | |
225 | slice.Reconstruct(); | |
226 | timer.Stop(); | |
00d07bcd | 227 | //fTime+= timer.CpuTime(); |
228 | //blaTime+= timer.CpuTime(); | |
d54804bf | 229 | fStatTime[0] += timer.CpuTime(); |
230 | fStatTime[1]+=slice.Timers()[0]; | |
231 | fStatTime[2]+=slice.Timers()[1]; | |
232 | fStatTime[3]+=slice.Timers()[2]; | |
233 | fStatTime[4]+=slice.Timers()[3]; | |
234 | fStatTime[5]+=slice.Timers()[4]; | |
235 | fStatTime[6]+=slice.Timers()[5]; | |
236 | fStatTime[7]+=slice.Timers()[6]; | |
eb30eb49 | 237 | fStatTime[8]+=slice.Timers()[7]; |
d54804bf | 238 | } |
00d07bcd | 239 | |
240 | timer2.Stop(); | |
241 | //cout<<"blaTime = "<<timer2.CpuTime()*1.e3<<endl; | |
242 | ||
d54804bf | 243 | for( Int_t iSlice=0; iSlice<fNSlices; iSlice++ ){ |
244 | AliHLTTPCCATracker &iS = fSlices[iSlice]; | |
245 | if( fSliceTrackInfos[iSlice] ) delete[] fSliceTrackInfos[iSlice]; | |
246 | fSliceTrackInfos[iSlice]=0; | |
247 | int iNTracks = iS.NOutTracks(); | |
248 | fSliceTrackInfos[iSlice] = new AliHLTTPCCAGBSliceTrackInfo[iNTracks]; | |
249 | for( Int_t itr=0; itr<iNTracks; itr++ ){ | |
250 | fSliceTrackInfos[iSlice][itr].fPrevNeighbour = -1; | |
251 | fSliceTrackInfos[iSlice][itr].fNextNeighbour = -1; | |
252 | fSliceTrackInfos[iSlice][itr].fUsed = 0; | |
253 | } | |
254 | } | |
255 | ||
256 | //cout<<"Start CA merging"<<endl; | |
257 | TStopwatch timerMerge; | |
258 | Merging(); | |
259 | timerMerge.Stop(); | |
eb30eb49 | 260 | fStatTime[9]+=timerMerge.CpuTime(); |
00d07bcd | 261 | //fTime+=timerMerge.CpuTime(); |
d54804bf | 262 | //cout<<"End CA merging"<<endl; |
00d07bcd | 263 | timer1.Stop(); |
264 | fTime+= timer1.CpuTime(); | |
d54804bf | 265 | |
266 | #ifdef DRAW | |
267 | AliHLTTPCCADisplay::Instance().Ask(); | |
268 | #endif //DRAW | |
269 | } | |
270 | ||
271 | void AliHLTTPCCAGBTracker::Merging() | |
272 | { | |
273 | //* track merging between slices | |
274 | ||
eb30eb49 | 275 | Float_t dalpha = fSlices[1].Param().Alpha() - fSlices[0].Param().Alpha(); |
276 | Int_t nextSlice[100], prevSlice[100]; | |
277 | for( Int_t iSlice=0; iSlice<fNSlices; iSlice++ ){ | |
278 | nextSlice[iSlice] = iSlice + 1; | |
279 | prevSlice[iSlice] = iSlice - 1; | |
280 | } | |
281 | nextSlice[ fNSlices/2 - 1 ] = 0; | |
282 | prevSlice[ 0 ] = fNSlices/2 - 1; | |
283 | nextSlice[ fNSlices - 1 ] = fNSlices/2; | |
284 | prevSlice[ fNSlices/2 ] = fNSlices - 1; | |
285 | ||
286 | TStopwatch timerMerge1; | |
287 | ||
d54804bf | 288 | Int_t maxNSliceTracks = 0; |
289 | for( Int_t iSlice=0; iSlice<fNSlices; iSlice++ ){ | |
290 | AliHLTTPCCATracker &iS = fSlices[iSlice]; | |
291 | if( maxNSliceTracks < iS.NOutTracks() ) maxNSliceTracks = iS.NOutTracks(); | |
292 | } | |
293 | ||
294 | //* arrays for rotated track parameters | |
295 | ||
296 | AliHLTTPCCATrackParam *iTrParams[2], *jTrParams[2]; | |
297 | Bool_t *iOK[2], *jOK[2]; | |
298 | for( int i=0; i<2; i++ ){ | |
299 | iTrParams[i] = new AliHLTTPCCATrackParam[maxNSliceTracks]; | |
300 | jTrParams[i] = new AliHLTTPCCATrackParam[maxNSliceTracks]; | |
301 | iOK[i] = new Bool_t [maxNSliceTracks]; | |
302 | jOK[i] = new Bool_t [maxNSliceTracks]; | |
303 | } | |
304 | ||
305 | for( Int_t iSlice=0; iSlice<fNSlices; iSlice++ ){ | |
eb30eb49 | 306 | //cout<<"\nMerge slice "<<iSlice<<endl<<endl; |
d54804bf | 307 | AliHLTTPCCATracker &iS = fSlices[iSlice]; |
eb30eb49 | 308 | Int_t jSlice = nextSlice[iSlice]; |
d54804bf | 309 | AliHLTTPCCATracker &jS = fSlices[jSlice]; |
310 | int iNTracks = iS.NOutTracks(); | |
311 | int jNTracks = jS.NOutTracks(); | |
312 | if( iNTracks<=0 || jNTracks<=0 ) continue; | |
313 | ||
314 | //* prepare slice tracks for merging | |
315 | ||
316 | for (Int_t itr=0; itr<iNTracks; itr++) { | |
317 | iOK[0][itr] = 0; | |
318 | iOK[1][itr] = 0; | |
eb30eb49 | 319 | if( iS.OutTracks()[itr].NHits()<10 ) continue; |
d54804bf | 320 | AliHLTTPCCATrackParam &iT1 = iTrParams[0][itr]; |
321 | AliHLTTPCCATrackParam &iT2 = iTrParams[1][itr]; | |
322 | iT1 = iS.OutTracks()[itr].StartPoint(); | |
323 | iT2 = iS.OutTracks()[itr].EndPoint(); | |
00d07bcd | 324 | iOK[0][itr] = iT1.Rotate( dalpha/2 - CAMath::Pi()/2 ); |
325 | iOK[1][itr] = iT2.Rotate( dalpha/2 - CAMath::Pi()/2 ); | |
d54804bf | 326 | |
327 | if( iOK[0][itr] ){ | |
00d07bcd | 328 | iOK[0][itr] = iT1.TransportToX( 0, .99 ); |
d54804bf | 329 | if( iS.Param().RMin() > iT1.Y() || iS.Param().RMax() < iT1.Y() ) iOK[0][itr]=0; |
330 | } | |
331 | if( iOK[1][itr] ){ | |
00d07bcd | 332 | iOK[1][itr] = iT2.TransportToX( 0, .99 ); |
d54804bf | 333 | if( iS.Param().RMin() > iT2.Y() || iS.Param().RMax() < iT2.Y() ) iOK[1][itr]=0; |
334 | } | |
335 | } | |
336 | ||
337 | for (Int_t jtr=0; jtr<jNTracks; jtr++) { | |
338 | jOK[0][jtr] = 0; | |
339 | jOK[1][jtr] = 0; | |
eb30eb49 | 340 | if( jS.OutTracks()[jtr].NHits()<10 ) continue; |
d54804bf | 341 | AliHLTTPCCATrackParam &jT1 = jTrParams[0][jtr]; |
342 | AliHLTTPCCATrackParam &jT2 = jTrParams[1][jtr]; | |
343 | jT1 = jS.OutTracks()[jtr].StartPoint(); | |
344 | jT2 = jS.OutTracks()[jtr].EndPoint(); | |
00d07bcd | 345 | jOK[0][jtr] = jT1.Rotate( -dalpha/2 - CAMath::Pi()/2 ); |
346 | jOK[1][jtr] = jT2.Rotate( -dalpha/2 - CAMath::Pi()/2 ); | |
d54804bf | 347 | if( jOK[0][jtr] ){ |
00d07bcd | 348 | jOK[0][jtr] = jT1.TransportToX( 0, .99 ); |
d54804bf | 349 | if( jS.Param().RMin() > jT1.Y() || jS.Param().RMax() < jT1.Y() ) jOK[0][jtr]=0; |
350 | } | |
351 | if( jOK[1][jtr] ){ | |
00d07bcd | 352 | jOK[1][jtr] = jT2.TransportToX( 0, .99 ); |
d54804bf | 353 | if( jS.Param().RMin() > jT2.Y() || jS.Param().RMax() < jT2.Y() ) jOK[1][jtr]=0; |
354 | } | |
355 | } | |
356 | ||
357 | //* start merging | |
eb30eb49 | 358 | //cout<<"Start slice merging.."<<endl; |
d54804bf | 359 | for (Int_t itr=0; itr<iNTracks; itr++) { |
360 | if( !iOK[0][itr] && !iOK[1][itr] ) continue; | |
361 | Int_t jBest = -1; | |
362 | Int_t lBest = 0; | |
363 | for (Int_t jtr=0; jtr<jNTracks; jtr++) { | |
364 | if( jS.OutTracks()[jtr].NHits() < lBest ) continue; | |
365 | if( !jOK[0][jtr] && !jOK[1][jtr] ) continue; | |
366 | for( Int_t ip=0; ip<2 && (jBest!=jtr) ; ip++ ){ | |
367 | if( !iOK[ip][itr] ) continue; | |
368 | for( Int_t jp=0; jp<2 && (jBest!=jtr) ; jp++ ){ | |
369 | if( !jOK[jp][jtr] ) continue; | |
370 | AliHLTTPCCATrackParam &iT = iTrParams[ip][itr]; | |
371 | AliHLTTPCCATrackParam &jT = jTrParams[jp][jtr]; | |
372 | // check for neighbouring | |
373 | { | |
374 | Float_t factor2 = 3.5*3.5; | |
375 | float d = jT.GetY() - iT.GetY(); | |
376 | float s2 = jT.GetErr2Y() + iT.GetErr2Y(); | |
377 | if( d*d>factor2*s2 ){ | |
378 | continue; | |
379 | } | |
380 | d = jT.GetZ() - iT.GetZ(); | |
381 | s2 = jT.GetErr2Z() + iT.GetErr2Z(); | |
382 | if( d*d>factor2*s2 ){ | |
383 | continue; | |
384 | } | |
385 | Bool_t ok = 1; | |
386 | { // phi, kappa, DsDz signs are the same | |
387 | d = jT.GetSinPhi() - iT.GetSinPhi(); | |
388 | s2 = jT.GetErr2SinPhi() + iT.GetErr2SinPhi(); | |
389 | if( d*d>factor2*s2 ) ok = 0; | |
390 | d = jT.GetKappa() - iT.GetKappa(); | |
391 | s2 = jT.GetErr2Kappa() + iT.GetErr2Kappa(); | |
392 | if( d*d>factor2*s2 ) ok = 0; | |
393 | d = jT.GetDzDs() - iT.GetDzDs(); | |
394 | s2 = jT.GetErr2DzDs() + iT.GetErr2DzDs(); | |
395 | if( d*d>factor2*s2 ) ok = 0; | |
396 | } | |
397 | if( !ok ){ // phi, kappa, DsDz signs are the different | |
398 | d = jT.GetSinPhi() + iT.GetSinPhi(); | |
399 | s2 = jT.GetErr2SinPhi() + iT.GetErr2SinPhi(); | |
400 | if( d*d>factor2*s2 ) continue; | |
401 | d = jT.GetKappa() + iT.GetKappa(); | |
402 | s2 = jT.GetErr2Kappa() + iT.GetErr2Kappa(); | |
403 | if( d*d>factor2*s2 ) continue; | |
404 | d = jT.GetDzDs() + iT.GetDzDs(); | |
405 | s2 = jT.GetErr2DzDs() + iT.GetErr2DzDs(); | |
406 | if( d*d>factor2*s2 ) continue; | |
407 | } | |
408 | // tracks can be matched | |
409 | ||
410 | lBest = jS.OutTracks()[jtr].NHits(); | |
411 | jBest = jtr; | |
412 | } | |
413 | } | |
414 | } | |
415 | } | |
416 | if( jBest>=0 ){ | |
417 | Int_t oldi = fSliceTrackInfos[jSlice][jBest].fPrevNeighbour; | |
418 | if( oldi >= 0 ){ | |
419 | if( iS.OutTracks()[ oldi ].NHits() < iS.OutTracks()[ itr ].NHits() ){ | |
420 | fSliceTrackInfos[jSlice][jBest].fPrevNeighbour = -1; | |
421 | fSliceTrackInfos[iSlice][oldi].fNextNeighbour = -1; | |
422 | } else continue; | |
423 | } | |
eb30eb49 | 424 | //SG!!! |
d54804bf | 425 | fSliceTrackInfos[iSlice][itr].fNextNeighbour = jBest; |
426 | fSliceTrackInfos[jSlice][jBest].fPrevNeighbour = itr; | |
427 | } | |
428 | } | |
429 | } | |
430 | ||
431 | for( Int_t i=0; i<2; i++){ | |
432 | if( iTrParams[i] ) delete[] iTrParams[i]; | |
433 | if( jTrParams[i] ) delete[] jTrParams[i]; | |
434 | if( iOK[i] ) delete[] iOK[i]; | |
435 | if( jOK[i] ) delete[] jOK[i]; | |
436 | } | |
00d07bcd | 437 | |
eb30eb49 | 438 | timerMerge1.Stop(); |
439 | fStatTime[10]+=timerMerge1.CpuTime(); | |
440 | ||
441 | TStopwatch timerMerge2; | |
d54804bf | 442 | |
443 | Int_t nTracksTot = 0; | |
444 | for( Int_t iSlice = 0; iSlice<fNSlices; iSlice++ ){ | |
445 | AliHLTTPCCATracker &slice = fSlices[iSlice]; | |
446 | nTracksTot+= slice.NOutTracks(); | |
447 | } | |
448 | ||
449 | if( fTrackHits ) delete[] fTrackHits; | |
450 | fTrackHits = 0; | |
451 | if(fTracks ) delete[] fTracks; | |
452 | fTracks = 0; | |
453 | fTrackHits = new Int_t [fNHits*10]; | |
454 | fTracks = new AliHLTTPCCAGBTrack[nTracksTot]; | |
455 | fNTracks = 0; | |
456 | ||
457 | Int_t nTrackHits = 0; | |
458 | ||
eb30eb49 | 459 | //cout<<"\nStart global track creation...\n"<<endl; |
460 | ||
461 | static int nRejected = 0; | |
462 | ||
463 | Int_t maxNRows = fSlices[0].Param().NRows(); | |
464 | ||
d54804bf | 465 | for( Int_t iSlice = 0; iSlice<fNSlices; iSlice++ ){ |
466 | ||
467 | AliHLTTPCCATracker &slice = fSlices[iSlice]; | |
468 | for( Int_t itr=0; itr<slice.NOutTracks(); itr++ ){ | |
469 | if( fSliceTrackInfos[iSlice][itr].fUsed ) continue; | |
eb30eb49 | 470 | //cout<<"\n slice "<<iSlice<<", track "<<itr<<"\n"<<endl; |
4646c6e3 | 471 | //AliHLTTPCCAOutTrack &tCA = slice.OutTracks()[itr]; |
d54804bf | 472 | AliHLTTPCCAGBTrack &t = fTracks[fNTracks]; |
eb30eb49 | 473 | //t.Param() = tCA.StartPoint(); |
474 | //t.Alpha() = slice.Param().Alpha(); | |
d54804bf | 475 | t.NHits() = 0; |
476 | t.FirstHitRef() = nTrackHits; | |
eb30eb49 | 477 | |
478 | struct FitPoint{ | |
479 | Int_t fISlice; | |
480 | Int_t fHitID; | |
481 | Float_t fX, fY, fZ, fErr2Y, fErr2Z, fAmp; | |
482 | } fitPoints[300]; | |
483 | for( Int_t i=0; i<maxNRows; i++ ) fitPoints[i].fISlice = -1; | |
484 | ||
485 | Int_t nHits = 0; | |
d54804bf | 486 | Int_t jSlice = iSlice; |
487 | Int_t jtr = itr; | |
eb30eb49 | 488 | do{ |
d54804bf | 489 | if( fSliceTrackInfos[jSlice][jtr].fUsed ) break; |
490 | fSliceTrackInfos[jSlice][jtr].fUsed = 1; | |
eb30eb49 | 491 | AliHLTTPCCATracker &jslice = fSlices[jSlice]; |
492 | AliHLTTPCCAOutTrack &jTr = jslice.OutTracks()[jtr]; | |
d54804bf | 493 | for( int jhit=0; jhit<jTr.NHits(); jhit++){ |
00d07bcd | 494 | int id = fFirstSliceHit[jSlice] + jslice.OutTrackHits()[jTr.FirstHitRef()+jhit]; |
eb30eb49 | 495 | AliHLTTPCCAGBHit &h = fHits[id]; |
496 | FitPoint &p = fitPoints[h.IRow()]; | |
497 | if( p.fISlice >=0 ) continue; | |
498 | p.fISlice = h.ISlice(); | |
499 | p.fHitID = id; | |
500 | p.fX = jslice.Rows()[h.IRow()].X(); | |
501 | p.fY = h.Y(); | |
502 | p.fZ = h.Z(); | |
00d07bcd | 503 | //p.fErr2Y = h.ErrY()*h.ErrY(); |
504 | //p.fErr2Z = h.ErrZ()*h.ErrZ(); | |
eb30eb49 | 505 | p.fAmp = h.Amp(); |
506 | nHits++; | |
d54804bf | 507 | } |
eb30eb49 | 508 | jtr = fSliceTrackInfos[jSlice][jtr].fNextNeighbour; |
509 | jSlice = nextSlice[jSlice]; | |
510 | } while( jtr >=0 ); | |
511 | ||
00d07bcd | 512 | if( nHits < 10 ) continue; //SG!!! |
eb30eb49 | 513 | |
514 | Int_t firstRow = 0, lastRow = maxNRows-1; | |
515 | for( firstRow=0; firstRow<maxNRows; firstRow++ ){ | |
516 | if( fitPoints[firstRow].fISlice>=0 ) break; | |
517 | } | |
518 | for( lastRow=maxNRows-1; lastRow>=0; lastRow-- ){ | |
519 | if( fitPoints[lastRow].fISlice>=0 ) break; | |
d54804bf | 520 | } |
eb30eb49 | 521 | Int_t mmidRow = (firstRow + lastRow )/2; |
522 | Int_t midRow = firstRow; | |
523 | for( Int_t i=firstRow+1; i<=lastRow; i++ ){ | |
524 | if( fitPoints[i].fISlice<0 ) continue; | |
00d07bcd | 525 | if( CAMath::Abs(i-mmidRow)>=CAMath::Abs(midRow-mmidRow) ) continue; |
eb30eb49 | 526 | midRow = i; |
527 | } | |
528 | if( midRow==firstRow || midRow==lastRow ) continue; | |
529 | ||
530 | Int_t searchRows[300]; | |
531 | Int_t nSearchRows = 0; | |
d54804bf | 532 | |
eb30eb49 | 533 | for( Int_t i=firstRow; i<=lastRow; i++ ) searchRows[nSearchRows++] = i; |
534 | for( Int_t i=lastRow+1; i<maxNRows; i++ ) searchRows[nSearchRows++] = i; | |
535 | for( Int_t i=firstRow-1; i>=0; i-- ) searchRows[nSearchRows++] = i; | |
536 | ||
d54804bf | 537 | // refit |
d54804bf | 538 | |
eb30eb49 | 539 | AliHLTTPCCATrackParam t0; |
d54804bf | 540 | |
eb30eb49 | 541 | { |
d54804bf | 542 | |
00d07bcd | 543 | { |
eb30eb49 | 544 | FitPoint &p0 = fitPoints[firstRow]; |
545 | FitPoint &p1 = fitPoints[midRow]; | |
546 | FitPoint &p2 = fitPoints[lastRow]; | |
547 | Float_t x0=p0.fX, y0=p0.fY, z0=p0.fZ; | |
548 | Float_t x1=p1.fX, y1=p1.fY, z1=p1.fZ; | |
549 | Float_t x2=p2.fX, y2=p2.fY, z2=p2.fZ; | |
550 | if( p1.fISlice!=p0.fISlice ){ | |
551 | Float_t dAlpha = fSlices[p0.fISlice].Param().Alpha() - fSlices[p1.fISlice].Param().Alpha(); | |
00d07bcd | 552 | Float_t c = CAMath::Cos(dAlpha); |
553 | Float_t s = CAMath::Sin(dAlpha); | |
eb30eb49 | 554 | x1 = p1.fX*c + p1.fY*s; |
555 | y1 = p1.fY*c - p1.fX*s; | |
d54804bf | 556 | } |
eb30eb49 | 557 | if( p2.fISlice!=p0.fISlice ){ |
558 | Float_t dAlpha = fSlices[p0.fISlice].Param().Alpha() - fSlices[p2.fISlice].Param().Alpha(); | |
00d07bcd | 559 | Float_t c = CAMath::Cos(dAlpha); |
560 | Float_t s = CAMath::Sin(dAlpha); | |
eb30eb49 | 561 | x2 = p2.fX*c + p2.fY*s; |
562 | y2 = p2.fY*c - p2.fX*s; | |
563 | } | |
564 | ||
565 | Float_t sp0[5] = {x0, y0, z0, .5, .5 }; | |
566 | Float_t sp1[5] = {x1, y1, z1, .5, .5 }; | |
567 | Float_t sp2[5] = {x2, y2, z2, .5, .5 }; | |
568 | t0.ConstructXYZ3(sp0,sp1,sp2,1., 0); | |
d54804bf | 569 | } |
570 | ||
eb30eb49 | 571 | Int_t currslice = fitPoints[firstRow].fISlice; |
572 | ||
573 | for( Int_t rowID=0; rowID<nSearchRows; rowID++ ){ | |
574 | Int_t iRow = searchRows[rowID]; | |
575 | FitPoint &p = fitPoints[iRow]; | |
576 | ||
577 | if( p.fISlice>=0 ){ | |
578 | ||
579 | //* Existing hit | |
580 | ||
581 | //* Rotate to the new slice | |
582 | ||
583 | if( p.fISlice!=currslice ){ | |
584 | if( !t0.Rotate( fSlices[p.fISlice].Param().Alpha() - fSlices[currslice].Param().Alpha() ) ) continue; | |
585 | currslice = p.fISlice; | |
586 | } | |
587 | //* Transport to the new row | |
588 | ||
00d07bcd | 589 | if( !t0.TransportToX( p.fX, .99 ) ) continue; |
eb30eb49 | 590 | |
591 | //* Calculate hit errors | |
592 | ||
593 | GetErrors2( p.fISlice, iRow, t0, p.fErr2Y, p.fErr2Z ); | |
594 | ||
595 | } else { | |
596 | //continue; //SG!! | |
597 | //* Search for the missed hit | |
598 | ||
599 | Float_t factor2 = 3.5*3.5; | |
600 | ||
d54804bf | 601 | AliHLTTPCCATracker *cslice = &(fSlices[currslice]); |
eb30eb49 | 602 | AliHLTTPCCARow *row = &(cslice->Rows()[iRow]); |
00d07bcd | 603 | if( !t0.TransportToX( row->X(), .99 ) ) continue; |
eb30eb49 | 604 | |
d54804bf | 605 | if( t0.GetY() > row->MaxY() ){ //next slice |
eb30eb49 | 606 | |
607 | Int_t j = nextSlice[currslice]; | |
608 | ||
d54804bf | 609 | //* Rotate to the new slice |
eb30eb49 | 610 | |
611 | if( !t0.Rotate( -fSlices[currslice].Param().Alpha() +fSlices[j].Param().Alpha() ) ) continue; | |
d54804bf | 612 | currslice = j; |
613 | cslice = &(fSlices[currslice]); | |
eb30eb49 | 614 | row = &(cslice->Rows()[iRow]); |
00d07bcd | 615 | if( !t0.TransportToX( row->X(), .99 ) ) continue; |
616 | if( CAMath::Abs(t0.GetY()) > row->MaxY() ) continue; | |
eb30eb49 | 617 | |
d54804bf | 618 | }else if( t0.GetY() < -row->MaxY() ){ //prev slice |
eb30eb49 | 619 | Int_t j = prevSlice[currslice]; |
d54804bf | 620 | //* Rotate to the new slice |
621 | if( !t0.Rotate( -fSlices[currslice].Param().Alpha() +fSlices[j].Param().Alpha() ) ) break; | |
622 | currslice = j; | |
623 | cslice = &(fSlices[currslice]); | |
eb30eb49 | 624 | row = &(cslice->Rows()[iRow]); |
00d07bcd | 625 | if( !t0.TransportToX( row->X(), .99 ) ) continue; |
626 | if( CAMath::Abs(t0.GetY()) > row->MaxY() ) continue; | |
d54804bf | 627 | } |
eb30eb49 | 628 | |
d54804bf | 629 | Int_t bestsh = -1; |
eb30eb49 | 630 | Float_t ds = 1.e10; |
d54804bf | 631 | for( Int_t ish=0; ish<row->NHits(); ish++ ){ |
00d07bcd | 632 | AliHLTTPCCAHit &sh = cslice->Hits()[row->FirstHit()+ish]; |
eb30eb49 | 633 | Float_t dy = sh.Y() - t0.GetY(); |
634 | Float_t dz = sh.Z() - t0.GetZ(); | |
635 | Float_t dds = dy*dy+dz*dz; | |
d54804bf | 636 | if( dds<ds ){ |
637 | ds = dds; | |
638 | bestsh = ish; | |
639 | } | |
640 | } | |
641 | if( bestsh<0 ) continue; | |
eb30eb49 | 642 | |
643 | //* Calculate hit errors | |
644 | ||
645 | GetErrors2( currslice, iRow, t0, p.fErr2Y, p.fErr2Z ); | |
646 | ||
00d07bcd | 647 | AliHLTTPCCAHit &sh = cslice->Hits()[row->FirstHit()+bestsh]; |
eb30eb49 | 648 | Float_t dy = sh.Y() - t0.GetY(); |
649 | Float_t dz = sh.Z() - t0.GetZ(); | |
650 | Float_t s2z = /*t0.GetErr2Z() + */ p.fErr2Z; | |
d54804bf | 651 | if( dz*dz>factor2*s2z ) continue; |
eb30eb49 | 652 | Float_t s2y = /*t0.GetErr2Y() + */ p.fErr2Y; |
d54804bf | 653 | if( dy*dy>factor2*s2y ) continue; |
eb30eb49 | 654 | |
655 | p.fISlice = currslice; | |
00d07bcd | 656 | p.fHitID = fFirstSliceHit[p.fISlice] + cslice->HitsID()[row->FirstHit() + bestsh]; |
eb30eb49 | 657 | p.fX = row->X(); |
658 | p.fY = sh.Y(); | |
659 | p.fZ = sh.Z(); | |
660 | p.fAmp = fHits[p.fHitID].Amp(); | |
661 | } | |
662 | ||
663 | //* Update the track | |
664 | ||
00d07bcd | 665 | t0.Filter2( p.fY, p.fZ, p.fErr2Y, p.fErr2Z, .99 ); |
d54804bf | 666 | } |
d54804bf | 667 | |
eb30eb49 | 668 | //* final refit, dE/dx calculation |
669 | //cout<<"\n\nstart refit..\n"<<endl; | |
00d07bcd | 670 | |
671 | AliHLTTPCCATrackParam::AliHLTTPCCATrackFitParam fitPar; | |
d54804bf | 672 | { |
eb30eb49 | 673 | Double_t sumDeDx = 0; |
674 | Int_t nDeDx = 0; | |
675 | t.NHits() = 0; | |
676 | ||
eb30eb49 | 677 | t0.CalculateFitParameters( fitPar, fSlices[0].Param().Bz() ); |
678 | ||
679 | t0.Cov()[ 0] = .1; | |
680 | t0.Cov()[ 1] = 0; | |
681 | t0.Cov()[ 2] = .1; | |
682 | t0.Cov()[ 3] = 0; | |
683 | t0.Cov()[ 4] = 0; | |
684 | t0.Cov()[ 5] = .1; | |
685 | t0.Cov()[ 6] = 0; | |
686 | t0.Cov()[ 7] = 0; | |
687 | t0.Cov()[ 8] = 0; | |
688 | t0.Cov()[ 9] = .1; | |
689 | t0.Cov()[10] = 0; | |
690 | t0.Cov()[11] = 0; | |
691 | t0.Cov()[12] = 0; | |
692 | t0.Cov()[13] = 0; | |
693 | t0.Cov()[14] = .1; | |
694 | t0.Chi2() = 0; | |
695 | t0.NDF() = -5; | |
696 | bool first = 1; | |
697 | for( Int_t iRow = maxNRows-1; iRow>=0; iRow-- ){ | |
698 | FitPoint &p = fitPoints[iRow]; | |
699 | if( p.fISlice<0 ) continue; | |
700 | fTrackHits[nTrackHits+t.NHits()] = p.fHitID; | |
701 | t.NHits()++; | |
702 | ||
703 | //* Rotate to the new slice | |
704 | ||
705 | if( p.fISlice!=currslice ){ | |
706 | //cout<<"rotate..."<<endl; | |
707 | //cout<<" before rotation:"<<endl; | |
708 | //t0.Print(); | |
709 | if( !t0.Rotate( fSlices[p.fISlice].Param().Alpha() - fSlices[currslice].Param().Alpha() ) ) continue; | |
710 | //cout<<" after rotation:"<<endl; | |
711 | //t0.Print(); | |
712 | currslice = p.fISlice; | |
d54804bf | 713 | } |
eb30eb49 | 714 | //* Transport to the new row |
715 | ||
716 | //cout<<" before transport:"<<endl; | |
717 | //t0.Print(); | |
718 | ||
00d07bcd | 719 | //if( !t0.TransportToX( p.fX, .99 ) ) continue; |
eb30eb49 | 720 | if( !t0.TransportToXWithMaterial( p.fX, fitPar ) ) continue; |
00d07bcd | 721 | //if( !t0.TransportToX( p.fX, .99 ) ) continue; |
eb30eb49 | 722 | //cout<<" after transport:"<<endl; |
723 | //t0.Print(); | |
724 | ||
725 | //* Update the track | |
726 | ||
727 | if( first ){ | |
728 | t0.Cov()[ 0] = .5*.5; | |
729 | t0.Cov()[ 1] = 0; | |
730 | t0.Cov()[ 2] = .5*.5; | |
731 | t0.Cov()[ 3] = 0; | |
732 | t0.Cov()[ 4] = 0; | |
733 | t0.Cov()[ 5] = .2*.2; | |
734 | t0.Cov()[ 6] = 0; | |
735 | t0.Cov()[ 7] = 0; | |
736 | t0.Cov()[ 8] = 0; | |
737 | t0.Cov()[ 9] = .2*.2; | |
738 | t0.Cov()[10] = 0; | |
739 | t0.Cov()[11] = 0; | |
740 | t0.Cov()[12] = 0; | |
741 | t0.Cov()[13] = 0; | |
742 | t0.Cov()[14] = .5*.5; | |
743 | t0.Chi2() = 0; | |
744 | t0.NDF() = -5; | |
d54804bf | 745 | } |
eb30eb49 | 746 | |
747 | //cout<<" before filtration:"<<endl; | |
748 | //t0.Print(); | |
749 | ||
00d07bcd | 750 | if( !t0.Filter2( p.fY, p.fZ, p.fErr2Y, p.fErr2Z, .99 ) ) continue; |
eb30eb49 | 751 | //cout<<" after filtration:"<<endl; |
752 | //t0.Print(); | |
753 | first = 0; | |
754 | ||
00d07bcd | 755 | if( CAMath::Abs( t0.CosPhi() )>1.e-4 ){ |
756 | Float_t dLdX = CAMath::Sqrt(1.+t0.DzDs()*t0.DzDs())/CAMath::Abs(t0.CosPhi()); | |
eb30eb49 | 757 | sumDeDx+=p.fAmp/dLdX; |
758 | nDeDx++; | |
759 | } | |
760 | } | |
761 | t.DeDx() = 0; | |
762 | if( nDeDx >0 ) t.DeDx() = sumDeDx/nDeDx; | |
763 | if( t0.GetErr2Y()<=0 ){ | |
764 | cout<<"nhits = "<<t.NHits()<<", t0.GetErr2Y() = "<<t0.GetErr2Y()<<endl; | |
765 | t0.Print(); | |
766 | //exit(1); | |
767 | } | |
d54804bf | 768 | } |
eb30eb49 | 769 | |
770 | if( t.NHits()<30 ) continue;//SG!! | |
00d07bcd | 771 | Double_t dAlpha = 0; |
772 | { | |
773 | Double_t xTPC=83.65; | |
774 | Double_t ddAlpha = 0.00609235; | |
775 | ||
776 | if( t0.TransportToXWithMaterial( xTPC, fitPar ) ){ | |
777 | Double_t y=t0.GetY(); | |
778 | Double_t ymax=xTPC*CAMath::Tan(dAlpha/2.); | |
779 | if (y > ymax) { | |
780 | if( t0.Rotate( ddAlpha ) ){ dAlpha=ddAlpha; t0.TransportToXWithMaterial( xTPC, fitPar ); } | |
781 | } else if (y <-ymax) { | |
782 | if( t0.Rotate( -ddAlpha ) ){ dAlpha=-ddAlpha; t0.TransportToXWithMaterial( xTPC, fitPar );} | |
783 | } | |
784 | } | |
785 | } | |
eb30eb49 | 786 | |
d54804bf | 787 | { |
eb30eb49 | 788 | Bool_t ok=1; |
789 | ||
790 | Float_t *c = t0.Cov(); | |
791 | for( int i=0; i<15; i++ ) ok = ok && finite(c[i]); | |
d54804bf | 792 | for( int i=0; i<5; i++ ) ok = ok && finite(t0.Par()[i]); |
793 | ok = ok && (t0.GetX()>50); | |
eb30eb49 | 794 | |
795 | if( c[0]<=0 || c[2]<=0 || c[5]<=0 || c[9]<=0 || c[14]<=0 ) ok = 0; | |
796 | //if( c[0]>5. || c[2]>5. || c[5]>2. || c[9]>2 || c[14]>2 ) ok = 0; | |
797 | if(!ok){ | |
798 | nRejected++; | |
799 | //cout<<"\n\nRejected: "<<nRejected<<"\n"<<endl; | |
800 | continue; | |
801 | } | |
d54804bf | 802 | } |
803 | ||
00d07bcd | 804 | if( CAMath::Abs(t0.Kappa())<1.e-8 ) t0.Kappa() = 1.e-8; |
d54804bf | 805 | t.Param() = t0; |
00d07bcd | 806 | t.Alpha() = fSlices[currslice].Param().Alpha() + dAlpha; |
d54804bf | 807 | nTrackHits+= t.NHits(); |
eb30eb49 | 808 | fNTracks++; |
d54804bf | 809 | } |
810 | } | |
811 | } | |
00d07bcd | 812 | //cout<<"\n\nRejected: "<<nRejected<<"\n"<<endl; |
eb30eb49 | 813 | timerMerge2.Stop(); |
814 | fStatTime[11]+=timerMerge2.CpuTime(); | |
d54804bf | 815 | |
eb30eb49 | 816 | TStopwatch timerMerge3; |
817 | ||
818 | //* selection | |
819 | //cout<<"Selection..."<<endl; | |
d54804bf | 820 | { |
821 | AliHLTTPCCAGBTrack *vtracks = new AliHLTTPCCAGBTrack [fNTracks]; | |
822 | Int_t *vhits = new Int_t [fNHits]; | |
823 | AliHLTTPCCAGBTrack **vptracks = new AliHLTTPCCAGBTrack* [fNTracks]; | |
824 | ||
825 | for( Int_t itr=0; itr<fNTracks; itr++ ){ | |
826 | vptracks[itr] = &(fTracks[itr]); | |
827 | } | |
828 | Int_t nTracks = 0; | |
829 | Int_t nHits = 0; | |
00d07bcd | 830 | std::sort(vptracks, vptracks+fNTracks, AliHLTTPCCAGBTrack::ComparePNClusters ); |
d54804bf | 831 | for( Int_t itr=0; itr<fNTracks; itr++ ){ |
832 | AliHLTTPCCAGBTrack &t = *(vptracks[itr]); | |
833 | AliHLTTPCCAGBTrack &to = vtracks[nTracks]; | |
834 | to=*(vptracks[itr]); | |
835 | to.FirstHitRef() = nHits; | |
836 | to.NHits() = 0; | |
837 | for( Int_t ih=0; ih<t.NHits(); ih++ ){ | |
838 | Int_t jh = fTrackHits[t.FirstHitRef()+ih]; | |
839 | AliHLTTPCCAGBHit &h = fHits[jh]; | |
840 | if( h.IsUsed() ) continue; | |
841 | vhits[to.FirstHitRef() + to.NHits()] = jh; | |
842 | to.NHits()++; | |
843 | h.IsUsed() = 1; | |
844 | } | |
00d07bcd | 845 | if( to.NHits()<10 ) continue;//SG!!! |
d54804bf | 846 | nHits+=to.NHits(); |
847 | nTracks++; | |
eb30eb49 | 848 | //cout<<to.Param().GetErr2Y()<<" "<<to.Param().GetErr2Z()<<endl; |
d54804bf | 849 | } |
850 | fNTracks = nTracks; | |
851 | if( fTrackHits ) delete[] fTrackHits; | |
852 | if( fTracks ) delete[] fTracks; | |
853 | fTrackHits = vhits; | |
854 | fTracks = vtracks; | |
855 | delete[] vptracks; | |
856 | } | |
eb30eb49 | 857 | timerMerge3.Stop(); |
858 | fStatTime[12]+=timerMerge3.CpuTime(); | |
859 | } | |
860 | ||
861 | void AliHLTTPCCAGBTracker::GetErrors2( Int_t iSlice, Int_t iRow, AliHLTTPCCATrackParam &t, Float_t &Err2Y, Float_t &Err2Z ) | |
862 | { | |
863 | // | |
864 | // Use calibrated cluster error from OCDB | |
865 | // | |
866 | ||
00d07bcd | 867 | Float_t z = CAMath::Abs((250.-0.275)-CAMath::Abs(t.GetZ())); |
eb30eb49 | 868 | Int_t type = (iRow<63) ? 0: (iRow>126) ? 1:2; |
00d07bcd | 869 | Float_t cosPhiInv = CAMath::Abs(t.GetCosPhi())>1.e-2 ?1./t.GetCosPhi() :0; |
eb30eb49 | 870 | Float_t angleY = t.GetSinPhi()*cosPhiInv ; |
871 | Float_t angleZ = t.GetDzDs()*cosPhiInv ; | |
872 | ||
873 | AliHLTTPCCATracker &slice = fSlices[iSlice]; | |
874 | ||
875 | Err2Y = slice.Param().GetClusterError2(0,type, z,angleY); | |
876 | Err2Z = slice.Param().GetClusterError2(1,type, z,angleZ); | |
877 | } | |
d54804bf | 878 | |
eb30eb49 | 879 | |
880 | void AliHLTTPCCAGBTracker::GetErrors2( AliHLTTPCCAGBHit &h, AliHLTTPCCATrackParam &t, Float_t &Err2Y, Float_t &Err2Z ) | |
881 | { | |
882 | // | |
883 | // Use calibrated cluster error from OCDB | |
884 | // | |
885 | ||
886 | GetErrors2( h.ISlice(), h.IRow(), t, Err2Y, Err2Z ); | |
887 | } | |
888 | ||
00d07bcd | 889 | void AliHLTTPCCAGBTracker::WriteSettings( ostream &out ) const |
eb30eb49 | 890 | { |
00d07bcd | 891 | //* write settings to the file |
eb30eb49 | 892 | out<< NSlices()<<endl; |
893 | for( int iSlice=0; iSlice<NSlices(); iSlice++ ){ | |
894 | fSlices[iSlice].Param().WriteSettings( out ); | |
895 | } | |
896 | } | |
897 | ||
898 | void AliHLTTPCCAGBTracker::ReadSettings( istream &in ) | |
899 | { | |
00d07bcd | 900 | //* Read settings from the file |
eb30eb49 | 901 | Int_t nSlices=0; |
902 | in >> nSlices; | |
903 | SetNSlices( nSlices ); | |
904 | for( int iSlice=0; iSlice<NSlices(); iSlice++ ){ | |
905 | AliHLTTPCCAParam param; | |
906 | param.ReadSettings ( in ); | |
907 | fSlices[iSlice].Initialize( param ); | |
908 | } | |
909 | } | |
910 | ||
00d07bcd | 911 | void AliHLTTPCCAGBTracker::WriteEvent( ostream &out ) const |
eb30eb49 | 912 | { |
00d07bcd | 913 | // write event to the file |
914 | ||
eb30eb49 | 915 | out<<NHits()<<endl; |
916 | for (Int_t ih=0; ih<NHits(); ih++) { | |
917 | AliHLTTPCCAGBHit &h = fHits[ih]; | |
918 | out<<h.X()<<" "; | |
919 | out<<h.Y()<<" "; | |
920 | out<<h.Z()<<" "; | |
921 | out<<h.ErrY()<<" "; | |
922 | out<<h.ErrZ()<<" "; | |
923 | out<<h.Amp()<<" "; | |
924 | out<<h.ID()<<" "; | |
925 | out<<h.ISlice()<<" "; | |
926 | out<<h.IRow()<<endl; | |
927 | } | |
928 | } | |
929 | ||
00d07bcd | 930 | void AliHLTTPCCAGBTracker::ReadEvent( istream &in ) |
eb30eb49 | 931 | { |
00d07bcd | 932 | //* Read event from file |
933 | ||
eb30eb49 | 934 | StartEvent(); |
935 | Int_t nHits; | |
936 | in >> nHits; | |
937 | SetNHits(nHits); | |
938 | for (Int_t i=0; i<nHits; i++) { | |
939 | Float_t x, y, z, errY, errZ; | |
940 | Float_t amp; | |
941 | Int_t id, iSlice, iRow; | |
942 | in>>x>>y>>z>>errY>>errZ>>amp>>id>>iSlice>>iRow; | |
943 | ReadHit( x, y, z, errY, errZ, amp, id, iSlice, iRow ); | |
944 | } | |
945 | } | |
946 | ||
00d07bcd | 947 | void AliHLTTPCCAGBTracker::WriteTracks( ostream &out ) const |
eb30eb49 | 948 | { |
00d07bcd | 949 | //* Write tracks to file |
950 | ||
eb30eb49 | 951 | out<<fTime<<endl; |
952 | Int_t nTrackHits = 0; | |
00d07bcd | 953 | for( Int_t itr=0; itr<fNTracks; itr++ ){ |
954 | nTrackHits+=fTracks[itr].NHits(); | |
eb30eb49 | 955 | } |
956 | out<<nTrackHits<<endl; | |
957 | for( Int_t ih=0; ih<nTrackHits; ih++ ){ | |
00d07bcd | 958 | out<< fTrackHits[ih]<<" "; |
eb30eb49 | 959 | } |
960 | out<<endl; | |
961 | ||
962 | out<<NTracks()<<endl; | |
00d07bcd | 963 | for( Int_t itr=0; itr<fNTracks; itr++ ){ |
964 | AliHLTTPCCAGBTrack &t = fTracks[itr]; | |
eb30eb49 | 965 | AliHLTTPCCATrackParam &p = t.Param(); |
966 | out<< t.NHits()<<" "; | |
967 | out<< t.FirstHitRef()<<" "; | |
968 | out<< t.Alpha()<<" "; | |
969 | out<< t.DeDx()<<endl; | |
970 | out<< p.X()<<" "; | |
971 | out<< p.CosPhi()<<" "; | |
972 | out<< p.Chi2()<<" "; | |
973 | out<< p.NDF()<<endl; | |
974 | for( Int_t i=0; i<5; i++ ) out<<p.Par()[i]<<" "; | |
975 | out<<endl; | |
976 | for( Int_t i=0; i<15; i++ ) out<<p.Cov()[i]<<" "; | |
977 | out<<endl; | |
978 | } | |
979 | } | |
980 | ||
981 | void AliHLTTPCCAGBTracker::ReadTracks( istream &in ) | |
982 | { | |
00d07bcd | 983 | //* Read tracks from file |
984 | ||
eb30eb49 | 985 | in>>fTime; |
986 | fStatTime[0]+=fTime; | |
987 | fStatNEvents++; | |
988 | if( fTrackHits ) delete[] fTrackHits; | |
989 | fTrackHits = 0; | |
990 | Int_t nTrackHits = 0; | |
991 | in >> nTrackHits; | |
992 | fTrackHits = new Int_t [nTrackHits]; | |
993 | for( Int_t ih=0; ih<nTrackHits; ih++ ){ | |
994 | in >> TrackHits()[ih]; | |
995 | } | |
996 | if( fTracks ) delete[] fTracks; | |
997 | fTracks = 0; | |
998 | in >> fNTracks; | |
999 | fTracks = new AliHLTTPCCAGBTrack[fNTracks]; | |
1000 | for( Int_t itr=0; itr<NTracks(); itr++ ){ | |
1001 | AliHLTTPCCAGBTrack &t = Tracks()[itr]; | |
1002 | AliHLTTPCCATrackParam &p = t.Param(); | |
1003 | in>> t.NHits(); | |
1004 | in>> t.FirstHitRef(); | |
1005 | in>> t.Alpha(); | |
1006 | in>> t.DeDx(); | |
1007 | in>> p.X(); | |
1008 | in>> p.CosPhi(); | |
1009 | in>> p.Chi2(); | |
1010 | in>> p.NDF(); | |
1011 | for( Int_t i=0; i<5; i++ ) in>>p.Par()[i]; | |
1012 | for( Int_t i=0; i<15; i++ ) in>>p.Cov()[i]; | |
1013 | } | |
d54804bf | 1014 | } |