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