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 ////////////////////////////////////////////////////////////////////////////
28 #include "TClonesArray.h"
29 #include "AliITSdigitSSD.h"
30 #include "AliITSclusterSSD.h"
32 ClassImp(AliITSclusterSSD)
34 //______________________________________________________________________
35 AliITSclusterSSD::AliITSclusterSSD():
41 fCrossedClusterIndexes(0),
42 fLeftNeighbour(kFALSE),
43 fRightNeighbour(kFALSE),
47 // default constructor
49 //______________________________________________________________________
50 AliITSclusterSSD::AliITSclusterSSD(Int_t ndigits, Int_t *DigitIndexes,
51 TObjArray *Digits, Bool_t side):
57 fCrossedClusterIndexes(0),
58 fLeftNeighbour(kFALSE),
59 fRightNeighbour(kFALSE),
63 // non-default constructor
65 fDigitsIndex = new TArrayI(fNDigits,DigitIndexes );
66 fCrossedClusterIndexes = new TArrayI(300);
68 //______________________________________________________________________
69 AliITSclusterSSD::~AliITSclusterSSD(){
73 delete fCrossedClusterIndexes;
75 //______________________________________________________________________
76 AliITSclusterSSD::AliITSclusterSSD(const AliITSclusterSSD &OneSCluster) :
78 fSide(OneSCluster.fSide),
79 fDigits(OneSCluster.fDigits),
80 fNDigits(OneSCluster.fNDigits),
82 fNCrosses(OneSCluster.fNCrosses),
83 fCrossedClusterIndexes(0),
84 fLeftNeighbour(OneSCluster.fLeftNeighbour),
85 fRightNeighbour(OneSCluster.fRightNeighbour),
86 fConsumed(OneSCluster.fConsumed),
91 fDigitsIndex = new TArrayI(fNDigits);
95 for (i = 0; i< fNCrosses ; i++){
96 fCrossedClusterIndexes[i] = OneSCluster.fCrossedClusterIndexes[i];
98 for (i = 0; i< fNDigits ; i++){
99 fDigitsIndex[i]=OneSCluster.fDigitsIndex[i];
103 //______________________________________________________________________
104 AliITSclusterSSD& AliITSclusterSSD::operator=(const AliITSclusterSSD
106 // assignment operator
108 if (this == &OneSCluster) return *this;
109 fNDigits = OneSCluster.fNDigits;
110 fSide=OneSCluster.fSide;
111 fDigits=OneSCluster.fDigits;
112 fDigitsIndex = new TArrayI(fNDigits);
113 fLeftNeighbour = OneSCluster.fLeftNeighbour;
114 fRightNeighbour = OneSCluster.fRightNeighbour;
117 fNCrosses = OneSCluster.fNCrosses;
118 fConsumed = OneSCluster.fConsumed;
120 for (i = 0; i< fNCrosses ; i++){
121 fCrossedClusterIndexes[i] = OneSCluster.fCrossedClusterIndexes[i];
123 for (i = 0; i< fNDigits ; i++){
124 fDigitsIndex[i]=OneSCluster.fDigitsIndex[i];
128 //______________________________________________________________________
129 Int_t AliITSclusterSSD::SplitCluster(Int_t where, Int_t *outdigits){
130 //This methods generate data necessery to make new object of this class
131 //I choosen this way, because methods TClonesArray::Add* dont work
132 //so I have to use constraction: new (a[i]) Creator(params...);
133 //where 'a' is a TClonesArray
134 //This method generate params - see AliITSmoduleSSD::SplitCluster;
135 Int_t tmp = fNDigits;
138 outdigits[ind++]=(*fDigitsIndex)[where];
139 //coping border strip (it is shared by this two clusters)
140 for (Int_t i = (where+1); i < tmp; i++) {
141 outdigits[ind++]=(*fDigitsIndex)[i];
142 //"moving" strips from this to the new one
143 (*fDigitsIndex)[i]=-1;
144 fNDigits--; //deleting strips from this cluster
148 //______________________________________________________________________
149 Int_t AliITSclusterSSD::GetDigitStripNo(Int_t digit){
150 // return strip no of a digit
151 if (digit<0) return -1;
152 return (digit>(fNDigits-1)) ? -1 :
153 ((AliITSdigitSSD*)(fDigits->At((*fDigitsIndex)[digit])))->GetStripNumber();
155 //______________________________________________________________________
156 Int_t AliITSclusterSSD::GetDigitSignal(Int_t digit){
157 // returns digit signal
159 if (digit<0||digit>=fNDigits) return -1;
160 index = (*fDigitsIndex)[digit];
161 signal = ((AliITSdigitSSD*)(fDigits->At(index)))->GetSignal();
163 if(signal>1.e5) printf("GetDigitSignal: digit %d index %d signal %d\n",
164 digit,index, signal);
168 //______________________________________________________________________
169 void AliITSclusterSSD::AddCross(Int_t clIndex){
170 // add cluster cross to list of cluster crosses
172 (*fCrossedClusterIndexes)[fNCrosses++] = clIndex;
174 //______________________________________________________________________
175 Int_t AliITSclusterSSD::GetCross(Int_t crIndex) const {
176 // return crossing cluster
178 return ((crIndex>-1)&&(crIndex<fNCrosses))?(*fCrossedClusterIndexes)[crIndex]:-1;
180 //______________________________________________________________________
181 Double_t AliITSclusterSSD::CentrOfGravity(){
182 // return center of gravity of the cluster
185 if (fLeftNeighbour) ret+=(GetDigitStripNo(0)*0.5*GetDigitSignal(0));
186 else ret+=(GetDigitStripNo(0)*GetDigitSignal(0));
187 if (fRightNeighbour) ret+=(GetDigitStripNo(fNDigits -1)*0.5*GetDigitSignal(fNDigits -1));
188 else ret+=(GetDigitStripNo(fNDigits -1)*GetDigitSignal(fNDigits-1));
189 for (Int_t i=1;i<fNDigits-1;i++){
190 ret +=GetDigitStripNo(i)*GetDigitSignal(i);
193 if (fTotalSignal<0) GetTotalSignal();
195 return (ret/fTotalSignal);
197 //______________________________________________________________________
198 Float_t AliITSclusterSSD::GetTotalSignal(){
199 // return total signal
204 fTotalSignal = (Float_t)GetDigitSignal(0);
205 //printf("1 digit: signal %d \n",GetDigitSignal(0));
208 if (fLeftNeighbour) fTotalSignal += (Float_t)(0.5*GetDigitSignal(0));
209 else fTotalSignal += (Float_t) GetDigitSignal(0);
210 //printf("GetTotalSignal :i DigitSignal %d %d \n",0,GetDigitSignal(0));
211 if (fRightNeighbour) fTotalSignal += (Float_t)(0.5*GetDigitSignal(
213 else fTotalSignal += (Float_t)GetDigitSignal(fNDigits-1);
214 //printf("GetTotalSignal :i DigitSignal %d %d \n",fNDigits -1,GetDigitSignal(fNDigits -1));
215 for (Int_t i = 1;i<fNDigits -1;i++){
216 fTotalSignal += (Float_t)GetDigitSignal(i);
217 //printf("GetTotalSignal :i DigitSignal %d %d \n",i,GetDigitSignal(i));
219 //printf("GetTotalSignal: fNDigits %d fTotalSignal %.0f \n",fNDigits,fTotalSignal);
223 //______________________________________________________________________
224 Float_t AliITSclusterSSD::GetTotalSignalError(){
225 // return the error on the signal
227 for (Int_t i =1; i<fNDigits -1; i++){
228 err+=0.1*GetDigitSignal(i);
230 if (GetLeftNeighbour()){
231 err+=GetDigitSignal(0);
233 err+=0.1*GetDigitSignal(0);
235 if (GetRightNeighbour()){
236 err+=GetDigitSignal(fNDigits -1);
238 err+=0.1*GetDigitSignal(fNDigits -1);
242 //______________________________________________________________________
243 void AliITSclusterSSD::DelCross(Int_t index){
244 // remove cross clusters from the list of cross clusters
245 Int_t i,j; //iterators
247 for (i =0;i<fNCrosses;i++){
248 if ((*fCrossedClusterIndexes)[i] == index){
249 for (j=i;j<fNCrosses-1;j++){
250 (*fCrossedClusterIndexes)[j]=(*fCrossedClusterIndexes)[j+1];
257 //______________________________________________________________________
258 Int_t *AliITSclusterSSD::GetTracks(Int_t &nt){
259 // return the track number of the cluster
260 Int_t ntrk = GetDigit(0)->GetNTracks();
261 Int_t ndig = GetNumOfDigits();
262 Int_t *idig = new Int_t[ndig];
263 Int_t *sdig = new Int_t[ndig];
264 Int_t *itrk = new Int_t[ndig*ntrk];
268 for(i=0;i<ndig;i++){idig[i] = i;sdig[i] = GetDigit(i)->GetSignal();}
269 TMath::Sort(ndig,sdig,idig,kTRUE);
270 for(i=0;i<ndig*ntrk;i++) itrk[i] = -3;
272 for(i=0;i<ndig;i++){ // fill itrk with track numbers in order of digit size
274 for(k=0;k<ntrk;k++) if((trk = GetDigit(j)->GetTrack(k))>=0) {
279 for(i=0;i<10;i++) fTrack[i] = -3;
280 fTrack[0] = itrk[0]; // first element
284 for(j=0;j<k;j++) if(fTrack[j]==itrk[i]) b = kFALSE;
285 if(b){fTrack[k] = itrk[i]; k++;}
302 for (i=0;i<10;i++) fTrack[i] = -3;
304 //cout<<"GetTrack start -------: fNDigits ="<<fNDigits<<endl;
306 for (i = 0; i<fNDigits; i++) {
307 tidx = GetDigit(i)->GetTracks();
308 n = GetDigit(i)->GetNTracks();
309 for (j = 0; j<n && j<10;j++) {
312 fTrack[ntracks] = tidx[j];
314 }else if(tidx[j] != fTrack[ntracks-1]){
319 } // end if ntracks > 9
320 fTrack[ntracks-1] = tidx[j];
321 } // end if ntracke == 0
322 } // end if tidx[j] >=0
323 } // 3-tracks loop for the digit
332 //______________________________________________________________________
333 Double_t AliITSclusterSSD::GetPosition(){
334 // return position of the cluster
339 ret = GetDigitStripNo(0);
342 ret = EtaAlgorithm();
345 ret = CentrOfGravity();
349 //______________________________________________________________________
350 Double_t AliITSclusterSSD::EtaAlgorithm(){
351 // algorithm for determing cluster position
352 if (fNDigits != 2) return -1;
354 Int_t strip1 = GetDigit(0)->GetStripNumber();
355 Int_t strip2 = GetDigit(1)->GetStripNumber();
356 Int_t signal1 = GetDigit(0)->GetSignal();
357 Int_t signal2 = GetDigit(1)->GetSignal();
363 eta = ((Double_t)signal2)/((Double_t)(signal1+signal2));
364 if (eta<0.04) return strip1;
365 if (eta>0.96) return strip2;
366 return (strip1 + 0.43478261*eta + 0.2826087);
368 eta = ((Double_t)signal1)/((Double_t)(signal1+signal2));
369 if (eta<0.04) return strip2;
370 if (eta>0.96) return strip1;
371 return (strip2 + 0.43478261*eta + 0.2826087);
374 //______________________________________________________________________
375 Double_t AliITSclusterSSD::GetPositionError() const {
376 // return the position error
377 return (GetNumOfDigits()+1)/2;
379 //______________________________________________________________________
380 Bool_t AliITSclusterSSD::IsCrossingWith(Int_t idx) const{
381 // return the cluster to which he crosses
383 for (Int_t i =0; i< fNCrosses;i++){
384 if (GetCross(i) == idx) return kTRUE;