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