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