1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
22 #include "TClonesArray.h"
23 #include "AliITSdigit.h"
24 #include "AliITSclusterSSD.h"
26 ClassImp(AliITSclusterSSD)
28 //______________________________________________________________________
29 AliITSclusterSSD::AliITSclusterSSD(){
30 // default constructor
39 fLeftNeighbour = kFALSE;
40 fRightNeighbour = kFALSE;
41 fCrossedClusterIndexes = 0;
44 //______________________________________________________________________
45 AliITSclusterSSD::AliITSclusterSSD(Int_t ndigits, Int_t *DigitIndexes,
46 TObjArray *Digits, Bool_t side){
47 // non-default constructor
52 fDigitsIndex = new TArrayI(fNDigits,DigitIndexes );
54 fCrossedClusterIndexes = new TArrayI(300);
55 fLeftNeighbour = kFALSE;
56 fRightNeighbour = kFALSE;
61 //______________________________________________________________________
62 AliITSclusterSSD::~AliITSclusterSSD(){
66 delete fCrossedClusterIndexes;
68 //______________________________________________________________________
69 AliITSclusterSSD::AliITSclusterSSD(const AliITSclusterSSD &OneSCluster){
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;
81 fNCrosses = OneSCluster.fNCrosses;
82 fConsumed = OneSCluster.fConsumed;
84 for (i = 0; i< fNCrosses ; i++){
85 fCrossedClusterIndexes[i] = OneSCluster.fCrossedClusterIndexes[i];
87 for (i = 0; i< fNDigits ; i++){
88 fDigitsIndex[i]=OneSCluster.fDigitsIndex[i];
92 //______________________________________________________________________
93 AliITSclusterSSD& AliITSclusterSSD::operator=(const AliITSclusterSSD
95 // assignment operator
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;
106 fNCrosses = OneSCluster.fNCrosses;
107 fConsumed = OneSCluster.fConsumed;
109 for (i = 0; i< fNCrosses ; i++){
110 fCrossedClusterIndexes[i] = OneSCluster.fCrossedClusterIndexes[i];
112 for (i = 0; i< fNDigits ; i++){
113 fDigitsIndex[i]=OneSCluster.fDigitsIndex[i];
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;
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
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();
144 //______________________________________________________________________
145 Int_t AliITSclusterSSD::GetDigitSignal(Int_t digit){
146 // returns digit signal
148 if (digit<0||digit>=fNDigits) return -1;
149 index = (*fDigitsIndex)[digit];
150 signal = ((AliITSdigitSSD*)(fDigits->At(index)))->GetSignal();
152 if(signal>1.e5) printf("GetDigitSignal: digit %d index %d signal %d\n",
153 digit,index, signal);
157 //______________________________________________________________________
158 void AliITSclusterSSD::AddCross(Int_t clIndex){
159 // add cluster cross to list of cluster crosses
161 (*fCrossedClusterIndexes)[fNCrosses++] = clIndex;
163 //______________________________________________________________________
164 Int_t AliITSclusterSSD::GetCross(Int_t crIndex){
165 // return crossing cluster
167 return ((crIndex>-1)&&(crIndex<fNCrosses))?(*fCrossedClusterIndexes)[crIndex]:-1;
169 //______________________________________________________________________
170 Double_t AliITSclusterSSD::CentrOfGravity(){
171 // return center of gravity of the cluster
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);
182 if (fTotalSignal<0) GetTotalSignal();
184 return (ret/fTotalSignal);
186 //______________________________________________________________________
187 Float_t AliITSclusterSSD::GetTotalSignal(){
188 // return total signal
193 fTotalSignal = (Float_t)GetDigitSignal(0);
194 //printf("1 digit: signal %d \n",GetDigitSignal(0));
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(
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));
208 //printf("GetTotalSignal: fNDigits %d fTotalSignal %.0f \n",fNDigits,fTotalSignal);
212 //______________________________________________________________________
213 Float_t AliITSclusterSSD::GetTotalSignalError(){
214 // return the error on the signal
216 for (Int_t i =1; i<fNDigits -1; i++){
217 err+=0.1*GetDigitSignal(i);
219 if (GetLeftNeighbour()){
220 err+=GetDigitSignal(0);
222 err+=0.1*GetDigitSignal(0);
224 if (GetRightNeighbour()){
225 err+=GetDigitSignal(fNDigits -1);
227 err+=0.1*GetDigitSignal(fNDigits -1);
231 //______________________________________________________________________
232 void AliITSclusterSSD::DelCross(Int_t index){
233 // remove cross clusters from the list of cross clusters
234 Int_t i,j; //iterators
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];
246 //______________________________________________________________________
247 Int_t *AliITSclusterSSD::GetTracks(Int_t &nt){
248 // return the track number of the cluster
255 for (i=0;i<10;i++) fTrack[i] = -3;
257 //cout<<"GetTrack start -------: fNDigits ="<<fNDigits<<endl;
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++) {
265 fTrack[ntracks] = tidx[j];
267 }else if(tidx[j] != fTrack[ntracks-1]){
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
284 //______________________________________________________________________
285 Double_t AliITSclusterSSD::GetPosition(){
286 // return position of the cluster
291 ret = GetDigitStripNo(0);
294 ret = EtaAlgorithm();
297 ret = CentrOfGravity();
301 //______________________________________________________________________
302 Double_t AliITSclusterSSD::EtaAlgorithm(){
303 // algorithm for determing cluster position
304 if (fNDigits != 2) return -1;
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();
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);
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);
326 //______________________________________________________________________
327 Double_t AliITSclusterSSD::GetPositionError(){
328 // return the position error
329 return (GetNumOfDigits()+1)/2;
331 //______________________________________________________________________
332 Bool_t AliITSclusterSSD::IsCrossingWith(Int_t idx){
333 // return the cluster to which he crosses
335 for (Int_t i =0; i< fNCrosses;i++){
336 if (GetCross(i) == idx) return kTRUE;