]>
Commit | Line | Data |
---|---|---|
3edbbba2 | 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 | ||
090026bf | 16 | /* $Id$ */ |
17 | ||
3edbbba2 | 18 | //-----------------------------------------------------// |
19 | // // | |
01c4d84a | 20 | // Source File : PMDClusteringV1.cxx, Version 00 // |
3edbbba2 | 21 | // // |
22 | // Date : September 26 2002 // | |
23 | // // | |
24 | // clustering code for alice pmd // | |
25 | // // | |
26 | //-----------------------------------------------------// | |
27 | ||
28 | /* -------------------------------------------------------------------- | |
29 | Code developed by S. C. Phatak, Institute of Physics, | |
30 | Bhubaneswar 751 005 ( phatak@iopb.res.in ) Given the energy deposited | |
31 | ( or ADC value ) in each cell of supermodule ( pmd or cpv ), the code | |
32 | builds up superclusters and breaks them into clusters. The input is | |
562718f9 | 33 | in array edepcell[kNMX] and cluster information is in a |
fd30f88e | 34 | TObjarray. Integer clno gives total number of clusters in the |
3edbbba2 | 35 | supermodule. |
36 | ||
562718f9 | 37 | fClusters is the only global ( public ) variables. |
3edbbba2 | 38 | Others are local ( private ) to the code. |
39 | At the moment, the data is read for whole detector ( all supermodules | |
40 | and pmd as well as cpv. This will have to be modify later ) | |
41 | LAST UPDATE : October 23, 2002 | |
42 | -----------------------------------------------------------------------*/ | |
43 | ||
090026bf | 44 | #include <Riostream.h> |
45 | #include <TMath.h> | |
3edbbba2 | 46 | #include <TNtuple.h> |
47 | #include <TObjArray.h> | |
562718f9 | 48 | #include "TRandom.h" |
3edbbba2 | 49 | #include <stdio.h> |
50 | ||
fd30f88e | 51 | #include "AliPMDcludata.h" |
3edbbba2 | 52 | #include "AliPMDcluster.h" |
53 | #include "AliPMDClustering.h" | |
54 | #include "AliPMDClusteringV1.h" | |
55 | #include "AliLog.h" | |
56 | ||
2c1131dd | 57 | |
3edbbba2 | 58 | ClassImp(AliPMDClusteringV1) |
59 | ||
60 | const Double_t AliPMDClusteringV1::fgkSqroot3by2=0.8660254; // sqrt(3.)/2. | |
61 | ||
62 | AliPMDClusteringV1::AliPMDClusteringV1(): | |
562718f9 | 63 | fPMDclucont(new TObjArray()), |
4755c3f1 | 64 | fCutoff(0.0), |
65 | fClusParam(0) | |
3edbbba2 | 66 | { |
fd30f88e | 67 | for(Int_t i = 0; i < kNDIMX; i++) |
3edbbba2 | 68 | { |
fd30f88e | 69 | for(Int_t j = 0; j < kNDIMY; j++) |
3edbbba2 | 70 | { |
71 | fCoord[0][i][j] = i+j/2.; | |
72 | fCoord[1][i][j] = fgkSqroot3by2*j; | |
3edbbba2 | 73 | } |
74 | } | |
75 | } | |
76 | // ------------------------------------------------------------------------ // | |
562718f9 | 77 | AliPMDClusteringV1::AliPMDClusteringV1(const AliPMDClusteringV1& pmdclv1): |
78 | AliPMDClustering(pmdclv1), | |
79 | fPMDclucont(0), | |
4755c3f1 | 80 | fCutoff(0), |
81 | fClusParam(0) | |
562718f9 | 82 | { |
83 | // copy constructor | |
84 | AliError("Copy constructor not allowed "); | |
85 | ||
86 | } | |
87 | // ------------------------------------------------------------------------ // | |
88 | AliPMDClusteringV1 &AliPMDClusteringV1::operator=(const AliPMDClusteringV1& /*pmdclv1*/) | |
89 | { | |
90 | // copy constructor | |
91 | AliError("Assignment operator not allowed "); | |
92 | return *this; | |
93 | } | |
94 | // ------------------------------------------------------------------------ // | |
3edbbba2 | 95 | AliPMDClusteringV1::~AliPMDClusteringV1() |
96 | { | |
562718f9 | 97 | delete fPMDclucont; |
3edbbba2 | 98 | } |
99 | // ------------------------------------------------------------------------ // | |
920e13db | 100 | void AliPMDClusteringV1::DoClust(Int_t idet, Int_t ismn, |
101 | Int_t celltrack[48][96], | |
102 | Int_t cellpid[48][96], | |
103 | Double_t celladc[48][96], | |
22bd512d | 104 | TObjArray *pmdcont) |
3edbbba2 | 105 | { |
106 | // main function to call other necessary functions to do clustering | |
107 | // | |
01c4d84a | 108 | |
562718f9 | 109 | AliPMDcluster *pmdcl = 0; |
3edbbba2 | 110 | |
2c1131dd | 111 | const float ktwobysqrt3 = 1.1547; // 2./sqrt(3.) |
112 | const Int_t kNmaxCell = 19; // # of cells surrounding a cluster center | |
113 | ||
be8b7039 | 114 | Int_t i = 0, j = 0, nmx1 = 0; |
115 | Int_t incr = 0, id = 0, jd = 0; | |
2c1131dd | 116 | Int_t celldataX[kNmaxCell], celldataY[kNmaxCell]; |
920e13db | 117 | Int_t celldataTr[kNmaxCell], celldataPid[kNmaxCell]; |
b0e4d1e1 | 118 | Float_t celldataAdc[kNmaxCell]; |
be8b7039 | 119 | Float_t clusdata[6] = {0.,0.,0.,0.,0.,0.}; |
562718f9 | 120 | Double_t cutoff, ave; |
121 | Double_t edepcell[kNMX]; | |
939c3b8e | 122 | Double_t cellenergy[11424]; |
9c294f00 | 123 | |
01c4d84a | 124 | // ndimXr and ndimYr are different because of different module size |
125 | ||
fd30f88e | 126 | Int_t ndimXr = 0; |
127 | Int_t ndimYr = 0; | |
01c4d84a | 128 | |
129 | if (ismn < 12) | |
130 | { | |
131 | ndimXr = 96; | |
132 | ndimYr = 48; | |
133 | } | |
134 | else if (ismn >= 12 && ismn <= 23) | |
135 | { | |
136 | ndimXr = 48; | |
137 | ndimYr = 96; | |
138 | } | |
139 | ||
78fc1b96 | 140 | for (i =0; i < 11424; i++) |
9c294f00 | 141 | { |
142 | cellenergy[i] = 0.; | |
143 | } | |
144 | ||
562718f9 | 145 | Int_t kk = 0; |
78fc1b96 | 146 | for (i = 0; i < kNDIMX; i++) |
3edbbba2 | 147 | { |
78fc1b96 | 148 | for (j = 0; j < kNDIMY; j++) |
01c4d84a | 149 | { |
562718f9 | 150 | edepcell[kk] = 0.; |
151 | kk++; | |
01c4d84a | 152 | } |
153 | } | |
154 | ||
155 | for (id = 0; id < ndimXr; id++) | |
156 | { | |
157 | for (jd = 0; jd < ndimYr; jd++) | |
3edbbba2 | 158 | { |
fd30f88e | 159 | j = jd; |
160 | i = id+(ndimYr/2-1)-(jd/2); | |
01c4d84a | 161 | |
9c294f00 | 162 | Int_t ij = i + j*kNDIMX; |
9c294f00 | 163 | |
01c4d84a | 164 | if (ismn < 12) |
165 | { | |
2c1131dd | 166 | cellenergy[ij] = celladc[jd][id]; |
01c4d84a | 167 | } |
168 | else if (ismn >= 12 && ismn <= 23) | |
169 | { | |
2c1131dd | 170 | cellenergy[ij] = celladc[id][jd]; |
01c4d84a | 171 | } |
3edbbba2 | 172 | } |
173 | } | |
562718f9 | 174 | |
78fc1b96 | 175 | for (i = 0; i < kNMX; i++) |
939c3b8e | 176 | { |
177 | edepcell[i] = cellenergy[i]; | |
178 | } | |
9c294f00 | 179 | |
562718f9 | 180 | Int_t iord1[kNMX]; |
df4e6759 | 181 | TMath::Sort((Int_t)kNMX,edepcell,iord1);// order the data |
2c1131dd | 182 | cutoff = fCutoff; // cutoff to discard cells |
562718f9 | 183 | ave = 0.; |
fd30f88e | 184 | nmx1 = -1; |
562718f9 | 185 | for(i = 0;i < kNMX; i++) |
3edbbba2 | 186 | { |
562718f9 | 187 | if(edepcell[i] > 0.) |
fd30f88e | 188 | { |
562718f9 | 189 | ave += edepcell[i]; |
fd30f88e | 190 | } |
562718f9 | 191 | if(edepcell[i] > cutoff ) |
fd30f88e | 192 | { |
193 | nmx1++; | |
194 | } | |
3edbbba2 | 195 | } |
9c294f00 | 196 | |
3edbbba2 | 197 | AliDebug(1,Form("Number of cells having energy >= %f are %d",cutoff,nmx1)); |
198 | ||
3edbbba2 | 199 | if (nmx1 == 0) nmx1 = 1; |
fd30f88e | 200 | ave = ave/nmx1; |
3edbbba2 | 201 | AliDebug(1,Form("Number of cells in a SuperM = %d and Average = %f", |
202 | kNMX,ave)); | |
562718f9 | 203 | |
204 | incr = CrClust(ave, cutoff, nmx1,iord1, edepcell ); | |
562718f9 | 205 | RefClust(incr,edepcell); |
206 | Int_t nentries1 = fPMDclucont->GetEntries(); | |
fd30f88e | 207 | AliDebug(1,Form("Detector Plane = %d Serial Module No = %d Number of clusters = %d",idet, ismn, nentries1)); |
208 | AliDebug(1,Form("Total number of clusters/module = %d",nentries1)); | |
562718f9 | 209 | |
fd30f88e | 210 | for (Int_t ient1 = 0; ient1 < nentries1; ient1++) |
3edbbba2 | 211 | { |
fd30f88e | 212 | AliPMDcludata *pmdcludata = |
562718f9 | 213 | (AliPMDcludata*)fPMDclucont->UncheckedAt(ient1); |
fd30f88e | 214 | Float_t cluXC = pmdcludata->GetClusX(); |
215 | Float_t cluYC = pmdcludata->GetClusY(); | |
216 | Float_t cluADC = pmdcludata->GetClusADC(); | |
217 | Float_t cluCELLS = pmdcludata->GetClusCells(); | |
218 | Float_t cluSIGX = pmdcludata->GetClusSigmaX(); | |
219 | Float_t cluSIGY = pmdcludata->GetClusSigmaY(); | |
220 | ||
3edbbba2 | 221 | Float_t cluY0 = ktwobysqrt3*cluYC; |
222 | Float_t cluX0 = cluXC - cluY0/2.; | |
fd30f88e | 223 | |
3edbbba2 | 224 | // |
225 | // Cluster X centroid is back transformed | |
226 | // | |
2c1131dd | 227 | |
01c4d84a | 228 | if (ismn < 12) |
229 | { | |
230 | clusdata[0] = cluX0 - (24-1) + cluY0/2.; | |
231 | } | |
fd30f88e | 232 | else if ( ismn >= 12 && ismn <= 23) |
01c4d84a | 233 | { |
234 | clusdata[0] = cluX0 - (48-1) + cluY0/2.; | |
235 | } | |
2c1131dd | 236 | |
01c4d84a | 237 | clusdata[1] = cluY0; |
238 | clusdata[2] = cluADC; | |
239 | clusdata[3] = cluCELLS; | |
fd30f88e | 240 | clusdata[4] = cluSIGX; |
241 | clusdata[5] = cluSIGY; | |
e6ba3040 | 242 | |
3edbbba2 | 243 | // |
244 | // Cells associated with a cluster | |
245 | // | |
562718f9 | 246 | |
2c1131dd | 247 | for (Int_t ihit = 0; ihit < kNmaxCell; ihit++) |
3edbbba2 | 248 | { |
2c1131dd | 249 | Int_t cellrow = pmdcludata->GetCellXY(ihit)/10000; |
250 | Int_t cellcol = pmdcludata->GetCellXY(ihit)%10000; | |
251 | ||
01c4d84a | 252 | if (ismn < 12) |
253 | { | |
2c1131dd | 254 | celldataX[ihit] = cellrow - (24-1) + int(cellcol/2.); |
01c4d84a | 255 | } |
256 | else if (ismn >= 12 && ismn <= 23) | |
257 | { | |
2c1131dd | 258 | celldataX[ihit] = cellrow - (48-1) + int(cellcol/2.); |
01c4d84a | 259 | } |
2c1131dd | 260 | |
261 | celldataY[ihit] = cellcol; | |
920e13db | 262 | |
263 | Int_t irow = celldataX[ihit]; | |
264 | Int_t icol = celldataY[ihit]; | |
2c1131dd | 265 | |
d270ca46 | 266 | if (ismn < 12) |
920e13db | 267 | { |
d270ca46 | 268 | if ((irow >= 0 && irow < 96) && (icol >= 0 && icol < 48)) |
269 | { | |
270 | celldataTr[ihit] = celltrack[icol][irow]; | |
271 | celldataPid[ihit] = cellpid[icol][irow]; | |
272 | celldataAdc[ihit] = (Float_t) celladc[icol][irow]; | |
273 | } | |
274 | else | |
275 | { | |
276 | celldataTr[ihit] = -1; | |
277 | celldataPid[ihit] = -1; | |
278 | celldataAdc[ihit] = -1; | |
279 | } | |
920e13db | 280 | } |
d270ca46 | 281 | else if (ismn >= 12 && ismn < 24) |
920e13db | 282 | { |
d270ca46 | 283 | if ((irow >= 0 && irow < 48) && (icol >= 0 && icol < 96)) |
284 | { | |
285 | celldataTr[ihit] = celltrack[irow][icol]; | |
286 | celldataPid[ihit] = cellpid[irow][icol]; | |
287 | celldataAdc[ihit] = (Float_t) celladc[irow][icol]; | |
e6ba3040 | 288 | |
d270ca46 | 289 | } |
290 | else | |
291 | { | |
292 | celldataTr[ihit] = -1; | |
293 | celldataPid[ihit] = -1; | |
294 | celldataAdc[ihit] = -1; | |
295 | } | |
920e13db | 296 | } |
d270ca46 | 297 | |
920e13db | 298 | } |
e6ba3040 | 299 | |
920e13db | 300 | pmdcl = new AliPMDcluster(idet, ismn, clusdata, celldataX, celldataY, |
b0e4d1e1 | 301 | celldataTr, celldataPid, celldataAdc); |
3edbbba2 | 302 | pmdcont->Add(pmdcl); |
303 | } | |
fd30f88e | 304 | |
91e6e2a0 | 305 | fPMDclucont->Delete(); |
3edbbba2 | 306 | } |
307 | // ------------------------------------------------------------------------ // | |
562718f9 | 308 | Int_t AliPMDClusteringV1::CrClust(Double_t ave, Double_t cutoff, Int_t nmx1, |
309 | Int_t iord1[], Double_t edepcell[]) | |
3edbbba2 | 310 | { |
fd30f88e | 311 | // Does crude clustering |
3edbbba2 | 312 | // Finds out only the big patch by just searching the |
313 | // connected cells | |
314 | // | |
2c1131dd | 315 | const Int_t kndim = 4609; |
be8b7039 | 316 | Int_t i=0,j=0,k=0,id1=0,id2=0,icl=0, numcell=0; |
317 | Int_t jd1=0,jd2=0, icell=0, cellcount=0; | |
318 | Int_t clust[2][kndim]; | |
fd30f88e | 319 | static Int_t neibx[6]={1,0,-1,-1,0,1}, neiby[6]={0,1,1,0,-1,-1}; |
320 | ||
3edbbba2 | 321 | AliDebug(1,Form("kNMX = %d nmx1 = %d kNDIMX = %d kNDIMY = %d ave = %f cutoff = %f",kNMX,nmx1,kNDIMX,kNDIMY,ave,cutoff)); |
322 | ||
fd30f88e | 323 | for (j = 0; j < kNDIMX; j++) |
324 | { | |
325 | for(k = 0; k < kNDIMY; k++) | |
326 | { | |
327 | fInfocl[0][j][k] = 0; | |
328 | fInfocl[1][j][k] = 0; | |
329 | } | |
330 | } | |
331 | for(i=0; i < kNMX; i++) | |
332 | { | |
333 | fInfcl[0][i] = -1; | |
562718f9 | 334 | |
335 | j = iord1[i]; | |
336 | id2 = j/kNDIMX; | |
337 | id1 = j-id2*kNDIMX; | |
338 | ||
339 | if(edepcell[j] <= cutoff) | |
fd30f88e | 340 | { |
341 | fInfocl[0][id1][id2] = -1; | |
342 | } | |
3edbbba2 | 343 | } |
562718f9 | 344 | |
3edbbba2 | 345 | // --------------------------------------------------------------- |
346 | // crude clustering begins. Start with cell having largest adc | |
347 | // count and loop over the cells in descending order of adc count | |
348 | // --------------------------------------------------------------- | |
562718f9 | 349 | |
fd30f88e | 350 | icl = -1; |
351 | cellcount = -1; | |
3edbbba2 | 352 | |
fd30f88e | 353 | for(icell = 0; icell <= nmx1; icell++) |
354 | { | |
562718f9 | 355 | j = iord1[icell]; |
356 | id2 = j/kNDIMX; | |
357 | id1 = j-id2*kNDIMX; | |
358 | ||
fd30f88e | 359 | if(fInfocl[0][id1][id2] == 0 ) |
360 | { | |
361 | icl++; | |
362 | numcell = 0; | |
363 | cellcount++; | |
364 | fInfocl[0][id1][id2] = 1; | |
365 | fInfocl[1][id1][id2] = icl; | |
366 | fInfcl[0][cellcount] = icl; | |
367 | fInfcl[1][cellcount] = id1; | |
368 | fInfcl[2][cellcount] = id2; | |
369 | ||
370 | clust[0][numcell] = id1; | |
371 | clust[1][numcell] = id2; | |
372 | ||
2c1131dd | 373 | for(i = 1; i < kndim; i++) |
fd30f88e | 374 | { |
375 | clust[0][i]=0; | |
376 | } | |
377 | // --------------------------------------------------------------- | |
378 | // check for adc count in neib. cells. If ne 0 put it in this clust | |
379 | // --------------------------------------------------------------- | |
380 | for(i = 0; i < 6; i++) | |
381 | { | |
382 | jd1 = id1 + neibx[i]; | |
383 | jd2 = id2 + neiby[i]; | |
384 | if( (jd1 >= 0 && jd1 < kNDIMX) && (jd2 >= 0 && jd2 < kNDIMY) && | |
385 | fInfocl[0][jd1][jd2] == 0) | |
386 | { | |
387 | numcell++; | |
388 | fInfocl[0][jd1][jd2] = 2; | |
389 | fInfocl[1][jd1][jd2] = icl; | |
390 | clust[0][numcell] = jd1; | |
391 | clust[1][numcell] = jd2; | |
392 | cellcount++; | |
393 | fInfcl[0][cellcount] = icl; | |
394 | fInfcl[1][cellcount] = jd1; | |
395 | fInfcl[2][cellcount] = jd2; | |
396 | } | |
397 | } | |
398 | // --------------------------------------------------------------- | |
399 | // check adc count for neighbour's neighbours recursively and | |
400 | // if nonzero, add these to the cluster. | |
401 | // --------------------------------------------------------------- | |
2c1131dd | 402 | for(i = 1; i < kndim;i++) |
fd30f88e | 403 | { |
404 | if(clust[0][i] != 0) | |
405 | { | |
406 | id1 = clust[0][i]; | |
407 | id2 = clust[1][i]; | |
408 | for(j = 0; j < 6 ; j++) | |
409 | { | |
410 | jd1 = id1 + neibx[j]; | |
411 | jd2 = id2 + neiby[j]; | |
412 | if( (jd1 >= 0 && jd1 < kNDIMX) && | |
413 | (jd2 >= 0 && jd2 < kNDIMY) && | |
414 | fInfocl[0][jd1][jd2] == 0 ) | |
415 | { | |
416 | fInfocl[0][jd1][jd2] = 2; | |
417 | fInfocl[1][jd1][jd2] = icl; | |
418 | numcell++; | |
419 | clust[0][numcell] = jd1; | |
420 | clust[1][numcell] = jd2; | |
421 | cellcount++; | |
422 | fInfcl[0][cellcount] = icl; | |
423 | fInfcl[1][cellcount] = jd1; | |
424 | fInfcl[2][cellcount] = jd2; | |
425 | } | |
426 | } | |
427 | } | |
3edbbba2 | 428 | } |
3edbbba2 | 429 | } |
3edbbba2 | 430 | } |
3edbbba2 | 431 | return cellcount; |
432 | } | |
433 | // ------------------------------------------------------------------------ // | |
562718f9 | 434 | void AliPMDClusteringV1::RefClust(Int_t incr, Double_t edepcell[]) |
3edbbba2 | 435 | { |
436 | // Does the refining of clusters | |
437 | // Takes the big patch and does gaussian fitting and | |
438 | // finds out the more refined clusters | |
439 | // | |
22d01768 | 440 | |
22d01768 | 441 | AliPMDcludata *pmdcludata = 0; |
2c1131dd | 442 | |
443 | const Int_t kNmaxCell = 19; // # of cells surrounding a cluster center | |
444 | ||
445 | Int_t ndim = incr + 1; | |
446 | ||
447 | Int_t *ncl = 0x0; | |
448 | Int_t *clxy = 0x0; | |
be8b7039 | 449 | Int_t i12 = 0, i22 = 0; |
450 | Int_t i = 0, j = 0, k = 0; | |
451 | Int_t i1 = 0, i2 = 0, id = 0, icl = 0; | |
452 | Int_t itest = 0, ihld = 0, ig = 0; | |
453 | Int_t nsupcl = 0, clno = 0, t1 = 0, t2 = 0; | |
562718f9 | 454 | Float_t clusdata[6]; |
be8b7039 | 455 | Double_t x1 = 0, y1 = 0, z1 = 0, x2 = 0, y2 = 0, z2 = 0, rr = 0; |
2c1131dd | 456 | |
457 | ncl = new Int_t [ndim]; | |
458 | clxy = new Int_t [kNmaxCell]; | |
459 | ||
562718f9 | 460 | // Initialisation |
2c1131dd | 461 | for(i = 0; i<ndim; i++) |
462 | { | |
463 | ncl[i] = -1; | |
562718f9 | 464 | if (i < 6) clusdata[i] = 0.; |
2c1131dd | 465 | if (i < kNmaxCell) clxy[i] = 0; |
fd30f88e | 466 | } |
562718f9 | 467 | |
fd30f88e | 468 | // clno counts the final clusters |
3edbbba2 | 469 | // nsupcl = # of superclusters; ncl[i]= # of cells in supercluster i |
470 | // x, y and z store (x,y) coordinates of and energy deposited in a cell | |
471 | // xc, yc store (x,y) coordinates of the cluster center | |
472 | // zc stores the energy deposited in a cluster | |
473 | // rc is cluster radius | |
fd30f88e | 474 | |
475 | clno = -1; | |
3edbbba2 | 476 | nsupcl = -1; |
562718f9 | 477 | |
fd30f88e | 478 | for(i = 0; i <= incr; i++) |
479 | { | |
480 | if(fInfcl[0][i] != nsupcl) | |
01c4d84a | 481 | { |
fd30f88e | 482 | nsupcl++; |
01c4d84a | 483 | } |
2c1131dd | 484 | if (nsupcl > ndim) |
01c4d84a | 485 | { |
fd30f88e | 486 | AliWarning("RefClust: Too many superclusters!"); |
2c1131dd | 487 | nsupcl = ndim; |
fd30f88e | 488 | break; |
01c4d84a | 489 | } |
fd30f88e | 490 | ncl[nsupcl]++; |
3edbbba2 | 491 | } |
fd30f88e | 492 | |
493 | AliDebug(1,Form("Number of cells = %d Number of Superclusters = %d", | |
494 | incr+1,nsupcl+1)); | |
495 | id = -1; | |
496 | icl = -1; | |
562718f9 | 497 | |
fd30f88e | 498 | for(i = 0; i <= nsupcl; i++) |
499 | { | |
500 | if(ncl[i] == 0) | |
01c4d84a | 501 | { |
fd30f88e | 502 | id++; |
503 | icl++; | |
2c1131dd | 504 | if (clno >= 4608) |
fd30f88e | 505 | { |
2c1131dd | 506 | AliWarning("RefClust: Too many clusters! more than 4608"); |
fd30f88e | 507 | return; |
508 | } | |
509 | clno++; | |
510 | i1 = fInfcl[1][id]; | |
511 | i2 = fInfcl[2][id]; | |
512 | ||
78fc1b96 | 513 | i12 = i1 + i2*kNDIMX; |
562718f9 | 514 | |
fd30f88e | 515 | clusdata[0] = fCoord[0][i1][i2]; |
516 | clusdata[1] = fCoord[1][i1][i2]; | |
562718f9 | 517 | clusdata[2] = edepcell[i12]; |
fd30f88e | 518 | clusdata[3] = 1.; |
22bd512d | 519 | clusdata[4] = 999.5; |
520 | clusdata[5] = 999.5; | |
562718f9 | 521 | |
2c1131dd | 522 | clxy[0] = i1*10000 + i2; |
523 | ||
524 | for(Int_t icltr = 1; icltr < kNmaxCell; icltr++) | |
fd30f88e | 525 | { |
562718f9 | 526 | clxy[icltr] = -1; |
3edbbba2 | 527 | } |
e6ba3040 | 528 | |
562718f9 | 529 | pmdcludata = new AliPMDcludata(clusdata,clxy); |
530 | fPMDclucont->Add(pmdcludata); | |
3edbbba2 | 531 | } |
fd30f88e | 532 | else if(ncl[i] == 1) |
533 | { | |
534 | id++; | |
535 | icl++; | |
2c1131dd | 536 | if (clno >= 4608) |
fd30f88e | 537 | { |
2c1131dd | 538 | AliWarning("RefClust: Too many clusters! more than 4608"); |
fd30f88e | 539 | return; |
540 | } | |
541 | clno++; | |
542 | i1 = fInfcl[1][id]; | |
543 | i2 = fInfcl[2][id]; | |
78fc1b96 | 544 | i12 = i1 + i2*kNDIMX; |
562718f9 | 545 | |
fd30f88e | 546 | x1 = fCoord[0][i1][i2]; |
547 | y1 = fCoord[1][i1][i2]; | |
562718f9 | 548 | z1 = edepcell[i12]; |
2c1131dd | 549 | |
550 | clxy[0] = i1*10000 + i2; | |
551 | ||
562718f9 | 552 | id++; |
fd30f88e | 553 | i1 = fInfcl[1][id]; |
554 | i2 = fInfcl[2][id]; | |
562718f9 | 555 | |
2c1131dd | 556 | i22 = i1 + i2*kNDIMX; |
fd30f88e | 557 | x2 = fCoord[0][i1][i2]; |
558 | y2 = fCoord[1][i1][i2]; | |
562718f9 | 559 | z2 = edepcell[i22]; |
2c1131dd | 560 | |
561 | clxy[1] = i1*10000 + i2; | |
562 | ||
563 | ||
564 | for(Int_t icltr = 2; icltr < kNmaxCell; icltr++) | |
fd30f88e | 565 | { |
562718f9 | 566 | clxy[icltr] = -1; |
fd30f88e | 567 | } |
fd30f88e | 568 | |
569 | clusdata[0] = (x1*z1+x2*z2)/(z1+z2); | |
570 | clusdata[1] = (y1*z1+y2*z2)/(z1+z2); | |
571 | clusdata[2] = z1+z2; | |
572 | clusdata[3] = 2.; | |
573 | clusdata[4] = 0.5; | |
574 | clusdata[5] = 0.0; | |
562718f9 | 575 | pmdcludata = new AliPMDcludata(clusdata,clxy); |
576 | fPMDclucont->Add(pmdcludata); | |
3edbbba2 | 577 | } |
fd30f88e | 578 | else |
579 | { | |
2c1131dd | 580 | |
581 | Int_t *iord, *tc, *t; | |
582 | Double_t *x, *y, *z, *xc, *yc, *zc; | |
583 | ||
584 | iord = new Int_t [ncl[i]+1]; | |
585 | tc = new Int_t [ncl[i]+1]; | |
586 | t = new Int_t [ncl[i]+1]; | |
587 | ||
588 | x = new Double_t [ncl[i]+1]; | |
589 | y = new Double_t [ncl[i]+1]; | |
590 | z = new Double_t [ncl[i]+1]; | |
591 | xc = new Double_t [ncl[i]+1]; | |
592 | yc = new Double_t [ncl[i]+1]; | |
593 | zc = new Double_t [ncl[i]+1]; | |
594 | ||
595 | for( k = 0; k < ncl[i]+1; k++) | |
596 | { | |
597 | iord[k] = -1; | |
598 | t[k] = -1; | |
599 | tc[k] = -1; | |
600 | x[k] = -1; | |
601 | y[k] = -1; | |
602 | z[k] = -1; | |
603 | xc[k] = -1; | |
604 | yc[k] = -1; | |
605 | zc[k] = -1; | |
606 | } | |
fd30f88e | 607 | id++; |
fd30f88e | 608 | // super-cluster of more than two cells - broken up into smaller |
609 | // clusters gaussian centers computed. (peaks separated by > 1 cell) | |
610 | // Begin from cell having largest energy deposited This is first | |
611 | // cluster center | |
612 | i1 = fInfcl[1][id]; | |
613 | i2 = fInfcl[2][id]; | |
78fc1b96 | 614 | i12 = i1 + i2*kNDIMX; |
562718f9 | 615 | |
fd30f88e | 616 | x[0] = fCoord[0][i1][i2]; |
617 | y[0] = fCoord[1][i1][i2]; | |
562718f9 | 618 | z[0] = edepcell[i12]; |
2c1131dd | 619 | t[0] = i1*10000 + i2; |
fd30f88e | 620 | |
2c1131dd | 621 | |
fd30f88e | 622 | iord[0] = 0; |
623 | for(j = 1; j <= ncl[i]; j++) | |
624 | { | |
625 | id++; | |
626 | i1 = fInfcl[1][id]; | |
627 | i2 = fInfcl[2][id]; | |
78fc1b96 | 628 | i12 = i1 + i2*kNDIMX; |
562718f9 | 629 | |
fd30f88e | 630 | iord[j] = j; |
631 | x[j] = fCoord[0][i1][i2]; | |
632 | y[j] = fCoord[1][i1][i2]; | |
562718f9 | 633 | z[j] = edepcell[i12]; |
2c1131dd | 634 | t[j] = i1*10000 + i2; |
562718f9 | 635 | |
3edbbba2 | 636 | } |
fd30f88e | 637 | |
fd30f88e | 638 | // arranging cells within supercluster in decreasing order |
2c1131dd | 639 | |
fd30f88e | 640 | for(j = 1;j <= ncl[i]; j++) |
641 | { | |
642 | itest = 0; | |
643 | ihld = iord[j]; | |
644 | for(i1 = 0; i1 < j; i1++) | |
645 | { | |
646 | if(itest == 0 && z[iord[i1]] < z[ihld]) | |
647 | { | |
648 | itest = 1; | |
649 | for(i2 = j-1; i2 >= i1; i2--) | |
650 | { | |
651 | iord[i2+1] = iord[i2]; | |
652 | } | |
653 | iord[i1] = ihld; | |
654 | } | |
655 | } | |
3edbbba2 | 656 | } |
b634e7ee | 657 | |
658 | if (fClusParam == 1) | |
659 | { | |
660 | // Clustering algorithm returns from here for PP collisions | |
661 | // for pp, only the output of crude clusterng is taken | |
662 | // sigx and sigy are not calculated at this moment | |
663 | ||
664 | Double_t supx=0., supy=0., supz=0.; | |
665 | ||
666 | for(j = 0;j <= ncl[i]; j++) | |
667 | { | |
668 | supx += x[iord[j]]*z[iord[j]]; | |
669 | supy += y[iord[j]]*z[iord[j]]; | |
670 | supz += z[iord[j]]; | |
671 | if(j < 19) | |
672 | { | |
673 | clxy[j] = t[iord[j]]; | |
674 | } | |
675 | } | |
676 | ||
677 | if( ncl[i] + 1 < 19) | |
678 | { | |
679 | for(Int_t ncel = ncl[i] + 1; ncel < kNmaxCell; ncel ++ ) | |
680 | { | |
681 | clxy[ncel] = -1; | |
682 | } | |
683 | } | |
684 | clusdata[0] = supx/supz; | |
685 | clusdata[1] = supy/supz; | |
686 | clusdata[2] = supz; | |
687 | clusdata[3] = ncl[i]+1; | |
688 | clusdata[4] = 0.5; | |
689 | clusdata[5] = 0.0; | |
690 | pmdcludata = new AliPMDcludata(clusdata,clxy); | |
691 | fPMDclucont->Add(pmdcludata); | |
692 | } | |
693 | ||
2c1131dd | 694 | /* MODIFICATION PART STARTS (Tapan July 2008) |
695 | iord[0] is the cell with highest ADC in the crude-cluster | |
696 | ig is the number of local maxima in the crude-cluster | |
697 | For the higest peak we make ig=0 which means first local maximum. | |
698 | Next we go down in terms of the ADC sequence and find out if any | |
699 | more of the cells form local maxima. The definition of local | |
700 | maxima is that all its neighbours are of less ADC compared to it. | |
701 | */ | |
b634e7ee | 702 | |
703 | if (fClusParam == 2) | |
fd30f88e | 704 | { |
b634e7ee | 705 | // This part is to split the supercluster |
706 | // | |
707 | ig = 0; | |
708 | xc[ig] = x[iord[0]]; | |
709 | yc[ig] = y[iord[0]]; | |
710 | zc[ig] = z[iord[0]]; | |
711 | tc[ig] = t[iord[0]]; | |
712 | Int_t ivalid = 0, icount = 0; | |
713 | ||
714 | for(j=1;j<=ncl[i];j++) | |
fd30f88e | 715 | { |
b634e7ee | 716 | x1 = x[iord[j]]; |
717 | y1 = y[iord[j]]; | |
718 | z1 = z[iord[j]]; | |
719 | t1 = t[iord[j]]; | |
720 | rr=Distance(x1,y1,xc[ig],yc[ig]); | |
721 | ||
722 | // Check the cells which are outside the neighbours (rr>1.2) | |
723 | if(rr>1.2 ) | |
2c1131dd | 724 | { |
b634e7ee | 725 | ivalid=0; |
726 | icount=0; | |
727 | for(Int_t j1=1;j1<j;j1++) | |
728 | { | |
729 | icount++; | |
730 | Float_t rr1=Distance(x1,y1,x[iord[j1]],y[iord[j1]]); | |
731 | if(rr1>1.2) ivalid++; | |
732 | } | |
733 | if(ivalid == icount && z1>0.5*zc[ig]) | |
734 | { | |
735 | ig++; | |
736 | xc[ig]=x1; | |
737 | yc[ig]=y1; | |
738 | zc[ig]=z1; | |
739 | tc[ig]=t1; | |
740 | } | |
741 | } | |
742 | } | |
2c1131dd | 743 | |
b634e7ee | 744 | icl=icl+ig+1; |
2c1131dd | 745 | |
b634e7ee | 746 | // We use simple Gaussian weighting. (Tapan Jan 2005) |
747 | // compute the number of cells belonging to each cluster. | |
748 | // cell can be shared between several clusters | |
749 | // in the ratio of cluster energy deposition | |
750 | // To calculate: | |
751 | // (1) number of cells belonging to a cluster (ig) and | |
752 | // (2) total ADC of the cluster (ig) | |
753 | // (3) x and y positions of the cluster | |
2c1131dd | 754 | |
b634e7ee | 755 | |
756 | Int_t *cellCount; | |
757 | Int_t **cellXY; | |
758 | ||
759 | Int_t *status; | |
760 | Double_t *totaladc, *totaladc2, *ncell,*weight; | |
761 | Double_t *xclust, *yclust, *sigxclust, *sigyclust; | |
762 | Double_t *ax, *ay, *ax2, *ay2; | |
763 | ||
764 | ||
765 | status = new Int_t [ncl[i]+1]; | |
766 | cellXY = new Int_t *[ncl[i]+1]; | |
767 | ||
768 | cellCount = new Int_t [ig+1]; | |
769 | totaladc = new Double_t [ig+1]; | |
770 | totaladc2 = new Double_t [ig+1]; | |
771 | ncell = new Double_t [ig+1]; | |
772 | weight = new Double_t [ig+1]; | |
773 | xclust = new Double_t [ig+1]; | |
774 | yclust = new Double_t [ig+1]; | |
775 | sigxclust = new Double_t [ig+1]; | |
776 | sigyclust = new Double_t [ig+1]; | |
777 | ax = new Double_t [ig+1]; | |
778 | ay = new Double_t [ig+1]; | |
779 | ax2 = new Double_t [ig+1]; | |
780 | ay2 = new Double_t [ig+1]; | |
781 | ||
782 | for(j = 0; j < ncl[i]+1; j++) | |
2c1131dd | 783 | { |
b634e7ee | 784 | status[j] = 0; |
785 | cellXY[j] = new Int_t[ig+1]; | |
2c1131dd | 786 | } |
b634e7ee | 787 | //initialization |
788 | for(Int_t kcl = 0; kcl < ig+1; kcl++) | |
fd30f88e | 789 | { |
b634e7ee | 790 | cellCount[kcl] = 0; |
791 | totaladc[kcl] = 0.; | |
792 | totaladc2[kcl] = 0.; | |
793 | ncell[kcl] = 0.; | |
794 | weight[kcl] = 0.; | |
795 | xclust[kcl] = 0.; | |
796 | yclust[kcl] = 0.; | |
797 | sigxclust[kcl] = 0.; | |
798 | sigyclust[kcl] = 0.; | |
799 | ax[kcl] = 0.; | |
800 | ay[kcl] = 0.; | |
801 | ax2[kcl] = 0.; | |
802 | ay2[kcl] = 0.; | |
803 | for(j = 0; j < ncl[i]+1; j++) | |
fd30f88e | 804 | { |
b634e7ee | 805 | cellXY[j][kcl] = 0; |
fd30f88e | 806 | } |
2c1131dd | 807 | } |
b634e7ee | 808 | Double_t sumweight, gweight; |
2c1131dd | 809 | |
b634e7ee | 810 | for(j = 0;j <= ncl[i]; j++) |
811 | { | |
812 | x1 = x[iord[j]]; | |
2c1131dd | 813 | y1 = y[iord[j]]; |
814 | z1 = z[iord[j]]; | |
815 | t1 = t[iord[j]]; | |
b634e7ee | 816 | |
817 | for(Int_t kcl=0; kcl<=ig; kcl++) | |
fd30f88e | 818 | { |
b634e7ee | 819 | x2 = xc[kcl]; |
820 | y2 = yc[kcl]; | |
2c1131dd | 821 | rr = Distance(x1,y1,x2,y2); |
b634e7ee | 822 | t2 = tc[kcl]; |
2c1131dd | 823 | |
b634e7ee | 824 | if(rr==0) |
fd30f88e | 825 | { |
b634e7ee | 826 | ncell[kcl] = 1.; |
827 | totaladc[kcl] = z1; | |
828 | totaladc2[kcl] = z1*z1; | |
829 | ax[kcl] = x1 * z1; | |
830 | ay[kcl] = y1 * z1; | |
831 | ax2[kcl] = 0.; | |
832 | ay2[kcl] = 0.; | |
833 | status[j] = 1; | |
fd30f88e | 834 | } |
835 | } | |
b634e7ee | 836 | } |
837 | ||
838 | for(j = 0; j <= ncl[i]; j++) | |
839 | { | |
840 | Int_t maxweight = 0; | |
841 | Double_t max = 0.; | |
2c1131dd | 842 | |
b634e7ee | 843 | if(status[j] == 0) |
844 | { | |
845 | x1 = x[iord[j]]; | |
846 | y1 = y[iord[j]]; | |
847 | z1 = z[iord[j]]; | |
848 | t1 = t[iord[j]]; | |
849 | sumweight = 0.; | |
850 | ||
851 | for(Int_t kcl = 0; kcl <= ig; kcl++) | |
852 | { | |
853 | x2 = xc[kcl]; | |
854 | y2 = yc[kcl]; | |
855 | rr = Distance(x1,y1,x2,y2); | |
856 | gweight = exp(-(rr*rr)/(2*(1.2*1.2))); | |
857 | weight[kcl] = zc[kcl] * gweight; | |
858 | sumweight = sumweight + weight[kcl]; | |
859 | ||
860 | if(weight[kcl] > max) | |
861 | { | |
862 | max = weight[kcl]; | |
863 | maxweight = kcl; | |
864 | } | |
865 | } | |
866 | ||
867 | cellXY[cellCount[maxweight]][maxweight] = iord[j]; | |
868 | ||
869 | cellCount[maxweight]++; | |
870 | ||
871 | x2 = xc[maxweight]; | |
872 | y2 = yc[maxweight]; | |
873 | totaladc[maxweight] += z1; | |
874 | ax[maxweight] += x1*z1; | |
875 | ay[maxweight] += y1*z1; | |
876 | totaladc2[maxweight] += z1*z1; | |
877 | ax2[maxweight] += z1*(x1-x2)*(x1-x2); | |
878 | ay2[maxweight] += z1*(y1-y2)*(y1-y2); | |
879 | ncell[maxweight]++; | |
880 | ||
881 | } | |
fd30f88e | 882 | } |
fd30f88e | 883 | |
b634e7ee | 884 | for(Int_t kcl = 0; kcl <= ig; kcl++) |
939c3b8e | 885 | { |
b634e7ee | 886 | if(totaladc[kcl] > 0.) |
887 | { | |
888 | xclust[kcl] = (ax[kcl])/ totaladc[kcl]; | |
889 | yclust[kcl] = (ay[kcl])/ totaladc[kcl]; | |
890 | ||
891 | //natasha | |
892 | Float_t sqtotadc = totaladc[kcl]*totaladc[kcl]; | |
893 | if(totaladc2[kcl] >= sqtotadc) | |
894 | { | |
895 | sigxclust[kcl] = 0.25; | |
896 | sigyclust[kcl] = 0.25; | |
897 | } | |
898 | else | |
899 | { | |
900 | sigxclust[kcl] = (totaladc[kcl]/(sqtotadc-totaladc2[kcl]))*ax2[kcl]; | |
901 | sigyclust[kcl] = (totaladc[kcl]/(sqtotadc-totaladc2[kcl]))*ay2[kcl]; | |
902 | } | |
903 | } | |
904 | ||
905 | for(j = 0; j < cellCount[kcl]; j++) clno++; | |
939c3b8e | 906 | |
b634e7ee | 907 | if (clno >= 4608) |
939c3b8e | 908 | { |
b634e7ee | 909 | AliWarning("RefClust: Too many clusters! more than 4608"); |
910 | return; | |
911 | } | |
912 | clusdata[0] = xclust[kcl]; | |
913 | clusdata[1] = yclust[kcl]; | |
914 | clusdata[2] = totaladc[kcl]; | |
915 | clusdata[3] = ncell[kcl]; | |
916 | ||
917 | if(sigxclust[kcl] > sigyclust[kcl]) | |
918 | { | |
919 | clusdata[4] = TMath::Sqrt(sigxclust[kcl]); | |
920 | clusdata[5] = TMath::Sqrt(sigyclust[kcl]); | |
939c3b8e | 921 | } |
922 | else | |
923 | { | |
b634e7ee | 924 | clusdata[4] = TMath::Sqrt(sigyclust[kcl]); |
925 | clusdata[5] = TMath::Sqrt(sigxclust[kcl]); | |
2c1131dd | 926 | } |
b634e7ee | 927 | |
928 | clxy[0] = tc[kcl]; | |
929 | ||
930 | Int_t Ncell=1; | |
931 | for (Int_t ii = 0; ii < cellCount[kcl]; ii++) | |
932 | { | |
933 | if(ii<18) | |
934 | { | |
935 | clxy[Ncell] = t[cellXY[ii][kcl]]; | |
936 | Ncell++; | |
937 | } | |
938 | } | |
939 | ||
940 | pmdcludata = new AliPMDcludata(clusdata,clxy); | |
941 | fPMDclucont->Add(pmdcludata); | |
942 | } | |
943 | delete [] cellCount; | |
944 | for(Int_t jj = 0; jj < ncl[i]+1; jj++) delete [] cellXY[jj]; | |
939c3b8e | 945 | |
b634e7ee | 946 | delete [] status; |
947 | delete [] totaladc; | |
948 | delete [] totaladc2; | |
949 | delete [] ncell; | |
950 | delete [] xclust; | |
951 | delete [] yclust; | |
952 | delete [] sigxclust; | |
953 | delete [] sigyclust; | |
954 | delete [] ax; | |
955 | delete [] ay; | |
956 | delete [] ax2; | |
957 | delete [] ay2; | |
958 | delete [] weight; | |
959 | ||
01c4d84a | 960 | } |
b634e7ee | 961 | |
2c1131dd | 962 | delete [] iord; |
963 | delete [] tc; | |
964 | delete [] t; | |
965 | delete [] x; | |
966 | delete [] y; | |
967 | delete [] z; | |
968 | delete [] xc; | |
969 | delete [] yc; | |
970 | delete [] zc; | |
b634e7ee | 971 | |
972 | ||
fd30f88e | 973 | } |
3edbbba2 | 974 | } |
2c1131dd | 975 | delete [] ncl; |
976 | delete [] clxy; | |
3edbbba2 | 977 | } |
978 | // ------------------------------------------------------------------------ // | |
fd30f88e | 979 | Double_t AliPMDClusteringV1::Distance(Double_t x1, Double_t y1, |
980 | Double_t x2, Double_t y2) | |
3edbbba2 | 981 | { |
fd30f88e | 982 | return TMath::Sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2)); |
3edbbba2 | 983 | } |
984 | // ------------------------------------------------------------------------ // | |
985 | void AliPMDClusteringV1::SetEdepCut(Float_t decut) | |
986 | { | |
987 | fCutoff = decut; | |
988 | } | |
989 | // ------------------------------------------------------------------------ // | |
4755c3f1 | 990 | void AliPMDClusteringV1::SetClusteringParam(Int_t cluspar) |
991 | { | |
992 | fClusParam = cluspar; | |
993 | } | |
994 | // ------------------------------------------------------------------------ // |