1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
16 ///////////////////////////////////////////////////////////////////////////////
19 // TRD 6-chambers stack //
22 ///////////////////////////////////////////////////////////////////////////////
24 #include "AliTRDgeometry.h"
25 #include "AliTRDmodule.h"
26 #include "AliTRDltuTracklet.h"
27 #include "AliTRDgtuTrack.h"
28 #include "AliTRDtrigParam.h"
29 #include "AliTRDzmaps.h"
31 ClassImp(AliTRDmodule)
33 //_____________________________________________________________________________
34 AliTRDmodule::AliTRDmodule(AliTRDtrigParam *trigp)
38 // AliTRDmodule default constructor
41 fDeltaY = trigp->GetDeltaY();
42 fDeltaS = trigp->GetDeltaS();
43 fXprojPlane = trigp->GetXprojPlane();
44 fField = trigp->GetField();
47 fTracklets = new TObjArray(400);
48 fTracks = new TObjArray(400);
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;
61 //_____________________________________________________________________________
62 AliTRDmodule::~AliTRDmodule()
70 //_____________________________________________________________________________
71 AliTRDmodule &AliTRDmodule::operator=(const AliTRDmodule &m)
74 // assignment operator
77 if (this != &m) ((AliTRDmodule &) m).Copy(*this);
82 //_____________________________________________________________________________
83 void AliTRDmodule::Copy(TObject &m) const
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;
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;
109 //_____________________________________________________________________________
110 void AliTRDmodule::Reset()
113 // Reset the tracks and tracklets in the module
121 fTracklets = new TObjArray(400);
122 fTracks = new TObjArray(400);
126 //_____________________________________________________________________________
127 void AliTRDmodule::ResetTracks()
130 // Reset the tracks in the module
136 for (Int_t i = 0; i < GetNtracks(); i++) {
149 //_____________________________________________________________________________
150 AliTRDgtuTrack* AliTRDmodule::GetTrack(Int_t pos) const
153 // Return track at position "pos"
156 if (fTracks == 0) return 0;
157 void * trk = fTracks->UncheckedAt(pos);
158 if (trk == 0) return 0;
160 return (AliTRDgtuTrack*)trk;
164 //_____________________________________________________________________________
165 void AliTRDmodule::RemoveTrack(Int_t pos)
168 // Remove the track at position "pos"
171 if (fTracks == 0) return;
172 fTracks->RemoveAt(pos);
177 //_____________________________________________________________________________
178 void AliTRDmodule::AddTracklet(Int_t det,
189 // Add a tracklet to this track
192 fLTUtrk = new AliTRDltuTracklet(det,row,rowz,slope,offset,time,ncl,label,q);
194 Tracklets()->Add(fLTUtrk);
198 //_____________________________________________________________________________
199 AliTRDltuTracklet* AliTRDmodule::GetTracklet(Int_t pos) const
202 // Get the tracklet at position "pos"
205 if (fTracklets == 0) return 0;
206 void * trk = fTracklets->UncheckedAt(pos);
207 if (trk == 0) return 0;
209 return (AliTRDltuTracklet*)trk;
213 //_____________________________________________________________________________
214 void AliTRDmodule::RemoveTracklet(Int_t pos)
217 // Remove the tracklet at position "pos"
220 if (fTracklets == 0) return;
221 fTracklets->RemoveAt(pos);
222 fTracklets->Compress();
226 //_____________________________________________________________________________
227 void AliTRDmodule::RemoveMultipleTracklets()
230 // Remove multiple found tracklets
233 Float_t offDiffMin = 0.5; // [cm]
235 AliTRDltuTracklet *trk;
236 Int_t det1, det2, row1, row2, ncl1, ncl2, label1, label2;
239 while (itrk < (GetNtracklets()-1)) {
241 trk = GetTracklet(itrk );
243 det1 = trk->GetDetector();
244 row1 = trk->GetRow();
245 off1 = trk->GetOffset();
246 ncl1 = trk->GetNclusters();
247 label1 = trk->GetLabel();
249 trk = GetTracklet(itrk+1);
251 det2 = trk->GetDetector();
252 row2 = trk->GetRow();
253 off2 = trk->GetOffset();
254 ncl2 = trk->GetNclusters();
255 label2 = trk->GetLabel();
257 if (det1 == det2 && row1 == row2) {
258 if ((off2-off1) < offDiffMin) {
260 RemoveTracklet(itrk );
262 RemoveTracklet(itrk+1);
273 //_____________________________________________________________________________
274 void AliTRDmodule::SortZ(Int_t cha)
277 // Match tracklets in the x-z plane (pad row sorting)
282 AliTRDltuTracklet *trk;
284 for (Int_t iTrk = 0; iTrk < GetNtracklets(); iTrk++) {
286 trk = GetTracklet(iTrk);
289 det = trk->GetDetector();
290 pla = trk->GetPlane(det);
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]++;
303 //_____________________________________________________________________________
304 void AliTRDmodule::InitZLUT()
307 // Initialize the pad row sorting look-up-table
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;
321 //_____________________________________________________________________________
322 void AliTRDmodule::FindTracks()
325 // Find tracks from tracklets
328 for (Int_t iZchan = 0; iZchan < kNsubZchan; iZchan++) {
329 FindTracksCombi(iZchan);
334 //_____________________________________________________________________________
335 void AliTRDmodule::FindTracksCombi(Int_t zchan)
338 // find tracks by pure combinatorics...
341 static Int_t trkTrack[12];
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 ;
350 Bool_t isPlane[kNplan];
352 for (Int_t iPlan1 = 0; iPlan1 < kNplan; iPlan1++) {
354 ntrk1 = fZnchan[iPlan1][zchan];
356 for (Int_t iTrk1 = 0; iTrk1 < ntrk1; iTrk1++) {
358 for (Int_t iPlan = 0; iPlan < kNplan; iPlan++) isPlane[iPlan] = kFALSE;
360 trkId1 = fZtrkid[iPlan1][iTrk1][zchan];
363 for (Int_t iList = 0; iList < kNmaxTrk; iList++) {
364 trkTrack[iList] = -1;
367 trkTrack[nTracklets++] = trkId1;
369 isPlane[iPlan1] = kTRUE;
371 trk1 = GetTracklet(trkId1);
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);
381 for (Int_t iPlan2 = 0; iPlan2 < kNplan; iPlan2++) {
383 if (iPlan2 == iPlan1) continue;
385 ntrk2 = fZnchan[iPlan2][zchan];
387 for (Int_t iTrk2 = 0; iTrk2 < ntrk2; iTrk2++) {
389 trkId2 = fZtrkid[iPlan2][iTrk2][zchan];
391 if (trkId2 == trkId1) continue;
393 trk2 = GetTracklet(trkId2);
395 y2 = trk2->GetYproj(fXprojPlane);
396 s2 = trk2->GetSlope();
397 z2 = trk2->GetZproj(fXprojPlane);
399 if ((y1min < y2 && y2 < y1max) &&
400 (s1min < s2 && s2 < s1max)) {
402 if (nTracklets >= kNmaxTrk) {
403 Warning("FindTracksCombi","Too many tracklets for this track.");
405 trkTrack[nTracklets++] = trkId2;
406 isPlane[iPlan2] = kTRUE;
416 for (Int_t iPlan = 0; iPlan < kNplan; iPlan++) {
417 nPlanes += (Int_t)isPlane[iPlan];
422 Int_t cha1, cha2, npoints1, npoints2;
423 for (Int_t iList = 0; iList < (nTracklets-1); iList++) {
425 if (trkTrack[iList] == -1 || trkTrack[iList+1] == -1) continue;
426 trk1 = GetTracklet(trkTrack[iList ]);
427 trk2 = GetTracklet(trkTrack[iList+1]);
429 cha1 = trk1->GetDetector();
430 cha2 = trk2->GetDetector();
431 if (cha1 != cha2) continue;
433 npoints1 = trk1->GetNclusters();
434 npoints2 = trk2->GetNclusters();
436 if (npoints1 == npoints2) {
437 trkTrack[iList] = -1;
439 if (npoints1 > npoints2) trkTrack[iList+1] = -1;
440 if (npoints1 < npoints2) trkTrack[iList ] = -1;
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);
451 fGTUtrk->Track(fXprojPlane,fField);
461 //_____________________________________________________________________________
462 void AliTRDmodule::AddTrack()
465 // Add a found track to the module
468 Tracks()->Add(fGTUtrk);
472 //_____________________________________________________________________________
473 void AliTRDmodule::RemoveMultipleTracks()
476 // Remove multiple found tracks
479 AliTRDgtuTrack *trk1;
480 AliTRDgtuTrack *trk2;
482 Float_t yproj1, yproj2, alpha1, alpha2;
486 while (iTrack < (GetNtracks()-1)) {
488 trk1 = GetTrack(iTrack );
489 trk2 = GetTrack(iTrack+1);
491 ntrk1 = trk1->GetNtracklets();
492 yproj1 = trk1->GetYproj();
493 alpha1 = trk1->GetSlope();
494 ntrk2 = trk2->GetNtracklets();
495 yproj2 = trk2->GetYproj();
496 alpha2 = trk2->GetSlope();
498 if (TMath::Abs(yproj1-yproj2) < fDeltaY && TMath::Abs(alpha1-alpha2) < fDeltaS) {
500 RemoveTrack(iTrack );
502 RemoveTrack(iTrack+1);