]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TRD/AliTRDmodule.cxx
- Adding classes AliMpArrayI, AliMpDetElementm, AliMpDEStore, AliMpDDL,
[u/mrichter/AliRoot.git] / TRD / AliTRDmodule.cxx
CommitLineData
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
6d50f529 24#include <TObject.h>
25
26#include "AliLog.h"
27
e3b2b5e5 28#include "AliTRDgeometry.h"
29#include "AliTRDmodule.h"
30#include "AliTRDltuTracklet.h"
31#include "AliTRDgtuTrack.h"
32#include "AliTRDtrigParam.h"
33#include "AliTRDzmaps.h"
34
35ClassImp(AliTRDmodule)
36
37//_____________________________________________________________________________
6d50f529 38AliTRDmodule::AliTRDmodule()
39 :TObject()
40 ,fXprojPlane(0)
41 ,fField(0)
42 ,fTracklets(NULL)
43 ,fTracks(NULL)
44 ,fDeltaY(0)
45 ,fDeltaS(0)
46 ,fLTUtrk(0)
47 ,fGTUtrk(0)
e3b2b5e5 48{
e3b2b5e5 49 //
50 // AliTRDmodule default constructor
51 //
52
6d50f529 53}
54
55//_____________________________________________________________________________
56AliTRDmodule::AliTRDmodule(AliTRDtrigParam *trigp)
57 :TObject()
58 ,fXprojPlane(trigp->GetXprojPlane())
59 ,fField(trigp->GetField())
60 ,fTracklets(new TObjArray(400))
61 ,fTracks(new TObjArray(400))
62 ,fDeltaY(trigp->GetDeltaY())
63 ,fDeltaS(trigp->GetDeltaS())
64 ,fLTUtrk(0)
65 ,fGTUtrk(0)
66{
67 //
68 // AliTRDmodule constructor
69 //
e3b2b5e5 70
71 for (Int_t iPlan = 0; iPlan < AliTRDgeometry::Nplan(); iPlan++) {
72 for (Int_t i = 0; i < kNsubZchan; i++) {
73 fZnchan[iPlan][i] = 0;
74 for (Int_t j = 0; j < kNmaxZchan; j++) {
75 fZtrkid[iPlan][j][i] = -1;
76 }
77 }
78 }
79
80}
81
6d50f529 82//_____________________________________________________________________________
83AliTRDmodule::AliTRDmodule(const AliTRDmodule &m)
84 :TObject(m)
85 ,fXprojPlane(m.fXprojPlane)
86 ,fField(m.fField)
87 ,fTracklets(NULL)
88 ,fTracks(NULL)
89 ,fDeltaY(m.fDeltaY)
90 ,fDeltaS(m.fDeltaS)
91 ,fLTUtrk(NULL)
92 ,fGTUtrk(NULL)
93{
94 //
95 // AliTRDmodule copy constructor
96 //
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
e3b2b5e5 109//_____________________________________________________________________________
110AliTRDmodule::~AliTRDmodule()
111{
112 //
6d50f529 113 // Destructor
e3b2b5e5 114 //
115
116}
117
118//_____________________________________________________________________________
119AliTRDmodule &AliTRDmodule::operator=(const AliTRDmodule &m)
120{
121 //
6d50f529 122 // Assignment operator
e3b2b5e5 123 //
124
125 if (this != &m) ((AliTRDmodule &) m).Copy(*this);
126 return *this;
127
128}
129
130//_____________________________________________________________________________
131void AliTRDmodule::Copy(TObject &m) const
132{
133 //
134 // copy function
135 //
136
6d50f529 137 ((AliTRDmodule &) m).fXprojPlane = fXprojPlane;
138 ((AliTRDmodule &) m).fField = fField;
139 ((AliTRDmodule &) m).fTracklets = NULL;
140 ((AliTRDmodule &) m).fTracks = NULL;
141 ((AliTRDmodule &) m).fDeltaY = fDeltaY;
142 ((AliTRDmodule &) m).fDeltaS = fDeltaS;
143 ((AliTRDmodule &) m).fLTUtrk = NULL;
144 ((AliTRDmodule &) m).fGTUtrk = NULL;
e3b2b5e5 145
146 for (Int_t iPlan = 0; iPlan < AliTRDgeometry::Nplan(); iPlan++) {
147 for (Int_t i = 0; i < kNsubZchan; i++) {
148 ((AliTRDmodule &) m).fZnchan[iPlan][i] = 0;
149 for (Int_t j = 0; j < kNmaxZchan; j++) {
150 ((AliTRDmodule &) m).fZtrkid[iPlan][j][i] = -1;
151 }
152 }
153 }
154
155}
156
157//_____________________________________________________________________________
158void AliTRDmodule::Reset()
159{
160 //
161 // Reset the tracks and tracklets in the module
162 //
163
164 ResetTracklets();
165 ResetTracks();
166
6d50f529 167 fLTUtrk = 0;
168 fGTUtrk = 0;
169 fTracklets = new TObjArray(400);
170 fTracks = new TObjArray(400);
e3b2b5e5 171
172}
173
174//_____________________________________________________________________________
175void AliTRDmodule::ResetTracks()
176{
177 //
178 // Reset the tracks in the module
179 //
180
181 if (fTracks) {
182
183 AliTRDgtuTrack *trk;
184 for (Int_t i = 0; i < GetNtracks(); i++) {
185
186 trk = GetTrack(i);
187 trk->Reset();
188
189 }
190
191 fTracks->Delete();
192
193 }
194
195}
196
197//_____________________________________________________________________________
5b0e57fd 198AliTRDgtuTrack *AliTRDmodule::GetTrack(Int_t pos) const
e3b2b5e5 199{
200 //
201 // Return track at position "pos"
202 //
203
6d50f529 204 if (fTracks == 0) {
205 return 0;
206 }
e3b2b5e5 207
6d50f529 208 void *trk = fTracks->UncheckedAt(pos);
209 if (trk == 0) {
210 return 0;
211 }
212
213 return (AliTRDgtuTrack *) trk;
e3b2b5e5 214
215}
216
217//_____________________________________________________________________________
218void AliTRDmodule::RemoveTrack(Int_t pos)
219{
220 //
221 // Remove the track at position "pos"
222 //
223
6d50f529 224 if (fTracks == 0) {
225 return;
226 }
227
e3b2b5e5 228 fTracks->RemoveAt(pos);
229 fTracks->Compress();
230
231}
232
233//_____________________________________________________________________________
6d50f529 234void AliTRDmodule::AddTracklet(Int_t det, Int_t row, Float_t rowz, Float_t slope
235 , Float_t offset, Float_t time, Int_t ncl
236 , Int_t label, Float_t q)
e3b2b5e5 237{
238 //
239 // Add a tracklet to this track
240 //
241
242 fLTUtrk = new AliTRDltuTracklet(det,row,rowz,slope,offset,time,ncl,label,q);
e3b2b5e5 243 Tracklets()->Add(fLTUtrk);
244
245}
246
247//_____________________________________________________________________________
5b0e57fd 248AliTRDltuTracklet *AliTRDmodule::GetTracklet(Int_t pos) const
e3b2b5e5 249{
250 //
251 // Get the tracklet at position "pos"
252 //
253
6d50f529 254 if (fTracklets == 0) {
255 return 0;
256 }
257
258 void *trk = fTracklets->UncheckedAt(pos);
259 if (trk == 0) {
260 return 0;
261 }
e3b2b5e5 262
6d50f529 263 return (AliTRDltuTracklet *) trk;
e3b2b5e5 264
265}
266
267//_____________________________________________________________________________
268void AliTRDmodule::RemoveTracklet(Int_t pos)
269{
270 //
271 // Remove the tracklet at position "pos"
272 //
273
6d50f529 274 if (fTracklets == 0) {
275 return;
276 }
277
e3b2b5e5 278 fTracklets->RemoveAt(pos);
279 fTracklets->Compress();
280
281}
282
283//_____________________________________________________________________________
284void AliTRDmodule::RemoveMultipleTracklets()
285{
286 //
287 // Remove multiple found tracklets
288 //
289
290 Float_t offDiffMin = 0.5; // [cm]
291
292 AliTRDltuTracklet *trk;
6d50f529 293 Int_t det1, det2, row1, row2, ncl1, ncl2, label1, label2;
e3b2b5e5 294 Float_t off1, off2;
6d50f529 295 Int_t itrk = 0;
296 while (itrk < (GetNtracklets() - 1)) {
297
298 trk = GetTracklet(itrk);
299 det1 = trk->GetDetector();
300 row1 = trk->GetRow();
301 off1 = trk->GetOffset();
302 ncl1 = trk->GetNclusters();
e3b2b5e5 303 label1 = trk->GetLabel();
304
6d50f529 305 trk = GetTracklet(itrk+1);
306 det2 = trk->GetDetector();
307 row2 = trk->GetRow();
308 off2 = trk->GetOffset();
309 ncl2 = trk->GetNclusters();
e3b2b5e5 310 label2 = trk->GetLabel();
311
6d50f529 312 if ((det1 == det2) && (row1 == row2)) {
313 if ((off2 - off1) < offDiffMin) {
e3b2b5e5 314 if (ncl1 < ncl2) {
315 RemoveTracklet(itrk );
6d50f529 316 }
317 else {
e3b2b5e5 318 RemoveTracklet(itrk+1);
319 }
320 }
321 }
322
323 itrk++;
324
325 }
326
327}
328
329//_____________________________________________________________________________
330void AliTRDmodule::SortZ(Int_t cha)
331{
332 //
333 // Match tracklets in the x-z plane (pad row sorting)
334 //
335
336 InitZLUT();
337
338 AliTRDltuTracklet *trk;
339 Int_t row, pla, det;
6d50f529 340
e3b2b5e5 341 for (Int_t iTrk = 0; iTrk < GetNtracklets(); iTrk++) {
342
343 trk = GetTracklet(iTrk);
e3b2b5e5 344 row = trk->GetRow();
345 det = trk->GetDetector();
346 pla = trk->GetPlane(det);
347
348 for (Int_t iZchan = 0; iZchan < kNsubZchan; iZchan++) {
349 if (fZChannelMap[cha][iZchan][pla][row] == 1) {
350 fZtrkid[pla][fZnchan[pla][iZchan]][iZchan] = iTrk;
351 fZnchan[pla][iZchan]++;
352 }
353 }
354
355 }
356
357}
358
359//_____________________________________________________________________________
360void AliTRDmodule::InitZLUT()
361{
362 //
363 // Initialize the pad row sorting look-up-table
364 //
365
366 for (Int_t iPlan = 0; iPlan < AliTRDgeometry::Nplan(); iPlan++) {
367 for (Int_t i = 0; i < kNsubZchan; i++) {
368 fZnchan[iPlan][i] = 0;
369 for (Int_t j = 0; j < kNmaxZchan; j++) {
370 fZtrkid[iPlan][j][i] = -1;
371 }
372 }
373 }
374
375}
376
377//_____________________________________________________________________________
378void AliTRDmodule::FindTracks()
379{
380 //
381 // Find tracks from tracklets
382 //
383
384 for (Int_t iZchan = 0; iZchan < kNsubZchan; iZchan++) {
385 FindTracksCombi(iZchan);
386 }
387
388}
389
390//_____________________________________________________________________________
391void AliTRDmodule::FindTracksCombi(Int_t zchan)
392{
393 //
6d50f529 394 // Find tracks by pure combinatorics...
e3b2b5e5 395 //
396
397 static Int_t trkTrack[12];
398
5b0e57fd 399 Int_t nTracklets;
400 Int_t nPlanes;
401 Int_t ntrk1;
402 Int_t trkId1;
403 Int_t ntrk2;
404 Int_t trkId2;
405
406 Float_t y1;
407 Float_t y1min;
408 Float_t y1max;
409 Float_t s1;
410 Float_t z1;
411 Float_t s1min;
412 Float_t s1max;
413 Float_t y2;
414 Float_t s2;
415 Float_t z2;
416
e3b2b5e5 417 AliTRDltuTracklet *trk1;
418 AliTRDltuTracklet *trk2;
419 AliTRDltuTracklet *trk ;
420
421 Bool_t isPlane[kNplan];
422
423 for (Int_t iPlan1 = 0; iPlan1 < kNplan; iPlan1++) {
424
425 ntrk1 = fZnchan[iPlan1][zchan];
426
427 for (Int_t iTrk1 = 0; iTrk1 < ntrk1; iTrk1++) {
428
6d50f529 429 for (Int_t iPlan = 0; iPlan < kNplan; iPlan++) {
430 isPlane[iPlan] = kFALSE;
431 }
e3b2b5e5 432
433 trkId1 = fZtrkid[iPlan1][iTrk1][zchan];
434
435 nTracklets = 0;
436 for (Int_t iList = 0; iList < kNmaxTrk; iList++) {
437 trkTrack[iList] = -1;
438 }
e3b2b5e5 439 trkTrack[nTracklets++] = trkId1;
440
441 isPlane[iPlan1] = kTRUE;
442
6d50f529 443 trk1 = GetTracklet(trkId1);
e3b2b5e5 444 y1 = trk1->GetYproj(fXprojPlane);
445 y1min = y1 - fDeltaY;
446 y1max = y1 + fDeltaY;
447 s1 = trk1->GetSlope();
448 s1min = s1 - fDeltaS;
449 s1max = s1 + fDeltaS;
450 z1 = trk1->GetZproj(fXprojPlane);
451
452 for (Int_t iPlan2 = 0; iPlan2 < kNplan; iPlan2++) {
453
454 if (iPlan2 == iPlan1) continue;
455
456 ntrk2 = fZnchan[iPlan2][zchan];
457
458 for (Int_t iTrk2 = 0; iTrk2 < ntrk2; iTrk2++) {
459
460 trkId2 = fZtrkid[iPlan2][iTrk2][zchan];
461
462 if (trkId2 == trkId1) continue;
463
464 trk2 = GetTracklet(trkId2);
6d50f529 465 y2 = trk2->GetYproj(fXprojPlane);
466 s2 = trk2->GetSlope();
467 z2 = trk2->GetZproj(fXprojPlane);
e3b2b5e5 468
469 if ((y1min < y2 && y2 < y1max) &&
470 (s1min < s2 && s2 < s1max)) {
471
472 if (nTracklets >= kNmaxTrk) {
6d50f529 473 AliWarning("Too many tracklets for this track.");
474 }
475 else {
e3b2b5e5 476 trkTrack[nTracklets++] = trkId2;
477 isPlane[iPlan2] = kTRUE;
478 }
479
480 }
481
482 } // end trk 2
483
484 } // end plan 2
485
486 nPlanes = 0;
487 for (Int_t iPlan = 0; iPlan < kNplan; iPlan++) {
6d50f529 488 nPlanes += (Int_t) isPlane[iPlan];
e3b2b5e5 489 }
490
491 if (nPlanes >= 4) {
492
493 Int_t cha1, cha2, npoints1, npoints2;
6d50f529 494 for (Int_t iList = 0; iList < (nTracklets - 1); iList++) {
e3b2b5e5 495
496 if (trkTrack[iList] == -1 || trkTrack[iList+1] == -1) continue;
497 trk1 = GetTracklet(trkTrack[iList ]);
498 trk2 = GetTracklet(trkTrack[iList+1]);
499
500 cha1 = trk1->GetDetector();
501 cha2 = trk2->GetDetector();
502 if (cha1 != cha2) continue;
503
504 npoints1 = trk1->GetNclusters();
505 npoints2 = trk2->GetNclusters();
506
507 if (npoints1 == npoints2) {
508 trkTrack[iList] = -1;
6d50f529 509 }
510 else {
e3b2b5e5 511 if (npoints1 > npoints2) trkTrack[iList+1] = -1;
512 if (npoints1 < npoints2) trkTrack[iList ] = -1;
513 }
514
515 }
516
517 fGTUtrk = new AliTRDgtuTrack();
518 for (Int_t iList = 0; iList < nTracklets; iList++) {
519 if (trkTrack[iList] == -1) continue;
520 trk = GetTracklet(trkTrack[iList]);
521 fGTUtrk->AddTracklet(trk);
522 }
523 fGTUtrk->Track(fXprojPlane,fField);
524 AddTrack();
6d50f529 525
e3b2b5e5 526 }
527
528 } // end trk 1
529
530 } // end plan 1
531
532}
533
534//_____________________________________________________________________________
535void AliTRDmodule::AddTrack()
536{
537 //
538 // Add a found track to the module
539 //
540
541 Tracks()->Add(fGTUtrk);
542
543}
544
545//_____________________________________________________________________________
546void AliTRDmodule::RemoveMultipleTracks()
547{
548 //
549 // Remove multiple found tracks
550 //
551
552 AliTRDgtuTrack *trk1;
553 AliTRDgtuTrack *trk2;
554
5b0e57fd 555 Float_t yproj1;
556 Float_t yproj2;
557 Float_t alpha1;
558 Float_t alpha2;
559 Int_t ntrk1;
560 Int_t ntrk2;
6d50f529 561 Int_t iTrack = 0;
e3b2b5e5 562
563 while (iTrack < (GetNtracks()-1)) {
564
6d50f529 565 trk1 = GetTrack(iTrack );
566 trk2 = GetTrack(iTrack+1);
e3b2b5e5 567
568 ntrk1 = trk1->GetNtracklets();
569 yproj1 = trk1->GetYproj();
570 alpha1 = trk1->GetSlope();
571 ntrk2 = trk2->GetNtracklets();
572 yproj2 = trk2->GetYproj();
573 alpha2 = trk2->GetSlope();
574
6d50f529 575 if ((TMath::Abs(yproj1-yproj2) < fDeltaY) &&
576 (TMath::Abs(alpha1-alpha2) < fDeltaS)) {
e3b2b5e5 577 if (ntrk1 < ntrk2) {
578 RemoveTrack(iTrack );
6d50f529 579 }
580 else {
e3b2b5e5 581 RemoveTrack(iTrack+1);
582 }
6d50f529 583 }
584 else {
e3b2b5e5 585 iTrack++;
586 }
587
588 }
589
590}
591
6d50f529 592//_____________________________________________________________________________
5b0e57fd 593TObjArray *AliTRDmodule::Tracklets()
6d50f529 594{
595 //
596 // Returns the list of tracklets
597 //
598
599 if (!fTracklets) {
600 fTracklets = new TObjArray(400);
601 }
602
603 return fTracklets;
604
605}
606
607//_____________________________________________________________________________
608void AliTRDmodule::ResetTracklets()
609{
610 //
611 // Resets the list of tracklets
612 //
613
614 if (fTracklets) {
615 fTracklets->Delete();
616 }
617
618}
619
620//_____________________________________________________________________________
621void AliTRDmodule::SortTracklets()
622{
623 //
624 // Sorts the list of tracklets
625 //
626
627 if (fTracklets) {
628 fTracklets->Sort();
629 }
630
631}
632
633//_____________________________________________________________________________
634Int_t AliTRDmodule::GetNtracklets() const
635{
636 //
637 // Returns the number of tracklets
638 //
639
640 if (fTracklets) {
641 return fTracklets->GetEntriesFast();
642 }
643
644 return 0;
645
646}
647
648//_____________________________________________________________________________
5b0e57fd 649TObjArray *AliTRDmodule::Tracks()
6d50f529 650{
651 //
652 // Returns the list of tracks
653 //
654
655 if (!fTracks) {
656 fTracks = new TObjArray(400);
657 }
658
659 return fTracks;
660
661}
662
663//_____________________________________________________________________________
664void AliTRDmodule::SortTracks()
665{
666 //
667 // Sort the list of tracks
668 //
669
670 if (fTracks) {
671 fTracks->Sort();
672 }
673
674}
675
676//_____________________________________________________________________________
677Int_t AliTRDmodule::GetNtracks() const
678{
679 //
680 // Returns the number of tracks
681 //
682
683 if (fTracks) {
684 return fTracks->GetEntriesFast();
685 }
686
687 return 0;
688
689}