]>
Commit | Line | Data |
---|---|---|
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 | #include <iostream.h> | |
17 | #include <TArrayI.h> | |
18 | #include "AliRun.h" | |
19 | #include "AliITS.h" | |
20 | #include "AliITSdigit.h" | |
21 | #include "AliITSRawCluster.h" | |
22 | #include "AliITSRecPoint.h" | |
23 | #include "AliITSMapA1.h" | |
24 | #include "AliITSClusterFinderSSD.h" | |
25 | #include "AliITSclusterSSD.h" | |
26 | #include "AliITSpackageSSD.h" | |
27 | #include "AliITSsegmentation.h" | |
28 | ||
29 | const Bool_t AliITSClusterFinderSSD::fgkSIDEP=kTRUE; | |
30 | const Bool_t AliITSClusterFinderSSD::fgkSIDEN=kFALSE; | |
31 | const Int_t debug=0; | |
32 | ||
33 | ClassImp(AliITSClusterFinderSSD) | |
34 | ||
35 | //____________________________________________________________________ | |
36 | // | |
37 | // Constructor | |
38 | //____________________________________________________________________ | |
39 | // | |
40 | ||
41 | ||
42 | AliITSClusterFinderSSD::AliITSClusterFinderSSD(AliITSsegmentation *seg, TClonesArray *digits) | |
43 | { | |
44 | //Standard constructor | |
45 | ||
46 | fSegmentation=seg; | |
47 | fDigits=digits; | |
48 | ||
49 | fMap = new AliITSMapA1(fSegmentation,fDigits); | |
50 | ||
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 | ||
69 | //SetAlpha1(1000); | |
70 | //SetAlpha2(1000); | |
71 | //SetAlpha3(1000); | |
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); | |
79 | ||
80 | fPNsignalRatio=7./8.; // warning: hard-wired number | |
81 | ||
82 | } | |
83 | ||
84 | //------------------------------------------------------- | |
85 | AliITSClusterFinderSSD::~AliITSClusterFinderSSD() { | |
86 | // Default destructor | |
87 | ||
88 | delete fClusterP; | |
89 | delete fClusterN; | |
90 | delete fPackages; | |
91 | delete fDigitsIndexP; | |
92 | delete fDigitsIndexN; | |
93 | delete fMap; | |
94 | ||
95 | } | |
96 | ||
97 | //------------------------------------------------------- | |
98 | void AliITSClusterFinderSSD::InitReconstruction() | |
99 | { | |
100 | // initialization of the cluster finder | |
101 | ||
102 | register Int_t i; //iterator | |
103 | ||
104 | for (i=0;i<fNClusterP;i++) | |
105 | { | |
106 | fClusterP->RemoveAt(i); | |
107 | } | |
108 | fNClusterP =0; | |
109 | for (i=0;i<fNClusterN;i++) | |
110 | { | |
111 | fClusterN->RemoveAt(i); | |
112 | } | |
113 | fNClusterN=0; | |
114 | ||
115 | for (i=0;i<fNPackages;i++) | |
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 | //--------------------------------------------- | |
134 | void AliITSClusterFinderSSD::FindRawClusters() | |
135 | { | |
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 | |
145 | fMap->FillMap(); | |
146 | FillDigitsIndex(); | |
147 | SortDigits(); | |
148 | FindNeighbouringDigits(); //ad. 2 | |
149 | //SeparateOverlappedClusters(); //ad. 3 | |
150 | ClustersToPackages(); //ad. 4 | |
151 | AliITSRecPoint rnew; | |
152 | fMap->ClearMap(); | |
153 | } | |
154 | ||
155 | ||
156 | //------------------------------------------------- | |
157 | void AliITSClusterFinderSSD::FindNeighbouringDigits() | |
158 | { | |
159 | //If there are any digits on this side, create 1st Cluster, | |
160 | // add to it this digit, and increment number of clusters | |
161 | ||
162 | ||
163 | register Int_t i; | |
164 | ||
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 | |
171 | TArrayI &lDigitsIndexP = *fDigitsIndexP; | |
172 | TArrayI &lDigitsIndexN = *fDigitsIndexN; | |
173 | TObjArray &lDigits = *(Digits()); | |
174 | TClonesArray &lClusterP = *fClusterP; | |
175 | TClonesArray &lClusterN = *fClusterN; | |
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 | |
181 | for (i=1; i<fNDigitsP; i++) { | |
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 | |
190 | new(lClusterP[fNClusterP++]) AliITSclusterSSD(dnumber,dbuffer,Digits(),fgkSIDEP); | |
191 | dbuffer[0]=lDigitsIndexP[i]; | |
192 | dnumber = 1; | |
193 | } | |
194 | } // end loop over fNDigitsP | |
195 | new(lClusterP[fNClusterP++]) AliITSclusterSSD(dnumber,dbuffer,Digits(),fgkSIDEP); | |
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 | |
203 | for (i=1; i<fNDigitsN; i++) { | |
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 { | |
209 | new(lClusterN[fNClusterN++]) AliITSclusterSSD(dnumber,dbuffer,Digits(),fgkSIDEN); | |
210 | dbuffer[0]=lDigitsIndexN[i]; | |
211 | dnumber = 1; | |
212 | } | |
213 | } // end loop over fNDigitsN | |
214 | new(lClusterN[fNClusterN++]) AliITSclusterSSD(dnumber,dbuffer,Digits(),fgkSIDEN); | |
215 | delete [] dbuffer; | |
216 | ||
217 | } // end condition on NDigits | |
218 | ||
219 | if (debug) cout<<"\n Found clusters: fNClusterP = "<<fNClusterP<<" fNClusterN ="<<fNClusterN<<"\n"; | |
220 | ||
221 | } | |
222 | ||
223 | //-------------------------------------------------------------- | |
224 | ||
225 | void AliITSClusterFinderSSD::SeparateOverlappedClusters() | |
226 | { | |
227 | // overlapped clusters separation | |
228 | ||
229 | register Int_t i; //iterator | |
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 | ||
246 | for (i=0;i<initPsize;i++) | |
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); | |
251 | for (Int_t j=1; j<nj; j++) | |
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 | |
263 | if(numerofsplits>0) SplitCluster(splitlist,numerofsplits,i,fgkSIDEP); | |
264 | numerofsplits=0; | |
265 | ||
266 | //in signed places (splitlist) | |
267 | } // end loop over clusters on Pside | |
268 | ||
269 | for (i=0;i<initNsize;i++) { | |
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); | |
273 | for (Int_t j=1; j<nj; j++) | |
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 | |
283 | if(numerofsplits>0) SplitCluster(splitlist,numerofsplits,i,fgkSIDEN); | |
284 | numerofsplits=0; //in signed places (splitlist) | |
285 | } // end loop over clusters on Nside | |
286 | ||
287 | delete splitlist; | |
288 | } | |
289 | ||
290 | //------------------------------------------------------- | |
291 | void AliITSClusterFinderSSD::SplitCluster(TArrayI *list, Int_t nsplits, Int_t index, Bool_t side) | |
292 | { | |
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])) ; | |
312 | for (i = nsplits; i>0 ;i--) { | |
313 | NN=curentcluster->SplitCluster((*list)[(i-1)],tmpdigits); | |
314 | new ((*fClusterP)[fNClusterP]) AliITSclusterSSD(NN,tmpdigits,Digits(),side); | |
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])); | |
327 | for (i = nsplits; i>0 ;i--) { | |
328 | NN=curentcluster->SplitCluster((*list)[(i-1)],tmpdigits); | |
329 | new ((*fClusterN)[fNClusterN]) AliITSclusterSSD(NN,tmpdigits,Digits(),side); | |
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 | //------------------------------------------------- | |
345 | Int_t AliITSClusterFinderSSD::SortDigitsP(Int_t start, Int_t end) | |
346 | { | |
347 | // sort digits on the P side | |
348 | ||
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 | { | |
360 | left = ((AliITSdigitSSD*)((*(Digits()))[(*fDigitsIndexP)[start]]))->GetStripNumber(); | |
361 | right= ((AliITSdigitSSD*)((*(Digits()))[(*fDigitsIndexP)[end]]))->GetStripNumber(); | |
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 | ||
376 | Int_t AliITSClusterFinderSSD::SortDigitsN(Int_t start, Int_t end) | |
377 | { | |
378 | // sort digits on the N side | |
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 | { | |
390 | left =((AliITSdigitSSD*)((*(Digits()))[(*fDigitsIndexN)[start]]))->GetStripNumber(); | |
391 | right=((AliITSdigitSSD*)((*(Digits()))[(*fDigitsIndexN)[end]]))->GetStripNumber(); | |
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 | //------------------------------------------------ | |
404 | void AliITSClusterFinderSSD::FillDigitsIndex() | |
405 | { | |
406 | //Fill the indexes of the clusters belonging to a given ITS module | |
407 | ||
408 | Int_t PNs=0, NNs=0; | |
409 | Int_t tmp,bit,k; | |
410 | Int_t N; | |
411 | Int_t i; | |
412 | ||
413 | N = fDigits->GetEntriesFast(); | |
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 | ||
422 | for ( i = 0 ; i< N; i++ ) { | |
423 | dig = (AliITSdigitSSD*)GetDigit(i); | |
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 | |
429 | for( k=0;k<PNs;k++) | |
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 | |
446 | for( k=0;k<NNs;k++) | |
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 | ||
462 | delete [] PSidx; | |
463 | delete [] NSidx; | |
464 | ||
465 | if (debug) cout<<"Digits : P = "<<fNDigitsP<<" N = "<<fNDigitsN<<endl; | |
466 | ||
467 | } | |
468 | ||
469 | ||
470 | //------------------------------------------- | |
471 | ||
472 | void AliITSClusterFinderSSD::SortDigits() | |
473 | { | |
474 | // sort digits | |
475 | ||
476 | Int_t i; | |
477 | if(fNDigitsP>1) | |
478 | for (i=0;i<fNDigitsP-1;i++) | |
479 | if (SortDigitsP(0,(fNDigitsP-1-i))==0) break; | |
480 | ||
481 | if(fNDigitsN>1) | |
482 | for (i=0;i<fNDigitsN-1;i++) | |
483 | if(SortDigitsN(0,(fNDigitsN-1-i))==0) break; | |
484 | } | |
485 | ||
486 | ||
487 | ||
488 | //---------------------------------------------- | |
489 | void AliITSClusterFinderSSD::FillClIndexArrays(Int_t* arrayP, Int_t *arrayN) | |
490 | { | |
491 | // fill cluster index array | |
492 | ||
493 | register Int_t i; | |
494 | for (i=0; i<fNClusterP;i++) | |
495 | { | |
496 | arrayP[i]=i; | |
497 | } | |
498 | for (i=0; i<fNClusterN;i++) | |
499 | { | |
500 | arrayN[i]=i; | |
501 | } | |
502 | } | |
503 | ||
504 | ||
505 | //------------------------------------------------------ | |
506 | void AliITSClusterFinderSSD::SortClusters(Int_t* arrayP, Int_t *arrayN) | |
507 | { | |
508 | // sort clusters | |
509 | ||
510 | Int_t i; | |
511 | if(fNClusterP>1) | |
512 | for (i=0;i<fNClusterP-1;i++) | |
513 | if (SortClustersP(0,(fNClusterP-1),arrayP)==0) break; | |
514 | ||
515 | ||
516 | if(fNClusterN>1) | |
517 | for (i=0;i<fNClusterN-1;i++) | |
518 | if (SortClustersN(0,(fNClusterN-1),arrayN)==0) break; | |
519 | ||
520 | } | |
521 | ||
522 | ||
523 | ||
524 | //--------------------------------------------------- | |
525 | Int_t AliITSClusterFinderSSD::SortClustersP(Int_t start, Int_t end, Int_t *array) | |
526 | { | |
527 | //Sort P side clusters | |
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 | //------------------------------------------------------- | |
555 | Int_t AliITSClusterFinderSSD::SortClustersN(Int_t start, Int_t end, Int_t *array) | |
556 | { | |
557 | //Sort N side clusters | |
558 | ||
559 | ||
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 | //------------------------------------------------------- | |
585 | void AliITSClusterFinderSSD::ClustersToPackages() | |
586 | { | |
587 | // fill packages | |
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 | ||
597 | //AliITSpackageSSD *currentpkg; | |
598 | AliITSclusterSSD *currentP; | |
599 | AliITSclusterSSD *currentN; | |
600 | Int_t j1, j2; | |
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); | |
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); | |
628 | ||
629 | } | |
630 | } | |
631 | ||
632 | delete oneSclP; | |
633 | delete oneSclN; | |
634 | ||
635 | } | |
636 | ||
637 | ||
638 | //------------------------------------------------------ | |
639 | Bool_t AliITSClusterFinderSSD:: | |
640 | CreateNewRecPoint(Float_t P, Float_t dP, Float_t N, Float_t dN, | |
641 | Float_t SigP,Float_t SigN, | |
642 | AliITSclusterSSD *clusterP, AliITSclusterSSD *clusterN, | |
643 | Stat_t prob) | |
644 | { | |
645 | // create the recpoints | |
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 | |
649 | const Float_t kconv = 1.0e-4; | |
650 | ||
651 | const Float_t kRMSx = 20.0*kconv; | |
652 | const Float_t kRMSz = 800.0*kconv; | |
653 | ||
654 | Int_t stripP, stripN; | |
655 | Int_t n=0; | |
656 | Int_t *tr; | |
657 | if (GetCrossing(P,N)) { | |
658 | ||
659 | GetCrossingError(dP,dN); | |
660 | AliITSRawClusterSSD cnew; | |
661 | Int_t nstripsP=clusterP->GetNumOfDigits(); | |
662 | Int_t nstripsN=clusterN->GetNumOfDigits(); | |
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; | |
681 | cnew.fMultiplicity=nstripsP; | |
682 | cnew.fMultiplicityN=nstripsN; | |
683 | cnew.fQErr=signalCut; | |
684 | ||
685 | //fITS->AddCluster(2,&cnew); | |
686 | ||
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" | |
690 | ||
691 | fSegmentation->GetPadIxz(P,N,stripP,stripN); | |
692 | ||
693 | //cout<<"NewRec: P,N microns,stripP,stripN ="<<P<<","<<N<<","<<stripP<<","<<stripN<<endl; | |
694 | ||
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; | |
698 | ||
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); | |
706 | //rnew.SetSigmaX2(1); //This has to be verified | |
707 | //rnew.SetSigmaZ2(1); //This has to be verified | |
708 | rnew.fTracks[0]=tr[0]; | |
709 | rnew.fTracks[1]=tr[1]; | |
710 | rnew.fTracks[2]=tr[2]; | |
711 | ||
712 | //fITS->AddRecPoint(rnew); | |
713 | ||
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" | |
717 | ||
718 | return kTRUE; | |
719 | } | |
720 | return kFALSE; | |
721 | } | |
722 | ||
723 | ||
724 | //------------------------------------------------------ | |
725 | void AliITSClusterFinderSSD::CalcStepFactor(Float_t Psteo, Float_t Nsteo ) | |
726 | { | |
727 | // calculate the step factor for matching clusters | |
728 | ||
729 | ||
730 | // 95 is the pitch, 4000 - dimension along z ? | |
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 | //----------------------------------------------------------- | |
742 | AliITSclusterSSD* AliITSClusterFinderSSD::GetPSideCluster(Int_t idx) | |
743 | { | |
744 | // get P side clusters | |
745 | ||
746 | ||
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 | //------------------------------------------------------- | |
761 | AliITSclusterSSD* AliITSClusterFinderSSD::GetNSideCluster(Int_t idx) | |
762 | { | |
763 | // get N side clusters | |
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 | //-------------------------------------------------------- | |
777 | AliITSclusterSSD* AliITSClusterFinderSSD::GetCluster(Int_t idx, Bool_t side) | |
778 | { | |
779 | // Get cluster | |
780 | ||
781 | return (side) ? GetPSideCluster(idx) : GetNSideCluster(idx); | |
782 | } | |
783 | ||
784 | //_______________________________________________________________________ | |
785 | ||
786 | Bool_t AliITSClusterFinderSSD::GetCrossing (Float_t &P, Float_t &N) | |
787 | { | |
788 | // get crossing | |
789 | ||
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; | |
803 | ||
804 | ||
805 | P *= fPitch; | |
806 | N *= fPitch; | |
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; | |
811 | ||
812 | /* | |
813 | Float_t x = xP + 0.21428*(1100-xP+xN); | |
814 | Float_t z = 31428.571 - (xP-xN)/0.035; | |
815 | */ | |
816 | ||
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; | |
821 | ||
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 | |
830 | ||
831 | return kTRUE; | |
832 | } | |
833 | ||
834 | ||
835 | //_________________________________________________________________________ | |
836 | ||
837 | void AliITSClusterFinderSSD::GetCrossingError(Float_t& dP, Float_t& dN) | |
838 | { | |
839 | // get crossing error | |
840 | ||
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 | } | |
850 | ||
851 | ||
852 | ||
853 | ||
854 | ||
855 | ||
856 |