]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ITS/AliITSClusterFinderSSD.cxx
Partical update of SetDefault.
[u/mrichter/AliRoot.git] / ITS / AliITSClusterFinderSSD.cxx
CommitLineData
b0f5e3fc 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
3c9a27a7 16#include <iostream.h>
eb08b98f 17#include <TArrayI.h>
b0f5e3fc 18#include "AliRun.h"
e8189707 19#include "AliITS.h"
3c9a27a7 20#include "AliITSdigit.h"
21#include "AliITSRawCluster.h"
22#include "AliITSRecPoint.h"
e8189707 23#include "AliITSMapA1.h"
b0f5e3fc 24#include "AliITSClusterFinderSSD.h"
e8189707 25#include "AliITSclusterSSD.h"
26#include "AliITSpackageSSD.h"
3c9a27a7 27#include "AliITSsegmentation.h"
b669392e 28
114da3a4 29const Bool_t AliITSClusterFinderSSD::fgkSIDEP=kTRUE;
30const Bool_t AliITSClusterFinderSSD::fgkSIDEN=kFALSE;
3c9a27a7 31const Int_t debug=0;
b0f5e3fc 32
33ClassImp(AliITSClusterFinderSSD)
34
35//____________________________________________________________________
36//
37// Constructor
38//____________________________________________________________________
39//
40
41
eb08b98f 42AliITSClusterFinderSSD::AliITSClusterFinderSSD(AliITSsegmentation *seg, TClonesArray *digits)
b0f5e3fc 43{
766ef0c8 44//Standard constructor
3c9a27a7 45
b0f5e3fc 46 fSegmentation=seg;
eb08b98f 47 fDigits=digits;
b0f5e3fc 48
eb08b98f 49 fMap = new AliITSMapA1(fSegmentation,fDigits);
e8189707 50
b0f5e3fc 51 fITS=(AliITS*)gAlice->GetModule("ITS");
52
53 fClusterP = new TClonesArray ("AliITSclusterSSD",200);
54 fNClusterP =0;
55
56 fClusterN= new TClonesArray ("AliITSclusterSSD",200);
57 fNClusterN =0;
58
59 fPackages = new TClonesArray ("AliITSpackageSSD",200); //packages
60 fNPackages = 0;
61
62
63 fDigitsIndexP = new TArrayI(300);
64 fNDigitsP = 0;
65
66 fDigitsIndexN = new TArrayI(300);
67 fNDigitsN = 0;
68
fd61217e 69 //SetAlpha1(1000);
70 //SetAlpha2(1000);
71 //SetAlpha3(1000);
b0f5e3fc 72
73
74 fPitch = fSegmentation->Dpx(0);
75 Float_t StereoP,StereoN;
76 fSegmentation->Angles(StereoP,StereoN);
77 fTanP=TMath::Tan(StereoP);
78 fTanN=TMath::Tan(StereoN);
e8189707 79
be33dccb 80 fPNsignalRatio=7./8.; // warning: hard-wired number
e8189707 81
b0f5e3fc 82}
83
84//-------------------------------------------------------
85AliITSClusterFinderSSD::~AliITSClusterFinderSSD() {
766ef0c8 86// Default destructor
3c9a27a7 87
b0f5e3fc 88 delete fClusterP;
89 delete fClusterN;
90 delete fPackages;
91 delete fDigitsIndexP;
92 delete fDigitsIndexN;
e8189707 93 delete fMap;
94
b0f5e3fc 95}
96
97//-------------------------------------------------------
98void AliITSClusterFinderSSD::InitReconstruction()
99{
766ef0c8 100// initialization of the cluster finder
b0f5e3fc 101
102 register Int_t i; //iterator
103
e8189707 104 for (i=0;i<fNClusterP;i++)
b0f5e3fc 105 {
106 fClusterP->RemoveAt(i);
107 }
108 fNClusterP =0;
e8189707 109 for (i=0;i<fNClusterN;i++)
b0f5e3fc 110 {
111 fClusterN->RemoveAt(i);
112 }
113 fNClusterN=0;
114
e8189707 115 for (i=0;i<fNPackages;i++)
b0f5e3fc 116 {
117 fPackages->RemoveAt(i);
118 }
119
120 fNPackages = 0;
121 fNDigitsP=0;
122 fNDigitsN=0;
123
124 Float_t StereoP,StereoN;
125 fSegmentation->Angles(StereoP,StereoN);
126
127 CalcStepFactor (StereoP,StereoN);
128
129 if (debug) cout<<"fSFF = "<<fSFF<<" fSFB = "<<fSFB<<"\n";
130}
131
132
133//---------------------------------------------
134void AliITSClusterFinderSSD::FindRawClusters()
135{
b0f5e3fc 136// This function findes out all clusters belonging to one module
137// 1. Zeroes all space after previous module reconstruction
138// 2. Finds all neighbouring digits
139// 3. If necesery, resolves for each group of neighbouring digits
140// how many clusters creates it.
141// 4. Creates packages
142// 5. Creates clusters
143
144 InitReconstruction(); //ad. 1
e8189707 145 fMap->FillMap();
b0f5e3fc 146 FillDigitsIndex();
147 SortDigits();
148 FindNeighbouringDigits(); //ad. 2
fd61217e 149 //SeparateOverlappedClusters(); //ad. 3
b0f5e3fc 150 ClustersToPackages(); //ad. 4
fd61217e 151 AliITSRecPoint rnew;
e8189707 152 fMap->ClearMap();
b0f5e3fc 153}
154
155
156//-------------------------------------------------
157void AliITSClusterFinderSSD::FindNeighbouringDigits()
158{
766ef0c8 159//If there are any digits on this side, create 1st Cluster,
160// add to it this digit, and increment number of clusters
b0f5e3fc 161
162
b0f5e3fc 163 register Int_t i;
164
b0f5e3fc 165
166 if ((fNDigitsP>0 ) && (fNDigitsN > 0 )) {
167
168 Int_t currentstripNo;
169 Int_t *dbuffer = new Int_t [300]; //buffer for strip numbers
170 Int_t dnumber; //curent number of digits in buffer
46019b87 171 TArrayI &lDigitsIndexP = *fDigitsIndexP;
172 TArrayI &lDigitsIndexN = *fDigitsIndexN;
173 TObjArray &lDigits = *(Digits());
174 TClonesArray &lClusterP = *fClusterP;
175 TClonesArray &lClusterN = *fClusterN;
b0f5e3fc 176
177 //process P side
178 dnumber = 1;
179 dbuffer[0]=lDigitsIndexP[0];
180 //If next digit is a neighbour of previous, adds to last cluster this digit
e8189707 181 for (i=1; i<fNDigitsP; i++) {
b0f5e3fc 182 //reads new digit
183 currentstripNo = ((AliITSdigitSSD*)lDigits[lDigitsIndexP[i]])->
184 GetStripNumber();
185 //check if it is a neighbour of a previous one
186 if ( (((AliITSdigitSSD*)lDigits[lDigitsIndexP[i-1]])->GetStripNumber())
187 == (currentstripNo-1) ) dbuffer[dnumber++]=lDigitsIndexP[i];
188 else {
189 //create a new one side cluster
46019b87 190 new(lClusterP[fNClusterP++]) AliITSclusterSSD(dnumber,dbuffer,Digits(),fgkSIDEP);
b0f5e3fc 191 dbuffer[0]=lDigitsIndexP[i];
192 dnumber = 1;
193 }
194 } // end loop over fNDigitsP
46019b87 195 new(lClusterP[fNClusterP++]) AliITSclusterSSD(dnumber,dbuffer,Digits(),fgkSIDEP);
b0f5e3fc 196
197
198 //process N side
199 //for comments, see above
200 dnumber = 1;
201 dbuffer[0]=lDigitsIndexN[0];
202 //If next digit is a neighbour of previous, adds to last cluster this digit
e8189707 203 for (i=1; i<fNDigitsN; i++) {
b0f5e3fc 204 currentstripNo = ((AliITSdigitSSD*)(lDigits[lDigitsIndexN[i]]))->
205 GetStripNumber();
206 if ( (((AliITSdigitSSD*)lDigits[lDigitsIndexN[i-1]])->GetStripNumber())
207 == (currentstripNo-1) ) dbuffer[dnumber++]=lDigitsIndexN[i];
208 else {
46019b87 209 new(lClusterN[fNClusterN++]) AliITSclusterSSD(dnumber,dbuffer,Digits(),fgkSIDEN);
b0f5e3fc 210 dbuffer[0]=lDigitsIndexN[i];
211 dnumber = 1;
212 }
213 } // end loop over fNDigitsN
46019b87 214 new(lClusterN[fNClusterN++]) AliITSclusterSSD(dnumber,dbuffer,Digits(),fgkSIDEN);
b0f5e3fc 215 delete [] dbuffer;
216
217 } // end condition on NDigits
218
219 if (debug) cout<<"\n Found clusters: fNClusterP = "<<fNClusterP<<" fNClusterN ="<<fNClusterN<<"\n";
220
221}
b0f5e3fc 222
fd61217e 223//--------------------------------------------------------------
b0f5e3fc 224
225void AliITSClusterFinderSSD::SeparateOverlappedClusters()
226{
766ef0c8 227// overlapped clusters separation
b0f5e3fc 228
e8189707 229 register Int_t i; //iterator
b0f5e3fc 230
231 Float_t factor=0.75; // How many percent must be lower signal
232 // on the middle one digit
233 // from its neighbours
234 Int_t signal0; //signal on the strip before the current one
235 Int_t signal1; //signal on the current one signal
236 Int_t signal2; //signal on the strip after the current one
237 TArrayI *splitlist; // List of splits
238 Int_t numerofsplits=0; // number of splits
239 Int_t initPsize = fNClusterP; //initial size of the arrays
240 Int_t initNsize = fNClusterN; //we have to keep it because it will grow
241 // in this function and it doasn't make
242 // sense to pass through it again
243
244 splitlist = new TArrayI(300);
245
e8189707 246 for (i=0;i<initPsize;i++)
b0f5e3fc 247 {
248 if (( ((AliITSclusterSSD*)(*fClusterP)[i])->GetNumOfDigits())==1) continue;
249 if (( ((AliITSclusterSSD*)(*fClusterP)[i])->GetNumOfDigits())==2) continue;
250 Int_t nj=(((AliITSclusterSSD*)(*fClusterP)[i])->GetNumOfDigits()-1);
e8189707 251 for (Int_t j=1; j<nj; j++)
b0f5e3fc 252 {
253 signal1=((AliITSclusterSSD*)(*fClusterP)[i])->GetDigitSignal(j);
254 signal0=((AliITSclusterSSD*)(*fClusterP)[i])->GetDigitSignal(j-1);
255 signal2=((AliITSclusterSSD*)(*fClusterP)[i])->GetDigitSignal(j+1);
256 //if signal is less then factor*signal of its neighbours
257 if ( (signal1<(factor*signal0)) && (signal1<(factor*signal2)) )
258 {
259 (*splitlist)[numerofsplits++]=j;
260 }
261 } // end loop over number of digits
262 //split this cluster if necessary
3c9a27a7 263 if(numerofsplits>0) SplitCluster(splitlist,numerofsplits,i,fgkSIDEP);
264 numerofsplits=0;
b0f5e3fc 265
266 //in signed places (splitlist)
267 } // end loop over clusters on Pside
268
e8189707 269 for (i=0;i<initNsize;i++) {
b0f5e3fc 270 if (( ((AliITSclusterSSD*)(*fClusterN)[i])->GetNumOfDigits())==1) continue;
271 if (( ((AliITSclusterSSD*)(*fClusterN)[i])->GetNumOfDigits())==2) continue;
272 Int_t nj=(((AliITSclusterSSD*)(*fClusterN)[i])->GetNumOfDigits()-1);
e8189707 273 for (Int_t j=1; j<nj; j++)
b0f5e3fc 274 {
275 signal1=((AliITSclusterSSD*)(*fClusterN)[i])->GetDigitSignal(j);
276 signal0=((AliITSclusterSSD*)(*fClusterN)[i])->GetDigitSignal(j-1);
277 signal2=((AliITSclusterSSD*)(*fClusterN)[i])->GetDigitSignal(j+1);
278 //if signal is less then factor*signal of its neighbours
279 if ( (signal1<(factor*signal0)) && (signal1<(factor*signal2)) )
280 (*splitlist)[numerofsplits++]=j;
281 } // end loop over number of digits
282 //split this cluster into more clusters
e8189707 283 if(numerofsplits>0) SplitCluster(splitlist,numerofsplits,i,fgkSIDEN);
b0f5e3fc 284 numerofsplits=0; //in signed places (splitlist)
285 } // end loop over clusters on Nside
286
287 delete splitlist;
288}
289
290//-------------------------------------------------------
291void AliITSClusterFinderSSD::SplitCluster(TArrayI *list, Int_t nsplits, Int_t index, Bool_t side)
292{
b0f5e3fc 293 //This function splits one side cluster into more clusters
294 //number of splits is defined by "nsplits"
295 //Place of splits are defined in the TArray "list"
296
297 // For further optimisation: Replace this function by two
298 // specialised ones (each for one side)
299 // save one "if"
300
301 //For comlete comments see AliITSclusterSSD::SplitCluster
302
303
304 register Int_t i; //iterator
305
306 AliITSclusterSSD* curentcluster;
307 Int_t *tmpdigits = new Int_t[100];
308 Int_t NN;
309 // side true means P side
310 if (side) {
311 curentcluster =((AliITSclusterSSD*)((*fClusterP)[index])) ;
e8189707 312 for (i = nsplits; i>0 ;i--) {
b0f5e3fc 313 NN=curentcluster->SplitCluster((*list)[(i-1)],tmpdigits);
46019b87 314 new ((*fClusterP)[fNClusterP]) AliITSclusterSSD(NN,tmpdigits,Digits(),side);
b0f5e3fc 315 ( (AliITSclusterSSD*)((*fClusterP)[fNClusterP]) )->
316 SetLeftNeighbour(kTRUE);
317 //if left cluster had neighbour on the right before split
318 //new should have it too
319 if ( curentcluster->GetRightNeighbour() )
320 ( (AliITSclusterSSD*)((*fClusterP)[fNClusterP]) )->
321 SetRightNeighbour(kTRUE);
322 else curentcluster->SetRightNeighbour(kTRUE);
323 fNClusterP++;
324 } // end loop over nplits
325 } else {
326 curentcluster =((AliITSclusterSSD*)((*fClusterN)[index]));
e8189707 327 for (i = nsplits; i>0 ;i--) {
b0f5e3fc 328 NN=curentcluster->SplitCluster((*list)[(i-1)],tmpdigits);
46019b87 329 new ((*fClusterN)[fNClusterN]) AliITSclusterSSD(NN,tmpdigits,Digits(),side);
b0f5e3fc 330 ((AliITSclusterSSD*)((*fClusterN)[fNClusterN]))->
331 SetRightNeighbour(kTRUE);
332 if (curentcluster->GetRightNeighbour())
333 ( (AliITSclusterSSD*)( (*fClusterN)[fNClusterN]) )->
334 SetRightNeighbour(kTRUE);
335 else curentcluster->SetRightNeighbour(kTRUE);
336 fNClusterN++;
337 } // end loop over nplits
338 } // end if side
339 delete []tmpdigits;
340
341}
342
343
344//-------------------------------------------------
345Int_t AliITSClusterFinderSSD::SortDigitsP(Int_t start, Int_t end)
346{
766ef0c8 347// sort digits on the P side
b0f5e3fc 348
b0f5e3fc 349
350 Int_t right;
351 Int_t left;
352 if (start != (end - 1) )
353 {
354 left=this->SortDigitsP(start,(start+end)/2);
355 right=this->SortDigitsP((start+end)/2,end);
356 return (left || right);
357 }
358 else
359 {
46019b87 360 left = ((AliITSdigitSSD*)((*(Digits()))[(*fDigitsIndexP)[start]]))->GetStripNumber();
361 right= ((AliITSdigitSSD*)((*(Digits()))[(*fDigitsIndexP)[end]]))->GetStripNumber();
b0f5e3fc 362 if( left > right )
363 {
364 Int_t tmp = (*fDigitsIndexP)[start];
365 (*fDigitsIndexP)[start]=(*fDigitsIndexP)[end];
366 (*fDigitsIndexP)[end]=tmp;
367 return 1;
368 }
369 else return 0;
370 }
371}
372
373
374//--------------------------------------------------
375
376Int_t AliITSClusterFinderSSD::SortDigitsN(Int_t start, Int_t end)
377{
766ef0c8 378// sort digits on the N side
b0f5e3fc 379
380 Int_t right;
381 Int_t left;
382 if (start != (end - 1))
383 {
384 left=this->SortDigitsN(start,(start+end)/2);
385 right=this->SortDigitsN((start+end)/2,end);
386 return (left || right);
387 }
388 else
389 {
46019b87 390 left =((AliITSdigitSSD*)((*(Digits()))[(*fDigitsIndexN)[start]]))->GetStripNumber();
391 right=((AliITSdigitSSD*)((*(Digits()))[(*fDigitsIndexN)[end]]))->GetStripNumber();
b0f5e3fc 392 if ( left > right )
393 {
394 Int_t tmp = (*fDigitsIndexN)[start];
395 (*fDigitsIndexN)[start]=(*fDigitsIndexN)[end];
396 (*fDigitsIndexN)[end]=tmp;
397 return 1;
398 }else return 0;
399 }
400}
401
402
403//------------------------------------------------
404void AliITSClusterFinderSSD::FillDigitsIndex()
405{
b0f5e3fc 406 //Fill the indexes of the clusters belonging to a given ITS module
b0f5e3fc 407
408 Int_t PNs=0, NNs=0;
409 Int_t tmp,bit,k;
410 Int_t N;
411 Int_t i;
412
eb08b98f 413 N = fDigits->GetEntriesFast();
b0f5e3fc 414
415 Int_t* PSidx = new Int_t [N*sizeof(Int_t)];
416 Int_t* NSidx = new Int_t [N*sizeof(Int_t)];
417 if (fDigitsIndexP==NULL) fDigitsIndexP = new TArrayI(N);
418 if (fDigitsIndexN==NULL) fDigitsIndexN = new TArrayI(N);
419
420 AliITSdigitSSD *dig;
421
e8189707 422 for ( i = 0 ; i< N; i++ ) {
46019b87 423 dig = (AliITSdigitSSD*)GetDigit(i);
b0f5e3fc 424 if(dig->IsSideP()) {
425 bit=1;
426 tmp=dig->GetStripNumber();
427 // I find this totally unnecessary - it's just a
428 // CPU consuming double check
e8189707 429 for( k=0;k<PNs;k++)
b0f5e3fc 430 {
431 if (tmp==PSidx[k])
432 {
433 if (debug) cout<<"Such a digit exists \n";
434 bit=0;
435 }
436 }
437 // end comment
438 if(bit) {
439 fDigitsIndexP->AddAt(i,fNDigitsP++);
440 PSidx[PNs++]=tmp;
441 }
442 } else {
443 bit=1;
444 tmp=dig->GetStripNumber();
445 // same as above
e8189707 446 for( k=0;k<NNs;k++)
b0f5e3fc 447 {
448 if (tmp==NSidx[k])
449 {
450 if (debug) cout<<"Such a digit exists \n";
451 bit=0;
452 }
453 }
454 // end comment
455 if (bit) {
456 fDigitsIndexN->AddAt(i,fNDigitsN++);
457 NSidx[NNs++] =tmp;
458 }
459 }
460 }
461
3c9a27a7 462 delete [] PSidx;
463 delete [] NSidx;
b0f5e3fc 464
465 if (debug) cout<<"Digits : P = "<<fNDigitsP<<" N = "<<fNDigitsN<<endl;
466
467}
468
469
470//-------------------------------------------
471
472void AliITSClusterFinderSSD::SortDigits()
473{
766ef0c8 474// sort digits
b0f5e3fc 475
476 Int_t i;
477 if(fNDigitsP>1)
e8189707 478 for (i=0;i<fNDigitsP-1;i++)
b0f5e3fc 479 if (SortDigitsP(0,(fNDigitsP-1-i))==0) break;
480
481 if(fNDigitsN>1)
e8189707 482 for (i=0;i<fNDigitsN-1;i++)
b0f5e3fc 483 if(SortDigitsN(0,(fNDigitsN-1-i))==0) break;
484}
485
486
487
488//----------------------------------------------
489void AliITSClusterFinderSSD::FillClIndexArrays(Int_t* arrayP, Int_t *arrayN)
490{
766ef0c8 491// fill cluster index array
b0f5e3fc 492
493 register Int_t i;
e8189707 494 for (i=0; i<fNClusterP;i++)
b0f5e3fc 495 {
496 arrayP[i]=i;
497 }
e8189707 498 for (i=0; i<fNClusterN;i++)
b0f5e3fc 499 {
500 arrayN[i]=i;
501 }
502}
503
504
505//------------------------------------------------------
506void AliITSClusterFinderSSD::SortClusters(Int_t* arrayP, Int_t *arrayN)
507{
766ef0c8 508// sort clusters
b0f5e3fc 509
510 Int_t i;
511 if(fNClusterP>1)
e8189707 512 for (i=0;i<fNClusterP-1;i++)
b0f5e3fc 513 if (SortClustersP(0,(fNClusterP-1),arrayP)==0) break;
514
515
516 if(fNClusterN>1)
e8189707 517 for (i=0;i<fNClusterN-1;i++)
b0f5e3fc 518 if (SortClustersN(0,(fNClusterN-1),arrayN)==0) break;
519
520}
521
522
523
524//---------------------------------------------------
525Int_t AliITSClusterFinderSSD::SortClustersP(Int_t start, Int_t end, Int_t *array)
526{
766ef0c8 527//Sort P side clusters
b0f5e3fc 528
529
530 Int_t right;
531 Int_t left;
532 if (start != (end - 1) ) {
533 left=this->SortClustersP(start,(start+end)/2,array);
534 right=this->SortClustersP((start+end)/2,end,array);
535 return (left || right);
536 } else {
537 left =((AliITSclusterSSD*)((*fClusterP)[array[start]]))->
538 GetDigitStripNo(0);
539 right=((AliITSclusterSSD*)((*fClusterP)[array[ end ]]))->
540 GetDigitStripNo(0);
541 if(left>right) {
542 Int_t tmp = array[start];
543 array[start]=array[end];
544 array[end]=tmp;
545 return 1;
546 } else return 0;
547 }
548
549
550}
551
552
553
554//-------------------------------------------------------
555Int_t AliITSClusterFinderSSD::SortClustersN(Int_t start, Int_t end, Int_t *array)
556{
766ef0c8 557//Sort N side clusters
b0f5e3fc 558
559
b0f5e3fc 560 Int_t right;
561 Int_t left;
562
563 if (start != (end - 1) ) {
564 left=this->SortClustersN(start,(start+end)/2,array);
565 right=this->SortClustersN((start+end)/2,end,array);
566 return (left || right);
567 } else {
568 left =((AliITSclusterSSD*)((*fClusterN)[array[start]]))->
569 GetDigitStripNo(0);
570 right=((AliITSclusterSSD*)((*fClusterN)[array[ end ]]))->
571 GetDigitStripNo(0);
572 if( left > right) {
573 Int_t tmp = array[start];
574 array[start]=array[end];
575 array[end]=tmp;
576 return 1;
577 } else return 0;
578 }
579
580}
581
582
583
584//-------------------------------------------------------
585void AliITSClusterFinderSSD::ClustersToPackages()
586{
766ef0c8 587// fill packages
b0f5e3fc 588
589 Int_t *oneSclP = new Int_t[fNClusterP]; //I want to have sorted 1 S clusters
590 Int_t *oneSclN = new Int_t[fNClusterN]; //I can not sort it in TClonesArray
591 //so, I create table of indexes and
592 //sort it
593 //I do not use TArrayI on purpose
594 // MB: well, that's not true that one
595 //cannot sort objects in TClonesArray
596
fd61217e 597 //AliITSpackageSSD *currentpkg;
b0f5e3fc 598 AliITSclusterSSD *currentP;
599 AliITSclusterSSD *currentN;
fd61217e 600 Int_t j1, j2;
b0f5e3fc 601
602//Fills in One Side Clusters Index Array
603 FillClIndexArrays(oneSclP,oneSclN);
604//Sorts filled Arrays
605 SortClusters(oneSclP,oneSclN);
606
607
608 fNPackages=1;
609 new ((*fPackages)[0]) AliITSpackageSSD(fClusterP,fClusterN);
fd61217e 610 //currentpkg = (AliITSpackageSSD*)((*fPackages)[0]);
611
612 // Take all pairs of recpoints x coordinates in both sides
613 // to calculate z coordinates of the recpoints
614 for (j1=0;j1<fNClusterP;j1++) {
615 currentP = GetPSideCluster(oneSclP[j1]);
616 Double_t xP = currentP->GetPosition();
617 //Int_t NxP = currentP->GetNumOfDigits();
618 //cout<<"ClusterToP:New NxP,xP ="<<NxP<<","<<xP<<endl;
619 Float_t signalP = currentP->GetTotalSignal();
620 for (j2=0;j2<fNClusterN;j2++) {
621 currentN = GetNSideCluster(oneSclN[j2]);
622 Double_t xN = currentN->GetPosition();
623 //Int_t NxN = currentN->GetNumOfDigits();
624 //cout<<"ClusterToP:New NxN,xN ="<<NxN<<","<<xN<<endl;
625 Float_t signalN = currentN->GetTotalSignal();
626 //cout<<"ClusterToP: signalP,signalN ="<<signalP<<","<<signalN<<endl;
627 CreateNewRecPoint(xP,1,xN,1,signalP,signalN,currentP, currentN, 0.75);
b0f5e3fc 628
b0f5e3fc 629 }
b0f5e3fc 630 }
631
fd61217e 632 delete oneSclP;
633 delete oneSclN;
b0f5e3fc 634
635}
636
637
b0f5e3fc 638//------------------------------------------------------
639Bool_t AliITSClusterFinderSSD::
640CreateNewRecPoint(Float_t P, Float_t dP, Float_t N, Float_t dN,
fd61217e 641 Float_t SigP,Float_t SigN,
b0f5e3fc 642 AliITSclusterSSD *clusterP, AliITSclusterSSD *clusterN,
643 Stat_t prob)
644{
766ef0c8 645// create the recpoints
fd61217e 646 const Float_t kADCtoKeV = 2.16;
647 // 50 ADC units -> 30000 e-h pairs; 1e-h pair -> 3.6e-3 KeV;
648 // 1 ADC unit -> (30000/50)*3.6e-3 = 2.16 KeV
b0f5e3fc 649 const Float_t kconv = 1.0e-4;
b0f5e3fc 650
fd61217e 651 const Float_t kRMSx = 20.0*kconv;
652 const Float_t kRMSz = 800.0*kconv;
b0f5e3fc 653
e8189707 654 Int_t stripP, stripN;
fd61217e 655 Int_t n=0;
656 Int_t *tr;
b0f5e3fc 657 if (GetCrossing(P,N)) {
fd61217e 658
b0f5e3fc 659 GetCrossingError(dP,dN);
660 AliITSRawClusterSSD cnew;
661 Int_t nstripsP=clusterP->GetNumOfDigits();
662 Int_t nstripsN=clusterN->GetNumOfDigits();
fd61217e 663 //Float_t signalP=clusterP->GetTotalSignal();
664 //Float_t signalN=clusterN->GetTotalSignal();
665
666 Float_t signal = 0;
667 Float_t dedx = 0;
668 if(SigP>SigN) {
669 signal = SigP;
670 dedx = SigP*kADCtoKeV;
671 }else{
672 signal = SigN;
673 dedx = SigN*kADCtoKeV;
674 }
675 Float_t signalCut = TMath::Abs((SigP-SigN)/signal);
676
677 //cnew.fSignalP=signalP;
678 //cnew.fSignalN=signalN;
679 cnew.fSignalP=SigP;
680 cnew.fSignalN=SigN;
b0f5e3fc 681 cnew.fMultiplicity=nstripsP;
682 cnew.fMultiplicityN=nstripsN;
fd61217e 683 cnew.fQErr=signalCut;
b0f5e3fc 684
fd61217e 685 //fITS->AddCluster(2,&cnew);
b0f5e3fc 686
fd61217e 687 if(signalCut<0.18) fITS->AddCluster(2,&cnew);
688 // the cut of the signals difference in P and N sides to
689 // remove the "ghosts"
b0f5e3fc 690
fd61217e 691 fSegmentation->GetPadIxz(P,N,stripP,stripN);
b0f5e3fc 692
fd61217e 693 //cout<<"NewRec: P,N microns,stripP,stripN ="<<P<<","<<N<<","<<stripP<<","<<stripN<<endl;
b0f5e3fc 694
fd61217e 695 tr = (Int_t*) clusterP->GetTracks(n);
696 //cout<<"!!!! ntr,tr0,tr1,tr2 ="<<n<<","<<tr[0]<<","<<tr[1]<<","<<tr[2]<<endl;
697 //cout<<"NewRec:AddRecP: xL,zL cm ="<<P*kconv<<","<<N*kconv<<endl;
b0f5e3fc 698
fd61217e 699 AliITSRecPoint rnew;
700 rnew.SetX(P*kconv);
701 rnew.SetZ(N*kconv);
702 rnew.SetQ(signal);
703 rnew.SetdEdX(dedx);
704 rnew.SetSigmaX2( kRMSx* kRMSx);
705 rnew.SetSigmaZ2( kRMSz* kRMSz);
add43cb3 706 //rnew.SetSigmaX2(1); //This has to be verified
707 //rnew.SetSigmaZ2(1); //This has to be verified
fd61217e 708 rnew.fTracks[0]=tr[0];
709 rnew.fTracks[1]=tr[1];
710 rnew.fTracks[2]=tr[2];
b0f5e3fc 711
fd61217e 712 //fITS->AddRecPoint(rnew);
b0f5e3fc 713
fd61217e 714 if(signalCut<0.18) fITS->AddRecPoint(rnew);
715 // the cut of the signals difference in P and N sides to
716 // remove the "ghosts"
b0f5e3fc 717
fd61217e 718 return kTRUE;
719 }
720 return kFALSE;
b0f5e3fc 721}
722
723
724//------------------------------------------------------
725void AliITSClusterFinderSSD::CalcStepFactor(Float_t Psteo, Float_t Nsteo )
726{
766ef0c8 727// calculate the step factor for matching clusters
b0f5e3fc 728
729
730 // 95 is the pitch, 4000 - dimension along z ?
b0f5e3fc 731
732
733 Float_t dz=fSegmentation->Dz();
734
735 fSFF = ( (Int_t) (Psteo*dz/fPitch ) );// +1;
736 fSFB = ( (Int_t) (Nsteo*dz/fPitch ) );// +1;
737
738}
739
740
741//-----------------------------------------------------------
742AliITSclusterSSD* AliITSClusterFinderSSD::GetPSideCluster(Int_t idx)
743{
766ef0c8 744// get P side clusters
b0f5e3fc 745
746
b0f5e3fc 747
748
749 if((idx<0)||(idx>=fNClusterP))
750 {
751 printf("AliITSClusterFinderSSD::GetPSideCluster : index out of range\n");
752 return 0;
753 }
754 else
755 {
756 return (AliITSclusterSSD*)((*fClusterP)[idx]);
757 }
758}
759
760//-------------------------------------------------------
761AliITSclusterSSD* AliITSClusterFinderSSD::GetNSideCluster(Int_t idx)
762{
766ef0c8 763// get N side clusters
b0f5e3fc 764
765 if((idx<0)||(idx>=fNClusterN))
766 {
767 printf("AliITSClusterFinderSSD::GetNSideCluster : index out of range\n");
768 return 0;
769 }
770 else
771 {
772 return (AliITSclusterSSD*)((*fClusterN)[idx]);
773 }
774}
775
776//--------------------------------------------------------
777AliITSclusterSSD* AliITSClusterFinderSSD::GetCluster(Int_t idx, Bool_t side)
778{
766ef0c8 779// Get cluster
b0f5e3fc 780
781 return (side) ? GetPSideCluster(idx) : GetNSideCluster(idx);
782}
783
b0f5e3fc 784//_______________________________________________________________________
785
786Bool_t AliITSClusterFinderSSD::GetCrossing (Float_t &P, Float_t &N)
787{
766ef0c8 788// get crossing
b0f5e3fc 789
fd61217e 790 Float_t Dx = fSegmentation->Dx(); // detector size in x direction, microns
791 Float_t Dz = fSegmentation->Dz(); // detector size in z direction, microns
792
793 Float_t xL; // x local coordinate
794 Float_t zL; // z local coordinate
795 Float_t x; // x = xL + Dx/2
796 Float_t z; // z = zL + Dz/2
797 Float_t xP; // x coordinate in the P side from the first P strip
798 Float_t xN; // x coordinate in the N side from the first N strip
799 Float_t kP = fTanP; // Tangent of 0.0075 mrad
800 Float_t kN = fTanN; // Tangent of 0.0275 mrad
801
802 //cout<<"1 GetCros: strP,srtN,fPitch,Dx ="<<P<<","<<N<<","<<fPitch<<","<<fSegmentation->Dx()<<endl;
b0f5e3fc 803
b0f5e3fc 804
b0f5e3fc 805 P *= fPitch;
806 N *= fPitch;
fd61217e 807 xP = N; // change the mistake for the P/N
808 xN = P; // coordinates correspondence in this function
809
810 //cout<<"2 GetCross: xP,xN,fTanP,fTanN ="<<xP<<","<<xN<<","<<fTanP<<","<<fTanN<<endl;
b0f5e3fc 811
fd61217e 812 /*
813 Float_t x = xP + 0.21428*(1100-xP+xN);
814 Float_t z = 31428.571 - (xP-xN)/0.035;
815 */
b0f5e3fc 816
fd61217e 817 x = xP + kP*(Dz*kN-xP+xN)/(kP+kN);
818 z = (Dz*kN-xP+xN)/(kP+kN);
819 xL = x - Dx/2;
820 zL = z - Dz/2;
b0f5e3fc 821
fd61217e 822 //cout<<"3 GetCross: x,z,xL,zL ="<<x<<","<<z<<","<<xL<<","<<zL<<endl;
823
824 P = xL;
825 N = zL;
826
827 if(TMath::Abs(xL) > Dx/2 || TMath::Abs(zL) > Dz/2) return kFALSE;
828 // Check that xL and zL are inside the detector for the
829 // correspondent xP and xN coordinates
b0f5e3fc 830
831 return kTRUE;
832}
833
834
835//_________________________________________________________________________
836
837void AliITSClusterFinderSSD::GetCrossingError(Float_t& dP, Float_t& dN)
838{
766ef0c8 839// get crossing error
840
b0f5e3fc 841 Float_t dz, dx;
842
843 dz = TMath::Abs(( dP + dN )*fPitch/(fTanP + fTanN) );
844 dx = fPitch*(TMath::Abs(dP*(1 - fTanP/(fTanP + fTanN))) +
845 TMath::Abs(dN *fTanP/(fTanP + fTanN) ));
846
847 dN = dz;
848 dP = dx;
849}
fd61217e 850
851
852
853
854
855
856