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