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