Release version of ITS code
[u/mrichter/AliRoot.git] / ITS / AliITSclusterSSD.cxx
CommitLineData
b0f5e3fc 1#include <iostream.h>
2
e8189707 3#include "AliITSdigit.h"
b0f5e3fc 4#include "AliITSclusterSSD.h"
5
6ClassImp(AliITSclusterSSD)
7
8AliITSclusterSSD::AliITSclusterSSD()
9{
10 // default constructor
e8189707 11 fSide = kTRUE;
b0f5e3fc 12 fDigits = 0;
13 fNDigits = 0;
14 fDigitsIndex = 0;
15 fNCrosses = 0;
16 fTotalSignal = -1;
17 fNTrack = -1;
18 fLeftNeighbour = kFALSE;
19 fRightNeighbour = kFALSE;
20 fCrossedClusterIndexes = new TArrayI(300);
21 fConsumed=kFALSE;
22
23}
24/*************************************************************************/
25
26AliITSclusterSSD::AliITSclusterSSD
27 (Int_t ndigits, Int_t *DigitIndexes,
28 TObjArray *Digits, Bool_t side)
29{
30 // comment to be written
31 fNDigits = ndigits;
32 fDigits = Digits;
33 fSide = side;
34 fDigitsIndex = new TArrayI(fNDigits,DigitIndexes );
35 fNCrosses = 0;
36 fCrossedClusterIndexes = new TArrayI(300);
37 fLeftNeighbour = kFALSE;
38 fRightNeighbour = kFALSE;
39 fTotalSignal =-1;
40 fNTrack = -1;
41 fConsumed=kFALSE;
42}
43/*************************************************************************/
44AliITSclusterSSD::~AliITSclusterSSD()
45{
46 // destructor
47 delete fDigitsIndex;
48 delete fCrossedClusterIndexes;
49}
50
51/*************************************************************************/
52AliITSclusterSSD::AliITSclusterSSD(const AliITSclusterSSD &OneSCluster)
53{
54 // copy constructor
55 if (this == &OneSCluster) return;
56 fNDigits = OneSCluster.fNDigits;
57 fSide=OneSCluster.fSide;
58 fDigits=OneSCluster.fDigits;
59 fDigitsIndex = new TArrayI(fNDigits);
60 fLeftNeighbour = OneSCluster.fLeftNeighbour;
61 fRightNeighbour = OneSCluster.fRightNeighbour;
62 fTotalSignal =-1;
63 fNTrack = -1;
64 fNCrosses = OneSCluster.fNCrosses;
65 fConsumed = OneSCluster.fConsumed;
66 Int_t i;
e8189707 67 for (i = 0; i< fNCrosses ; i++)
b0f5e3fc 68 {
69 fCrossedClusterIndexes[i] = OneSCluster.fCrossedClusterIndexes[i];
70 }
e8189707 71 for (i = 0; i< fNDigits ; i++)
b0f5e3fc 72 {
73 fDigitsIndex[i]=OneSCluster.fDigitsIndex[i];
74 }
75 return;
76}
77
78/*************************************************************************/
79AliITSclusterSSD& AliITSclusterSSD::operator=(const AliITSclusterSSD & OneSCluster)
80{
81 // assignment operator
82 if (this == &OneSCluster) return *this;
83 fNDigits = OneSCluster.fNDigits;
84 fSide=OneSCluster.fSide;
85 fDigits=OneSCluster.fDigits;
86 fDigitsIndex = new TArrayI(fNDigits);
87 fLeftNeighbour = OneSCluster.fLeftNeighbour;
88 fRightNeighbour = OneSCluster.fRightNeighbour;
89 fTotalSignal =-1;
90 fNTrack = -1;
91 fNCrosses = OneSCluster.fNCrosses;
92 fConsumed = OneSCluster.fConsumed;
93 Int_t i;
e8189707 94 for (i = 0; i< fNCrosses ; i++)
b0f5e3fc 95 {
96 fCrossedClusterIndexes[i] = OneSCluster.fCrossedClusterIndexes[i];
97 }
e8189707 98 for (i = 0; i< fNDigits ; i++)
b0f5e3fc 99 {
100 fDigitsIndex[i]=OneSCluster.fDigitsIndex[i];
101 }
102 return *this;
103}
104
105/*************************************************************************/
106Int_t AliITSclusterSSD::SplitCluster(Int_t where, Int_t *outdigits)
107{
108//This methods generate data necessery to make new object of this class
109//I choosen this way, because methods TClonesArray::Add* dont work
110//so I have to use constraction: new (a[i]) Creator(params...);
111//where 'a' is a TClonesArray
112//This method generate params - see AliITSmoduleSSD::SplitCluster;
113
114
115 Int_t tmp = fNDigits;
116 Int_t ind = 0;
117 outdigits[ind++]=(*fDigitsIndex)[where];
118 //coping border strip (it is shared by this two clusters)
e8189707 119 for (Int_t i = (where+1); i < tmp; i++)
b0f5e3fc 120 {
121 outdigits[ind++]=(*fDigitsIndex)[i]; //"moving" strips from this to the new one
122 (*fDigitsIndex)[i]=-1;
123 fNDigits--; //deleting strips from this cluster
124 }
125 return ind;
126}
127
128/*******************************************************************/
129Int_t AliITSclusterSSD::GetDigitStripNo(Int_t digit)
130{
131 // comment to be written
132 if (digit<0) return -1;
133 return (digit>(fNDigits-1))?-1 :
134 ((AliITSdigitSSD*)((*fDigits)[(*fDigitsIndex)[digit]]))->GetStripNumber();
135}
136/************************************************************/
137Int_t AliITSclusterSSD::GetDigitSignal(Int_t digit)
138{
139 Int_t index,signal;
140 // returns digit signal
141 if (digit<0||digit>=fNDigits) return -1;
142 index = (*fDigitsIndex)[digit];
143 signal = ((AliITSdigitSSD*)((*fDigits)[index]))->GetSignal();
144 /*
145 if(signal>1.e5) printf("GetDigitSignal: digit %d index %d signal %d\n",
146 digit,index, signal);
147 */
148 return signal;
149}
150
151/***********************************************************/
152void AliITSclusterSSD::AddCross(Int_t clIndex)
153{
154 // comment to be written
155 (*fCrossedClusterIndexes)[fNCrosses++] = clIndex;
156}
157/***********************************************************/
158
159Int_t AliITSclusterSSD::GetCross(Int_t crIndex)
160{
161 // comment to be written
162 return ((crIndex>-1)&&(crIndex<fNCrosses))?(*fCrossedClusterIndexes)[crIndex]:-1;
163}
164/***********************************************************/
165Double_t AliITSclusterSSD::CentrOfGravity()
166{
167 // comment to be written
168 Float_t ret=0;
169
170 if (fLeftNeighbour) ret+=(GetDigitStripNo(0)*0.5*GetDigitSignal(0));
171 else ret+=(GetDigitStripNo(0)*GetDigitSignal(0));
172
173 if (fRightNeighbour) ret+=(GetDigitStripNo(fNDigits -1)*0.5*GetDigitSignal(fNDigits -1));
174 else ret+=(GetDigitStripNo(fNDigits -1)*GetDigitSignal(fNDigits-1));
e8189707 175
176 for (Int_t i=1;i<fNDigits-1;i++)
b0f5e3fc 177 {
178 ret +=GetDigitStripNo(i)*GetDigitSignal(i);
179 }
180
181 if (fTotalSignal<0) GetTotalSignal();
182
183 return (ret/fTotalSignal);
184}
185
186/***********************************************************/
187Float_t AliITSclusterSSD::GetTotalSignal()
188{
189 // comment to be written
190 if(fTotalSignal <0)
191 {
192 fTotalSignal=0;
193 if (fNDigits ==1) {
194 fTotalSignal = (Float_t)GetDigitSignal(0);
195 //printf("1 digit: signal %d \n",GetDigitSignal(0));
196 return fTotalSignal;
197 }
198
199 if (fLeftNeighbour) fTotalSignal += (Float_t)(0.5*GetDigitSignal(0));
200 else fTotalSignal += (Float_t) GetDigitSignal(0);
201 //printf("GetTotalSignal :i DigitSignal %d %d \n",0,GetDigitSignal(0));
202
203 if (fRightNeighbour) fTotalSignal += (Float_t)(0.5*GetDigitSignal(fNDigits -1));
204 else fTotalSignal += (Float_t)GetDigitSignal(fNDigits-1);
205 //printf("GetTotalSignal :i DigitSignal %d %d \n",fNDigits -1,GetDigitSignal(fNDigits -1));
e8189707 206
207 for (Int_t i = 1;i<fNDigits -1;i++)
b0f5e3fc 208 {
209 fTotalSignal += (Float_t)GetDigitSignal(i);
210 //printf("GetTotalSignal :i DigitSignal %d %d \n",i,GetDigitSignal(i));
211 }
212 //printf("GetTotalSignal: fNDigits %d fTotalSignal %.0f \n",fNDigits,fTotalSignal);
213 }
214 return fTotalSignal;
215}
216/***********************************************************/
217
218Float_t AliITSclusterSSD::GetTotalSignalError()
219{
220 // comment to be written
221 Float_t err =0;
e8189707 222 for (Int_t i =1; i<fNDigits -1; i++)
b0f5e3fc 223 {
224 err+=0.1*GetDigitSignal(i);
225 }
226 if (GetLeftNeighbour())
227 {
228 err+=GetDigitSignal(0);
229 }
230 else
231 {
232 err+=0.1*GetDigitSignal(0);
233 }
234 if (GetRightNeighbour())
235 {
236 err+=GetDigitSignal(fNDigits -1);
237 }
238 else
239 {
240 err+=0.1*GetDigitSignal(fNDigits -1);
241 }
242 return err;
243
244}
245
246/***********************************************************/
247
248void AliITSclusterSSD::DelCross(Int_t index)
249{
250 // comment to be written
251Int_t i,j; //iterators
252
e8189707 253for (i =0;i<fNCrosses;i++)
b0f5e3fc 254 {
255 if ((*fCrossedClusterIndexes)[i] == index)
256 {
e8189707 257 for (j=i;j<fNCrosses-1;j++)
b0f5e3fc 258 {
259 (*fCrossedClusterIndexes)[j]=(*fCrossedClusterIndexes)[j+1];
260 }
261 fNCrosses--;
262 return;
263 }
264 }
265
266}
267/***********************************************************/
268
269Int_t *AliITSclusterSSD::GetTracks(Int_t &nt)
270{
271 // comment to be written
272 Int_t *tidx=0;
273 Int_t i, bit;
274 nt=0;
275
276
277
278 fNTrack =0;
e8189707 279 for (i=0;i<10;i++)
b0f5e3fc 280 {
281 fTrack[i] = 0;
282 }
283
284 tidx=GetDigit(0)->GetTracks();
285
e8189707 286 for (i = 0; i<3;i++)
b0f5e3fc 287 {
288 fTrack[i]=tidx[i];
289 if (fTrack[i] != 0) fNTrack++;
290 }
e8189707 291 for (i = 1; i<fNDigits; i++)
b0f5e3fc 292 {
293 tidx=GetDigit(i)->GetTracks();
e8189707 294 for (Int_t j = 0; j<3;j++)
b0f5e3fc 295 {
296 bit = 1;
297 if (tidx[j]==0) break;
e8189707 298 for (Int_t k = 0; k < fNTrack;k++)
b0f5e3fc 299 {
300 if (tidx[j]==fTrack[k]) bit =0;
301 }
302 if (bit) fTrack[fNTrack++]=tidx[j];
303 }
304 }
305
306
307 if (fNTrack > 10)
308 {
309 cout<<"\n\n Error AliITSclusterSSD::GetTracks OUT "<<fNDigits<<" "<<fNTrack<<"\n\n\n\n\n";
310
311 }
312
313
314 nt = fNTrack;
315 if(!nt) return 0;
316 return &(fTrack[0]);
317}
318/***********************************************************/
319
320Double_t AliITSclusterSSD::GetPosition()
321{
322 // comment to be written
323 Float_t ret;
324 switch(fNDigits)
325 {
326 case 1:
327 ret = GetDigitStripNo(0);
328 break;
329 case 2:
330 ret = EtaAlgorithm();
331 break;
332 default:
333 ret = CentrOfGravity();
334 }
335 return ret;
336}
337
338/***********************************************************/
339
340Double_t AliITSclusterSSD::EtaAlgorithm()
341{
342 // comment to be written
343 if (fNDigits != 2) return -1;
344
345 Int_t strip1 = GetDigit(0)->GetStripNumber();
346 Int_t strip2 = GetDigit(1)->GetStripNumber();
347 Int_t signal1 = GetDigit(0)->GetSignal();
348 Int_t signal2 = GetDigit(1)->GetSignal();
349
350 Double_t eta;
351
352
353 if (strip1<strip2)
354 {
355 eta = ((Double_t)signal2)/((Double_t)(signal1+signal2));
356 if (eta<0.04) return strip1;
357 if (eta>0.96) return strip2;
358 return (strip1 + 0.43478261*eta + 0.2826087);
359 }
360 else
361 {
362 eta = ((Double_t)signal1)/((Double_t)(signal1+signal2));
363 if (eta<0.04) return strip2;
364 if (eta>0.96) return strip1;
365 return (strip2 + 0.43478261*eta + 0.2826087);
366 }
367
368
369}
370
371Double_t AliITSclusterSSD::GetPositionError()
372{
373 // comment to be written
374 return (GetNumOfDigits()+1)/2;
375}
376
377Bool_t AliITSclusterSSD::IsCrossingWith(Int_t idx)
378{
379 // comment to be written
e8189707 380 for (Int_t i =0; i< fNCrosses;i++)
b0f5e3fc 381 {
382 if (GetCross(i) == idx) return kTRUE;
383 }
384 return kFALSE;
385}