]>
Commit | Line | Data |
---|---|---|
c98c0281 | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
7 | * Permission to use, copy, modify and distribute this software and its * | |
8 | * documentation strictly for non-commercial purposes is hereby granted * | |
9 | * without fee, provided that the above copyright notice appears in all * | |
10 | * copies and that both the copyright notice and this permission notice * | |
11 | * appear in the supporting documentation. The authors make no claims * | |
12 | * about the suitability of this software for any purpose. It is * | |
13 | * provided "as is" without express or implied warranty. * | |
14 | **************************************************************************/ | |
04366a57 | 15 | //////////////////////////////////////////////////////////////////////////// |
16 | // Cluster finder /// | |
17 | // for Silicon pixels // | |
18 | // // | |
19 | //////////////////////////////////////////////////////////////////////////// | |
f77f13c8 | 20 | |
f77f13c8 | 21 | #include "AliITSClusterFinderSPD.h" |
7d62fb64 | 22 | #include "AliITSDetTypeRec.h" |
41b19549 | 23 | #include "AliITSRawClusterSPD.h" |
c98c0281 | 24 | #include "AliITSRecPoint.h" |
f77f13c8 | 25 | #include "AliITSdigitSPD.h" |
aacedc3e | 26 | #include "AliITSsegmentationSPD.h" |
6cae184e | 27 | #include "AliITSgeom.h" |
f77f13c8 | 28 | #include "AliLog.h" |
c98c0281 | 29 | |
9e1e0cd7 | 30 | //#define DEBUG |
c98c0281 | 31 | |
32 | ClassImp(AliITSClusterFinderSPD) | |
33 | ||
aacedc3e | 34 | //______________________________________________________________________ |
35 | AliITSClusterFinderSPD::AliITSClusterFinderSPD():AliITSClusterFinder(), | |
36 | fDz(0.0), | |
37 | fDx(0.0), | |
38 | fMinNCells(0){ | |
39 | // constructor | |
40 | } | |
c98c0281 | 41 | //---------------------------------------------------------- |
8ba39da9 | 42 | AliITSClusterFinderSPD::AliITSClusterFinderSPD(AliITSDetTypeRec* dettyp): |
43 | AliITSClusterFinder(dettyp), | |
aacedc3e | 44 | fDz(0.0), |
45 | fDx(0.0), | |
46 | fMinNCells(0){ | |
9e1e0cd7 | 47 | // constructor |
48 | ||
c98c0281 | 49 | SetDx(); |
50 | SetDz(); | |
51 | } | |
aacedc3e | 52 | //---------------------------------------------------------- |
8ba39da9 | 53 | AliITSClusterFinderSPD::AliITSClusterFinderSPD(AliITSDetTypeRec* dettyp, |
aacedc3e | 54 | TClonesArray *digits, |
55 | TClonesArray *recp): | |
8ba39da9 | 56 | AliITSClusterFinder(dettyp,digits), |
aacedc3e | 57 | fDz(0.0), |
58 | fDx(0.0), | |
59 | fMinNCells(0){ | |
9e1e0cd7 | 60 | // constructor |
61 | ||
aacedc3e | 62 | SetDigits(digits); |
63 | SetClusters(recp); | |
9e1e0cd7 | 64 | SetDx(); |
65 | SetDz(); | |
c98c0281 | 66 | } |
e56160b8 | 67 | /* |
9e1e0cd7 | 68 | //______________________________________________________________________ |
04366a57 | 69 | AliITSClusterFinderSPD::AliITSClusterFinderSPD(const AliITSClusterFinderSPD &source) : AliITSClusterFinder(source) { |
70 | // Copy constructor | |
71 | // Copies are not allowed. The method is protected to avoid misuse. | |
72 | Fatal("AliITSClusterFinderSPD","Copy constructor not allowed\n"); | |
73 | } | |
e56160b8 | 74 | */ |
04366a57 | 75 | //______________________________________________________________________ |
e56160b8 | 76 | //AliITSClusterFinderSPD& AliITSClusterFinderSPD::operator=(const AliITSClusterFinderSPD& /* source */){ |
04366a57 | 77 | // Assignment operator |
78 | // Assignment is not allowed. The method is protected to avoid misuse. | |
e56160b8 | 79 | //Fatal("= operator","Assignment operator not allowed\n"); |
80 | //return *this; | |
81 | //} | |
9e1e0cd7 | 82 | //______________________________________________________________________ |
83 | void AliITSClusterFinderSPD::FindRawClusters(Int_t module){ | |
84 | // input of Cluster Finder | |
85 | Int_t digitcount = 0; | |
86 | Int_t numberd = 100000; | |
c98c0281 | 87 | Int_t *digx = new Int_t[numberd]; |
88 | Int_t *digz = new Int_t[numberd]; | |
89 | Int_t *digtr1 = new Int_t[numberd]; | |
90 | Int_t *digtr2 = new Int_t[numberd]; | |
91 | Int_t *digtr3 = new Int_t[numberd]; | |
92 | Int_t *digtr4 = new Int_t[numberd]; | |
c98c0281 | 93 | // output of Cluster Finder |
9e1e0cd7 | 94 | Int_t numberc = 10000; |
aacedc3e | 95 | Double_t *xcenterl = new Double_t[numberc]; |
96 | Double_t *zcenterl = new Double_t[numberc]; | |
97 | Double_t *errxcenter = new Double_t[numberc]; | |
98 | Double_t *errzcenter = new Double_t[numberc]; | |
c98c0281 | 99 | Int_t *tr1clus = new Int_t[numberc]; |
100 | Int_t *tr2clus = new Int_t[numberc]; | |
101 | Int_t *tr3clus = new Int_t[numberc]; | |
9e1e0cd7 | 102 | Int_t nclus; |
c98c0281 | 103 | |
aacedc3e | 104 | SetModule(module); |
c98c0281 | 105 | digitcount=0; |
aacedc3e | 106 | Int_t ndigits = Digits()->GetEntriesFast(); |
c98c0281 | 107 | if (!ndigits) return; |
108 | ||
ee86d557 | 109 | AliITSdigitSPD *dig; |
aacedc3e | 110 | Int_t ndig=0,i; |
5d766c75 | 111 | /* |
f77f13c8 | 112 | AliDebug(4," "); |
fc9f1fd2 | 113 | scanf("%d",&ndig); |
5d766c75 | 114 | */ |
c98c0281 | 115 | for(ndig=0; ndig<ndigits; ndig++) { |
aacedc3e | 116 | dig= (AliITSdigitSPD*)GetDigit(ndig); |
117 | digx[digitcount] = dig->GetCoord2()+1; //starts at 1 | |
118 | digz[digitcount] = dig->GetCoord1()+1; //starts at 1 | |
119 | digtr1[digitcount] = dig->GetTrack(0); | |
120 | digtr2[digitcount] = -3; | |
121 | digtr3[digitcount] = -3; | |
f77f13c8 | 122 | AliDebug(5,Form("digtr1[%d]=%d fTracks[%d]=%d: ", |
123 | digitcount,digtr1[digitcount],0,dig->GetTrack(0))); | |
aacedc3e | 124 | i=1; |
125 | while(digtr1[digitcount]==dig->GetTrack(i) && i<dig->GetNTracks()) i++; | |
f77f13c8 | 126 | AliDebug(5,Form(" fTracks[%d]=%d",i,dig->GetTrack(i))); |
aacedc3e | 127 | if(i<dig->GetNTracks()){ |
128 | digtr2[digitcount] = dig->GetTrack(i); | |
f77f13c8 | 129 | AliDebug(5,Form("digtr2[%d]=%d: ",digitcount,digtr2[digitcount])); |
aacedc3e | 130 | while((digtr1[digitcount]==dig->GetTrack(i) || |
131 | digtr2[digitcount]==dig->GetTrack(i))&& | |
132 | i<=dig->GetNTracks()) i++; | |
133 | if(i<dig->GetNTracks()) digtr3[digitcount] = dig->GetTrack(i); | |
f77f13c8 | 134 | AliDebug(5,Form(" fTracks[%d]=%d digtr3[%d]=%d", |
135 | i,i<dig->GetNTracks()?dig->GetTrack(i):-1,digitcount,digtr3[digitcount])); | |
aacedc3e | 136 | } // end if |
f77f13c8 | 137 | // if(GetDebug(4)) cout<<endl; |
aacedc3e | 138 | digtr4[digitcount] = dig->GetSignal(); |
139 | digitcount++; | |
9e1e0cd7 | 140 | } // end for ndig |
c98c0281 | 141 | ClusterFinder(digitcount,digx,digz,digtr1,digtr2,digtr3,digtr4, |
aacedc3e | 142 | nclus,xcenterl,zcenterl,errxcenter,errzcenter, |
143 | tr1clus, tr2clus, tr3clus); | |
c98c0281 | 144 | DigitToPoint(nclus,xcenterl,zcenterl,errxcenter,errzcenter, |
aacedc3e | 145 | tr1clus, tr2clus, tr3clus); |
9e1e0cd7 | 146 | delete[] digx; |
147 | delete[] digz; | |
148 | delete[] digtr1; | |
149 | delete[] digtr2; | |
150 | delete[] digtr3; | |
151 | delete[] digtr4; | |
152 | delete[] xcenterl; | |
153 | delete[] zcenterl; | |
154 | delete[] errxcenter; | |
155 | delete[] errzcenter; | |
156 | delete[] tr1clus; | |
157 | delete[] tr2clus; | |
158 | delete[] tr3clus; | |
c98c0281 | 159 | } |
9e1e0cd7 | 160 | //---------------------------------------------------------------------- |
161 | void AliITSClusterFinderSPD::ClusterFinder(Int_t ndigits,Int_t digx[], | |
162 | Int_t digz[],Int_t digtr1[], | |
163 | Int_t digtr2[],Int_t digtr3[], | |
164 | Int_t digtr4[],Int_t &nclus, | |
aacedc3e | 165 | Double_t xcenter[],Double_t zcenter[], |
166 | Double_t errxcenter[], | |
167 | Double_t errzcenter[], | |
9e1e0cd7 | 168 | Int_t tr1clus[],Int_t tr2clus[], |
aacedc3e | 169 | Int_t tr3clus[]){ |
9e1e0cd7 | 170 | // Search for clusters of fired pixels (digits). Two digits are linked |
171 | // inside a cluster if they are countiguous both in row or column | |
172 | // direction. Diagonal digits are not linked. | |
173 | // xcenter, ycenter, zcenter are the coordinates of the center | |
174 | // of each found cluster, calculated from the averaging the corresponding | |
175 | // coordinate of the center of the linked digits. The coordinates are | |
176 | // given in the local reference sistem. | |
177 | // errxcenter, errycenter, errzcenter are the errors associated to | |
178 | // the corresponding average. | |
179 | Int_t if1, min, max, nd; | |
180 | Int_t x1, z1, t1, t2, t3, t4; | |
181 | Int_t ndx, ndz, ndxmin=0, ndxmax=0, ndzmin=0, ndzmax=0; | |
aacedc3e | 182 | Double_t dx, dz; |
9e1e0cd7 | 183 | Int_t i,k,ipos=0; |
184 | Float_t xdum, zdum; | |
185 | Int_t kmax, sigmax; | |
aacedc3e | 186 | Double_t deltax, deltaz; |
187 | Double_t ndig; | |
9e1e0cd7 | 188 | Int_t numberd = 10000; |
189 | Int_t *ifpad = new Int_t[numberd]; | |
190 | Int_t *xpad = new Int_t[numberd]; | |
191 | Int_t *zpad = new Int_t[numberd]; | |
192 | Int_t *tr1pad = new Int_t[numberd]; | |
193 | Int_t *tr2pad = new Int_t[numberd]; | |
194 | Int_t *tr3pad = new Int_t[numberd]; | |
195 | Int_t *tr4pad = new Int_t[numberd]; | |
196 | Int_t *iclus = new Int_t[numberd]; | |
197 | ||
198 | nclus=1; | |
199 | for (i=0; i < ndigits ; i++){ | |
aacedc3e | 200 | ifpad[i] = -1; |
201 | iclus[i] = 0; | |
9e1e0cd7 | 202 | } // end for i |
203 | ||
204 | ifpad[0]=0; | |
205 | for (i=0; i < ndigits-1 ; i++) { | |
aacedc3e | 206 | if ( ifpad[i] == -1 ) { |
207 | nclus++; | |
208 | ipos++; | |
209 | ifpad[i]=nclus-1; | |
210 | } // end if ipad[i] | |
211 | for (Int_t j=i+1 ; j < ndigits ; j++) { | |
212 | if (ifpad[j]== -1 ) { | |
213 | dx = TMath::Abs(digx[i]-digx[j]); | |
214 | dz = TMath::Abs(digz[i]-digz[j]); | |
215 | // if ( ( dx+dz )==1 ) //clusters are not diagonal | |
216 | if(( dx+dz )==1 || (dx==1 && dz==1)){ | |
217 | //diagonal clusters allowed | |
218 | ipos++; | |
219 | ifpad[j] = ifpad[i]; | |
220 | ||
221 | x1 = digx[j]; | |
222 | z1 = digz[j]; | |
223 | digx[j] = digx[ipos]; | |
224 | digz[j] = digz[ipos]; | |
225 | digx[ipos] = x1; | |
226 | digz[ipos] = z1; | |
227 | ||
228 | t1 = digtr1[j]; | |
229 | t2 = digtr2[j]; | |
230 | t3 = digtr3[j]; | |
231 | t4 = digtr4[j]; | |
232 | digtr1[j] = digtr1[ipos]; | |
233 | digtr2[j] = digtr2[ipos]; | |
234 | digtr3[j] = digtr3[ipos]; | |
235 | digtr4[j] = digtr4[ipos]; | |
236 | digtr1[ipos] = t1; | |
237 | digtr2[ipos] = t2; | |
238 | digtr3[ipos] = t3; | |
239 | digtr4[ipos] = t4; | |
240 | ||
241 | if1 = ifpad[j]; | |
242 | ifpad[j] = ifpad[ipos]; | |
243 | ifpad[ipos] = if1; | |
244 | } // end dx+dx... | |
245 | }// end if ifpad[j]== -1 | |
246 | } // end for j | |
9e1e0cd7 | 247 | }//end loop on digits |
248 | if ( ifpad[ndigits-1] == -1 ) { | |
aacedc3e | 249 | nclus++; |
250 | ifpad[ndigits-1]=nclus-1; | |
9e1e0cd7 | 251 | } // end if ifpad[ndigits-1] == -1 |
aacedc3e | 252 | |
9e1e0cd7 | 253 | for (i=0 ; i < ndigits ; i++) iclus[ifpad[i]]++; |
254 | ||
255 | min=0; | |
256 | max=0; | |
257 | // loop on found clusters | |
258 | for (i=0 ; i < nclus ; i++){ | |
aacedc3e | 259 | min = max; |
260 | max += iclus[i]; | |
261 | deltax = GetSeg()->Dpx(0); | |
262 | if (iclus[i]!=1){ | |
263 | //cluster with more than one digit | |
264 | nd=iclus[i]; | |
265 | ndig=(Double_t) nd; | |
266 | Int_t count=0; | |
267 | for (k=min;k<min+nd;k++){ | |
268 | xpad[count] = digx[k]; | |
269 | zpad[count] = digz[k]; | |
9e1e0cd7 | 270 | |
aacedc3e | 271 | tr1pad[count] = digtr1[k]; |
272 | tr2pad[count] = digtr2[k]; | |
273 | tr3pad[count] = digtr3[k]; | |
274 | tr4pad[count] = digtr4[k]; | |
275 | ||
276 | count++; | |
277 | } // end for k | |
278 | ndxmin = xpad[TMath::LocMin(nd,xpad)]; | |
279 | ndxmax = xpad[TMath::LocMax(nd,xpad)]; | |
280 | ndzmin = zpad[TMath::LocMin(nd,zpad)]; | |
281 | ndzmax = zpad[TMath::LocMax(nd,zpad)]; | |
282 | ndx = ndxmax - ndxmin+1; | |
283 | ndz = ndzmax - ndzmin+1; | |
284 | ||
285 | // calculate x and z coordinates of the center of the cluster | |
286 | GetSeg()->GetPadCxz(digx[min],digz[min]-1,xdum, zdum); | |
287 | ||
288 | if (ndx == 1) { | |
289 | xcenter[i] = xdum; | |
290 | }else{ | |
291 | xcenter[i] = 0.; | |
292 | for (k=0;k<nd;k++) { | |
293 | GetSeg()->GetPadCxz(xpad[k],zpad[k]-1,xdum,zdum); | |
294 | xcenter[i] += (xdum / nd); | |
295 | } // end for k | |
296 | } // end if ndx | |
297 | ||
298 | if (ndz == 1) { | |
299 | zcenter[i] = zdum; | |
300 | } else { | |
301 | zcenter[i] = 0.; | |
302 | for (k=0;k<nd;k++) { | |
303 | GetSeg()->GetPadCxz(xpad[k],zpad[k]-1,xdum,zdum); | |
304 | zcenter[i] += (zdum / nd); | |
305 | } // end for k | |
306 | } // end if ndz | |
307 | ||
308 | // error on points in x and z directions | |
309 | ||
310 | if (ndx == 1) { | |
311 | errxcenter[i] = deltax / TMath::Sqrt(12.); | |
312 | } else { | |
313 | errxcenter[i] = 0.; | |
314 | for (k=0;k<nd;k++){ | |
315 | GetSeg()->GetPadCxz(xpad[k],zpad[k]-1,xdum,zdum); | |
316 | errxcenter[i] += ((xdum-xcenter[i])*(xdum-xcenter[i]))/ | |
317 | (nd*(nd-1)); | |
318 | } // end for k | |
319 | errxcenter[i] = TMath::Sqrt(errxcenter[i]); | |
320 | } // end if ndx | |
321 | if (ndz == 1) { | |
322 | deltaz = GetSeg()->Dpz(digz[min]); | |
323 | errzcenter[i] = deltaz / TMath::Sqrt(12.); | |
324 | } else { | |
325 | errzcenter[i] = 0.; | |
326 | for (k=0;k<nd;k++){ | |
327 | GetSeg()->GetPadCxz(xpad[k],zpad[k]-1,xdum,zdum); | |
328 | errzcenter[i] += ((zdum-zcenter[i])*(zdum-zcenter[i]))/ | |
329 | (nd*(nd-1)); | |
330 | } // end for k | |
331 | errzcenter[i] = TMath::Sqrt(errzcenter[i]); | |
332 | } // end if ndz | |
333 | // take three track numbers for the cluster | |
334 | // choose the track numbers of the digit with higher signal | |
335 | kmax = 0; | |
336 | sigmax = 0; | |
337 | for (k=0;k<nd;k++){ | |
338 | if(tr4pad[k] > sigmax){ | |
339 | sigmax = tr4pad[k]; | |
340 | kmax = k; | |
341 | } // end if tr4pad[k] | |
342 | } // end for k | |
343 | if(sigmax != 0) { | |
344 | tr1clus[i]= tr1pad[kmax]; | |
345 | tr2clus[i]= tr2pad[kmax]; | |
346 | tr3clus[i]= tr3pad[kmax]; | |
347 | } else { | |
348 | tr1clus[i]= -2; | |
349 | tr2clus[i]= -2; | |
350 | tr3clus[i]= -2; | |
351 | } // end if sigmax | |
352 | } else { | |
353 | // cluster with single digit | |
354 | ndig= 1.; | |
355 | ndx = 1; | |
356 | ndz = 1; | |
357 | GetSeg()->GetPadCxz(digx[min],digz[min]-1,xdum,zdum); | |
358 | xcenter[i] = xdum; | |
359 | zcenter[i] = zdum; | |
360 | tr1clus[i]=digtr1[min]; | |
361 | tr2clus[i]=digtr2[min]; | |
362 | tr3clus[i]=digtr3[min]; | |
363 | deltaz = GetSeg()->Dpz(digz[min]); | |
364 | errxcenter[i] = deltax / TMath::Sqrt(12.); | |
365 | errzcenter[i] = deltaz / TMath::Sqrt(12.); | |
366 | } // end if iclus[i] | |
9e1e0cd7 | 367 | |
aacedc3e | 368 | // store the cluster information to the AliITSRawCLusterSPD object |
04366a57 | 369 | |
9e1e0cd7 | 370 | |
aacedc3e | 371 | //put the cluster center in local reference frame of the detector |
372 | // and in microns | |
373 | xcenter[i] = xcenter[i] - GetSeg()->Dx()/2.; | |
374 | zcenter[i] = zcenter[i] - GetSeg()->Dz()/2.; | |
9e1e0cd7 | 375 | |
aacedc3e | 376 | AliITSRawClusterSPD *clust = new AliITSRawClusterSPD(zcenter[i], //f |
377 | xcenter[i], //f | |
378 | ndig, //f | |
379 | ndz,ndx, //ii | |
380 | ndxmin,ndxmax,//ii | |
381 | (Double_t) ndzmin, | |
382 | (Double_t) ndzmax, | |
383 | 0,GetModule()); | |
7d62fb64 | 384 | fDetTypeRec->AddCluster(0,clust); |
aacedc3e | 385 | delete clust; |
9e1e0cd7 | 386 | }//end loop on clusters |
387 | delete[] ifpad; | |
388 | delete[] xpad ; | |
389 | delete[] zpad ; | |
390 | delete[] iclus; | |
391 | delete[] tr1pad; | |
392 | delete[] tr2pad; | |
393 | delete[] tr3pad; | |
394 | delete[] tr4pad; | |
c98c0281 | 395 | } |
9e1e0cd7 | 396 | //______________________________________________________---------------- |
c98c0281 | 397 | void AliITSClusterFinderSPD::DigitToPoint(Int_t nclus, |
aacedc3e | 398 | Double_t *xcenter,Double_t *zcenter, |
399 | Double_t *errxcenter, | |
400 | Double_t *errzcenter, | |
9e1e0cd7 | 401 | Int_t *tr1clus, Int_t *tr2clus, |
402 | Int_t *tr3clus){ | |
403 | // A point is associated to each cluster of SPD digits. The points | |
404 | // and their associated errors are stored in the file galiceSP.root. | |
aacedc3e | 405 | Double_t l[3],xg,zg; |
406 | const Double_t kconv = 1.0e-4; // micron -> cm | |
9e1e0cd7 | 407 | |
00a7cc50 | 408 | Int_t lay,lad,det; |
409 | fDetTypeRec->GetITSgeom()->GetModuleId(fModule,lay,lad,det); | |
410 | Int_t ind=(lad-1)*fDetTypeRec->GetITSgeom()->GetNdetectors(lay)+(det-1); | |
411 | Int_t lyr=(lay-1); | |
9e1e0cd7 | 412 | // get rec points |
9e1e0cd7 | 413 | for (Int_t i=0; i<nclus; i++){ |
c98c0281 | 414 | l[0] = kconv*xcenter[i]; |
aacedc3e | 415 | l[1] = kconv*GetSeg()->Dy()/2.; |
c98c0281 | 416 | l[2] = kconv*zcenter[i]; |
417 | ||
418 | xg = l[0]; | |
419 | zg = l[2]; | |
420 | ||
aacedc3e | 421 | Double_t sigma2x = (kconv*errxcenter[i]) * (kconv*errxcenter[i]); |
422 | Double_t sigma2z = (kconv*errzcenter[i]) * (kconv*errzcenter[i]); | |
75fb37cc | 423 | |
424 | Int_t lab[4] = {tr1clus[i],tr2clus[i],tr3clus[i],ind}; | |
425 | Float_t hit[5] = {xg,zg,sigma2x,sigma2z,1.0}; | |
426 | Int_t info[3] = {0,0,lyr}; | |
427 | ||
428 | AliITSRecPoint rnew(lab,hit,info,kTRUE); | |
c98c0281 | 429 | rnew.SetdEdX(0.); |
75fb37cc | 430 | |
7d62fb64 | 431 | fDetTypeRec->AddRecPoint(rnew); |
9e1e0cd7 | 432 | } // end for i |
c98c0281 | 433 | } |