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