2 #include "AliITSdigit.h"
3 #include "AliITSclusterSSD.h"
5 ClassImp(AliITSclusterSSD)
7 AliITSclusterSSD::AliITSclusterSSD()
18 fLeftNeighbour = kFALSE;
19 fRightNeighbour = kFALSE;
20 fCrossedClusterIndexes = 0;
24 /*************************************************************************/
26 AliITSclusterSSD::AliITSclusterSSD
27 (Int_t ndigits, Int_t *DigitIndexes,
28 TObjArray *Digits, Bool_t side)
30 // non-default constructor
35 fDigitsIndex = new TArrayI(fNDigits,DigitIndexes );
37 fCrossedClusterIndexes = new TArrayI(300);
38 fLeftNeighbour = kFALSE;
39 fRightNeighbour = kFALSE;
44 /*************************************************************************/
45 AliITSclusterSSD::~AliITSclusterSSD()
49 delete fCrossedClusterIndexes;
52 /*************************************************************************/
53 AliITSclusterSSD::AliITSclusterSSD(const AliITSclusterSSD &OneSCluster)
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;
66 fNCrosses = OneSCluster.fNCrosses;
67 fConsumed = OneSCluster.fConsumed;
69 for (i = 0; i< fNCrosses ; i++)
71 fCrossedClusterIndexes[i] = OneSCluster.fCrossedClusterIndexes[i];
73 for (i = 0; i< fNDigits ; i++)
75 fDigitsIndex[i]=OneSCluster.fDigitsIndex[i];
80 /*************************************************************************/
81 AliITSclusterSSD& AliITSclusterSSD::operator=(const AliITSclusterSSD & OneSCluster)
83 // assignment operator
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;
94 fNCrosses = OneSCluster.fNCrosses;
95 fConsumed = OneSCluster.fConsumed;
97 for (i = 0; i< fNCrosses ; i++)
99 fCrossedClusterIndexes[i] = OneSCluster.fCrossedClusterIndexes[i];
101 for (i = 0; i< fNDigits ; i++)
103 fDigitsIndex[i]=OneSCluster.fDigitsIndex[i];
108 /*************************************************************************/
109 Int_t AliITSclusterSSD::SplitCluster(Int_t where, Int_t *outdigits)
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;
118 Int_t tmp = fNDigits;
120 outdigits[ind++]=(*fDigitsIndex)[where];
121 //coping border strip (it is shared by this two clusters)
122 for (Int_t i = (where+1); i < tmp; i++)
124 outdigits[ind++]=(*fDigitsIndex)[i]; //"moving" strips from this to the new one
125 (*fDigitsIndex)[i]=-1;
126 fNDigits--; //deleting strips from this cluster
131 /*******************************************************************/
132 Int_t AliITSclusterSSD::GetDigitStripNo(Int_t digit)
134 // return strip no of a digit
135 if (digit<0) return -1;
136 return (digit>(fNDigits-1))?-1 :
137 //PH ((AliITSdigitSSD*)((*fDigits)[(*fDigitsIndex)[digit]]))->GetStripNumber();
138 ((AliITSdigitSSD*)(fDigits->At((*fDigitsIndex)[digit])))->GetStripNumber();
140 /************************************************************/
141 Int_t AliITSclusterSSD::GetDigitSignal(Int_t digit)
143 // returns digit signal
145 if (digit<0||digit>=fNDigits) return -1;
146 index = (*fDigitsIndex)[digit];
147 //PH signal = ((AliITSdigitSSD*)((*fDigits)[index]))->GetSignal();
148 signal = ((AliITSdigitSSD*)(fDigits->At(index)))->GetSignal();
150 if(signal>1.e5) printf("GetDigitSignal: digit %d index %d signal %d\n",
151 digit,index, signal);
156 /***********************************************************/
157 void AliITSclusterSSD::AddCross(Int_t clIndex)
159 // add cluster cross to list of cluster crosses
161 (*fCrossedClusterIndexes)[fNCrosses++] = clIndex;
163 /***********************************************************/
165 Int_t AliITSclusterSSD::GetCross(Int_t crIndex)
167 // return crossing cluster
169 return ((crIndex>-1)&&(crIndex<fNCrosses))?(*fCrossedClusterIndexes)[crIndex]:-1;
171 /***********************************************************/
172 Double_t AliITSclusterSSD::CentrOfGravity()
174 // return center of gravity of the cluster
177 if (fLeftNeighbour) ret+=(GetDigitStripNo(0)*0.5*GetDigitSignal(0));
178 else ret+=(GetDigitStripNo(0)*GetDigitSignal(0));
180 if (fRightNeighbour) ret+=(GetDigitStripNo(fNDigits -1)*0.5*GetDigitSignal(fNDigits -1));
181 else ret+=(GetDigitStripNo(fNDigits -1)*GetDigitSignal(fNDigits-1));
183 for (Int_t i=1;i<fNDigits-1;i++)
185 ret +=GetDigitStripNo(i)*GetDigitSignal(i);
188 if (fTotalSignal<0) GetTotalSignal();
190 return (ret/fTotalSignal);
193 /***********************************************************/
194 Float_t AliITSclusterSSD::GetTotalSignal()
196 // return total signal
202 fTotalSignal = (Float_t)GetDigitSignal(0);
203 //printf("1 digit: signal %d \n",GetDigitSignal(0));
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));
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));
215 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));
220 //printf("GetTotalSignal: fNDigits %d fTotalSignal %.0f \n",fNDigits,fTotalSignal);
224 /***********************************************************/
226 Float_t AliITSclusterSSD::GetTotalSignalError()
228 // return the error on the signal
230 for (Int_t i =1; i<fNDigits -1; i++)
232 err+=0.1*GetDigitSignal(i);
234 if (GetLeftNeighbour())
236 err+=GetDigitSignal(0);
240 err+=0.1*GetDigitSignal(0);
242 if (GetRightNeighbour())
244 err+=GetDigitSignal(fNDigits -1);
248 err+=0.1*GetDigitSignal(fNDigits -1);
254 /***********************************************************/
256 void AliITSclusterSSD::DelCross(Int_t index)
258 // remove cross clusters from the list of cross clusters
259 Int_t i,j; //iterators
261 for (i =0;i<fNCrosses;i++)
263 if ((*fCrossedClusterIndexes)[i] == index)
265 for (j=i;j<fNCrosses-1;j++)
267 (*fCrossedClusterIndexes)[j]=(*fCrossedClusterIndexes)[j+1];
275 /***********************************************************/
277 Int_t *AliITSclusterSSD::GetTracks(Int_t &nt)
279 // return the track number of the cluster
290 //cout<<"GetTrack start -------: fNDigits ="<<fNDigits<<endl;
292 for (i = 0; i<fNDigits; i++) {
293 tidx=GetDigit(i)->GetTracks();
294 for (j = 0; j<3;j++) {
298 fTrack[ntracks-1] = tidx[j];
299 }else if(tidx[j] != fTrack[ntracks-1]){
305 fTrack[ntracks-1] = tidx[j];
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
316 //if(nt == 0) cout<<"!!! No tracks"<<endl;
317 //cout<<"GetTracks: nt,fTrack0,fTrack1,fTrack2 ="<< nt<<","<<fTrack[0]<<","<<fTrack[1]<<","<<fTrack[2]<<endl;
320 /***********************************************************/
322 Double_t AliITSclusterSSD::GetPosition()
324 // return position of the cluster
329 ret = GetDigitStripNo(0);
332 ret = EtaAlgorithm();
335 ret = CentrOfGravity();
340 /***********************************************************/
342 Double_t AliITSclusterSSD::EtaAlgorithm()
344 // algorithm for determing cluster position
345 if (fNDigits != 2) return -1;
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();
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);
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);
373 Double_t AliITSclusterSSD::GetPositionError()
375 // return the position error
376 return (GetNumOfDigits()+1)/2;
379 Bool_t AliITSclusterSSD::IsCrossingWith(Int_t idx)
381 // return the cluster to which he crosses
382 for (Int_t i =0; i< fNCrosses;i++)
384 if (GetCross(i) == idx) return kTRUE;