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