]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ITS/UPGRADE/v0/AliITSUpgradeClusterFinder.cxx
Code reordering : old MC ITS Upgrade code has been moved into the version 0 folder.
[u/mrichter/AliRoot.git] / ITS / UPGRADE / v0 / AliITSUpgradeClusterFinder.cxx
CommitLineData
1d9af2d5 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/* $Id$ */
17
18////////////////////////////////////////////////////////////////////////////
19// //
20// Base Class used to find //
21// the reconstructed points for ITS Upgrade //
22// //
23////////////////////////////////////////////////////////////////////////////
24
25#include "AliITSUpgradeClusterFinder.h"
6ea6235b 26#include "AliITSsegmentationUpgrade.h"
84ab81bf 27#include "AliITSRecPointU.h"
6ea6235b 28#include "AliITSDigitUpgrade.h"
1d9af2d5 29#include "AliITSRawStreamSPD.h"
0ac80088 30#include "AliITSUPixelModule.h"
1d9af2d5 31#include "AliLog.h"
32#include <string.h>
33#include <TObjString.h>
6ea6235b 34#include <TClonesArray.h>
35#include <TTree.h>
36#include <TMath.h>
1d9af2d5 37
38AliITSUpgradeClusterFinder::AliITSUpgradeClusterFinder() :
7dc6449a 39 TObject(),
1d9af2d5 40 fNhitsLeft(0),
41 fOldModule(-1),
42 fClusterTypeFlag(kTRUE),
43 fFindClusterType(kFALSE),
44 fClusterTypeOrigCol(0),
45 fClusterTypeOrigRow(0),
46 fColSum(0),fRowSum(0),
47 fCharge(0),
48 fClusterWidthMaxCol(0),
49 fClusterWidthMinCol(0),
50 fClusterWidthMaxRow(0),
51 fClusterWidthMinRow(0),
0ac80088 52 fClusterList(0x0),
6ea6235b 53 fChargeArray(0x0),
4211bbc5 54 fRecPoints(0x0),
9b615954 55 fNLayers(),
0ac80088 56 fNSectors()
1d9af2d5 57{
b86a9a14 58 //
59 // Default constructor
60 //
4211bbc5 61 AliITSsegmentationUpgrade *s = new AliITSsegmentationUpgrade();
9b615954 62 fNLayers = s->GetNLayers();
0ac80088 63 fNSectors = s->GetNSectors();
4211bbc5 64 delete s;
0ac80088 65 fClusterList = new AliITSUpgradeClusterList*[fNSectors];
c79d5f80 66 for(Int_t imod =0; imod < fNSectors; imod++){
67 fClusterList[imod] = new AliITSUpgradeClusterList();
68 }
0ac80088 69
1d9af2d5 70 fChargeArray = new TObjArray();
84ab81bf 71 fChargeArray->SetOwner(kTRUE);
72 fRecPoints = new TClonesArray("AliITSRecPointU",3000);
9b615954 73 for (Int_t i=0; i<kMaxLab; i++) fTmpLabel[i]=-5;
74 for(int il=0; il<kMAXCLUSTERTYPESIDEZ*kMAXCLUSTERTYPESIDEY*kMaxLab;il++) fLabels[il]=-5;
2204e928 75 for(int k=0; k<999999; k++){
4211bbc5 76 fHitCol[k]=999;
77 fHitRow[k]=999;
2204e928 78 }
1d9af2d5 79}
80
81//___________________________________________________________________________________
6ea6235b 82AliITSUpgradeClusterFinder::~AliITSUpgradeClusterFinder() {
83 if(fChargeArray) delete fChargeArray;
84 if(fRecPoints) delete fRecPoints;
0ac80088 85 if(fClusterList)delete [] fClusterList;
6ea6235b 86}
1d9af2d5 87//___________________________________________________________________________________
88void AliITSUpgradeClusterFinder::StartEvent() {
89 NewEvent();
90}
91//___________________________________________________________________________________
9b615954 92Int_t AliITSUpgradeClusterFinder::ProcessHit(Int_t module , UInt_t col, UInt_t row, UShort_t charge, Int_t label[kMaxLab]) {
b86a9a14 93 //
94 // Adds one pixel to the cluster
95 //
9b615954 96 AliDebug(2,Form("module,col,row,charge,label(0,1,2...) = %d,%d,%d,%d,(%d,%d,%d ...)\n",module ,col,row,charge,label[0],label[1],label[2]));
0ac80088 97 if (module>=fNSectors) {
9b615954 98 AliError(Form("Out of bounds: module ,col,row, charge, label(0,1,2...)= %d,%d,%d,%d,(%d,%d,%d...)\n",module ,col,row,charge,label[0],label[1],label[2]));
6ea6235b 99 return 1;
1d9af2d5 100 }
1d9af2d5 101 // do we need to perform clustering on previous module?
0ac80088 102 if (fOldModule!=-1 && (Int_t)module!=fOldModule) {
103 //fChargeArray->AddLast(new TObjString(Form("%i %i %i %i %i %i",col,row,charge,label[0],label[1],label[2])));
104 AliITSUPixelModule *pix = new AliITSUPixelModule(module,col, row, charge, label);
9b615954 105 fChargeArray->AddLast(pix);
1d9af2d5 106 DoModuleClustering(fOldModule,charge);
107 NewModule();
108 }
109 // add hit
0ac80088 110 AliITSUPixelModule *pix = new AliITSUPixelModule(module,col, row, charge, label);
c79d5f80 111 fChargeArray->AddLast(pix);
112 // fChargeArray->AddLast(new TObjString(Form("%i %i %i %i %i %i",col,row,charge,label[0],label[1],label[2])));
9b615954 113
0ac80088 114 fOldModule=module;
1d9af2d5 115 fHitCol[fNhitsLeft]=col;
116 fHitRow[fNhitsLeft]=row;
117 fHits[col][row]=kTRUE;
9b615954 118 for (Int_t i=0; i<kMaxLab; i++)
119 fTmpLabel[i]=label[i];
1d9af2d5 120 fNhitsLeft++;
9b615954 121
1d9af2d5 122 return 0;
123}
124//___________________________________________________________________________________
125void AliITSUpgradeClusterFinder::FinishEvent() {
126 if (fNhitsLeft>0) {
127 DoModuleClustering(fOldModule,fCharge);
128 }
129}
130//___________________________________________________________________________________
0ac80088 131UInt_t AliITSUpgradeClusterFinder::GetClusterCount(Int_t module) const {
b86a9a14 132 //
0ac80088 133 // number of clusters in the module
b86a9a14 134 //
0ac80088 135 if (module>fNSectors ) {
136 printf("ERROR: UpgradeClusterFinder::GetClusterCount: Module out of bounds: module = %d\n",module);
1d9af2d5 137 return 0;
138 }
0ac80088 139 return fClusterList[module]->GetNrEntries();
1d9af2d5 140}
141//___________________________________________________________________________________
0ac80088 142Float_t AliITSUpgradeClusterFinder::GetClusterMeanCol(Int_t module, UInt_t index) {
b86a9a14 143 //
144 // cluster position in terms of colums : mean column ID
145 //
0ac80088 146 if (module>=fNSectors) {
147 printf("ERROR: UpgradeClusterFinder::GetClusterMeanCol: Module out of bounds: module = %d\n",module);
1d9af2d5 148 return 0;
149 }
0ac80088 150 return fClusterList[module]->GetColIndex(index);
1d9af2d5 151}
152//___________________________________________________________________________________
0ac80088 153Float_t AliITSUpgradeClusterFinder::GetClusterMeanRow(Int_t module, UInt_t index) {
b86a9a14 154 //
155 // cluster position in terms of rows : mean row ID
156 //
0ac80088 157 if (module>=fNSectors) {
158 printf("ERROR: UpgradeClusterFinder::GetClusterMeanRow: Module out of bounds: module = %d\n",module);
1d9af2d5 159 return 0;
160 }
0ac80088 161 return fClusterList[module]->GetRowIndex(index);
1d9af2d5 162}
163//___________________________________________________________________________________
0ac80088 164UInt_t AliITSUpgradeClusterFinder::GetClusterSize(Int_t module, UInt_t index) {
b86a9a14 165 //
166 // total number of pixels of the cluster
167 //
0ac80088 168 if (module>=fNSectors) {
169 printf("ERROR: UpgradeClusterFinder::GetClusterSize: Module out of bounds: module = %d\n",module);
1d9af2d5 170 return 0;
171 }
0ac80088 172 return fClusterList[module]->GetSizeIndex(index);
1d9af2d5 173}
174//___________________________________________________________________________________
0ac80088 175UInt_t AliITSUpgradeClusterFinder::GetClusterWidthZ(Int_t module, UInt_t index) {
b86a9a14 176 //
177 // # pixels of the cluster in Z direction
178 //
179
0ac80088 180 if (module>=fNSectors) {
181 printf("ERROR: UpgradeClusterFinder::GetClusterWidthZ: Module out of bounds: module = %d\n",module);
1d9af2d5 182 return 0;
183 }
0ac80088 184 return fClusterList[module]->GetWidthZIndex(index);
1d9af2d5 185}
186//___________________________________________________________________________________
0ac80088 187UInt_t AliITSUpgradeClusterFinder::GetClusterWidthPhi(Int_t module, UInt_t index) {
b86a9a14 188 //
189 // # pixels of the cluster in phi direction (XY plane)
190 //
191
0ac80088 192 if (module>=fNSectors) {
193 printf("ERROR: UpgradeClusterFinder::GetClusterWidthPhi: Module out of bounds: module = %d\n",module);
1d9af2d5 194 return 0;
195 }
0ac80088 196 return fClusterList[module]->GetWidthPhiIndex(index);
1d9af2d5 197}
198//___________________________________________________________________________________
0ac80088 199UInt_t AliITSUpgradeClusterFinder::GetClusterType(Int_t module, UInt_t index) {
b86a9a14 200 //
201 // cluster shape
202 //
203
0ac80088 204 if (module>=fNSectors) {
205 printf("ERROR: UpgradeClusterFinder::GetClusterType: Module out of bounds: layer = %d\n",module);
1d9af2d5 206 return 0;
207 }
0ac80088 208 return fClusterList[module]->GetTypeIndex(index);
1d9af2d5 209}
210//___________________________________________________________________________________
211void AliITSUpgradeClusterFinder::PrintAllClusters() {
b86a9a14 212 //
213 // printout of the cluster information
214 //
215
0ac80088 216 for (Int_t module=0; module<fNSectors; module++) {
217 PrintClusters(module);
1d9af2d5 218 }
219}
220//___________________________________________________________________________________
0ac80088 221void AliITSUpgradeClusterFinder::PrintClusters(Int_t module) {
b86a9a14 222 //
223 // printout of the cluster information
224 //
225
0ac80088 226 if (module>=fNSectors) {
227 printf("ERROR: UpgradeClusterFinder::PrintClusters: Out of bounds: layer = %d\n",module);
1d9af2d5 228 return;
229 }
0ac80088 230 if(fClusterList[module]->GetNrEntries()==0) {
1d9af2d5 231 printf("no cluster list entries. Exiting... \n");
232 return;
233 }
c79d5f80 234 // for (UInt_t c=0; c<fClusterList[layer]->GetNrEntries(); c++) {
235 //printf("layer %d , z,y=%f,%f , size=%d , type=%d labels=%d %d %d (label printout to be implemented...)\n",layer,fClusterList[layer].GetColIndex(c),fClusterList[layer].GetRowIndex(c),fClusterList[layer].GetSizeIndex(c),fClusterList[layer].GetTypeIndex(c),999,999,999);
236 // }
1d9af2d5 237}
238//___________________________________________________________________________________
239void AliITSUpgradeClusterFinder::NewEvent() {
b86a9a14 240 //
241 // Cleaning up and preparation for the clustering procedure
242 //
243
0ac80088 244 for (Int_t i=0; i<fNSectors; i++) {
c79d5f80 245 fClusterList[i]->Clear();
246 }
0ac80088 247 //NewModule();
1d9af2d5 248 fOldModule = -1;
249}
250//___________________________________________________________________________________
251void AliITSUpgradeClusterFinder::NewModule() {
b86a9a14 252 //
253 // Initializations
254 //
1d9af2d5 255 fNhitsLeft=0;
256 memset(fHits,0,999*999*sizeof(Bool_t));
84ab81bf 257 fChargeArray->Clear();
1d9af2d5 258}
259//___________________________________________________________________________________
0ac80088 260Int_t AliITSUpgradeClusterFinder::DoModuleClustering(Int_t module, UShort_t charge) {
b86a9a14 261 //
262 // Clustering and cluster-list container filling
263 //
1d9af2d5 264 UInt_t maxHits=fNhitsLeft;
265 for (UInt_t hit=0; hit<maxHits; hit++) {
266 if (fClusterTypeFlag) fFindClusterType = kTRUE;
4211bbc5 267
1d9af2d5 268 fClusterWidthMinCol = fHitCol[hit];
269 fClusterWidthMinRow = fHitRow[hit];
270 fClusterWidthMaxCol = fHitCol[hit];
271 fClusterWidthMaxRow = fHitRow[hit];
1d9af2d5 272
273 fClusterTypeOrigCol = fHitCol[hit];
274 fClusterTypeOrigRow = fHitRow[hit];
275 memset(fClusterTypeArea,0,kMAXCLUSTERTYPESIDEZ*kMAXCLUSTERTYPESIDEY*sizeof(Bool_t));
276 fColSum=0;
277 fRowSum=0;
c79d5f80 278 UInt_t size = FindClusterRecu(fClusterTypeOrigCol,fClusterTypeOrigRow,charge);
1d9af2d5 279 if(size==1){
280 fCharge=GetPixelCharge(fColSum,fRowSum);
281 AddLabelIndex(fColSum,fRowSum);
282 }
283 if (size>0) {
9b615954 284 if(size>1)
285 AliDebug(2,Form("DoModuleClustering, size %i , labels : %i %i %i %i %i %i\n",
286 size,fLabels[0],fLabels[1],fLabels[2],fLabels[3],fLabels[4],fLabels[5]));
287 fClusterList[module]->Insert((Float_t)fColSum/size, (Float_t)fRowSum/size, size,
288 GetClusterWidthZ(), GetClusterWidthPhi(),
289 GetClusterType(size), fCharge,fLabels);
1d9af2d5 290 fCharge=0;
9b615954 291 for(Int_t i=0; i<kMAXCLUSTERTYPESIDEZ*kMAXCLUSTERTYPESIDEY*kMaxLab; i++) fLabels[i]=-5;
1d9af2d5 292 }
293 if (fNhitsLeft==0) break;
294 }
295 return 0;
296}
297//___________________________________________________________________________________
298UInt_t AliITSUpgradeClusterFinder::FindClusterRecu(Int_t col, Int_t row, UShort_t charge) {
b86a9a14 299 //
300 // Pixel selection for the clusters (adjiacent pixels or pixels at the corners)
301 //
4211bbc5 302 if (col<0 || !fHits[col][row]) {
303 return 0;
304 }
1d9af2d5 305 fHits[col][row]=kFALSE;
306 fColSum+=col;
307 fRowSum+=row;
308 fNhitsLeft--;
309 UInt_t size=1;
310
311 if (col>fClusterWidthMaxCol) fClusterWidthMaxCol = col;
312 if (col<fClusterWidthMinCol) fClusterWidthMinCol = col;
313 if (row>fClusterWidthMaxRow) fClusterWidthMaxRow = row;
314 if (row<fClusterWidthMaxRow) fClusterWidthMinRow = row;
315
316 if (fFindClusterType) {
317 Short_t diffz = fClusterTypeOrigCol - col;
318 Short_t diffy = row - fClusterTypeOrigRow;
319 if (diffz>=kMAXCLUSTERTYPESIDEZ || diffy>=kMAXCLUSTERTYPESIDEY) {
320 fFindClusterType=kFALSE;
321 }
322 else {
323 if (diffz==-1) {
324 ShiftClusterTypeArea(kSHIFTRIGHT);
325 diffz=0;
326 }
327 if (diffy==-1) {
328 ShiftClusterTypeArea(kSHIFTDOWN);
329 diffy=0;
330 }
331 fClusterTypeArea[diffz][diffy] = kTRUE;
332 }
333 }
334 // straight:
335 size+=FindClusterRecu(col ,row-1,charge);
336 fCharge+=GetPixelCharge(col,row-1);
337 AddLabelIndex(col,row-1);
338
339 size+=FindClusterRecu(col-1,row ,charge);
340 fCharge+=GetPixelCharge(col-1,row);
341 AddLabelIndex(col-1,row);
342
343 size+=FindClusterRecu(col ,row+1,charge);
344 fCharge+=GetPixelCharge(col,row+1);
345 AddLabelIndex(col,row+1);
346
347 size+=FindClusterRecu(col+1,row ,charge );
348 fCharge+=GetPixelCharge(col+1,row);
349 AddLabelIndex(col+1,row);
350
351 // diagonal:
352 size+=FindClusterRecu(col-1,row-1,charge);
353 fCharge+=GetPixelCharge(col-1,row-1);
354 AddLabelIndex(col-1,row-1);
355
356 size+=FindClusterRecu(col-1,row+1,charge);
357 fCharge+=GetPixelCharge(col-1,row+1);
358 AddLabelIndex(col-1,row+1);
359
360 size+=FindClusterRecu(col+1,row-1,charge);
361 fCharge+=GetPixelCharge(col+1,row-1);
362 AddLabelIndex(col+1,row-1);
363
364 size+=FindClusterRecu(col+1,row+1,charge);
365 fCharge+=GetPixelCharge(col+1,row+1);
366 AddLabelIndex(col+1,row+1);
1d9af2d5 367 return size;
368}
369//___________________________________________________________________________________
370void AliITSUpgradeClusterFinder::ShiftClusterTypeArea(UInt_t direction) {
b86a9a14 371 //
372 // Cluster checks
373 //
374
1d9af2d5 375 if (direction == kSHIFTRIGHT) {
376 fClusterTypeOrigCol++;
377 Bool_t tmpClusterTypeArea[kMAXCLUSTERTYPESIDEZ][kMAXCLUSTERTYPESIDEY];
378 memset(tmpClusterTypeArea,0,kMAXCLUSTERTYPESIDEZ*kMAXCLUSTERTYPESIDEY*sizeof(Bool_t));
379 for (UInt_t z=0; z<kMAXCLUSTERTYPESIDEZ; z++) {
380 for (UInt_t y=0; y<kMAXCLUSTERTYPESIDEY; y++) {
381 if (fClusterTypeArea[z][y]) {
382 if (z==kMAXCLUSTERTYPESIDEZ-1) {
383 fFindClusterType=kFALSE;
384 return;
385 }
386 else {
387 tmpClusterTypeArea[z+1][y] = kTRUE;
388 }
389 }
390 }
391 }
392 memcpy(fClusterTypeArea,tmpClusterTypeArea,kMAXCLUSTERTYPESIDEZ*kMAXCLUSTERTYPESIDEY*sizeof(Bool_t));
393 }
394 else if (direction == kSHIFTDOWN) {
395 fClusterTypeOrigRow--;
396 Bool_t tmpClusterTypeArea[kMAXCLUSTERTYPESIDEZ][kMAXCLUSTERTYPESIDEY];
397 memset(tmpClusterTypeArea,0,kMAXCLUSTERTYPESIDEZ*kMAXCLUSTERTYPESIDEY*sizeof(Bool_t));
398 for (UInt_t z=0; z<kMAXCLUSTERTYPESIDEZ; z++) {
399 for (UInt_t y=0; y<kMAXCLUSTERTYPESIDEY; y++) {
400 if (fClusterTypeArea[z][y]) {
401 if (y==kMAXCLUSTERTYPESIDEY-1) {
402 fFindClusterType=kFALSE;
403 return;
404 }
405 else {
406 tmpClusterTypeArea[z][y+1] = kTRUE;
407 }
408 }
409 }
410 }
411 memcpy(fClusterTypeArea,tmpClusterTypeArea,kMAXCLUSTERTYPESIDEZ*kMAXCLUSTERTYPESIDEY*sizeof(Bool_t));
412 }
413}
1d9af2d5 414//___________________________________________________________________________________
0ac80088 415UShort_t AliITSUpgradeClusterFinder::GetCharge(Int_t module,UInt_t index ) {
416 return fClusterList[module]->GetCharge(index);
1d9af2d5 417}
418//___________________________________________________________________________________
0ac80088 419Int_t * AliITSUpgradeClusterFinder::GetLabels(Int_t module,UInt_t index) {
420 return fClusterList[module]->GetLabels(index);
1d9af2d5 421}
422
423//___________________________________________________________________________________
424UInt_t AliITSUpgradeClusterFinder::GetClusterWidthZ() {
425 return fClusterWidthMaxCol-fClusterWidthMinCol+1;
426}
427//___________________________________________________________________________________
428UInt_t AliITSUpgradeClusterFinder::GetClusterWidthPhi() {
429 return fClusterWidthMaxRow-fClusterWidthMinRow+1;
430}
431//___________________________________________________________________________________
432UInt_t AliITSUpgradeClusterFinder::GetClusterType(UInt_t size) {
6ea6235b 433 //
434 // Cluster shape
435 //
1d9af2d5 436 if (!fFindClusterType || size>4)
437 return 0;
438
439 // X
440 if (size==1)
441 return 1;
442
443 // X
444 // X
445 if (size==2 &&
446 fClusterTypeArea[0][1] &&
447 fClusterTypeArea[0][0] )
448 return 2;
449
450 // XX
451 if (size==2 &&
452 fClusterTypeArea[1][0] &&
453 fClusterTypeArea[0][0] )
454 return 3;
455
456 // X
457 // X
458 // X
459 if (size==3 &&
460 fClusterTypeArea[0][2] &&
461 fClusterTypeArea[0][1] &&
462 fClusterTypeArea[0][0] )
463 return 4;
464
465 // XX
466 // X and equivalent...
467 if (size==3 &&
468 (
469 (
470 fClusterTypeArea[0][0] &&
471 fClusterTypeArea[0][1] &&
472 (fClusterTypeArea[1][1] ||
473 fClusterTypeArea[1][0])
474 )
475 ||
476 (
477 fClusterTypeArea[1][0] &&
478 fClusterTypeArea[1][1] &&
479 (fClusterTypeArea[0][1] ||
480 fClusterTypeArea[0][0])
481 )
482 )
483 )
484 return 5;
485
486 // XXX
487 if (size==3 &&
488 fClusterTypeArea[2][0] &&
489 fClusterTypeArea[1][0] &&
490 fClusterTypeArea[0][0] )
491 return 6;
492
493 // X
494 // X
495 // X
496 // X
497 if (size==4 &&
498 fClusterTypeArea[0][3] &&
499 fClusterTypeArea[0][2] &&
500 fClusterTypeArea[0][1] &&
501 fClusterTypeArea[0][0] )
502 return 7;
503
504 // XX
505 // XX
506 if (size==4 &&
507 fClusterTypeArea[1][1] &&
508 fClusterTypeArea[1][0] &&
509 fClusterTypeArea[0][1] &&
510 fClusterTypeArea[0][0] )
511 return 8;
512
513 // XX
514 // X
515 // X and equivalent...
516 if (size==4 &&
517 (
518 (
519 fClusterTypeArea[1][0] &&
520 fClusterTypeArea[1][1] &&
521 fClusterTypeArea[1][2] &&
522 fClusterTypeArea[0][0]
523 )
524 ||
525 (
526 fClusterTypeArea[1][0] &&
527 fClusterTypeArea[1][1] &&
528 fClusterTypeArea[1][2] &&
529 fClusterTypeArea[0][2]
530 )
531 ||
532 (
533 fClusterTypeArea[0][0] &&
534 fClusterTypeArea[0][1] &&
535 fClusterTypeArea[0][2] &&
536 fClusterTypeArea[1][0]
537 )
538 ||
539 (
540 fClusterTypeArea[0][0] &&
541 fClusterTypeArea[0][1] &&
542 fClusterTypeArea[0][2] &&
543 fClusterTypeArea[1][2]
544 )
545 )
546 )
547 return 9;
548
549 // X
550 // XX
551 // X and equivalent...
552 if (size==4 &&
553 (
554 (
555 fClusterTypeArea[1][0] &&
556 fClusterTypeArea[1][1] &&
557 fClusterTypeArea[1][2] &&
558 fClusterTypeArea[0][1]
559 )
560 ||
561 (
562 fClusterTypeArea[0][0] &&
563 fClusterTypeArea[0][1] &&
564 fClusterTypeArea[0][2] &&
565 fClusterTypeArea[1][1]
566 )
567 )
568 )
569 return 10;
570
571 // X
572 // XXX and equivalent...
573 if (size==4 &&
574 (
575 (
576 fClusterTypeArea[2][0] &&
577 fClusterTypeArea[2][1] &&
578 fClusterTypeArea[1][1] &&
579 fClusterTypeArea[0][1]
580 )
581 ||
582 (
583 fClusterTypeArea[0][0] &&
584 fClusterTypeArea[2][1] &&
585 fClusterTypeArea[1][1] &&
586 fClusterTypeArea[0][1]
587 )
588 ||
589 (
590 fClusterTypeArea[2][1] &&
591 fClusterTypeArea[2][0] &&
592 fClusterTypeArea[1][0] &&
593 fClusterTypeArea[0][0]
594 )
595 ||
596 (
597 fClusterTypeArea[0][1] &&
598 fClusterTypeArea[2][0] &&
599 fClusterTypeArea[1][0] &&
600 fClusterTypeArea[0][0]
601 )
602 )
603 )
604 return 11;
605
606 // X
607 // XXX and equivalent...
608 if (size==4 &&
609 (
610 (
611 fClusterTypeArea[1][0] &&
612 fClusterTypeArea[2][1] &&
613 fClusterTypeArea[1][1] &&
614 fClusterTypeArea[0][1]
615 )
616 ||
617 (
618 fClusterTypeArea[1][1] &&
619 fClusterTypeArea[2][0] &&
620 fClusterTypeArea[1][0] &&
621 fClusterTypeArea[0][0]
622 )
623 )
624 )
625 return 12;
626
627 // X
628 // X and equivalent...
629 if (size==2 &&
630 (
631 (
632 fClusterTypeArea[0][0] &&
633 fClusterTypeArea[1][1]
634 )
635 ||
636 (
637 fClusterTypeArea[1][0] &&
638 fClusterTypeArea[0][1]
639 )
640 )
641 )
642 return 13;
643
644 // X
645 // X
646 // X and equivalent...
647 if (size==3 &&
648 (
649 (
650 fClusterTypeArea[0][0] &&
651 fClusterTypeArea[0][1] &&
652 fClusterTypeArea[1][2]
653 )
654 ||
655 (
656 fClusterTypeArea[1][0] &&
657 fClusterTypeArea[1][1] &&
658 fClusterTypeArea[0][2]
659 )
660 ||
661 (
662 fClusterTypeArea[1][0] &&
663 fClusterTypeArea[0][1] &&
664 fClusterTypeArea[0][2]
665 )
666 ||
667 (
668 fClusterTypeArea[0][0] &&
669 fClusterTypeArea[1][1] &&
670 fClusterTypeArea[1][2]
671 )
672 )
673 )
674 return 14;
675
676 // XX
677 // X and equivalent...
678 if (size==3 &&
679 (
680 (
681 fClusterTypeArea[0][0] &&
682 fClusterTypeArea[1][0] &&
683 fClusterTypeArea[2][1]
684 )
685 ||
686 (
687 fClusterTypeArea[0][1] &&
688 fClusterTypeArea[1][1] &&
689 fClusterTypeArea[2][0]
690 )
691 ||
692 (
693 fClusterTypeArea[0][0] &&
694 fClusterTypeArea[1][1] &&
695 fClusterTypeArea[2][1]
696 )
697 ||
698 (
699 fClusterTypeArea[0][1] &&
700 fClusterTypeArea[1][0] &&
701 fClusterTypeArea[2][0]
702 )
703 )
704 )
705 return 15;
706
707
708
709 return 0;
710}
711
712//___________________________________________________________________________________________________
1d9af2d5 713UInt_t AliITSUpgradeClusterFinder::GetPixelCharge(UInt_t col, UInt_t row){
6ea6235b 714 //
715 //...self explaining
716 //
1d9af2d5 717 Int_t q=0;
dd290e92 718 for(Int_t entry =0; entry < fChargeArray->GetEntriesFast(); entry++){
0ac80088 719 AliITSUPixelModule *pixMod = (AliITSUPixelModule*)fChargeArray->At(entry);
c79d5f80 720 // pixMod->PrintInfo();
0ac80088 721 if(col!=pixMod->GetCol())continue;
722 if(row!=pixMod->GetRow())continue;
723 q= pixMod->GetCharge();
1d9af2d5 724
c79d5f80 725 }
1d9af2d5 726 return q;
727}
728//____________________________________________________
729
730void AliITSUpgradeClusterFinder::AddLabelIndex(UInt_t col, UInt_t row){
6ea6235b 731 //
732 // Adding cluster labels
733 //
1d9af2d5 734
dd290e92 735 for(Int_t entry =0; entry < fChargeArray->GetEntriesFast(); entry++){
c79d5f80 736 AliITSUPixelModule *pix= (AliITSUPixelModule*)fChargeArray->At(entry);
737 if(col!=pix->GetCol())continue;
738 if(row!=pix->GetRow())continue;
9b615954 739 Int_t label[kMaxLab];
740 for(Int_t i=0; i< kMaxLab; i++) label[i]=-1;
b58cd5bb 741
742 Int_t max = kMaxLab;
743 // maximum number of labels stored in the AliITSDigitUpgrade (or AliITSUPixelModule) is normally less!
744 if (AliITSUPixelModule::kMaxLab<max) max = AliITSUPixelModule::kMaxLab;
745 for(Int_t i=0;i<max;i++){
9b615954 746 label[i] = pix->GetLabel(i);
0ac80088 747 }
6ea6235b 748 SetLabels(label);
1d9af2d5 749 }
1d9af2d5 750}
751//____________________________________________________
752
9b615954 753void AliITSUpgradeClusterFinder::SetLabels(Int_t label[kMaxLab]){
4211bbc5 754
755 //Set the MC lables to the cluster
9b615954 756 for(Int_t k=0; k<kMaxLab; k++){
757 if(label[k]<0) break; // digit label is dummy -> rest is dummy
758 for(Int_t i=0; i<kMAXCLUSTERTYPESIDEZ*kMAXCLUSTERTYPESIDEY*kMaxLab; i++){
759 if (fLabels[i]==label[k])
760 break; // label already exists in the cluster
761 if (fLabels[i]<0) {// assign label to "cluster labels"
762 fLabels[i]=label[k];
763 break;
6ea6235b 764 }
9b615954 765 } // end "cluster label" loop
766 } // end "digit label" loop
767
6ea6235b 768}
1d9af2d5 769
6ea6235b 770//____________________________________________________
771void AliITSUpgradeClusterFinder::MakeRecPointBranch(TTree *treeR){
772 //
773 // Creating the branch (see AliITSUpgradeReconstructor::Reconstruct)
774 //
775
84ab81bf 776 if(!fRecPoints)fRecPoints = new TClonesArray("AliITSRecPointU",1000);
6ea6235b 777 if (treeR) {
dd290e92 778 if (treeR->GetBranch("ITSRecPoints")) return ;
779 else treeR->Branch("ITSRecPoints",&fRecPoints);
6ea6235b 780 }
781}
782//____________________________________________________
783void AliITSUpgradeClusterFinder::SetRecPointTreeAddress(TTree *treeR){
784 //
785 // Addressing the branch (see AliITSUpgradeReconstructor::Reconstruct)
786 //
787 if(!treeR) return;
84ab81bf 788 if(!fRecPoints) fRecPoints = new TClonesArray("AliITSRecPointU",1000);
6ea6235b 789
790 TBranch *branch;
791 branch = treeR->GetBranch("ITSRecPoints");
792 if (branch) {
793 branch->SetAddress(&fRecPoints);
794 } else AliError("No RecPoint branch available");
1d9af2d5 795
6ea6235b 796}
9b615954 797
6ea6235b 798//____________________________________________________
b86a9a14 799void AliITSUpgradeClusterFinder::DigitsToRecPoints(const TObjArray *digList) {
6ea6235b 800 //
801 // the clusterization is performed here
802 //
8d499867 803 AliITSsegmentationUpgrade *segmentation = new AliITSsegmentationUpgrade();
84ab81bf 804 AliITSRecPointU recpnt;
6ea6235b 805 Int_t nClusters =0;
806 TClonesArray &lrecp = *fRecPoints;
9b615954 807 for(Int_t ilayer=0; ilayer < fNLayers; ilayer ++){
0ac80088 808 NewModule();
6ea6235b 809 TClonesArray *pArrDig= (TClonesArray*)digList->At(ilayer);
0ac80088 810 StartEvent();
811 pArrDig->Sort();
812
dd290e92 813 for(Int_t ientr =0; ientr < pArrDig->GetEntriesFast() ; ientr++){
6ea6235b 814 AliITSDigitUpgrade *dig = (AliITSDigitUpgrade*)pArrDig->At(ientr);
815 Int_t colz=dig->GetzPixelNumber();
816 Int_t rowx=dig->GetxPixelNumber();
817 Double_t hitcharge= (dig->GetNelectrons());
9b615954 818
0ac80088 819 ProcessHit(dig->GetModule(),colz, rowx,(Short_t)hitcharge,dig->GetTracks());
6ea6235b 820 }//ientr
821 FinishEvent();
0ac80088 822 for(Int_t module=0; module<fNSectors; module++){
823
c79d5f80 824 // printf(" module loop %i \n", module);
825 for(UInt_t nClu = 0; nClu < GetClusterCount(module); nClu++){
826 //printf(" nclu in getclustercount %i \n", nClu);
827 UShort_t charge = GetCharge(module, nClu);
828 recpnt.SetQ(charge);
829 recpnt.SetLayer(ilayer);
830 recpnt.SetModule(module);
9b615954 831 recpnt.SetNTracksIdMC(0);
caadc8fb 832 recpnt.CleanLabels();
c79d5f80 833 Int_t *lab=GetLabels(module,nClu);
9b615954 834 Int_t nLabels =0;
835 for (Int_t il=0; il<kMAXCLUSTERTYPESIDEZ*kMAXCLUSTERTYPESIDEY*kMaxLab;il++) {
836 if (lab[il]>-1) {
837 nLabels++; // count how many labels have been sent
838 recpnt.AddTrackID(lab[il]);
839 }
840 }
841 if (nLabels>kMaxLab)
842 AliWarning(Form(" Not all MC labels are stored in the RecPoint (lay,mod)=(%d,%d): Skipping %d labels (out of %d)",ilayer,module,nLabels-kMaxLab,nLabels));
843 recpnt.SetNTracksIdMC(nLabels); // sets number of ALL label (even the ones which are skipped)
c79d5f80 844
845 Double_t xzl2[2]={0.,0.};
846 Double_t xPixC2,zPixC2=0.;
847
848 xPixC2 = GetClusterMeanRow(module, nClu);
849 zPixC2 = GetClusterMeanCol(module, nClu);
850 //cout << "zPixC2 "<< zPixC2 << endl;
851 xzl2[0] = xPixC2*(segmentation->GetCellSizeX(ilayer))+0.5*(segmentation-> GetCellSizeX(ilayer));
852 xzl2[1] = zPixC2*(segmentation->GetCellSizeZ(ilayer))+0.5*(segmentation->GetCellSizeZ(ilayer))-(segmentation->GetHalfLength(ilayer));
853 //check2 = segmentation->DetToGlobal(ilayer,xzl2[0], xzl2[1],xcheck2,ycheck2,zcheck2);
854 recpnt.SetType(GetClusterType(module,nClu ));
855 recpnt.SetLocalCoord(xzl2[0],xzl2[1]); //temporary solution (no LocalToTrack Matrix)
856 //from global to tracking system coordinate
857 // global coordinate -> local coordinate getting alpha angle of the recpoint
858 /////
859 Double_t yclu1 = 0.;//upgrade clusters global coordinate ( ITS official: GetX tracking coordinate)
860 Double_t zclu1 = 0.;//upgrade clusters global coordinate ( ITS official: GetX tracking coordinate)
861 // Float_t xclg = xcheck2;//upgrade clusters global coordinate ( ITS official: GetX tracking coordinate)
862 // Float_t yclg = ycheck2;
863 // Float_t zclg = zcheck2;
864 Bool_t detr=kFALSE;
865 detr = segmentation->DetToTrack(ilayer,module, xzl2[0],xzl2[1], yclu1, zclu1);
866 // printf( " det to track in clusterfinder il %i xl %f zl %f y track %f z track %f module %i \n", ilayer, xzl2[0] , xzl2[1] , yclu1, zclu1, module);
867
868 //////////////////////////
869 recpnt.SetX(0.);
870 recpnt.SetY(yclu1);
871 recpnt.SetZ(zclu1);
0ac80088 872
873
c79d5f80 874 Double_t xsize, zsize;
875 segmentation->GetSegmentation(ilayer,xsize, zsize);
876 recpnt.SetSigmaY2(xsize/TMath::Sqrt(12)*xsize/TMath::Sqrt(12));
877 recpnt.SetSigmaZ2(zsize/TMath::Sqrt(12)*zsize/TMath::Sqrt(12));
878 new(lrecp[nClusters++]) AliITSRecPointU(recpnt);
879 //Int_t idx = fRecPoints->GetEntries();
dd290e92 880 AliDebug(1,Form("recpoint : Nelectrons %f (entry %i)",recpnt.GetQ(),fRecPoints->GetEntriesFast()));
0ac80088 881
c79d5f80 882 }//cluster list entries
883 }//module
6ea6235b 884 }//ilayer
8d499867 885 if(segmentation) delete segmentation;
1d9af2d5 886}
887