]>
Commit | Line | Data |
---|---|---|
e3b2b5e5 | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
7 | * Permission to use, copy, modify and distribute this software and its * | |
8 | * documentation strictly for non-commercial purposes is hereby granted * | |
9 | * without fee, provided that the above copyright notice appears in all * | |
10 | * copies and that both the copyright notice and this permission notice * | |
11 | * appear in the supporting documentation. The authors make no claims * | |
12 | * about the suitability of this software for any purpose. It is * | |
13 | * provided "as is" without express or implied warranty. * | |
14 | **************************************************************************/ | |
15 | ||
16 | /////////////////////////////////////////////////////////////////////////////// | |
17 | // // | |
18 | // // | |
19 | // TRD 6-chambers stack // | |
20 | // // | |
21 | // // | |
22 | /////////////////////////////////////////////////////////////////////////////// | |
23 | ||
24 | #include "AliTRDgeometry.h" | |
25 | #include "AliTRDmodule.h" | |
26 | #include "AliTRDltuTracklet.h" | |
27 | #include "AliTRDgtuTrack.h" | |
28 | #include "AliTRDtrigParam.h" | |
29 | #include "AliTRDzmaps.h" | |
30 | ||
31 | ClassImp(AliTRDmodule) | |
32 | ||
33 | //_____________________________________________________________________________ | |
34 | AliTRDmodule::AliTRDmodule(AliTRDtrigParam *trigp) | |
35 | { | |
36 | ||
37 | // | |
38 | // AliTRDmodule default constructor | |
39 | // | |
40 | ||
41 | fDeltaY = trigp->GetDeltaY(); | |
42 | fDeltaS = trigp->GetDeltaS(); | |
43 | fXprojPlane = trigp->GetXprojPlane(); | |
44 | fField = trigp->GetField(); | |
45 | fLTUtrk = 0; | |
46 | fGTUtrk = 0; | |
47 | fTracklets = new TObjArray(400); | |
48 | fTracks = new TObjArray(400); | |
49 | ||
50 | for (Int_t iPlan = 0; iPlan < AliTRDgeometry::Nplan(); iPlan++) { | |
51 | for (Int_t i = 0; i < kNsubZchan; i++) { | |
52 | fZnchan[iPlan][i] = 0; | |
53 | for (Int_t j = 0; j < kNmaxZchan; j++) { | |
54 | fZtrkid[iPlan][j][i] = -1; | |
55 | } | |
56 | } | |
57 | } | |
58 | ||
59 | } | |
60 | ||
61 | //_____________________________________________________________________________ | |
62 | AliTRDmodule::~AliTRDmodule() | |
63 | { | |
64 | // | |
65 | // destructor | |
66 | // | |
67 | ||
68 | } | |
69 | ||
70 | //_____________________________________________________________________________ | |
71 | AliTRDmodule &AliTRDmodule::operator=(const AliTRDmodule &m) | |
72 | { | |
73 | // | |
74 | // assignment operator | |
75 | // | |
76 | ||
77 | if (this != &m) ((AliTRDmodule &) m).Copy(*this); | |
78 | return *this; | |
79 | ||
80 | } | |
81 | ||
82 | //_____________________________________________________________________________ | |
83 | void AliTRDmodule::Copy(TObject &m) const | |
84 | { | |
85 | // | |
86 | // copy function | |
87 | // | |
88 | ||
89 | ((AliTRDmodule &) m).fXprojPlane = fXprojPlane; | |
90 | ((AliTRDmodule &) m).fField = fField; | |
91 | ((AliTRDmodule &) m).fTracklets = NULL; | |
92 | ((AliTRDmodule &) m).fTracks = NULL; | |
93 | ((AliTRDmodule &) m).fDeltaY = fDeltaY; | |
94 | ((AliTRDmodule &) m).fDeltaS = fDeltaS; | |
95 | ((AliTRDmodule &) m).fLTUtrk = NULL; | |
96 | ((AliTRDmodule &) m).fGTUtrk = NULL; | |
97 | ||
98 | for (Int_t iPlan = 0; iPlan < AliTRDgeometry::Nplan(); iPlan++) { | |
99 | for (Int_t i = 0; i < kNsubZchan; i++) { | |
100 | ((AliTRDmodule &) m).fZnchan[iPlan][i] = 0; | |
101 | for (Int_t j = 0; j < kNmaxZchan; j++) { | |
102 | ((AliTRDmodule &) m).fZtrkid[iPlan][j][i] = -1; | |
103 | } | |
104 | } | |
105 | } | |
106 | ||
107 | } | |
108 | ||
109 | //_____________________________________________________________________________ | |
110 | void AliTRDmodule::Reset() | |
111 | { | |
112 | // | |
113 | // Reset the tracks and tracklets in the module | |
114 | // | |
115 | ||
116 | ResetTracklets(); | |
117 | ResetTracks(); | |
118 | ||
119 | fLTUtrk = 0; | |
120 | fGTUtrk = 0; | |
121 | fTracklets = new TObjArray(400); | |
122 | fTracks = new TObjArray(400); | |
123 | ||
124 | } | |
125 | ||
126 | //_____________________________________________________________________________ | |
127 | void AliTRDmodule::ResetTracks() | |
128 | { | |
129 | // | |
130 | // Reset the tracks in the module | |
131 | // | |
132 | ||
133 | if (fTracks) { | |
134 | ||
135 | AliTRDgtuTrack *trk; | |
136 | for (Int_t i = 0; i < GetNtracks(); i++) { | |
137 | ||
138 | trk = GetTrack(i); | |
139 | trk->Reset(); | |
140 | ||
141 | } | |
142 | ||
143 | fTracks->Delete(); | |
144 | ||
145 | } | |
146 | ||
147 | } | |
148 | ||
149 | //_____________________________________________________________________________ | |
150 | AliTRDgtuTrack* AliTRDmodule::GetTrack(Int_t pos) const | |
151 | { | |
152 | // | |
153 | // Return track at position "pos" | |
154 | // | |
155 | ||
156 | if (fTracks == 0) return 0; | |
157 | void * trk = fTracks->UncheckedAt(pos); | |
158 | if (trk == 0) return 0; | |
159 | ||
160 | return (AliTRDgtuTrack*)trk; | |
161 | ||
162 | } | |
163 | ||
164 | //_____________________________________________________________________________ | |
165 | void AliTRDmodule::RemoveTrack(Int_t pos) | |
166 | { | |
167 | // | |
168 | // Remove the track at position "pos" | |
169 | // | |
170 | ||
171 | if (fTracks == 0) return; | |
172 | fTracks->RemoveAt(pos); | |
173 | fTracks->Compress(); | |
174 | ||
175 | } | |
176 | ||
177 | //_____________________________________________________________________________ | |
178 | void AliTRDmodule::AddTracklet(Int_t det, | |
179 | Int_t row, | |
180 | Float_t rowz, | |
181 | Float_t slope, | |
182 | Float_t offset, | |
183 | Float_t time, | |
184 | Int_t ncl, | |
185 | Int_t label, | |
186 | Float_t q) | |
187 | { | |
188 | // | |
189 | // Add a tracklet to this track | |
190 | // | |
191 | ||
192 | fLTUtrk = new AliTRDltuTracklet(det,row,rowz,slope,offset,time,ncl,label,q); | |
193 | ||
194 | Tracklets()->Add(fLTUtrk); | |
195 | ||
196 | } | |
197 | ||
198 | //_____________________________________________________________________________ | |
199 | AliTRDltuTracklet* AliTRDmodule::GetTracklet(Int_t pos) const | |
200 | { | |
201 | // | |
202 | // Get the tracklet at position "pos" | |
203 | // | |
204 | ||
205 | if (fTracklets == 0) return 0; | |
206 | void * trk = fTracklets->UncheckedAt(pos); | |
207 | if (trk == 0) return 0; | |
208 | ||
209 | return (AliTRDltuTracklet*)trk; | |
210 | ||
211 | } | |
212 | ||
213 | //_____________________________________________________________________________ | |
214 | void AliTRDmodule::RemoveTracklet(Int_t pos) | |
215 | { | |
216 | // | |
217 | // Remove the tracklet at position "pos" | |
218 | // | |
219 | ||
220 | if (fTracklets == 0) return; | |
221 | fTracklets->RemoveAt(pos); | |
222 | fTracklets->Compress(); | |
223 | ||
224 | } | |
225 | ||
226 | //_____________________________________________________________________________ | |
227 | void AliTRDmodule::RemoveMultipleTracklets() | |
228 | { | |
229 | // | |
230 | // Remove multiple found tracklets | |
231 | // | |
232 | ||
233 | Float_t offDiffMin = 0.5; // [cm] | |
234 | ||
235 | AliTRDltuTracklet *trk; | |
236 | Int_t det1, det2, row1, row2, ncl1, ncl2, label1, label2; | |
237 | Float_t off1, off2; | |
238 | Int_t itrk = 0; | |
239 | while (itrk < (GetNtracklets()-1)) { | |
240 | ||
241 | trk = GetTracklet(itrk ); | |
242 | ||
243 | det1 = trk->GetDetector(); | |
244 | row1 = trk->GetRow(); | |
245 | off1 = trk->GetOffset(); | |
246 | ncl1 = trk->GetNclusters(); | |
247 | label1 = trk->GetLabel(); | |
248 | ||
249 | trk = GetTracklet(itrk+1); | |
250 | ||
251 | det2 = trk->GetDetector(); | |
252 | row2 = trk->GetRow(); | |
253 | off2 = trk->GetOffset(); | |
254 | ncl2 = trk->GetNclusters(); | |
255 | label2 = trk->GetLabel(); | |
256 | ||
257 | if (det1 == det2 && row1 == row2) { | |
258 | if ((off2-off1) < offDiffMin) { | |
259 | if (ncl1 < ncl2) { | |
260 | RemoveTracklet(itrk ); | |
261 | } else { | |
262 | RemoveTracklet(itrk+1); | |
263 | } | |
264 | } | |
265 | } | |
266 | ||
267 | itrk++; | |
268 | ||
269 | } | |
270 | ||
271 | } | |
272 | ||
273 | //_____________________________________________________________________________ | |
274 | void AliTRDmodule::SortZ(Int_t cha) | |
275 | { | |
276 | // | |
277 | // Match tracklets in the x-z plane (pad row sorting) | |
278 | // | |
279 | ||
280 | InitZLUT(); | |
281 | ||
282 | AliTRDltuTracklet *trk; | |
283 | Int_t row, pla, det; | |
284 | for (Int_t iTrk = 0; iTrk < GetNtracklets(); iTrk++) { | |
285 | ||
286 | trk = GetTracklet(iTrk); | |
287 | ||
288 | row = trk->GetRow(); | |
289 | det = trk->GetDetector(); | |
290 | pla = trk->GetPlane(det); | |
291 | ||
292 | for (Int_t iZchan = 0; iZchan < kNsubZchan; iZchan++) { | |
293 | if (fZChannelMap[cha][iZchan][pla][row] == 1) { | |
294 | fZtrkid[pla][fZnchan[pla][iZchan]][iZchan] = iTrk; | |
295 | fZnchan[pla][iZchan]++; | |
296 | } | |
297 | } | |
298 | ||
299 | } | |
300 | ||
301 | } | |
302 | ||
303 | //_____________________________________________________________________________ | |
304 | void AliTRDmodule::InitZLUT() | |
305 | { | |
306 | // | |
307 | // Initialize the pad row sorting look-up-table | |
308 | // | |
309 | ||
310 | for (Int_t iPlan = 0; iPlan < AliTRDgeometry::Nplan(); iPlan++) { | |
311 | for (Int_t i = 0; i < kNsubZchan; i++) { | |
312 | fZnchan[iPlan][i] = 0; | |
313 | for (Int_t j = 0; j < kNmaxZchan; j++) { | |
314 | fZtrkid[iPlan][j][i] = -1; | |
315 | } | |
316 | } | |
317 | } | |
318 | ||
319 | } | |
320 | ||
321 | //_____________________________________________________________________________ | |
322 | void AliTRDmodule::FindTracks() | |
323 | { | |
324 | // | |
325 | // Find tracks from tracklets | |
326 | // | |
327 | ||
328 | for (Int_t iZchan = 0; iZchan < kNsubZchan; iZchan++) { | |
329 | FindTracksCombi(iZchan); | |
330 | } | |
331 | ||
332 | } | |
333 | ||
334 | //_____________________________________________________________________________ | |
335 | void AliTRDmodule::FindTracksCombi(Int_t zchan) | |
336 | { | |
337 | // | |
338 | // find tracks by pure combinatorics... | |
339 | // | |
340 | ||
341 | static Int_t trkTrack[12]; | |
342 | ||
343 | Int_t nTracklets, nPlanes; | |
344 | Int_t ntrk1, trkId1, ntrk2, trkId2; | |
345 | Float_t y1, y1min, y1max, s1, z1, s1min, s1max, y2, s2, z2; | |
346 | AliTRDltuTracklet *trk1; | |
347 | AliTRDltuTracklet *trk2; | |
348 | AliTRDltuTracklet *trk ; | |
349 | ||
350 | Bool_t isPlane[kNplan]; | |
351 | ||
352 | for (Int_t iPlan1 = 0; iPlan1 < kNplan; iPlan1++) { | |
353 | ||
354 | ntrk1 = fZnchan[iPlan1][zchan]; | |
355 | ||
356 | for (Int_t iTrk1 = 0; iTrk1 < ntrk1; iTrk1++) { | |
357 | ||
358 | for (Int_t iPlan = 0; iPlan < kNplan; iPlan++) isPlane[iPlan] = kFALSE; | |
359 | ||
360 | trkId1 = fZtrkid[iPlan1][iTrk1][zchan]; | |
361 | ||
362 | nTracklets = 0; | |
363 | for (Int_t iList = 0; iList < kNmaxTrk; iList++) { | |
364 | trkTrack[iList] = -1; | |
365 | } | |
366 | ||
367 | trkTrack[nTracklets++] = trkId1; | |
368 | ||
369 | isPlane[iPlan1] = kTRUE; | |
370 | ||
371 | trk1 = GetTracklet(trkId1); | |
372 | ||
373 | y1 = trk1->GetYproj(fXprojPlane); | |
374 | y1min = y1 - fDeltaY; | |
375 | y1max = y1 + fDeltaY; | |
376 | s1 = trk1->GetSlope(); | |
377 | s1min = s1 - fDeltaS; | |
378 | s1max = s1 + fDeltaS; | |
379 | z1 = trk1->GetZproj(fXprojPlane); | |
380 | ||
381 | for (Int_t iPlan2 = 0; iPlan2 < kNplan; iPlan2++) { | |
382 | ||
383 | if (iPlan2 == iPlan1) continue; | |
384 | ||
385 | ntrk2 = fZnchan[iPlan2][zchan]; | |
386 | ||
387 | for (Int_t iTrk2 = 0; iTrk2 < ntrk2; iTrk2++) { | |
388 | ||
389 | trkId2 = fZtrkid[iPlan2][iTrk2][zchan]; | |
390 | ||
391 | if (trkId2 == trkId1) continue; | |
392 | ||
393 | trk2 = GetTracklet(trkId2); | |
394 | ||
395 | y2 = trk2->GetYproj(fXprojPlane); | |
396 | s2 = trk2->GetSlope(); | |
397 | z2 = trk2->GetZproj(fXprojPlane); | |
398 | ||
399 | if ((y1min < y2 && y2 < y1max) && | |
400 | (s1min < s2 && s2 < s1max)) { | |
401 | ||
402 | if (nTracklets >= kNmaxTrk) { | |
403 | Warning("FindTracksCombi","Too many tracklets for this track."); | |
404 | } else { | |
405 | trkTrack[nTracklets++] = trkId2; | |
406 | isPlane[iPlan2] = kTRUE; | |
407 | } | |
408 | ||
409 | } | |
410 | ||
411 | } // end trk 2 | |
412 | ||
413 | } // end plan 2 | |
414 | ||
415 | nPlanes = 0; | |
416 | for (Int_t iPlan = 0; iPlan < kNplan; iPlan++) { | |
417 | nPlanes += (Int_t)isPlane[iPlan]; | |
418 | } | |
419 | ||
420 | if (nPlanes >= 4) { | |
421 | ||
422 | Int_t cha1, cha2, npoints1, npoints2; | |
423 | for (Int_t iList = 0; iList < (nTracklets-1); iList++) { | |
424 | ||
425 | if (trkTrack[iList] == -1 || trkTrack[iList+1] == -1) continue; | |
426 | trk1 = GetTracklet(trkTrack[iList ]); | |
427 | trk2 = GetTracklet(trkTrack[iList+1]); | |
428 | ||
429 | cha1 = trk1->GetDetector(); | |
430 | cha2 = trk2->GetDetector(); | |
431 | if (cha1 != cha2) continue; | |
432 | ||
433 | npoints1 = trk1->GetNclusters(); | |
434 | npoints2 = trk2->GetNclusters(); | |
435 | ||
436 | if (npoints1 == npoints2) { | |
437 | trkTrack[iList] = -1; | |
438 | } else { | |
439 | if (npoints1 > npoints2) trkTrack[iList+1] = -1; | |
440 | if (npoints1 < npoints2) trkTrack[iList ] = -1; | |
441 | } | |
442 | ||
443 | } | |
444 | ||
445 | fGTUtrk = new AliTRDgtuTrack(); | |
446 | for (Int_t iList = 0; iList < nTracklets; iList++) { | |
447 | if (trkTrack[iList] == -1) continue; | |
448 | trk = GetTracklet(trkTrack[iList]); | |
449 | fGTUtrk->AddTracklet(trk); | |
450 | } | |
451 | fGTUtrk->Track(fXprojPlane,fField); | |
452 | AddTrack(); | |
453 | } | |
454 | ||
455 | } // end trk 1 | |
456 | ||
457 | } // end plan 1 | |
458 | ||
459 | } | |
460 | ||
461 | //_____________________________________________________________________________ | |
462 | void AliTRDmodule::AddTrack() | |
463 | { | |
464 | // | |
465 | // Add a found track to the module | |
466 | // | |
467 | ||
468 | Tracks()->Add(fGTUtrk); | |
469 | ||
470 | } | |
471 | ||
472 | //_____________________________________________________________________________ | |
473 | void AliTRDmodule::RemoveMultipleTracks() | |
474 | { | |
475 | // | |
476 | // Remove multiple found tracks | |
477 | // | |
478 | ||
479 | AliTRDgtuTrack *trk1; | |
480 | AliTRDgtuTrack *trk2; | |
481 | ||
482 | Float_t yproj1, yproj2, alpha1, alpha2; | |
483 | Int_t ntrk1, ntrk2; | |
484 | Int_t iTrack = 0; | |
485 | ||
486 | while (iTrack < (GetNtracks()-1)) { | |
487 | ||
488 | trk1 = GetTrack(iTrack ); | |
489 | trk2 = GetTrack(iTrack+1); | |
490 | ||
491 | ntrk1 = trk1->GetNtracklets(); | |
492 | yproj1 = trk1->GetYproj(); | |
493 | alpha1 = trk1->GetSlope(); | |
494 | ntrk2 = trk2->GetNtracklets(); | |
495 | yproj2 = trk2->GetYproj(); | |
496 | alpha2 = trk2->GetSlope(); | |
497 | ||
498 | if (TMath::Abs(yproj1-yproj2) < fDeltaY && TMath::Abs(alpha1-alpha2) < fDeltaS) { | |
499 | if (ntrk1 < ntrk2) { | |
500 | RemoveTrack(iTrack ); | |
501 | } else { | |
502 | RemoveTrack(iTrack+1); | |
503 | } | |
504 | } else { | |
505 | iTrack++; | |
506 | } | |
507 | ||
508 | } | |
509 | ||
510 | } | |
511 |