]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TRD/AliTRDrecPoint.cxx
09d1184ae52e34faa9dbe50954a5450c4b4057bf
[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 /*
17 $Log$
18 Revision 1.7.6.2  2002/07/24 10:09:31  alibrary
19 Updating VirtualMC
20
21 Revision 1.7.6.1  2002/06/10 15:28:58  hristov
22 Merged with v3-08-02
23
24 Revision 1.8  2002/03/28 14:59:07  cblume
25 Coding conventions
26
27 Revision 1.9  2002/06/12 09:54:35  cblume
28 Update of tracking code provided by Sergei
29
30 Revision 1.8  2002/03/28 14:59:07  cblume
31 Coding conventions
32
33 Revision 1.7  2001/12/05 15:04:34  hristov
34 Changes related to the corrections of AliRecPoint
35
36 Revision 1.6  2001/02/14 18:22:26  cblume
37 Change in the geometry of the padplane
38
39 Revision 1.5  2000/11/14 14:40:27  cblume
40 Correction for the Sun compiler (kTRUE and kFALSE)
41
42 Revision 1.4  2000/11/01 14:53:21  cblume
43 Merge with TRD-develop
44
45 Revision 1.1.4.2  2000/10/04 16:34:58  cblume
46 Replace include files by forward declarations
47
48 Revision 1.1.4.1  2000/09/22 14:50:39  cblume
49 Adapted to tracking code
50
51 Revision 1.3  2000/06/09 11:10:07  cblume
52 Compiler warnings and coding conventions, next round
53
54 Revision 1.2  2000/06/08 18:32:58  cblume
55 Make code compliant to coding conventions
56
57 Revision 1.1  2000/02/28 19:02:07  cblume
58 Add new TRD classes
59
60 */
61
62 ///////////////////////////////////////////////////////////////////////////////
63 //                                                                           //
64 //  TRD reconstructed point                                                  //
65 //                                                                           //
66 ///////////////////////////////////////////////////////////////////////////////
67
68 #include "AliRun.h"
69
70 #include "AliTRDgeometry.h"
71 #include "AliTRDrecPoint.h"
72 #include "AliTRD.h"
73
74 ClassImp(AliTRDrecPoint)
75
76 //_____________________________________________________________________________
77 AliTRDrecPoint::AliTRDrecPoint():AliRecPoint()
78 {
79   //
80   // Standard constructor
81   //
82
83   fDetector = 0;
84
85   AliTRD *trd;
86   if ((gAlice) &&
87       (trd = ((AliTRD*) gAlice->GetDetector("TRD")))) {
88     fGeom = trd->GetGeometry();
89   }
90   else {
91     fGeom = NULL;
92   }
93
94 }
95
96 //_____________________________________________________________________________
97 AliTRDrecPoint::AliTRDrecPoint(const char * opt):AliRecPoint(opt)
98 {
99   //
100   // Standard constructor
101   //
102
103   fDetector = 0;
104
105   AliTRD *trd;
106   if ((gAlice) &&
107       (trd = ((AliTRD*) gAlice->GetDetector("TRD")))) {
108     fGeom = trd->GetGeometry();
109   }
110   else {
111     fGeom = NULL;
112   }
113
114 }
115
116 //_____________________________________________________________________________
117 AliTRDrecPoint::~AliTRDrecPoint()
118 {
119   //
120   // AliTRDrecPoint destructor
121   //
122
123 }
124
125 //_____________________________________________________________________________
126 void AliTRDrecPoint::AddDigit(Int_t digit)
127 {
128   //
129   // Adds the index of a digit to the digits list
130   //
131
132   // First resize the list 
133   // (no clusters with more than 3 digits for the TRD
134   if ((fMulDigit == 0) && (fMaxDigit >= 5)) {
135     fMaxDigit = 5;
136     delete fDigitsList;
137     fDigitsList = new int[fMaxDigit];
138   }
139
140   // Increase the size of the list if necessary
141   if (fMulDigit >= fMaxDigit) { 
142     fMaxDigit *= 2;
143     int *tempo = new (int[fMaxDigit]); 
144     Int_t index; 
145     for (index = 0; index < fMulDigit; index++)
146       tempo[index] = fDigitsList[index]; 
147     delete fDigitsList; 
148     fDigitsList = tempo; 
149   }
150   
151   fDigitsList[fMulDigit++] = digit;
152
153 }
154
155 //_____________________________________________________________________________
156 void AliTRDrecPoint::SetLocalPosition(TVector3 &pos)
157 {
158   //
159   // Sets the position of the point in the local coordinate system
160   // (row,col,time) and calculates the error matrix in the same
161   // system.
162   //
163
164   //const Float_t kSq12 = 3.464101615;
165
166   // Set the position
167   //fLocPos = pos;
168
169   // Set the error matrix
170   // row:  pad-size / sqrt(12)
171   // col:  not defined yet
172   // time: bin-size / sqrt(12)
173   //Int_t plane   = ((AliTRDgeometry *) fGeom)->GetPlane(fDetector);
174   //Int_t chamber = ((AliTRDgeometry *) fGeom)->GetChamber(fDetector);
175   //Int_t sector  = ((AliTRDgeometry *) fGeom)->GetSector(fDetector);
176   //fLocPosM->operator()(0,0) = ((AliTRDgeometry *) fGeom)->GetRowPadSize(plane
177   //                                                                     ,chamber
178   //                                                                     ,sector) 
179   //                          / kSq12;
180   //fLocPosM->operator()(1,1) = 0.0;
181   //fLocPosM->operator()(2,2) = ((AliTRDgeometry *) fGeom)->GetTimeBinSize() 
182   //                          / kSq12;
183
184   //  printf("rec. point: row = %f, col = %f, time = %f \n",
185   //           fLocPos[0],fLocPos[1],fLocPos[2]); 
186
187 }
188
189 //_____________________________________________________________________________
190 void AliTRDrecPoint::SetTrackingYZ(Float_t sigmaY, Float_t sigmaZ)
191 {
192  //
193  // Sets the position of the point in the local coordinate system
194  // of tracking sector
195  //
196
197   //Int_t plane = ((AliTRDgeometry *) fGeom)->GetPlane(fDetector);
198   //Int_t chamber = ((AliTRDgeometry *) fGeom)->GetChamber(fDetector);
199   //Int_t sector = ((AliTRDgeometry *) fGeom)->GetSector(fDetector);
200
201
202  // Set the position
203
204   //Float_t   padRow    = fLocPos[0];             // Pad Row position
205   //Float_t   padCol    = fLocPos[1];             // Pad Column position
206
207   //Float_t   col0 = ((AliTRDgeometry *) fGeom)->GetCol0(plane);
208   //Float_t   row0 = ((AliTRDgeometry *) fGeom)->GetRow0(plane,chamber,sector);
209
210   //  Float_t   offset = 0.5 * ((AliTRDgeometry *) fGeom)->GetChamberWidth(plane);
211
212   //fY = - (col0 + padCol * ((AliTRDgeometry *) fGeom)->GetColPadSize(plane));
213   //fZ =    row0 + padRow * ((AliTRDgeometry *) fGeom)->GetRowPadSize(plane
214   //                                                                   ,chamber
215   //                                                                 ,sector);
216
217   //  fSigmaY = sigmaY * sigmaY;
218   //  fSigmaZ = sigmaZ * sigmaZ;
219
220 //fSigmaY2 = 0.05 * 0.05;
221
222 //fSigmaZ2 = ((AliTRDgeometry *) fGeom)->GetRowPadSize(plane,chamber,sector)
223 //         * ((AliTRDgeometry *) fGeom)->GetRowPadSize(plane,chamber,sector) 
224 //         / 12.;
225
226 }                                    
227
228 //_____________________________________________________________________________
229 void AliTRDrecPoint::AddTrackIndex(Int_t *track)
230 {
231  // Adds track index. Currently assumed that track is an array of
232  // size 9, and up to 3 track indexes are stored in fTracks[3].
233  // Indexes are sorted according to:
234  //  1) index of max number of appearances is stored first
235  //  2) if two or more indexes appear equal number of times, the lowest
236  //     ones are stored first;
237
238   const Int_t kSize = 9;
239
240   Int_t entries[kSize][2], i, j, index;
241
242   Bool_t indexAdded;
243
244   for (i=0; i<kSize; i++) {
245     entries[i][0]=-1;
246     entries[i][1]=0;
247   }
248
249
250   for (Int_t k=0; k<kSize; k++) {
251     index=track[k];
252     indexAdded=kFALSE; j=0;
253     if (index >= 0) {
254       while ( (!indexAdded) && ( j < kSize ) ) {
255         if ((entries[j][0]==index) || (entries[j][1]==0)) {
256           entries[j][0]=index;
257           entries[j][1]=entries[j][1]+1;
258           indexAdded=kTRUE;
259         }
260         j++;
261       }
262     }
263   }                   
264
265   // sort by number of appearances and index value
266   Int_t swap=1, tmp0, tmp1;
267   while ( swap > 0) {
268     swap=0;
269     for(i=0; i<(kSize-1); i++) {
270       if ((entries[i][0] >= 0) && (entries[i+1][0] >= 0)) {
271         if ((entries[i][1] < entries[i+1][1]) ||
272             ((entries[i][1] == entries[i+1][1]) &&
273              (entries[i][0] > entries[i+1][0]))) {
274                tmp0=entries[i][0];
275                tmp1=entries[i][1];
276                entries[i][0]=entries[i+1][0];
277                entries[i][1]=entries[i+1][1];
278                entries[i+1][0]=tmp0;
279                entries[i+1][1]=tmp1;
280                swap++;
281         }
282       }
283     }
284   }
285
286   // set track indexes
287
288   for(i=0; i<3; i++) {
289     fTracks[i] = entries[i][0];
290   }
291
292   return;
293
294 }                    
295
296
297
298
299
300
301