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