]>
Commit | Line | Data |
---|---|---|
b0f5e3fc | 1 | #include <iostream.h> |
e8189707 | 2 | #include "AliITSdigit.h" |
b0f5e3fc | 3 | #include "AliITSclusterSSD.h" |
4 | ||
5 | ClassImp(AliITSclusterSSD) | |
6 | ||
7 | AliITSclusterSSD::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; | |
20 | fCrossedClusterIndexes = new TArrayI(300); | |
21 | fConsumed=kFALSE; | |
22 | ||
23 | } | |
24 | /*************************************************************************/ | |
25 | ||
26 | AliITSclusterSSD::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 | /*************************************************************************/ | |
45 | AliITSclusterSSD::~AliITSclusterSSD() | |
46 | { | |
47 | // destructor | |
48 | delete fDigitsIndex; | |
49 | delete fCrossedClusterIndexes; | |
50 | } | |
51 | ||
52 | /*************************************************************************/ | |
53 | AliITSclusterSSD::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 | /*************************************************************************/ | |
81 | AliITSclusterSSD& 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 | /*************************************************************************/ | |
109 | Int_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 | /*******************************************************************/ | |
132 | Int_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 : | |
137 | ((AliITSdigitSSD*)((*fDigits)[(*fDigitsIndex)[digit]]))->GetStripNumber(); | |
138 | } | |
139 | /************************************************************/ | |
140 | Int_t AliITSclusterSSD::GetDigitSignal(Int_t digit) | |
141 | { | |
b0f5e3fc | 142 | // returns digit signal |
766ef0c8 | 143 | Int_t index,signal; |
b0f5e3fc | 144 | if (digit<0||digit>=fNDigits) return -1; |
145 | index = (*fDigitsIndex)[digit]; | |
146 | signal = ((AliITSdigitSSD*)((*fDigits)[index]))->GetSignal(); | |
147 | /* | |
148 | if(signal>1.e5) printf("GetDigitSignal: digit %d index %d signal %d\n", | |
149 | digit,index, signal); | |
150 | */ | |
151 | return signal; | |
152 | } | |
153 | ||
154 | /***********************************************************/ | |
155 | void AliITSclusterSSD::AddCross(Int_t clIndex) | |
156 | { | |
766ef0c8 | 157 | // add cluster cross to list of cluster crosses |
158 | ||
b0f5e3fc | 159 | (*fCrossedClusterIndexes)[fNCrosses++] = clIndex; |
160 | } | |
161 | /***********************************************************/ | |
162 | ||
163 | Int_t AliITSclusterSSD::GetCross(Int_t crIndex) | |
164 | { | |
766ef0c8 | 165 | // return crossing cluster |
166 | ||
b0f5e3fc | 167 | return ((crIndex>-1)&&(crIndex<fNCrosses))?(*fCrossedClusterIndexes)[crIndex]:-1; |
168 | } | |
169 | /***********************************************************/ | |
170 | Double_t AliITSclusterSSD::CentrOfGravity() | |
171 | { | |
766ef0c8 | 172 | // return center of gravity of the cluster |
b0f5e3fc | 173 | Float_t ret=0; |
174 | ||
175 | if (fLeftNeighbour) ret+=(GetDigitStripNo(0)*0.5*GetDigitSignal(0)); | |
176 | else ret+=(GetDigitStripNo(0)*GetDigitSignal(0)); | |
177 | ||
178 | if (fRightNeighbour) ret+=(GetDigitStripNo(fNDigits -1)*0.5*GetDigitSignal(fNDigits -1)); | |
179 | else ret+=(GetDigitStripNo(fNDigits -1)*GetDigitSignal(fNDigits-1)); | |
e8189707 | 180 | |
181 | for (Int_t i=1;i<fNDigits-1;i++) | |
b0f5e3fc | 182 | { |
183 | ret +=GetDigitStripNo(i)*GetDigitSignal(i); | |
184 | } | |
185 | ||
186 | if (fTotalSignal<0) GetTotalSignal(); | |
187 | ||
188 | return (ret/fTotalSignal); | |
189 | } | |
190 | ||
191 | /***********************************************************/ | |
192 | Float_t AliITSclusterSSD::GetTotalSignal() | |
193 | { | |
766ef0c8 | 194 | // return total signal |
195 | ||
b0f5e3fc | 196 | if(fTotalSignal <0) |
197 | { | |
198 | fTotalSignal=0; | |
199 | if (fNDigits ==1) { | |
200 | fTotalSignal = (Float_t)GetDigitSignal(0); | |
201 | //printf("1 digit: signal %d \n",GetDigitSignal(0)); | |
202 | return fTotalSignal; | |
203 | } | |
204 | ||
205 | if (fLeftNeighbour) fTotalSignal += (Float_t)(0.5*GetDigitSignal(0)); | |
206 | else fTotalSignal += (Float_t) GetDigitSignal(0); | |
207 | //printf("GetTotalSignal :i DigitSignal %d %d \n",0,GetDigitSignal(0)); | |
208 | ||
209 | if (fRightNeighbour) fTotalSignal += (Float_t)(0.5*GetDigitSignal(fNDigits -1)); | |
210 | else fTotalSignal += (Float_t)GetDigitSignal(fNDigits-1); | |
211 | //printf("GetTotalSignal :i DigitSignal %d %d \n",fNDigits -1,GetDigitSignal(fNDigits -1)); | |
e8189707 | 212 | |
213 | for (Int_t i = 1;i<fNDigits -1;i++) | |
b0f5e3fc | 214 | { |
215 | fTotalSignal += (Float_t)GetDigitSignal(i); | |
216 | //printf("GetTotalSignal :i DigitSignal %d %d \n",i,GetDigitSignal(i)); | |
217 | } | |
218 | //printf("GetTotalSignal: fNDigits %d fTotalSignal %.0f \n",fNDigits,fTotalSignal); | |
219 | } | |
220 | return fTotalSignal; | |
221 | } | |
222 | /***********************************************************/ | |
223 | ||
224 | Float_t AliITSclusterSSD::GetTotalSignalError() | |
225 | { | |
766ef0c8 | 226 | // return the error on the signal |
b0f5e3fc | 227 | Float_t err =0; |
e8189707 | 228 | for (Int_t i =1; i<fNDigits -1; i++) |
b0f5e3fc | 229 | { |
230 | err+=0.1*GetDigitSignal(i); | |
231 | } | |
232 | if (GetLeftNeighbour()) | |
233 | { | |
234 | err+=GetDigitSignal(0); | |
235 | } | |
236 | else | |
237 | { | |
238 | err+=0.1*GetDigitSignal(0); | |
239 | } | |
240 | if (GetRightNeighbour()) | |
241 | { | |
242 | err+=GetDigitSignal(fNDigits -1); | |
243 | } | |
244 | else | |
245 | { | |
246 | err+=0.1*GetDigitSignal(fNDigits -1); | |
247 | } | |
248 | return err; | |
249 | ||
250 | } | |
251 | ||
252 | /***********************************************************/ | |
253 | ||
254 | void AliITSclusterSSD::DelCross(Int_t index) | |
255 | { | |
766ef0c8 | 256 | // remove cross clusters from the list of cross clusters |
b0f5e3fc | 257 | Int_t i,j; //iterators |
258 | ||
e8189707 | 259 | for (i =0;i<fNCrosses;i++) |
b0f5e3fc | 260 | { |
261 | if ((*fCrossedClusterIndexes)[i] == index) | |
262 | { | |
e8189707 | 263 | for (j=i;j<fNCrosses-1;j++) |
b0f5e3fc | 264 | { |
265 | (*fCrossedClusterIndexes)[j]=(*fCrossedClusterIndexes)[j+1]; | |
266 | } | |
267 | fNCrosses--; | |
268 | return; | |
269 | } | |
270 | } | |
271 | ||
272 | } | |
273 | /***********************************************************/ | |
274 | ||
275 | Int_t *AliITSclusterSSD::GetTracks(Int_t &nt) | |
276 | { | |
766ef0c8 | 277 | // return the track number of the cluster |
b0f5e3fc | 278 | Int_t *tidx=0; |
f239b2fe | 279 | Int_t i, j; |
280 | Int_t bit =0; | |
281 | Int_t ntracks=0; | |
b0f5e3fc | 282 | nt=0; |
283 | ||
f239b2fe | 284 | for (i=0;i<10;i++) { |
285 | fTrack[i] = -2; | |
286 | } | |
b0f5e3fc | 287 | |
f239b2fe | 288 | //cout<<"GetTrack start -------: fNDigits ="<<fNDigits<<endl; |
b0f5e3fc | 289 | |
f239b2fe | 290 | for (i = 0; i<fNDigits; i++) { |
291 | tidx=GetDigit(i)->GetTracks(); | |
292 | for (j = 0; j<3;j++) { | |
293 | if (tidx[j] >= 0) { | |
294 | if(ntracks == 0){ | |
295 | ntracks++; | |
296 | fTrack[ntracks-1] = tidx[j]; | |
297 | }else if(tidx[j] != fTrack[ntracks-1]){ | |
298 | ntracks++; | |
299 | if(ntracks > 9) { | |
300 | bit = 1; | |
301 | break; | |
302 | } | |
303 | fTrack[ntracks-1] = tidx[j]; | |
304 | } | |
305 | } | |
306 | //cout<<"digit,dtrack,tidx,bit ="<<i<<","<<j<<","<<tidx[j]<<","<<bit<<endl; | |
307 | //if(ntracks>0) cout<<"digit,dtrack,fTrack,ntracks ="<<i<<","<<j<<","<<fTrack[ntracks-1]<<","<<ntracks<<endl; | |
308 | } // 3-tracks loop for the digit | |
309 | if(bit == 1) break; | |
310 | } // digit loop | |
311 | ||
312 | SetNTracks(ntracks); | |
313 | nt = ntracks; | |
314 | //if(nt == 0) cout<<"!!! No tracks"<<endl; | |
315 | //cout<<"GetTracks: nt,fTrack0,fTrack1,fTrack2 ="<< nt<<","<<fTrack[0]<<","<<fTrack[1]<<","<<fTrack[2]<<endl; | |
b0f5e3fc | 316 | return &(fTrack[0]); |
317 | } | |
318 | /***********************************************************/ | |
319 | ||
320 | Double_t AliITSclusterSSD::GetPosition() | |
321 | { | |
766ef0c8 | 322 | // return position of the cluster |
b0f5e3fc | 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 | ||
340 | Double_t AliITSclusterSSD::EtaAlgorithm() | |
341 | { | |
766ef0c8 | 342 | // algorithm for determing cluster position |
b0f5e3fc | 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 | ||
371 | Double_t AliITSclusterSSD::GetPositionError() | |
372 | { | |
766ef0c8 | 373 | // return the position error |
b0f5e3fc | 374 | return (GetNumOfDigits()+1)/2; |
375 | } | |
376 | ||
377 | Bool_t AliITSclusterSSD::IsCrossingWith(Int_t idx) | |
378 | { | |
766ef0c8 | 379 | // return the cluster to which he crosses |
e8189707 | 380 | for (Int_t i =0; i< fNCrosses;i++) |
b0f5e3fc | 381 | { |
382 | if (GetCross(i) == idx) return kTRUE; | |
383 | } | |
384 | return kFALSE; | |
385 | } |