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 **************************************************************************/
17 ////////////////////////////////////////////////////////////////////////////
18 //Piotr Krzysztof Skowronski //
19 //Warsaw University of Technology //
20 //skowron@if.pw.edu.pl //
22 // Describes set of neighbouring digits on one side of detector, //
23 // that are supposed to be generated by one particle. //
24 // includes information about clusters on other side that it crosses with //
25 ////////////////////////////////////////////////////////////////////////////
29 #include <TClonesArray.h>
32 #include "AliITSdigitSSD.h"
33 #include "AliITSclusterSSD.h"
35 ClassImp(AliITSclusterSSD)
37 //______________________________________________________________________
38 AliITSclusterSSD::AliITSclusterSSD():
44 fCrossedClusterIndexes(0),
45 fLeftNeighbour(kFALSE),
46 fRightNeighbour(kFALSE),
50 // default constructor
51 for (Int_t i = 0; i < 10; i++)
54 //______________________________________________________________________
55 AliITSclusterSSD::AliITSclusterSSD(Int_t ndigits, Int_t *DigitIndexes,
56 TObjArray *Digits, Bool_t side):
62 fCrossedClusterIndexes(0),
63 fLeftNeighbour(kFALSE),
64 fRightNeighbour(kFALSE),
68 // non-default constructor
70 fDigitsIndex = new TArrayI(fNDigits,DigitIndexes );
71 fCrossedClusterIndexes = new TArrayI(300);
72 for (Int_t i = 0; i < 10; i++)
75 //______________________________________________________________________
76 AliITSclusterSSD::~AliITSclusterSSD(){
80 delete fCrossedClusterIndexes;
82 //______________________________________________________________________
83 AliITSclusterSSD::AliITSclusterSSD(const AliITSclusterSSD &OneSCluster) :
85 fSide(OneSCluster.fSide),
86 fDigits(OneSCluster.fDigits),
87 fNDigits(OneSCluster.fNDigits),
89 fNCrosses(OneSCluster.fNCrosses),
90 fCrossedClusterIndexes(0),
91 fLeftNeighbour(OneSCluster.fLeftNeighbour),
92 fRightNeighbour(OneSCluster.fRightNeighbour),
93 fConsumed(OneSCluster.fConsumed),
98 fDigitsIndex = new TArrayI(fNDigits);
102 for (i = 0; i < 10; i++)
104 for (i = 0; i< fNCrosses ; i++){
105 fCrossedClusterIndexes[i] = OneSCluster.fCrossedClusterIndexes[i];
107 for (i = 0; i< fNDigits ; i++){
108 fDigitsIndex[i]=OneSCluster.fDigitsIndex[i];
112 //______________________________________________________________________
113 AliITSclusterSSD& AliITSclusterSSD::operator=(const AliITSclusterSSD
115 // assignment operator
117 if (this == &OneSCluster) return *this;
118 fNDigits = OneSCluster.fNDigits;
119 fSide=OneSCluster.fSide;
120 fDigits=OneSCluster.fDigits;
121 fDigitsIndex = new TArrayI(fNDigits);
122 fLeftNeighbour = OneSCluster.fLeftNeighbour;
123 fRightNeighbour = OneSCluster.fRightNeighbour;
126 fNCrosses = OneSCluster.fNCrosses;
127 fConsumed = OneSCluster.fConsumed;
129 for (i = 0; i< fNCrosses ; i++){
130 fCrossedClusterIndexes[i] = OneSCluster.fCrossedClusterIndexes[i];
132 for (i = 0; i< fNDigits ; i++){
133 fDigitsIndex[i]=OneSCluster.fDigitsIndex[i];
137 //______________________________________________________________________
138 Int_t AliITSclusterSSD::SplitCluster(Int_t where, Int_t *outdigits){
139 //This methods generate data necessery to make new object of this class
140 //I choosen this way, because methods TClonesArray::Add* dont work
141 //so I have to use constraction: new (a[i]) Creator(params...);
142 //where 'a' is a TClonesArray
143 //This method generate params - see AliITSmoduleSSD::SplitCluster;
144 Int_t tmp = fNDigits;
147 outdigits[ind++]=(*fDigitsIndex)[where];
148 //coping border strip (it is shared by this two clusters)
149 for (Int_t i = (where+1); i < tmp; i++) {
150 outdigits[ind++]=(*fDigitsIndex)[i];
151 //"moving" strips from this to the new one
152 (*fDigitsIndex)[i]=-1;
153 fNDigits--; //deleting strips from this cluster
157 //______________________________________________________________________
158 Int_t AliITSclusterSSD::GetDigitStripNo(Int_t digit){
159 // return strip no of a digit
160 if (digit<0) return -1;
161 return (digit>(fNDigits-1)) ? -1 :
162 ((AliITSdigitSSD*)(fDigits->At((*fDigitsIndex)[digit])))->GetStripNumber();
164 //______________________________________________________________________
165 Int_t AliITSclusterSSD::GetDigitSignal(Int_t digit){
166 // returns digit signal
168 if (digit<0||digit>=fNDigits) return -1;
169 index = (*fDigitsIndex)[digit];
170 signal = ((AliITSdigitSSD*)(fDigits->At(index)))->GetSignal();
172 if(signal>1.e5) printf("GetDigitSignal: digit %d index %d signal %d\n",
173 digit,index, signal);
177 //______________________________________________________________________
178 void AliITSclusterSSD::AddCross(Int_t clIndex){
179 // add cluster cross to list of cluster crosses
181 (*fCrossedClusterIndexes)[fNCrosses++] = clIndex;
183 //______________________________________________________________________
184 Int_t AliITSclusterSSD::GetCross(Int_t crIndex) const {
185 // return crossing cluster
187 return ((crIndex>-1)&&(crIndex<fNCrosses))?(*fCrossedClusterIndexes)[crIndex]:-1;
189 //______________________________________________________________________
190 Double_t AliITSclusterSSD::CentrOfGravity(){
191 // return center of gravity of the cluster
194 if (fLeftNeighbour) ret+=(GetDigitStripNo(0)*0.5*GetDigitSignal(0));
195 else ret+=(GetDigitStripNo(0)*GetDigitSignal(0));
196 if (fRightNeighbour) ret+=(GetDigitStripNo(fNDigits -1)*0.5*GetDigitSignal(fNDigits -1));
197 else ret+=(GetDigitStripNo(fNDigits -1)*GetDigitSignal(fNDigits-1));
198 for (Int_t i=1;i<fNDigits-1;i++){
199 ret +=GetDigitStripNo(i)*GetDigitSignal(i);
202 if (fTotalSignal<0) GetTotalSignal();
204 return (ret/fTotalSignal);
206 //______________________________________________________________________
207 Float_t AliITSclusterSSD::GetTotalSignal(){
208 // return total signal
213 fTotalSignal = (Float_t)GetDigitSignal(0);
214 //printf("1 digit: signal %d \n",GetDigitSignal(0));
217 if (fLeftNeighbour) fTotalSignal += (Float_t)(0.5*GetDigitSignal(0));
218 else fTotalSignal += (Float_t) GetDigitSignal(0);
219 //printf("GetTotalSignal :i DigitSignal %d %d \n",0,GetDigitSignal(0));
220 if (fRightNeighbour) fTotalSignal += (Float_t)(0.5*GetDigitSignal(
222 else fTotalSignal += (Float_t)GetDigitSignal(fNDigits-1);
223 //printf("GetTotalSignal :i DigitSignal %d %d \n",fNDigits -1,GetDigitSignal(fNDigits -1));
224 for (Int_t i = 1;i<fNDigits -1;i++){
225 fTotalSignal += (Float_t)GetDigitSignal(i);
226 //printf("GetTotalSignal :i DigitSignal %d %d \n",i,GetDigitSignal(i));
228 //printf("GetTotalSignal: fNDigits %d fTotalSignal %.0f \n",fNDigits,fTotalSignal);
232 //______________________________________________________________________
233 Float_t AliITSclusterSSD::GetTotalSignalError(){
234 // return the error on the signal
236 for (Int_t i =1; i<fNDigits -1; i++){
237 err+=0.1*GetDigitSignal(i);
239 if (GetLeftNeighbour()){
240 err+=GetDigitSignal(0);
242 err+=0.1*GetDigitSignal(0);
244 if (GetRightNeighbour()){
245 err+=GetDigitSignal(fNDigits -1);
247 err+=0.1*GetDigitSignal(fNDigits -1);
251 //______________________________________________________________________
252 void AliITSclusterSSD::DelCross(Int_t index){
253 // remove cross clusters from the list of cross clusters
254 Int_t i,j; //iterators
256 for (i =0;i<fNCrosses;i++){
257 if ((*fCrossedClusterIndexes)[i] == index){
258 for (j=i;j<fNCrosses-1;j++){
259 (*fCrossedClusterIndexes)[j]=(*fCrossedClusterIndexes)[j+1];
266 //______________________________________________________________________
267 Int_t *AliITSclusterSSD::GetTracks(Int_t &nt){
268 // return the track number of the cluster
269 Int_t ntrk = GetDigit(0)->GetNTracks();
270 Int_t ndig = GetNumOfDigits();
271 Int_t *idig = new Int_t[ndig];
272 Int_t *sdig = new Int_t[ndig];
273 Int_t *itrk = new Int_t[ndig*ntrk];
277 for(i=0;i<ndig;i++){idig[i] = i;sdig[i] = GetDigit(i)->GetSignal();}
278 TMath::Sort(ndig,sdig,idig,kTRUE);
279 for(i=0;i<ndig*ntrk;i++) itrk[i] = -3;
281 for(i=0;i<ndig;i++){ // fill itrk with track numbers in order of digit size
283 for(k=0;k<ntrk;k++) if((trk = GetDigit(j)->GetTrack(k))>=0) {
288 for(i=0;i<10;i++) fTrack[i] = -3;
289 fTrack[0] = itrk[0]; // first element
293 for(j=0;j<k;j++) if(fTrack[j]==itrk[i]) b = kFALSE;
294 if(b){fTrack[k] = itrk[i]; k++;}
311 for (i=0;i<10;i++) fTrack[i] = -3;
313 //cout<<"GetTrack start -------: fNDigits ="<<fNDigits<<endl;
315 for (i = 0; i<fNDigits; i++) {
316 tidx = GetDigit(i)->GetTracks();
317 n = GetDigit(i)->GetNTracks();
318 for (j = 0; j<n && j<10;j++) {
321 fTrack[ntracks] = tidx[j];
323 }else if(tidx[j] != fTrack[ntracks-1]){
328 } // end if ntracks > 9
329 fTrack[ntracks-1] = tidx[j];
330 } // end if ntracke == 0
331 } // end if tidx[j] >=0
332 } // 3-tracks loop for the digit
341 //______________________________________________________________________
342 Double_t AliITSclusterSSD::GetPosition(){
343 // return position of the cluster
348 ret = GetDigitStripNo(0);
351 ret = EtaAlgorithm();
354 ret = CentrOfGravity();
358 //______________________________________________________________________
359 Double_t AliITSclusterSSD::EtaAlgorithm(){
360 // algorithm for determing cluster position
361 if (fNDigits != 2) return -1;
363 Int_t strip1 = GetDigit(0)->GetStripNumber();
364 Int_t strip2 = GetDigit(1)->GetStripNumber();
365 Int_t signal1 = GetDigit(0)->GetSignal();
366 Int_t signal2 = GetDigit(1)->GetSignal();
372 eta = ((Double_t)signal2)/((Double_t)(signal1+signal2));
373 if (eta<0.04) return strip1;
374 if (eta>0.96) return strip2;
375 return (strip1 + 0.43478261*eta + 0.2826087);
377 eta = ((Double_t)signal1)/((Double_t)(signal1+signal2));
378 if (eta<0.04) return strip2;
379 if (eta>0.96) return strip1;
380 return (strip2 + 0.43478261*eta + 0.2826087);
383 //______________________________________________________________________
384 Double_t AliITSclusterSSD::GetPositionError() const {
385 // return the position error
386 return (GetNumOfDigits()+1)/2;
388 //______________________________________________________________________
389 Bool_t AliITSclusterSSD::IsCrossingWith(Int_t idx) const{
390 // return the cluster to which he crosses
392 for (Int_t i =0; i< fNCrosses;i++){
393 if (GetCross(i) == idx) return kTRUE;