]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TRD/AliTRDrecPoint.cxx
Removing semaphore .done files.
[u/mrichter/AliRoot.git] / TRD / AliTRDrecPoint.cxx
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 /* $Id$ */
17
18 ///////////////////////////////////////////////////////////////////////////////
19 //                                                                           //
20 //  TRD reconstructed point                                                  //
21 //                                                                           //
22 ///////////////////////////////////////////////////////////////////////////////
23
24 #include "AliRun.h"
25
26 #include "AliTRDgeometry.h"
27 #include "AliTRDrecPoint.h"
28
29 ClassImp(AliTRDrecPoint)
30
31 //_____________________________________________________________________________
32 AliTRDrecPoint::AliTRDrecPoint()
33   :AliRecPoint()
34   ,fDetector(0)
35   ,fTimeBin(0)
36   ,fUsed(0)
37   ,fY(0)
38   ,fZ(0)
39   ,fSigmaY2(0)
40   ,fSigmaZ2(0)
41 {
42   //
43   // Default constructor
44   //
45
46   for (Int_t i = 0; i < 3; i++) {
47     fTracks[i] = 0;
48   }
49   fGeom = AliTRDgeometry::GetGeometry();
50
51 }
52
53 //_____________________________________________________________________________
54 AliTRDrecPoint::AliTRDrecPoint(const char * opt)
55   :AliRecPoint(opt)
56   ,fDetector(0)
57   ,fTimeBin(0)
58   ,fUsed(0)
59   ,fY(0)
60   ,fZ(0)
61   ,fSigmaY2(0)
62   ,fSigmaZ2(0)
63 {
64   //
65   // Standard constructor
66   //
67
68   for (Int_t i = 0; i < 3; i++) {
69     fTracks[i] = 0;
70   }
71   fGeom = AliTRDgeometry::GetGeometry();
72
73 }
74
75 //_____________________________________________________________________________
76 AliTRDrecPoint::~AliTRDrecPoint()
77 {
78   //
79   // AliTRDrecPoint destructor
80   //
81
82 }
83
84 //_____________________________________________________________________________
85 void AliTRDrecPoint::AddDigit(Int_t digit)
86 {
87   //
88   // Adds the index of a digit to the digits list
89   //
90
91   // First resize the list 
92   // (no clusters with more than 3 digits for the TRD
93   if ((fMulDigit == 0) && 
94       (fMaxDigit >= 5)) {
95     fMaxDigit = 5;
96     delete fDigitsList;
97     fDigitsList = new int[fMaxDigit];
98   }
99
100   // Increase the size of the list if necessary
101   if (fMulDigit >= fMaxDigit) { 
102     fMaxDigit *= 2;
103     Int_t *tempo = new Int_t[fMaxDigit]; 
104     Int_t  index; 
105     for (index = 0; index < fMulDigit; index++) {
106       tempo[index] = fDigitsList[index]; 
107     }
108     delete fDigitsList; 
109     fDigitsList = tempo; 
110   }
111   
112   fDigitsList[fMulDigit++] = digit;
113
114 }
115
116 //_____________________________________________________________________________
117 void AliTRDrecPoint::SetLocalPosition(TVector3 & /*pos*/)
118 {
119   //
120   // Sets the position of the point in the local coordinate system
121   // (row,col,time) and calculates the error matrix in the same
122   // system.
123   //
124
125   AliFatal("Not implemented");
126
127 }
128
129 //_____________________________________________________________________________
130 void AliTRDrecPoint::SetTrackingYZ(Float_t /*sigmaY*/, Float_t /*sigmaZ*/)
131 {
132   //
133   // Sets the position of the point in the local coordinate system
134   // of tracking sector
135   //
136   
137   AliFatal("Not implemented");
138
139 }                                    
140
141 //_____________________________________________________________________________
142 void AliTRDrecPoint::AddTrackIndex(Int_t *track)
143 {
144   //
145   // Adds track index. Currently assumed that track is an array of
146   // size 9, and up to 3 track indexes are stored in fTracks[3].
147   // Indexes are sorted according to:
148   //  1) index of max number of appearances is stored first
149   //  2) if two or more indexes appear equal number of times, the lowest
150   //     ones are stored first;
151   //
152
153   const Int_t kSize = 9;
154   Int_t entries[kSize][2];
155
156   Int_t i = 0;
157   Int_t j = 0;
158   Int_t k = 0;
159   Int_t index;
160
161   Bool_t indexAdded;
162
163   for (i = 0; i < kSize; i++) {
164     entries[i][0] = -1;
165     entries[i][1] =  0;
166   }
167
168   for (k = 0; k < kSize; k++) {
169     index      = track[k];
170     indexAdded = kFALSE; 
171     j = 0;
172     if (index >= 0) {
173       while ((!indexAdded) && (j < kSize)) {
174         if ((entries[j][0] == index) || 
175             (entries[j][1] ==     0)) {
176           entries[j][0] = index;
177           entries[j][1] = entries[j][1]+1;
178           indexAdded    = kTRUE;
179         }
180         j++;
181       }
182     }
183   }
184
185   // Sort by number of appearances and index value
186   Int_t swap = 1;
187   Int_t tmp0;
188   Int_t tmp1;
189   while (swap > 0) {
190     swap = 0;
191     for (i = 0; i < (kSize - 1); i++) {
192       if ((entries[i][0]   >= 0) && 
193           (entries[i+1][0] >= 0)) {
194         if ((entries[i][1] < entries[i+1][1]) ||
195             ((entries[i][1] == entries[i+1][1]) &&
196              (entries[i][0]  > entries[i+1][0]))) {
197                tmp0            = entries[i][0];
198                tmp1            = entries[i][1];
199                entries[i][0]   = entries[i+1][0];
200                entries[i][1]   = entries[i+1][1];
201                entries[i+1][0] = tmp0;
202                entries[i+1][1] = tmp1;
203                swap++;
204         }
205       }
206     }
207   }
208
209   // Set track indexes
210   for(i = 0; i < 3; i++) {
211     fTracks[i] = entries[i][0];
212   }
213
214   return;
215
216 }                    
217
218
219
220
221
222
223