For Pythia with tune don't switch off MI in ConfigHeavyFlavor
[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
88cb7938 16/* $Id$ */
7d62fb64 17////////////////////////////////////////////////////////////////////////////
18//Piotr Krzysztof Skowronski //
19//Warsaw University of Technology //
20//skowron@if.pw.edu.pl //
21// //
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////////////////////////////////////////////////////////////////////////////
ee86d557 26
090026bf 27#include <TArrayI.h>
28#include <TMath.h>
29#include <TClonesArray.h>
30
31
e869281d 32#include "AliITSdigitSSD.h"
b0f5e3fc 33#include "AliITSclusterSSD.h"
34
35ClassImp(AliITSclusterSSD)
36
ee86d557 37//______________________________________________________________________
e56160b8 38AliITSclusterSSD::AliITSclusterSSD():
39fSide(kTRUE),
40fDigits(0),
41fNDigits(0),
42fDigitsIndex(0),
43fNCrosses(0),
44fCrossedClusterIndexes(0),
45fLeftNeighbour(kFALSE),
46fRightNeighbour(kFALSE),
47fConsumed(kFALSE),
48fTotalSignal(-1),
49fNTracks(-1){
ee86d557 50 // default constructor
b0f5e3fc 51}
ee86d557 52//______________________________________________________________________
53AliITSclusterSSD::AliITSclusterSSD(Int_t ndigits, Int_t *DigitIndexes,
e56160b8 54 TObjArray *Digits, Bool_t side):
55fSide(side),
56fDigits(Digits),
57fNDigits(ndigits),
58fDigitsIndex(0),
59fNCrosses(0),
60fCrossedClusterIndexes(0),
61fLeftNeighbour(kFALSE),
62fRightNeighbour(kFALSE),
63fConsumed(kFALSE),
64fTotalSignal(-1),
65fNTracks(-1){
ee86d557 66 // non-default constructor
b0f5e3fc 67
ee86d557 68 fDigitsIndex = new TArrayI(fNDigits,DigitIndexes );
ee86d557 69 fCrossedClusterIndexes = new TArrayI(300);
b0f5e3fc 70}
ee86d557 71//______________________________________________________________________
72AliITSclusterSSD::~AliITSclusterSSD(){
73 // destructor
f239b2fe 74
ee86d557 75 delete fDigitsIndex;
76 delete fCrossedClusterIndexes;
77}
78//______________________________________________________________________
ac74f489 79AliITSclusterSSD::AliITSclusterSSD(const AliITSclusterSSD &OneSCluster) :
e56160b8 80TObject(OneSCluster),
81fSide(OneSCluster.fSide),
82fDigits(OneSCluster.fDigits),
83fNDigits(OneSCluster.fNDigits),
84fDigitsIndex(0),
85fNCrosses(OneSCluster.fNCrosses),
86fCrossedClusterIndexes(0),
87fLeftNeighbour(OneSCluster.fLeftNeighbour),
88fRightNeighbour(OneSCluster.fRightNeighbour),
89fConsumed(OneSCluster.fConsumed),
90fTotalSignal(-1),
91fNTracks(-1){
ee86d557 92 // copy constructor
b0f5e3fc 93
ee86d557 94 fDigitsIndex = new TArrayI(fNDigits);
ee86d557 95 fTotalSignal =-1;
96 fNTracks = -1;
ee86d557 97 Int_t i;
98 for (i = 0; i< fNCrosses ; i++){
99 fCrossedClusterIndexes[i] = OneSCluster.fCrossedClusterIndexes[i];
100 }
101 for (i = 0; i< fNDigits ; i++){
102 fDigitsIndex[i]=OneSCluster.fDigitsIndex[i];
103 }
104 return;
105}
106//______________________________________________________________________
107AliITSclusterSSD& AliITSclusterSSD::operator=(const AliITSclusterSSD
108 &OneSCluster){
109 // assignment operator
f239b2fe 110
ee86d557 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;
118 fTotalSignal =-1;
119 fNTracks = -1;
120 fNCrosses = OneSCluster.fNCrosses;
121 fConsumed = OneSCluster.fConsumed;
122 Int_t i;
123 for (i = 0; i< fNCrosses ; i++){
124 fCrossedClusterIndexes[i] = OneSCluster.fCrossedClusterIndexes[i];
125 }
126 for (i = 0; i< fNDigits ; i++){
127 fDigitsIndex[i]=OneSCluster.fDigitsIndex[i];
128 }
129 return *this;
130}
131//______________________________________________________________________
132Int_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;
139 Int_t ind = 0;
b0f5e3fc 140
b0f5e3fc 141 outdigits[ind++]=(*fDigitsIndex)[where];
ee86d557 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
148 }
149 return ind;
b0f5e3fc 150}
ee86d557 151//______________________________________________________________________
152Int_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();
b0f5e3fc 157}
ee86d557 158//______________________________________________________________________
159Int_t AliITSclusterSSD::GetDigitSignal(Int_t digit){
160 // returns digit signal
161 Int_t index,signal;
162 if (digit<0||digit>=fNDigits) return -1;
163 index = (*fDigitsIndex)[digit];
164 signal = ((AliITSdigitSSD*)(fDigits->At(index)))->GetSignal();
165 /*
166 if(signal>1.e5) printf("GetDigitSignal: digit %d index %d signal %d\n",
167 digit,index, signal);
168 */
169 return signal;
b0f5e3fc 170}
ee86d557 171//______________________________________________________________________
172void AliITSclusterSSD::AddCross(Int_t clIndex){
173 // add cluster cross to list of cluster crosses
766ef0c8 174
ee86d557 175 (*fCrossedClusterIndexes)[fNCrosses++] = clIndex;
b0f5e3fc 176}
ee86d557 177//______________________________________________________________________
7d62fb64 178Int_t AliITSclusterSSD::GetCross(Int_t crIndex) const {
ee86d557 179 // return crossing cluster
b0f5e3fc 180
ee86d557 181 return ((crIndex>-1)&&(crIndex<fNCrosses))?(*fCrossedClusterIndexes)[crIndex]:-1;
b0f5e3fc 182}
ee86d557 183//______________________________________________________________________
184Double_t AliITSclusterSSD::CentrOfGravity(){
185 // return center of gravity of the cluster
186 Float_t ret=0;
b0f5e3fc 187
ee86d557 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);
194 }// end for i
b0f5e3fc 195
ee86d557 196 if (fTotalSignal<0) GetTotalSignal();
b0f5e3fc 197
198 return (ret/fTotalSignal);
199}
ee86d557 200//______________________________________________________________________
201Float_t AliITSclusterSSD::GetTotalSignal(){
202 // return total signal
766ef0c8 203
ee86d557 204 if(fTotalSignal <0){
205 fTotalSignal=0;
206 if (fNDigits ==1) {
207 fTotalSignal = (Float_t)GetDigitSignal(0);
208 //printf("1 digit: signal %d \n",GetDigitSignal(0));
209 return fTotalSignal;
210 }
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(
215 fNDigits -1));
b0f5e3fc 216 else fTotalSignal += (Float_t)GetDigitSignal(fNDigits-1);
ee86d557 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));
b0f5e3fc 221 }
ee86d557 222 //printf("GetTotalSignal: fNDigits %d fTotalSignal %.0f \n",fNDigits,fTotalSignal);
b0f5e3fc 223 }
ee86d557 224 return fTotalSignal;
b0f5e3fc 225}
ee86d557 226//______________________________________________________________________
227Float_t AliITSclusterSSD::GetTotalSignalError(){
228 // return the error on the signal
229 Float_t err =0;
230 for (Int_t i =1; i<fNDigits -1; i++){
231 err+=0.1*GetDigitSignal(i);
b0f5e3fc 232 }
ee86d557 233 if (GetLeftNeighbour()){
234 err+=GetDigitSignal(0);
235 }else{
236 err+=0.1*GetDigitSignal(0);
237 }
238 if (GetRightNeighbour()){
239 err+=GetDigitSignal(fNDigits -1);
240 }else{
241 err+=0.1*GetDigitSignal(fNDigits -1);
242 }
243 return err;
b0f5e3fc 244}
ee86d557 245//______________________________________________________________________
246void AliITSclusterSSD::DelCross(Int_t index){
247 // remove cross clusters from the list of cross clusters
248 Int_t i,j; //iterators
b0f5e3fc 249
ee86d557 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];
254 }
255 fNCrosses--;
256 return;
257 }
258 }
b0f5e3fc 259}
ee86d557 260//______________________________________________________________________
261Int_t *AliITSclusterSSD::GetTracks(Int_t &nt){
262 // return the track number of the cluster
f8d9a5b8 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];
268 Int_t i,j,k,l,trk;
269 Bool_t b;
270
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;
274 j = k = l = 0;
275 for(i=0;i<ndig;i++){ // fill itrk with track numbers in order of digit size
276 j = idig[i];
277 for(k=0;k<ntrk;k++) if((trk = GetDigit(j)->GetTrack(k))>=0) {
278 itrk[l] = trk;
279 l++;
280 } // end for k/if
281 } // end for i
282 for(i=0;i<10;i++) fTrack[i] = -3;
283 fTrack[0] = itrk[0]; // first element
284 k = 1;
285 b = kTRUE;
286 for(i=1;i<l;i++){
287 for(j=0;j<k;j++) if(fTrack[j]==itrk[i]) b = kFALSE;
288 if(b){fTrack[k] = itrk[i]; k++;}
289 if(k>9) break;
290 } // end for i
291 nt = k;
292
293 delete[] idig;
294 delete[] sdig;
295 delete[] itrk;
296
297 return fTrack;
298/*
ee86d557 299 Int_t *tidx=0;
300 Int_t i, j,n;
301 Int_t bit =0;
302 Int_t ntracks=0;
303 nt=0;
b0f5e3fc 304
ee86d557 305 for (i=0;i<10;i++) fTrack[i] = -3;
b0f5e3fc 306
ee86d557 307 //cout<<"GetTrack start -------: fNDigits ="<<fNDigits<<endl;
b0f5e3fc 308
ee86d557 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++) {
313 if (tidx[j] >= 0) {
314 if(ntracks == 0){
315 fTrack[ntracks] = tidx[j];
316 ntracks++;
317 }else if(tidx[j] != fTrack[ntracks-1]){
318 ntracks++;
319 if(ntracks > 9) {
320 bit = 1;
321 break;
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
327 if(bit == 1) break;
328 } // digit loop
f239b2fe 329
ee86d557 330 SetNTracks(ntracks);
331 nt = ntracks;
332 return &(fTrack[0]);
f8d9a5b8 333*/
b0f5e3fc 334}
ee86d557 335//______________________________________________________________________
336Double_t AliITSclusterSSD::GetPosition(){
337 // return position of the cluster
338 Float_t ret;
b0f5e3fc 339
ee86d557 340 switch(fNDigits){
341 case 1:
342 ret = GetDigitStripNo(0);
343 break;
344 case 2:
345 ret = EtaAlgorithm();
346 break;
347 default:
348 ret = CentrOfGravity();
349 }
350 return ret;
b0f5e3fc 351}
ee86d557 352//______________________________________________________________________
353Double_t AliITSclusterSSD::EtaAlgorithm(){
354 // algorithm for determing cluster position
355 if (fNDigits != 2) return -1;
b0f5e3fc 356
ee86d557 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();
b0f5e3fc 361
ee86d557 362 Double_t eta;
b0f5e3fc 363
364
ee86d557 365 if (strip1<strip2){
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);
370 } else{
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);
375 }
b0f5e3fc 376}
ee86d557 377//______________________________________________________________________
7d62fb64 378Double_t AliITSclusterSSD::GetPositionError() const {
ee86d557 379 // return the position error
380 return (GetNumOfDigits()+1)/2;
b0f5e3fc 381}
ee86d557 382//______________________________________________________________________
7d62fb64 383Bool_t AliITSclusterSSD::IsCrossingWith(Int_t idx) const{
ee86d557 384 // return the cluster to which he crosses
b0f5e3fc 385
ee86d557 386 for (Int_t i =0; i< fNCrosses;i++){
387 if (GetCross(i) == idx) return kTRUE;
388 }
389 return kFALSE;
b0f5e3fc 390}