]>
Commit | Line | Data |
---|---|---|
b0f5e3fc | 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 | ||
17 | #include "AliITSClusterFinderSPD.h" | |
e8189707 | 18 | #include "AliITSMapA1.h" |
19 | #include "AliITS.h" | |
e5a1716a | 20 | #include "AliITSdigit.h" |
21 | #include "AliITSRawCluster.h" | |
22 | #include "AliITSRecPoint.h" | |
23 | #include "AliITSsegmentation.h" | |
24 | #include "AliITSresponse.h" | |
b0f5e3fc | 25 | #include "AliRun.h" |
26 | ||
27 | ||
28 | ||
29 | ClassImp(AliITSClusterFinderSPD) | |
30 | ||
31 | //---------------------------------------------------------- | |
32 | AliITSClusterFinderSPD::AliITSClusterFinderSPD | |
33 | (AliITSsegmentation *seg, TClonesArray *digits, TClonesArray *recp) | |
34 | { | |
35 | // constructor | |
36 | fSegmentation=seg; | |
37 | fDigits=digits; | |
38 | fClusters=recp; | |
39 | fNclusters= fClusters->GetEntriesFast(); | |
40 | SetDx(); | |
41 | SetDz(); | |
e5a1716a | 42 | fMap=new AliITSMapA1(fSegmentation,fDigits); |
b0f5e3fc | 43 | SetNCells(); |
44 | } | |
45 | ||
46 | //_____________________________________________________________________________ | |
47 | AliITSClusterFinderSPD::AliITSClusterFinderSPD() | |
48 | { | |
49 | // constructor | |
50 | fSegmentation=0; | |
51 | fDigits=0; | |
52 | fClusters=0; | |
53 | fNclusters=0; | |
e8189707 | 54 | fMap=0; |
b0f5e3fc | 55 | SetDx(); |
56 | SetDz(); | |
b0f5e3fc | 57 | SetNCells(); |
58 | ||
59 | } | |
60 | ||
e8189707 | 61 | //_____________________________________________________________________________ |
62 | AliITSClusterFinderSPD::~AliITSClusterFinderSPD() | |
63 | { | |
64 | // destructor | |
65 | if (fMap) delete fMap; | |
66 | ||
67 | ||
68 | } | |
b0f5e3fc | 69 | //__________________________________________________________________________ |
70 | AliITSClusterFinderSPD::AliITSClusterFinderSPD(const AliITSClusterFinderSPD &source){ | |
71 | // Copy Constructor | |
72 | if(&source == this) return; | |
73 | this->fClusters = source.fClusters ; | |
74 | this->fNclusters = source.fNclusters ; | |
75 | this->fMap = source.fMap ; | |
76 | this->fDz = source.fDz ; | |
77 | this->fDx = source.fDx ; | |
78 | this->fMinNCells = source.fMinNCells ; | |
79 | return; | |
80 | } | |
81 | ||
82 | //_________________________________________________________________________ | |
83 | AliITSClusterFinderSPD& | |
84 | AliITSClusterFinderSPD::operator=(const AliITSClusterFinderSPD &source) { | |
85 | // Assignment operator | |
86 | if(&source == this) return *this; | |
87 | this->fClusters = source.fClusters ; | |
88 | this->fNclusters = source.fNclusters ; | |
89 | this->fMap = source.fMap ; | |
90 | this->fDz = source.fDz ; | |
91 | this->fDx = source.fDx ; | |
92 | this->fMinNCells = source.fMinNCells ; | |
93 | return *this; | |
94 | } | |
95 | ||
96 | //_____________________________________________________________________________ | |
97 | void AliITSClusterFinderSPD::SetMap() | |
98 | { | |
99 | // set map | |
a3e16987 | 100 | |
b0f5e3fc | 101 | if(!fMap) fMap=new AliITSMapA1(fSegmentation,fDigits); |
a3e16987 | 102 | |
b0f5e3fc | 103 | } |
104 | ||
105 | //_____________________________________________________________________________ | |
106 | ||
107 | void AliITSClusterFinderSPD::Find1DClusters() | |
108 | { | |
109 | // Find one dimensional clusters, i.e. | |
110 | // in r*phi(x) direction for each colunm in z direction | |
111 | ||
112 | AliITS *iTS=(AliITS*)gAlice->GetModule("ITS"); | |
113 | ||
114 | // retrieve the parameters | |
115 | Int_t fNofPixels = fSegmentation->Npz(); | |
116 | Int_t fMaxNofSamples = fSegmentation->Npx(); | |
117 | ||
118 | // read in digits -> do not apply threshold | |
119 | // signal in fired pixels is always 1 | |
a3e16987 | 120 | |
b0f5e3fc | 121 | fMap->FillMap(); |
122 | ||
123 | Int_t nofFoundClusters = 0; | |
124 | ||
125 | Int_t k,it,m; | |
126 | for(k=0;k<fNofPixels;k++) { | |
127 | ||
128 | Int_t mmax = 10; // a size of the window for the cluster finding | |
129 | ||
130 | for(it=0;it<fMaxNofSamples;it++) { | |
131 | ||
132 | Int_t lclx = 0; | |
133 | Int_t xstart = 0; | |
134 | Int_t xstop = 0; | |
135 | Int_t id = 0; | |
136 | Int_t ilcl =0; | |
137 | ||
138 | for(m=0;m<mmax;m++) { // find the cluster inside the window | |
139 | id = it+m; | |
140 | if(id >= fMaxNofSamples) break; // ! no possible for the fadc | |
141 | ||
e8189707 | 142 | if(fMap->TestHit(k,id) == kUnused) { // start of the cluster |
b0f5e3fc | 143 | lclx += 1; |
144 | if(lclx == 1) xstart = id; | |
145 | ||
146 | } | |
147 | ||
e8189707 | 148 | if(lclx > 0 && fMap->TestHit(k,id) == kEmpty) { |
b0f5e3fc | 149 | // end of cluster if a gap exists |
150 | xstop = id-1; | |
151 | ilcl = 1; | |
152 | break; | |
153 | } | |
154 | ||
155 | } // end of m-loop | |
156 | ||
157 | if(lclx == 0 && ilcl == 0) it = id; // no cluster in the window, | |
158 | // continue the "it" loop | |
159 | ||
160 | if(id >= fMaxNofSamples && lclx == 0) break; // the x row finished | |
161 | ||
162 | if(id < fMaxNofSamples && ilcl == 0 && lclx > 0) { | |
e8189707 | 163 | // cluster end is outside of the window, |
b0f5e3fc | 164 | mmax += 5; // increase mmax and repeat the cluster |
e8189707 | 165 | // finding |
b0f5e3fc | 166 | it -= 1; |
167 | } | |
168 | ||
169 | if(id >= fMaxNofSamples && lclx > 0) { // the x row finished but | |
e8189707 | 170 | xstop = fMaxNofSamples - 1; // the end cluster exists |
b0f5e3fc | 171 | ilcl = 1; |
172 | } | |
173 | ||
174 | // --- Calculate z and x coordinates for one dimensional clusters | |
175 | ||
176 | if(ilcl == 1) { // new cluster exists | |
177 | it = id; | |
178 | mmax = 10; | |
179 | nofFoundClusters++; | |
180 | Float_t clusterCharge = 0.; | |
b0f5e3fc | 181 | Float_t zpitch = fSegmentation->Dpz(k+1); |
182 | Float_t clusterZ, dummyX; | |
183 | Int_t dummy=0; | |
e8189707 | 184 | fSegmentation->GetPadCxz(dummy,k,dummyX,clusterZ); |
b0f5e3fc | 185 | Float_t zstart = clusterZ - 0.5*zpitch; |
186 | Float_t zstop = clusterZ + 0.5*zpitch; | |
187 | Float_t clusterX = 0.; | |
188 | Int_t xstartfull = xstart; | |
189 | Int_t xstopfull = xstop; | |
190 | Int_t clusterSizeX = lclx; | |
191 | Int_t clusterSizeZ = 1; | |
192 | ||
193 | Int_t its; | |
194 | for(its=xstart; its<=xstop; its++) { | |
195 | Int_t firedpixel=0; | |
e8189707 | 196 | if (fMap->GetHitIndex(k,its)>=0) firedpixel=1; |
b0f5e3fc | 197 | clusterCharge += firedpixel; |
198 | clusterX +=its + 0.5; | |
199 | } | |
200 | Float_t fRphiPitch = fSegmentation->Dpx(dummy); | |
201 | clusterX /= (clusterSizeX/fRphiPitch); // center of gravity for x | |
202 | ||
203 | ||
204 | //printf("ClusterZ ClusterX %f %f \n",clusterZ, clusterX); | |
205 | ||
206 | // Int_t nclusters = fClusters->GetEntriesFast(); | |
207 | // cout << nclusters << " clusters" << endl; | |
208 | // cout<< "Create point"<<endl; | |
209 | ||
210 | // Write the points (coordinates and some cluster information) to the | |
211 | // AliITSRawClusterSPD object | |
212 | ||
213 | AliITSRawClusterSPD *clust = new AliITSRawClusterSPD(clusterZ,clusterX,clusterCharge,clusterSizeZ,clusterSizeX,xstart,xstop,xstartfull,xstopfull,zstart,zstop,k); | |
214 | // fClusters->Add(point); | |
215 | iTS->AddCluster(0,clust); | |
216 | // cout << "Cluster at Ladder: " << fLadder << ", Detector: " <<fDetector<<endl; | |
217 | ||
218 | // cout<<" end of cluster finding for Z pixel "<<endl; | |
219 | ||
220 | } // new cluster (ilcl=1) | |
221 | } // X direction loop (it) | |
222 | } // Z direction loop (k) | |
e8189707 | 223 | |
224 | //fMap->ClearMap(); | |
b0f5e3fc | 225 | return; |
226 | ||
227 | } | |
228 | ||
229 | //_____________________________________________________________________________ | |
230 | void AliITSClusterFinderSPD::GroupClusters() | |
231 | { | |
232 | // Find two dimensional clusters, i.e. group one dimensional clusters | |
233 | // into two dimensional ones (go both in x and z directions). | |
234 | ||
235 | // get number of clusters for this module | |
236 | Int_t nofClusters = fClusters->GetEntriesFast(); | |
237 | nofClusters -= fNclusters; | |
b0f5e3fc | 238 | |
239 | AliITSRawClusterSPD *clusterI; | |
240 | AliITSRawClusterSPD *clusterJ; | |
241 | ||
e8189707 | 242 | Int_t *label=new Int_t[nofClusters]; |
b0f5e3fc | 243 | Int_t i,j; |
244 | for(i=0; i<nofClusters; i++) label[i] = 0; | |
245 | for(i=0; i<nofClusters; i++) { | |
246 | if(label[i] != 0) continue; | |
247 | for(j=i+1; j<nofClusters; j++) { | |
248 | if(label[j] != 0) continue; | |
249 | clusterI = (AliITSRawClusterSPD*) fClusters->At(i); | |
250 | clusterJ = (AliITSRawClusterSPD*) fClusters->At(j); | |
251 | Bool_t pair = clusterI->Brother(clusterJ,fDz,fDx); | |
252 | if(pair) { | |
253 | ||
254 | // if((clusterI->XStop() == clusterJ->XStart()-1)||(clusterI->XStart()==clusterJ->XStop()+1)) cout<<"!! Diagonal cluster"<<endl; | |
e5a1716a | 255 | /* |
256 | cout << "clusters " << i << "," << j << " before grouping" << endl; | |
e8189707 | 257 | clusterI->PrintInfo(); |
258 | clusterJ->PrintInfo(); | |
b0f5e3fc | 259 | */ |
260 | clusterI->Add(clusterJ); | |
261 | // cout << "remove cluster " << j << endl; | |
262 | label[j] = 1; | |
263 | fClusters->RemoveAt(j); | |
264 | /* | |
265 | cout << "cluster " << i << " after grouping" << endl; | |
e8189707 | 266 | clusterI->PrintInfo(); |
b0f5e3fc | 267 | */ |
268 | } // pair | |
269 | } // J clusters | |
270 | label[i] = 1; | |
271 | } // I clusters | |
272 | fClusters->Compress(); | |
a3e16987 | 273 | // Int_t totalNofClusters = fClusters->GetEntriesFast(); |
274 | // cout << " Nomber of clusters at the group end ="<< totalNofClusters<<endl; | |
b0f5e3fc | 275 | |
dccfe216 | 276 | delete [] label; |
e8189707 | 277 | |
b0f5e3fc | 278 | return; |
279 | ||
280 | ||
281 | } | |
282 | //_____________________________________________________________________________ | |
283 | ||
a3e16987 | 284 | void AliITSClusterFinderSPD::TracksInCluster() |
285 | { | |
286 | ||
287 | // Find tracks creating one cluster | |
288 | ||
289 | // get number of clusters for this module | |
290 | Int_t nofClusters = fClusters->GetEntriesFast(); | |
291 | nofClusters -= fNclusters; | |
292 | ||
e5a1716a | 293 | //printf("nofClusters fNclusters %d %d\n",nofClusters,fNclusters); //commented 18-09-00 |
294 | ||
a3e16987 | 295 | Int_t i, ix, iz, jx, jz, xstart, xstop, zstart, zstop, nclx, nclz; |
296 | // Int_t signal, track0, track1, track2; | |
d4e03339 | 297 | const Int_t trmax = 100; |
a3e16987 | 298 | Int_t cltracks[trmax], itr, tracki, ii, is, js, ie, ntr, tr0, tr1, tr2; |
299 | ||
300 | for(i=0; i<nofClusters; i++) { | |
301 | ii = 0; | |
302 | memset(cltracks,-1,sizeof(int)*trmax); | |
e5a1716a | 303 | tr0=tr1=tr2=-3; |
a3e16987 | 304 | |
305 | AliITSRawClusterSPD *clusterI = (AliITSRawClusterSPD*) fClusters->At(i); | |
e5a1716a | 306 | //printf("clusterI %p\n",clusterI); //commented 18-09-00 |
a3e16987 | 307 | |
308 | nclx = clusterI->NclX(); | |
309 | nclz = clusterI->NclZ(); | |
310 | xstart = clusterI->XStartf(); | |
311 | xstop = clusterI->XStopf(); | |
312 | zstart = clusterI->Zend()-nclz+1; | |
313 | zstop = clusterI->Zend(); | |
314 | ||
315 | Int_t ind; | |
316 | ||
317 | for(iz=0; iz<nclz; iz++) { | |
318 | jz = zstart + iz; | |
319 | for(ix=0; ix<nclx; ix++) { | |
320 | jx = xstart + ix; | |
321 | ind = fMap->GetHitIndex(jz,jx); | |
e5a1716a | 322 | //printf("ind %d\n",ind); // commented 18-09-00 |
323 | // this part must be wrong - the index of the digit | |
324 | // can be zero but not -1 !!! comment out this part | |
325 | // and replace it - see below | |
326 | /* | |
a3e16987 | 327 | if(ind == 0 && iz >= 0 && ix > 0) { |
328 | continue; | |
329 | } | |
330 | if(ind == 0 && iz > 0 && ix >= 0) { | |
331 | continue; | |
332 | } | |
333 | if(ind == 0 && iz == 0 && ix == 0 && i > 0) { | |
334 | continue; | |
335 | } | |
e5a1716a | 336 | */ |
337 | // change the conditions above to : | |
338 | if (ind < 0) continue; | |
a3e16987 | 339 | |
340 | AliITSdigitSPD *dig = (AliITSdigitSPD*)fMap->GetHit(jz,jx); | |
e5a1716a | 341 | if (!dig) printf("SPD: something wrong ! dig %p\n",dig); |
a3e16987 | 342 | /* |
343 | signal=dig->fSignal; | |
344 | track0=dig->fTracks[0]; | |
345 | track1=dig->fTracks[1]; | |
346 | track2=dig->fTracks[2]; | |
347 | */ | |
348 | for(itr=0; itr<3; itr++) { | |
349 | tracki = dig->fTracks[itr]; | |
e5a1716a | 350 | //printf("tracki %d\n",tracki); //commented 18-09-00 |
a3e16987 | 351 | if(tracki >= 0) { |
352 | ii += 1; | |
353 | cltracks[ii-1] = tracki; | |
354 | } | |
355 | } | |
356 | } // ix pixel | |
357 | } // iz pixel | |
358 | ||
359 | for(is=0; is<trmax; is++) { | |
360 | if(cltracks[is]<0) continue; | |
361 | for(js=is+1; js<trmax; js++) { | |
362 | if(cltracks[js]<0) continue; | |
363 | if(cltracks[js]==cltracks[is]) cltracks[js]=-5; | |
364 | } | |
365 | } | |
366 | ||
367 | ntr = 0; | |
368 | for(ie=0; ie<trmax; ie++) { | |
369 | if(cltracks[ie] >= 0) { | |
370 | ntr=ntr+1; | |
371 | if(ntr==1) tr0=cltracks[ie]; | |
372 | if(ntr==2) tr1=cltracks[ie]; | |
373 | if(ntr==3) tr2=cltracks[ie]; | |
374 | } | |
375 | } | |
376 | // if delta ray only | |
377 | if(ntr == 0) ntr = 1; | |
378 | ||
379 | clusterI->SetNTracks(ntr); | |
380 | clusterI->SetTracks(tr0,tr1,tr2); | |
381 | ||
382 | } // I cluster | |
383 | ||
384 | } | |
385 | //_____________________________________________________________________________ | |
386 | ||
b0f5e3fc | 387 | void AliITSClusterFinderSPD::GetRecPoints() |
388 | { | |
389 | // get rec points | |
390 | AliITS *iTS=(AliITS*)gAlice->GetModule("ITS"); | |
391 | ||
392 | // get number of clusters for this module | |
393 | Int_t nofClusters = fClusters->GetEntriesFast(); | |
394 | nofClusters -= fNclusters; | |
b0f5e3fc | 395 | const Float_t kconv = 1.0e-4; |
396 | const Float_t kRMSx = 12.0*kconv; // microns -> cm ITS TDR Table 1.3 | |
21d3c626 | 397 | const Float_t kRMSz = 120.0*kconv; // resolution for 425 micron pixel |
b0f5e3fc | 398 | |
e8189707 | 399 | Float_t spdLength = fSegmentation->Dz(); |
400 | Float_t spdWidth = fSegmentation->Dx(); | |
401 | ||
a3e16987 | 402 | Int_t i; |
403 | Int_t track0, track1, track2; | |
404 | ||
b0f5e3fc | 405 | for(i=0; i<nofClusters; i++) { |
a3e16987 | 406 | |
b0f5e3fc | 407 | AliITSRawClusterSPD *clusterI = (AliITSRawClusterSPD*) fClusters->At(i); |
a3e16987 | 408 | clusterI->GetTracks(track0, track1, track2); |
b0f5e3fc | 409 | AliITSRecPoint rnew; |
a3e16987 | 410 | |
e8189707 | 411 | rnew.SetX((clusterI->X() - spdWidth/2)*kconv); |
412 | rnew.SetZ((clusterI->Z() - spdLength/2)*kconv); | |
b0f5e3fc | 413 | rnew.SetQ(1.); |
414 | rnew.SetdEdX(0.); | |
415 | rnew.SetSigmaX2(kRMSx*kRMSx); | |
416 | rnew.SetSigmaZ2(kRMSz*kRMSz); | |
a3e16987 | 417 | rnew.fTracks[0]=track0; |
418 | rnew.fTracks[1]=track1; | |
419 | rnew.fTracks[2]=track2; | |
b0f5e3fc | 420 | iTS->AddRecPoint(rnew); |
421 | } // I clusters | |
e8189707 | 422 | |
423 | fMap->ClearMap(); | |
b0f5e3fc | 424 | |
425 | } | |
426 | //_____________________________________________________________________________ | |
427 | ||
428 | void AliITSClusterFinderSPD::FindRawClusters() | |
429 | { | |
430 | // find raw clusters | |
431 | Find1DClusters(); | |
432 | GroupClusters(); | |
a3e16987 | 433 | TracksInCluster(); |
b0f5e3fc | 434 | GetRecPoints(); |
e8189707 | 435 | |
b0f5e3fc | 436 | } |
437 |