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