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