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 **************************************************************************/
18 Revision 1.7.6.1 2002/10/14 13:14:08 hristov
19 Updating VirtualMC to v3-09-02
21 Revision 1.8 2002/09/09 17:23:28 nilsen
22 Minor changes in support of changes to AliITSdigitS?D class'.
28 #include "TClonesArray.h"
29 #include "AliITSdigit.h"
30 #include "AliITSclusterSSD.h"
32 ClassImp(AliITSclusterSSD)
34 //______________________________________________________________________
35 AliITSclusterSSD::AliITSclusterSSD(){
36 // default constructor
45 fLeftNeighbour = kFALSE;
46 fRightNeighbour = kFALSE;
47 fCrossedClusterIndexes = 0;
50 //______________________________________________________________________
51 AliITSclusterSSD::AliITSclusterSSD(Int_t ndigits, Int_t *DigitIndexes,
52 TObjArray *Digits, Bool_t side){
53 // non-default constructor
58 fDigitsIndex = new TArrayI(fNDigits,DigitIndexes );
60 fCrossedClusterIndexes = new TArrayI(300);
61 fLeftNeighbour = kFALSE;
62 fRightNeighbour = kFALSE;
67 //______________________________________________________________________
68 AliITSclusterSSD::~AliITSclusterSSD(){
72 delete fCrossedClusterIndexes;
74 //______________________________________________________________________
75 AliITSclusterSSD::AliITSclusterSSD(const AliITSclusterSSD &OneSCluster){
78 if (this == &OneSCluster) return;
79 fNDigits = OneSCluster.fNDigits;
80 fSide=OneSCluster.fSide;
81 fDigits=OneSCluster.fDigits;
82 fDigitsIndex = new TArrayI(fNDigits);
83 fLeftNeighbour = OneSCluster.fLeftNeighbour;
84 fRightNeighbour = OneSCluster.fRightNeighbour;
87 fNCrosses = OneSCluster.fNCrosses;
88 fConsumed = OneSCluster.fConsumed;
90 for (i = 0; i< fNCrosses ; i++){
91 fCrossedClusterIndexes[i] = OneSCluster.fCrossedClusterIndexes[i];
93 for (i = 0; i< fNDigits ; i++){
94 fDigitsIndex[i]=OneSCluster.fDigitsIndex[i];
98 //______________________________________________________________________
99 AliITSclusterSSD& AliITSclusterSSD::operator=(const AliITSclusterSSD
101 // assignment operator
103 if (this == &OneSCluster) return *this;
104 fNDigits = OneSCluster.fNDigits;
105 fSide=OneSCluster.fSide;
106 fDigits=OneSCluster.fDigits;
107 fDigitsIndex = new TArrayI(fNDigits);
108 fLeftNeighbour = OneSCluster.fLeftNeighbour;
109 fRightNeighbour = OneSCluster.fRightNeighbour;
112 fNCrosses = OneSCluster.fNCrosses;
113 fConsumed = OneSCluster.fConsumed;
115 for (i = 0; i< fNCrosses ; i++){
116 fCrossedClusterIndexes[i] = OneSCluster.fCrossedClusterIndexes[i];
118 for (i = 0; i< fNDigits ; i++){
119 fDigitsIndex[i]=OneSCluster.fDigitsIndex[i];
123 //______________________________________________________________________
124 Int_t AliITSclusterSSD::SplitCluster(Int_t where, Int_t *outdigits){
125 //This methods generate data necessery to make new object of this class
126 //I choosen this way, because methods TClonesArray::Add* dont work
127 //so I have to use constraction: new (a[i]) Creator(params...);
128 //where 'a' is a TClonesArray
129 //This method generate params - see AliITSmoduleSSD::SplitCluster;
130 Int_t tmp = fNDigits;
133 outdigits[ind++]=(*fDigitsIndex)[where];
134 //coping border strip (it is shared by this two clusters)
135 for (Int_t i = (where+1); i < tmp; i++) {
136 outdigits[ind++]=(*fDigitsIndex)[i];
137 //"moving" strips from this to the new one
138 (*fDigitsIndex)[i]=-1;
139 fNDigits--; //deleting strips from this cluster
143 //______________________________________________________________________
144 Int_t AliITSclusterSSD::GetDigitStripNo(Int_t digit){
145 // return strip no of a digit
146 if (digit<0) return -1;
147 return (digit>(fNDigits-1)) ? -1 :
148 ((AliITSdigitSSD*)(fDigits->At((*fDigitsIndex)[digit])))->GetStripNumber();
150 //______________________________________________________________________
151 Int_t AliITSclusterSSD::GetDigitSignal(Int_t digit){
152 // returns digit signal
154 if (digit<0||digit>=fNDigits) return -1;
155 index = (*fDigitsIndex)[digit];
156 signal = ((AliITSdigitSSD*)(fDigits->At(index)))->GetSignal();
158 if(signal>1.e5) printf("GetDigitSignal: digit %d index %d signal %d\n",
159 digit,index, signal);
163 //______________________________________________________________________
164 void AliITSclusterSSD::AddCross(Int_t clIndex){
165 // add cluster cross to list of cluster crosses
167 (*fCrossedClusterIndexes)[fNCrosses++] = clIndex;
169 //______________________________________________________________________
170 Int_t AliITSclusterSSD::GetCross(Int_t crIndex){
171 // return crossing cluster
173 return ((crIndex>-1)&&(crIndex<fNCrosses))?(*fCrossedClusterIndexes)[crIndex]:-1;
175 //______________________________________________________________________
176 Double_t AliITSclusterSSD::CentrOfGravity(){
177 // return center of gravity of the cluster
180 if (fLeftNeighbour) ret+=(GetDigitStripNo(0)*0.5*GetDigitSignal(0));
181 else ret+=(GetDigitStripNo(0)*GetDigitSignal(0));
182 if (fRightNeighbour) ret+=(GetDigitStripNo(fNDigits -1)*0.5*GetDigitSignal(fNDigits -1));
183 else ret+=(GetDigitStripNo(fNDigits -1)*GetDigitSignal(fNDigits-1));
184 for (Int_t i=1;i<fNDigits-1;i++){
185 ret +=GetDigitStripNo(i)*GetDigitSignal(i);
188 if (fTotalSignal<0) GetTotalSignal();
190 return (ret/fTotalSignal);
192 //______________________________________________________________________
193 Float_t AliITSclusterSSD::GetTotalSignal(){
194 // return total signal
199 fTotalSignal = (Float_t)GetDigitSignal(0);
200 //printf("1 digit: signal %d \n",GetDigitSignal(0));
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 if (fRightNeighbour) fTotalSignal += (Float_t)(0.5*GetDigitSignal(
208 else fTotalSignal += (Float_t)GetDigitSignal(fNDigits-1);
209 //printf("GetTotalSignal :i DigitSignal %d %d \n",fNDigits -1,GetDigitSignal(fNDigits -1));
210 for (Int_t i = 1;i<fNDigits -1;i++){
211 fTotalSignal += (Float_t)GetDigitSignal(i);
212 //printf("GetTotalSignal :i DigitSignal %d %d \n",i,GetDigitSignal(i));
214 //printf("GetTotalSignal: fNDigits %d fTotalSignal %.0f \n",fNDigits,fTotalSignal);
218 //______________________________________________________________________
219 Float_t AliITSclusterSSD::GetTotalSignalError(){
220 // return the error on the signal
222 for (Int_t i =1; i<fNDigits -1; i++){
223 err+=0.1*GetDigitSignal(i);
225 if (GetLeftNeighbour()){
226 err+=GetDigitSignal(0);
228 err+=0.1*GetDigitSignal(0);
230 if (GetRightNeighbour()){
231 err+=GetDigitSignal(fNDigits -1);
233 err+=0.1*GetDigitSignal(fNDigits -1);
237 //______________________________________________________________________
238 void AliITSclusterSSD::DelCross(Int_t index){
239 // remove cross clusters from the list of cross clusters
240 Int_t i,j; //iterators
242 for (i =0;i<fNCrosses;i++){
243 if ((*fCrossedClusterIndexes)[i] == index){
244 for (j=i;j<fNCrosses-1;j++){
245 (*fCrossedClusterIndexes)[j]=(*fCrossedClusterIndexes)[j+1];
252 //______________________________________________________________________
253 Int_t *AliITSclusterSSD::GetTracks(Int_t &nt){
254 // return the track number of the cluster
261 for (i=0;i<10;i++) fTrack[i] = -3;
263 //cout<<"GetTrack start -------: fNDigits ="<<fNDigits<<endl;
265 for (i = 0; i<fNDigits; i++) {
266 tidx = GetDigit(i)->GetTracks();
267 n = GetDigit(i)->GetNTracks();
268 for (j = 0; j<n && j<10;j++) {
271 fTrack[ntracks] = tidx[j];
273 }else if(tidx[j] != fTrack[ntracks-1]){
278 } // end if ntracks > 9
279 fTrack[ntracks-1] = tidx[j];
280 } // end if ntracke == 0
281 } // end if tidx[j] >=0
282 } // 3-tracks loop for the digit
290 //______________________________________________________________________
291 Double_t AliITSclusterSSD::GetPosition(){
292 // return position of the cluster
297 ret = GetDigitStripNo(0);
300 ret = EtaAlgorithm();
303 ret = CentrOfGravity();
307 //______________________________________________________________________
308 Double_t AliITSclusterSSD::EtaAlgorithm(){
309 // algorithm for determing cluster position
310 if (fNDigits != 2) return -1;
312 Int_t strip1 = GetDigit(0)->GetStripNumber();
313 Int_t strip2 = GetDigit(1)->GetStripNumber();
314 Int_t signal1 = GetDigit(0)->GetSignal();
315 Int_t signal2 = GetDigit(1)->GetSignal();
321 eta = ((Double_t)signal2)/((Double_t)(signal1+signal2));
322 if (eta<0.04) return strip1;
323 if (eta>0.96) return strip2;
324 return (strip1 + 0.43478261*eta + 0.2826087);
326 eta = ((Double_t)signal1)/((Double_t)(signal1+signal2));
327 if (eta<0.04) return strip2;
328 if (eta>0.96) return strip1;
329 return (strip2 + 0.43478261*eta + 0.2826087);
332 //______________________________________________________________________
333 Double_t AliITSclusterSSD::GetPositionError(){
334 // return the position error
335 return (GetNumOfDigits()+1)/2;
337 //______________________________________________________________________
338 Bool_t AliITSclusterSSD::IsCrossingWith(Int_t idx){
339 // return the cluster to which he crosses
341 for (Int_t i =0; i< fNCrosses;i++){
342 if (GetCross(i) == idx) return kTRUE;