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