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
52 //______________________________________________________________________
53 AliITSclusterSSD::AliITSclusterSSD(Int_t ndigits, Int_t *DigitIndexes,
54 TObjArray *Digits, Bool_t side):
60 fCrossedClusterIndexes(0),
61 fLeftNeighbour(kFALSE),
62 fRightNeighbour(kFALSE),
66 // non-default constructor
68 fDigitsIndex = new TArrayI(fNDigits,DigitIndexes );
69 fCrossedClusterIndexes = new TArrayI(300);
71 //______________________________________________________________________
72 AliITSclusterSSD::~AliITSclusterSSD(){
76 delete fCrossedClusterIndexes;
78 //______________________________________________________________________
79 AliITSclusterSSD::AliITSclusterSSD(const AliITSclusterSSD &OneSCluster) :
81 fSide(OneSCluster.fSide),
82 fDigits(OneSCluster.fDigits),
83 fNDigits(OneSCluster.fNDigits),
85 fNCrosses(OneSCluster.fNCrosses),
86 fCrossedClusterIndexes(0),
87 fLeftNeighbour(OneSCluster.fLeftNeighbour),
88 fRightNeighbour(OneSCluster.fRightNeighbour),
89 fConsumed(OneSCluster.fConsumed),
94 fDigitsIndex = new TArrayI(fNDigits);
98 for (i = 0; i< fNCrosses ; i++){
99 fCrossedClusterIndexes[i] = OneSCluster.fCrossedClusterIndexes[i];
101 for (i = 0; i< fNDigits ; i++){
102 fDigitsIndex[i]=OneSCluster.fDigitsIndex[i];
106 //______________________________________________________________________
107 AliITSclusterSSD& AliITSclusterSSD::operator=(const AliITSclusterSSD
109 // assignment operator
111 if (this == &OneSCluster) return *this;
112 fNDigits = OneSCluster.fNDigits;
113 fSide=OneSCluster.fSide;
114 fDigits=OneSCluster.fDigits;
115 fDigitsIndex = new TArrayI(fNDigits);
116 fLeftNeighbour = OneSCluster.fLeftNeighbour;
117 fRightNeighbour = OneSCluster.fRightNeighbour;
120 fNCrosses = OneSCluster.fNCrosses;
121 fConsumed = OneSCluster.fConsumed;
123 for (i = 0; i< fNCrosses ; i++){
124 fCrossedClusterIndexes[i] = OneSCluster.fCrossedClusterIndexes[i];
126 for (i = 0; i< fNDigits ; i++){
127 fDigitsIndex[i]=OneSCluster.fDigitsIndex[i];
131 //______________________________________________________________________
132 Int_t AliITSclusterSSD::SplitCluster(Int_t where, Int_t *outdigits){
133 //This methods generate data necessery to make new object of this class
134 //I choosen this way, because methods TClonesArray::Add* dont work
135 //so I have to use constraction: new (a[i]) Creator(params...);
136 //where 'a' is a TClonesArray
137 //This method generate params - see AliITSmoduleSSD::SplitCluster;
138 Int_t tmp = fNDigits;
141 outdigits[ind++]=(*fDigitsIndex)[where];
142 //coping border strip (it is shared by this two clusters)
143 for (Int_t i = (where+1); i < tmp; i++) {
144 outdigits[ind++]=(*fDigitsIndex)[i];
145 //"moving" strips from this to the new one
146 (*fDigitsIndex)[i]=-1;
147 fNDigits--; //deleting strips from this cluster
151 //______________________________________________________________________
152 Int_t AliITSclusterSSD::GetDigitStripNo(Int_t digit){
153 // return strip no of a digit
154 if (digit<0) return -1;
155 return (digit>(fNDigits-1)) ? -1 :
156 ((AliITSdigitSSD*)(fDigits->At((*fDigitsIndex)[digit])))->GetStripNumber();
158 //______________________________________________________________________
159 Int_t AliITSclusterSSD::GetDigitSignal(Int_t digit){
160 // returns digit signal
162 if (digit<0||digit>=fNDigits) return -1;
163 index = (*fDigitsIndex)[digit];
164 signal = ((AliITSdigitSSD*)(fDigits->At(index)))->GetSignal();
166 if(signal>1.e5) printf("GetDigitSignal: digit %d index %d signal %d\n",
167 digit,index, signal);
171 //______________________________________________________________________
172 void AliITSclusterSSD::AddCross(Int_t clIndex){
173 // add cluster cross to list of cluster crosses
175 (*fCrossedClusterIndexes)[fNCrosses++] = clIndex;
177 //______________________________________________________________________
178 Int_t AliITSclusterSSD::GetCross(Int_t crIndex) const {
179 // return crossing cluster
181 return ((crIndex>-1)&&(crIndex<fNCrosses))?(*fCrossedClusterIndexes)[crIndex]:-1;
183 //______________________________________________________________________
184 Double_t AliITSclusterSSD::CentrOfGravity(){
185 // return center of gravity of the cluster
188 if (fLeftNeighbour) ret+=(GetDigitStripNo(0)*0.5*GetDigitSignal(0));
189 else ret+=(GetDigitStripNo(0)*GetDigitSignal(0));
190 if (fRightNeighbour) ret+=(GetDigitStripNo(fNDigits -1)*0.5*GetDigitSignal(fNDigits -1));
191 else ret+=(GetDigitStripNo(fNDigits -1)*GetDigitSignal(fNDigits-1));
192 for (Int_t i=1;i<fNDigits-1;i++){
193 ret +=GetDigitStripNo(i)*GetDigitSignal(i);
196 if (fTotalSignal<0) GetTotalSignal();
198 return (ret/fTotalSignal);
200 //______________________________________________________________________
201 Float_t AliITSclusterSSD::GetTotalSignal(){
202 // return total signal
207 fTotalSignal = (Float_t)GetDigitSignal(0);
208 //printf("1 digit: signal %d \n",GetDigitSignal(0));
211 if (fLeftNeighbour) fTotalSignal += (Float_t)(0.5*GetDigitSignal(0));
212 else fTotalSignal += (Float_t) GetDigitSignal(0);
213 //printf("GetTotalSignal :i DigitSignal %d %d \n",0,GetDigitSignal(0));
214 if (fRightNeighbour) fTotalSignal += (Float_t)(0.5*GetDigitSignal(
216 else fTotalSignal += (Float_t)GetDigitSignal(fNDigits-1);
217 //printf("GetTotalSignal :i DigitSignal %d %d \n",fNDigits -1,GetDigitSignal(fNDigits -1));
218 for (Int_t i = 1;i<fNDigits -1;i++){
219 fTotalSignal += (Float_t)GetDigitSignal(i);
220 //printf("GetTotalSignal :i DigitSignal %d %d \n",i,GetDigitSignal(i));
222 //printf("GetTotalSignal: fNDigits %d fTotalSignal %.0f \n",fNDigits,fTotalSignal);
226 //______________________________________________________________________
227 Float_t AliITSclusterSSD::GetTotalSignalError(){
228 // return the error on the signal
230 for (Int_t i =1; i<fNDigits -1; i++){
231 err+=0.1*GetDigitSignal(i);
233 if (GetLeftNeighbour()){
234 err+=GetDigitSignal(0);
236 err+=0.1*GetDigitSignal(0);
238 if (GetRightNeighbour()){
239 err+=GetDigitSignal(fNDigits -1);
241 err+=0.1*GetDigitSignal(fNDigits -1);
245 //______________________________________________________________________
246 void AliITSclusterSSD::DelCross(Int_t index){
247 // remove cross clusters from the list of cross clusters
248 Int_t i,j; //iterators
250 for (i =0;i<fNCrosses;i++){
251 if ((*fCrossedClusterIndexes)[i] == index){
252 for (j=i;j<fNCrosses-1;j++){
253 (*fCrossedClusterIndexes)[j]=(*fCrossedClusterIndexes)[j+1];
260 //______________________________________________________________________
261 Int_t *AliITSclusterSSD::GetTracks(Int_t &nt){
262 // return the track number of the cluster
263 Int_t ntrk = GetDigit(0)->GetNTracks();
264 Int_t ndig = GetNumOfDigits();
265 Int_t *idig = new Int_t[ndig];
266 Int_t *sdig = new Int_t[ndig];
267 Int_t *itrk = new Int_t[ndig*ntrk];
271 for(i=0;i<ndig;i++){idig[i] = i;sdig[i] = GetDigit(i)->GetSignal();}
272 TMath::Sort(ndig,sdig,idig,kTRUE);
273 for(i=0;i<ndig*ntrk;i++) itrk[i] = -3;
275 for(i=0;i<ndig;i++){ // fill itrk with track numbers in order of digit size
277 for(k=0;k<ntrk;k++) if((trk = GetDigit(j)->GetTrack(k))>=0) {
282 for(i=0;i<10;i++) fTrack[i] = -3;
283 fTrack[0] = itrk[0]; // first element
287 for(j=0;j<k;j++) if(fTrack[j]==itrk[i]) b = kFALSE;
288 if(b){fTrack[k] = itrk[i]; k++;}
305 for (i=0;i<10;i++) fTrack[i] = -3;
307 //cout<<"GetTrack start -------: fNDigits ="<<fNDigits<<endl;
309 for (i = 0; i<fNDigits; i++) {
310 tidx = GetDigit(i)->GetTracks();
311 n = GetDigit(i)->GetNTracks();
312 for (j = 0; j<n && j<10;j++) {
315 fTrack[ntracks] = tidx[j];
317 }else if(tidx[j] != fTrack[ntracks-1]){
322 } // end if ntracks > 9
323 fTrack[ntracks-1] = tidx[j];
324 } // end if ntracke == 0
325 } // end if tidx[j] >=0
326 } // 3-tracks loop for the digit
335 //______________________________________________________________________
336 Double_t AliITSclusterSSD::GetPosition(){
337 // return position of the cluster
342 ret = GetDigitStripNo(0);
345 ret = EtaAlgorithm();
348 ret = CentrOfGravity();
352 //______________________________________________________________________
353 Double_t AliITSclusterSSD::EtaAlgorithm(){
354 // algorithm for determing cluster position
355 if (fNDigits != 2) return -1;
357 Int_t strip1 = GetDigit(0)->GetStripNumber();
358 Int_t strip2 = GetDigit(1)->GetStripNumber();
359 Int_t signal1 = GetDigit(0)->GetSignal();
360 Int_t signal2 = GetDigit(1)->GetSignal();
366 eta = ((Double_t)signal2)/((Double_t)(signal1+signal2));
367 if (eta<0.04) return strip1;
368 if (eta>0.96) return strip2;
369 return (strip1 + 0.43478261*eta + 0.2826087);
371 eta = ((Double_t)signal1)/((Double_t)(signal1+signal2));
372 if (eta<0.04) return strip2;
373 if (eta>0.96) return strip1;
374 return (strip2 + 0.43478261*eta + 0.2826087);
377 //______________________________________________________________________
378 Double_t AliITSclusterSSD::GetPositionError() const {
379 // return the position error
380 return (GetNumOfDigits()+1)/2;
382 //______________________________________________________________________
383 Bool_t AliITSclusterSSD::IsCrossingWith(Int_t idx) const{
384 // return the cluster to which he crosses
386 for (Int_t i =0; i< fNCrosses;i++){
387 if (GetCross(i) == idx) return kTRUE;