]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TRD/AliTRDarrayDictionary.cxx
added track covariance matrix (yz plane) to the tracklet
[u/mrichter/AliRoot.git] / TRD / AliTRDarrayDictionary.cxx
CommitLineData
b65e5048 1/*************************************************************************
2* Copyright(c) 1998-2008, 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/* $Id: AliTRDarrayDictionary.cxx 25392 2008-04-23 19:40:29Z cblume $ */
17
18/////////////////////////////////////////////////////////
19// //
20// Container Class for Dictionary Info //
21// //
22// Author: //
23// Hermes Leon Vargas (hleon@ikf.uni-frankfurt.de) //
24// //
25/////////////////////////////////////////////////////////
26
27#include "AliTRDarrayDictionary.h"
28
29ClassImp(AliTRDarrayDictionary)
30
31//________________________________________________________________________________
32AliTRDarrayDictionary::AliTRDarrayDictionary()
33 :TObject()
34 ,fNdet(0)
35 ,fNrow(0)
36 ,fNcol(0)
37 ,fNtime(0)
38 ,fNDdim(0)
39 ,fDictionary(0)
40{
41 //
42 // AliTRDarrayDictionary default contructor
43 //
44
45}
46
47//________________________________________________________________________________
48AliTRDarrayDictionary::AliTRDarrayDictionary(Int_t nrow, Int_t ncol, Int_t ntime)
49 :TObject()
50 ,fNdet(0)
51 ,fNrow(0)
52 ,fNcol(0)
53 ,fNtime(0)
54 ,fNDdim(0)
55 ,fDictionary(0)
56
57{
58 //
59 // AliTRDarrayDictionary contructor
60 //
61
62 Allocate(nrow,ncol,ntime);
63
64}
65
66//________________________________________________________________________________
67AliTRDarrayDictionary::AliTRDarrayDictionary(const AliTRDarrayDictionary &a)
68 :TObject()
69 ,fNdet(a.fNdet)
70 ,fNrow(a.fNrow)
71 ,fNcol(a.fNcol)
72 ,fNtime(a.fNtime)
73 ,fNDdim(a.fNDdim)
74 ,fDictionary(0)
75{
76 //
77 // AliTRDarrayDictionary copy constructor
78 //
79
80 fDictionary = new Int_t[fNDdim];
81 for(Int_t i=0; i<fNDdim; i++)
82 {
83 fDictionary[i]=a.fDictionary[i];
84 }
85
86}
87
88//________________________________________________________________________________
89AliTRDarrayDictionary::~AliTRDarrayDictionary()
90{
91 //
92 // AliTRDarrayDictionary destructor
93 //
94
95 if(fDictionary)
96 {
97 delete [] fDictionary;
98 fDictionary=0;
99 }
100
101}
102
103//________________________________________________________________________________
104AliTRDarrayDictionary &AliTRDarrayDictionary::operator=(const AliTRDarrayDictionary &a)
105{
106 //
107 // Assignment operator
108 //
109
110 if(this==&a)
111 {
112 return *this;
113 }
114
115 if(fDictionary)
116 {
117 delete [] fDictionary;
118 }
119 fNdet=a.fNdet;
120 fNDdim=a.fNDdim;
121 fNrow=a.fNrow;
122 fNcol=a.fNcol;
123 fNtime=a.fNtime;
124 fDictionary = new Int_t[fNDdim];
125 for(Int_t i=0; i<fNDdim; i++)
126 {
127 fDictionary[i]=a.fDictionary[i];
128 }
129 return *this;
130
131}
132
133//________________________________________________________________________________
134void AliTRDarrayDictionary::Allocate(Int_t nrow, Int_t ncol, Int_t ntime)
135{
136 //
137 // Allocates memory for the dictionary array with dimensions
138 // Row*Col*Time
139 // Object initialized to -1
140 //
141
142 fNrow=nrow;
143 fNcol=ncol;
144 fNtime=ntime;
145 fNDdim=nrow*ncol*ntime;
146 if(fDictionary)
147 {
148 delete [] fDictionary;
149 fDictionary=0;
150 }
151 fDictionary = new Int_t[fNDdim];
152 for(Int_t i=0; i<fNDdim; i++)
153 {
154 fDictionary[i] = -1;
155 }
156
157}
158
159//________________________________________________________________________________
160void AliTRDarrayDictionary::Compress()
161{
162 //
163 // Compress the array
164 //
165
166
167 // AliDebug(1,"Compressing");
168 Int_t counter=0;
169 Int_t newDim=0;
170 Int_t j;
171 Int_t r=0;
172 Int_t *longArr;
173 longArr = new Int_t[fNDdim];
174 Int_t k=0;
175 for(Int_t i=0; i<fNDdim;i++)
176 {
177 longArr[i]=0;
178 }
179 for(Int_t i=0;i<fNDdim; i++)
180 {
181 j=0;
182 if(fDictionary[i]==-1)
183 {
184 for(k=i;k<fNDdim;k++)
185 {
186 if(fDictionary[k]==-1)
187 {
188 j=j+1;
189 longArr[r]=j;
190 }
191 else
192 {
193 break;
194 }
195 }
196 r=r+1;
197 }
198 i=i+j;
199 }
200 //Calculate the size of the compressed array
201 for(Int_t i=0; i<fNDdim;i++)
202 {
203 if(longArr[i]!=0)
204 {
205 counter=counter+longArr[i]-1;
206 }
207 }
208 newDim=fNDdim-counter; //Size of the compressed array
209 //Fill the buffer of the compressed array
210 Int_t* buffer;
211 buffer = new Int_t[newDim];
212 Int_t counterTwo=0;
213 Int_t g=0;
214 for(Int_t i=0; i<newDim; i++)
215 {
216 if(counterTwo<fNDdim)
217 {
218 if(fDictionary[counterTwo]!=-1)
219 {
220 buffer[i]=fDictionary[counterTwo];
221 }
222 if(fDictionary[counterTwo]==-1)
223 {
224 buffer[i]=-(longArr[g]);
225 counterTwo=counterTwo+longArr[g]-1;
226 g++;
227 }
228 counterTwo++;
229 }
230 }
231
232 //Copy the buffer
233 if(fDictionary)
234 {
235 delete [] fDictionary;
236 fDictionary=0;
237 }
238 fDictionary = new Int_t[newDim];
239 fNDdim = newDim;
240 for(Int_t i=0; i<newDim; i++)
241 {
242 fDictionary[i] = buffer[i];
243 }
244 if(buffer)
245 {
246 delete [] buffer;
247 buffer=0;
248 }
249 if(longArr)
250 {
251 delete [] longArr;
252 longArr=0;
253 }
254
255}
256
257//________________________________________________________________________________
258void AliTRDarrayDictionary::Expand()
259{
260 //
261 // Expand the array
262 //
263
264 Int_t *longArr;
265 longArr = new Int_t[fNDdim];
266 Int_t dimexp=0;
267 for(Int_t i=0; i<fNDdim;i++)
268 {
269 longArr[i]=0;
270 }
271 Int_t r2=0;
272 for(Int_t i=0; i<fNDdim;i++)
273 {
274 if((fDictionary[i]<0)&&(fDictionary[i]!=-1))
275 {
276 longArr[r2]=-fDictionary[i];
277 r2++;
278 }
279 }
280
281 //Calculate new dimensions
282 for(Int_t i=0; i<fNDdim;i++)
283 {
284 if(longArr[i]!=0)
285 {
286 dimexp=dimexp+longArr[i]-1;
287 }
288 }
289 dimexp=dimexp+fNDdim;
290
291 //Write in the buffer the new array
292 Int_t* bufferE;
293 bufferE = new Int_t[dimexp];
294 Int_t contaexp =0;
295 Int_t h=0;
296 for(Int_t i=0; i<dimexp; i++)
297 {
298 if(fDictionary[contaexp]>=-1)
299 {
300 bufferE[i]=fDictionary[contaexp];
301 }
302 if(fDictionary[contaexp]<-1)
303 {
304 for(Int_t j=0; j<longArr[h];j++)
305 {
306 bufferE[i+j]=-1;
307 }
308 i=i+longArr[h]-1;
309 h++;
310 }
311 contaexp++;
312 }
313
314 //Copy the buffer
315 if(fDictionary)
316 {
317 delete [] fDictionary;
318 fDictionary=0;
319 }
320
321 fDictionary = new Int_t[dimexp];
322 fNDdim = dimexp;
323 for(Int_t i=0; i<dimexp; i++)
324 {
325 fDictionary[i] = bufferE[i];
326 }
327 if(bufferE) delete [] bufferE;
328 if(longArr) delete [] longArr;
329
330}