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