]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ITS/AliITSclusterSSD.cxx
Added macro for visualization of the TOF ROOT geometry
[u/mrichter/AliRoot.git] / ITS / AliITSclusterSSD.cxx
CommitLineData
ee86d557 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
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 **************************************************************************/
15
16/*
17$Log$
18*/
19
b0f5e3fc 20#include <iostream.h>
ee86d557 21#include "TArrayI.h"
22#include "TClonesArray.h"
e8189707 23#include "AliITSdigit.h"
b0f5e3fc 24#include "AliITSclusterSSD.h"
25
26ClassImp(AliITSclusterSSD)
27
ee86d557 28//______________________________________________________________________
29AliITSclusterSSD::AliITSclusterSSD(){
30 // default constructor
b0f5e3fc 31
ee86d557 32 fSide = kTRUE;
33 fDigits = 0;
34 fNDigits = 0;
35 fDigitsIndex = 0;
36 fNCrosses = 0;
37 fTotalSignal = -1;
38 fNTracks = -1;
39 fLeftNeighbour = kFALSE;
40 fRightNeighbour = kFALSE;
41 fCrossedClusterIndexes = 0;
42 fConsumed=kFALSE;
b0f5e3fc 43}
ee86d557 44//______________________________________________________________________
45AliITSclusterSSD::AliITSclusterSSD(Int_t ndigits, Int_t *DigitIndexes,
46 TObjArray *Digits, Bool_t side){
47 // non-default constructor
b0f5e3fc 48
ee86d557 49 fNDigits = ndigits;
50 fDigits = Digits;
51 fSide = side;
52 fDigitsIndex = new TArrayI(fNDigits,DigitIndexes );
53 fNCrosses = 0;
54 fCrossedClusterIndexes = new TArrayI(300);
55 fLeftNeighbour = kFALSE;
56 fRightNeighbour = kFALSE;
57 fTotalSignal =-1;
58 fNTracks = -1;
59 fConsumed=kFALSE;
b0f5e3fc 60}
ee86d557 61//______________________________________________________________________
62AliITSclusterSSD::~AliITSclusterSSD(){
63 // destructor
f239b2fe 64
ee86d557 65 delete fDigitsIndex;
66 delete fCrossedClusterIndexes;
67}
68//______________________________________________________________________
69AliITSclusterSSD::AliITSclusterSSD(const AliITSclusterSSD &OneSCluster){
70 // copy constructor
b0f5e3fc 71
ee86d557 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;
79 fTotalSignal =-1;
80 fNTracks = -1;
81 fNCrosses = OneSCluster.fNCrosses;
82 fConsumed = OneSCluster.fConsumed;
83 Int_t i;
84 for (i = 0; i< fNCrosses ; i++){
85 fCrossedClusterIndexes[i] = OneSCluster.fCrossedClusterIndexes[i];
86 }
87 for (i = 0; i< fNDigits ; i++){
88 fDigitsIndex[i]=OneSCluster.fDigitsIndex[i];
89 }
90 return;
91}
92//______________________________________________________________________
93AliITSclusterSSD& AliITSclusterSSD::operator=(const AliITSclusterSSD
94 &OneSCluster){
95 // assignment operator
f239b2fe 96
ee86d557 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;
104 fTotalSignal =-1;
105 fNTracks = -1;
106 fNCrosses = OneSCluster.fNCrosses;
107 fConsumed = OneSCluster.fConsumed;
108 Int_t i;
109 for (i = 0; i< fNCrosses ; i++){
110 fCrossedClusterIndexes[i] = OneSCluster.fCrossedClusterIndexes[i];
111 }
112 for (i = 0; i< fNDigits ; i++){
113 fDigitsIndex[i]=OneSCluster.fDigitsIndex[i];
114 }
115 return *this;
116}
117//______________________________________________________________________
118Int_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;
125 Int_t ind = 0;
b0f5e3fc 126
b0f5e3fc 127 outdigits[ind++]=(*fDigitsIndex)[where];
ee86d557 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
134 }
135 return ind;
b0f5e3fc 136}
ee86d557 137//______________________________________________________________________
138Int_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();
b0f5e3fc 143}
ee86d557 144//______________________________________________________________________
145Int_t AliITSclusterSSD::GetDigitSignal(Int_t digit){
146 // returns digit signal
147 Int_t index,signal;
148 if (digit<0||digit>=fNDigits) return -1;
149 index = (*fDigitsIndex)[digit];
150 signal = ((AliITSdigitSSD*)(fDigits->At(index)))->GetSignal();
151 /*
152 if(signal>1.e5) printf("GetDigitSignal: digit %d index %d signal %d\n",
153 digit,index, signal);
154 */
155 return signal;
b0f5e3fc 156}
ee86d557 157//______________________________________________________________________
158void AliITSclusterSSD::AddCross(Int_t clIndex){
159 // add cluster cross to list of cluster crosses
766ef0c8 160
ee86d557 161 (*fCrossedClusterIndexes)[fNCrosses++] = clIndex;
b0f5e3fc 162}
ee86d557 163//______________________________________________________________________
164Int_t AliITSclusterSSD::GetCross(Int_t crIndex){
165 // return crossing cluster
b0f5e3fc 166
ee86d557 167 return ((crIndex>-1)&&(crIndex<fNCrosses))?(*fCrossedClusterIndexes)[crIndex]:-1;
b0f5e3fc 168}
ee86d557 169//______________________________________________________________________
170Double_t AliITSclusterSSD::CentrOfGravity(){
171 // return center of gravity of the cluster
172 Float_t ret=0;
b0f5e3fc 173
ee86d557 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);
180 }// end for i
b0f5e3fc 181
ee86d557 182 if (fTotalSignal<0) GetTotalSignal();
b0f5e3fc 183
184 return (ret/fTotalSignal);
185}
ee86d557 186//______________________________________________________________________
187Float_t AliITSclusterSSD::GetTotalSignal(){
188 // return total signal
766ef0c8 189
ee86d557 190 if(fTotalSignal <0){
191 fTotalSignal=0;
192 if (fNDigits ==1) {
193 fTotalSignal = (Float_t)GetDigitSignal(0);
194 //printf("1 digit: signal %d \n",GetDigitSignal(0));
195 return fTotalSignal;
196 }
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(
201 fNDigits -1));
b0f5e3fc 202 else fTotalSignal += (Float_t)GetDigitSignal(fNDigits-1);
ee86d557 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));
b0f5e3fc 207 }
ee86d557 208 //printf("GetTotalSignal: fNDigits %d fTotalSignal %.0f \n",fNDigits,fTotalSignal);
b0f5e3fc 209 }
ee86d557 210 return fTotalSignal;
b0f5e3fc 211}
ee86d557 212//______________________________________________________________________
213Float_t AliITSclusterSSD::GetTotalSignalError(){
214 // return the error on the signal
215 Float_t err =0;
216 for (Int_t i =1; i<fNDigits -1; i++){
217 err+=0.1*GetDigitSignal(i);
b0f5e3fc 218 }
ee86d557 219 if (GetLeftNeighbour()){
220 err+=GetDigitSignal(0);
221 }else{
222 err+=0.1*GetDigitSignal(0);
223 }
224 if (GetRightNeighbour()){
225 err+=GetDigitSignal(fNDigits -1);
226 }else{
227 err+=0.1*GetDigitSignal(fNDigits -1);
228 }
229 return err;
b0f5e3fc 230}
ee86d557 231//______________________________________________________________________
232void AliITSclusterSSD::DelCross(Int_t index){
233 // remove cross clusters from the list of cross clusters
234 Int_t i,j; //iterators
b0f5e3fc 235
ee86d557 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];
240 }
241 fNCrosses--;
242 return;
243 }
244 }
b0f5e3fc 245}
ee86d557 246//______________________________________________________________________
247Int_t *AliITSclusterSSD::GetTracks(Int_t &nt){
248 // return the track number of the cluster
249 Int_t *tidx=0;
250 Int_t i, j,n;
251 Int_t bit =0;
252 Int_t ntracks=0;
253 nt=0;
b0f5e3fc 254
ee86d557 255 for (i=0;i<10;i++) fTrack[i] = -3;
b0f5e3fc 256
ee86d557 257 //cout<<"GetTrack start -------: fNDigits ="<<fNDigits<<endl;
b0f5e3fc 258
ee86d557 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++) {
263 if (tidx[j] >= 0) {
264 if(ntracks == 0){
265 fTrack[ntracks] = tidx[j];
266 ntracks++;
267 }else if(tidx[j] != fTrack[ntracks-1]){
268 ntracks++;
269 if(ntracks > 9) {
270 bit = 1;
271 break;
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
277 if(bit == 1) break;
278 } // digit loop
f239b2fe 279
ee86d557 280 SetNTracks(ntracks);
281 nt = ntracks;
282 return &(fTrack[0]);
b0f5e3fc 283}
ee86d557 284//______________________________________________________________________
285Double_t AliITSclusterSSD::GetPosition(){
286 // return position of the cluster
287 Float_t ret;
b0f5e3fc 288
ee86d557 289 switch(fNDigits){
290 case 1:
291 ret = GetDigitStripNo(0);
292 break;
293 case 2:
294 ret = EtaAlgorithm();
295 break;
296 default:
297 ret = CentrOfGravity();
298 }
299 return ret;
b0f5e3fc 300}
ee86d557 301//______________________________________________________________________
302Double_t AliITSclusterSSD::EtaAlgorithm(){
303 // algorithm for determing cluster position
304 if (fNDigits != 2) return -1;
b0f5e3fc 305
ee86d557 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();
b0f5e3fc 310
ee86d557 311 Double_t eta;
b0f5e3fc 312
313
ee86d557 314 if (strip1<strip2){
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);
319 } else{
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);
324 }
b0f5e3fc 325}
ee86d557 326//______________________________________________________________________
327Double_t AliITSclusterSSD::GetPositionError(){
328 // return the position error
329 return (GetNumOfDigits()+1)/2;
b0f5e3fc 330}
ee86d557 331//______________________________________________________________________
332Bool_t AliITSclusterSSD::IsCrossingWith(Int_t idx){
333 // return the cluster to which he crosses
b0f5e3fc 334
ee86d557 335 for (Int_t i =0; i< fNCrosses;i++){
336 if (GetCross(i) == idx) return kTRUE;
337 }
338 return kFALSE;
b0f5e3fc 339}