]>
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 | **************************************************************************/ | |
48058160 | 15 | /* |
16 | $Id$ | |
17 | $Log$ | |
507cf1a7 | 18 | Revision 1.30 2003/03/03 16:34:35 masera |
19 | Corrections to comply with coding conventions | |
20 | ||
bf3f2830 | 21 | Revision 1.29 2002/10/25 18:54:22 barbera |
22 | Various improvements and updates from B.S.Nilsen and T. Virgili | |
23 | ||
f8d9a5b8 | 24 | Revision 1.28 2002/10/22 14:45:29 alibrary |
25 | Introducing Riostream.h | |
26 | ||
4ae5bbc4 | 27 | Revision 1.27 2002/10/14 14:57:00 hristov |
28 | Merging the VirtualMC branch to the main development branch (HEAD) | |
29 | ||
b9d0a01d | 30 | Revision 1.23.4.2 2002/10/14 13:14:07 hristov |
31 | Updating VirtualMC to v3-09-02 | |
32 | ||
33 | Revision 1.26 2002/09/09 17:23:28 nilsen | |
34 | Minor changes in support of changes to AliITSdigitS?D class'. | |
35 | ||
ee86d557 | 36 | Revision 1.25 2002/05/10 22:29:40 nilsen |
37 | Change my Massimo Masera in the default constructor to bring things into | |
38 | compliance. | |
39 | ||
355ccb70 | 40 | Revision 1.24 2002/04/24 22:02:31 nilsen |
41 | New SDigits and Digits routines, and related changes, (including new | |
42 | noise values). | |
43 | ||
48058160 | 44 | */ |
bf3f2830 | 45 | // |
46 | // Cluster finder | |
47 | // for Silicon | |
48 | // Drift Detector | |
49 | // | |
4ae5bbc4 | 50 | #include <Riostream.h> |
bf3f2830 | 51 | |
a1f090e0 | 52 | #include <TMath.h> |
53 | #include <math.h> | |
b0f5e3fc | 54 | |
55 | #include "AliITSClusterFinderSDD.h" | |
e8189707 | 56 | #include "AliITSMapA1.h" |
57 | #include "AliITS.h" | |
78a228db | 58 | #include "AliITSdigit.h" |
59 | #include "AliITSRawCluster.h" | |
60 | #include "AliITSRecPoint.h" | |
61 | #include "AliITSsegmentation.h" | |
5dd4cc39 | 62 | #include "AliITSresponseSDD.h" |
b0f5e3fc | 63 | #include "AliRun.h" |
64 | ||
b0f5e3fc | 65 | ClassImp(AliITSClusterFinderSDD) |
66 | ||
42da2935 | 67 | //______________________________________________________________________ |
68 | AliITSClusterFinderSDD::AliITSClusterFinderSDD(AliITSsegmentation *seg, | |
50d05d7b | 69 | AliITSresponse *response, |
70 | TClonesArray *digits, | |
71 | TClonesArray *recp){ | |
42da2935 | 72 | // standard constructor |
78a228db | 73 | |
b48af428 | 74 | fSegmentation = seg; |
75 | fResponse = response; | |
76 | fDigits = digits; | |
77 | fClusters = recp; | |
78 | fNclusters = fClusters->GetEntriesFast(); | |
b0f5e3fc | 79 | SetCutAmplitude(); |
80 | SetDAnode(); | |
81 | SetDTime(); | |
355ccb70 | 82 | SetMinPeak((Int_t)(((AliITSresponseSDD*)fResponse)->GetNoiseAfterElectronics()*5)); |
83 | // SetMinPeak(); | |
78a228db | 84 | SetMinNCells(); |
85 | SetMaxNCells(); | |
86 | SetTimeCorr(); | |
a1f090e0 | 87 | SetMinCharge(); |
b48af428 | 88 | fMap = new AliITSMapA1(fSegmentation,fDigits,fCutAmplitude); |
b0f5e3fc | 89 | } |
42da2935 | 90 | //______________________________________________________________________ |
91 | AliITSClusterFinderSDD::AliITSClusterFinderSDD(){ | |
92 | // default constructor | |
b0f5e3fc | 93 | |
b48af428 | 94 | fSegmentation = 0; |
95 | fResponse = 0; | |
96 | fDigits = 0; | |
97 | fClusters = 0; | |
98 | fNclusters = 0; | |
99 | fMap = 0; | |
100 | fCutAmplitude = 0; | |
355ccb70 | 101 | fDAnode = 0; |
102 | fDTime = 0; | |
103 | fMinPeak = 0; | |
104 | fMinNCells = 0; | |
105 | fMaxNCells = 0; | |
106 | fTimeCorr = 0; | |
107 | fMinCharge = 0; | |
108 | /* | |
b0f5e3fc | 109 | SetDAnode(); |
110 | SetDTime(); | |
48058160 | 111 | SetMinPeak((Int_t)(((AliITSresponseSDD*)fResponse)->GetNoiseAfterElectronics()*5)); |
78a228db | 112 | SetMinNCells(); |
113 | SetMaxNCells(); | |
114 | SetTimeCorr(); | |
a1f090e0 | 115 | SetMinCharge(); |
355ccb70 | 116 | */ |
b0f5e3fc | 117 | } |
42da2935 | 118 | //____________________________________________________________________________ |
119 | AliITSClusterFinderSDD::~AliITSClusterFinderSDD(){ | |
e8189707 | 120 | // destructor |
121 | ||
122 | if(fMap) delete fMap; | |
e8189707 | 123 | } |
42da2935 | 124 | //______________________________________________________________________ |
125 | void AliITSClusterFinderSDD::SetCutAmplitude(Float_t nsigma){ | |
126 | // set the signal threshold for cluster finder | |
bf3f2830 | 127 | Float_t baseline,noise,noiseAfterEl; |
42da2935 | 128 | |
129 | fResponse->GetNoiseParam(noise,baseline); | |
bf3f2830 | 130 | noiseAfterEl = ((AliITSresponseSDD*)fResponse)->GetNoiseAfterElectronics(); |
131 | fCutAmplitude = (Int_t)((baseline + nsigma*noiseAfterEl)); | |
5dd4cc39 | 132 | } |
42da2935 | 133 | //______________________________________________________________________ |
134 | void AliITSClusterFinderSDD::Find1DClusters(){ | |
135 | // find 1D clusters | |
b48af428 | 136 | static AliITS *iTS = (AliITS*)gAlice->GetModule("ITS"); |
a1f090e0 | 137 | |
42da2935 | 138 | // retrieve the parameters |
b48af428 | 139 | Int_t fNofMaps = fSegmentation->Npz(); |
42da2935 | 140 | Int_t fMaxNofSamples = fSegmentation->Npx(); |
b48af428 | 141 | Int_t fNofAnodes = fNofMaps/2; |
142 | Int_t dummy = 0; | |
143 | Float_t fTimeStep = fSegmentation->Dpx(dummy); | |
144 | Float_t fSddLength = fSegmentation->Dx(); | |
145 | Float_t fDriftSpeed = fResponse->DriftSpeed(); | |
146 | Float_t anodePitch = fSegmentation->Dpz(dummy); | |
42da2935 | 147 | |
148 | // map the signal | |
50d05d7b | 149 | fMap->ClearMap(); |
42da2935 | 150 | fMap->SetThreshold(fCutAmplitude); |
151 | fMap->FillMap(); | |
a1f090e0 | 152 | |
42da2935 | 153 | Float_t noise; |
154 | Float_t baseline; | |
155 | fResponse->GetNoiseParam(noise,baseline); | |
a1f090e0 | 156 | |
42da2935 | 157 | Int_t nofFoundClusters = 0; |
158 | Int_t i; | |
159 | Float_t **dfadc = new Float_t*[fNofAnodes]; | |
160 | for(i=0;i<fNofAnodes;i++) dfadc[i] = new Float_t[fMaxNofSamples]; | |
b48af428 | 161 | Float_t fadc = 0.; |
42da2935 | 162 | Float_t fadc1 = 0.; |
163 | Float_t fadc2 = 0.; | |
164 | Int_t j,k,idx,l,m; | |
165 | for(j=0;j<2;j++) { | |
50d05d7b | 166 | for(k=0;k<fNofAnodes;k++) { |
167 | idx = j*fNofAnodes+k; | |
168 | // signal (fadc) & derivative (dfadc) | |
169 | dfadc[k][255]=0.; | |
170 | for(l=0; l<fMaxNofSamples; l++) { | |
171 | fadc2=(Float_t)fMap->GetSignal(idx,l); | |
172 | if(l>0) fadc1=(Float_t)fMap->GetSignal(idx,l-1); | |
173 | if(l>0) dfadc[k][l-1] = fadc2-fadc1; | |
174 | } // samples | |
175 | } // anodes | |
42da2935 | 176 | |
50d05d7b | 177 | for(k=0;k<fNofAnodes;k++) { |
178 | //cout << "Anode: " << k+1 << ", Wing: " << j+1 << endl; | |
179 | idx = j*fNofAnodes+k; | |
180 | Int_t imax = 0; | |
181 | Int_t imaxd = 0; | |
182 | Int_t it = 0; | |
183 | while(it <= fMaxNofSamples-3) { | |
184 | imax = it; | |
185 | imaxd = it; | |
186 | // maximum of signal | |
187 | Float_t fadcmax = 0.; | |
188 | Float_t dfadcmax = 0.; | |
189 | Int_t lthrmina = 1; | |
190 | Int_t lthrmint = 3; | |
191 | Int_t lthra = 1; | |
192 | Int_t lthrt = 0; | |
193 | for(m=0;m<20;m++) { | |
194 | Int_t id = it+m; | |
195 | if(id>=fMaxNofSamples) break; | |
196 | fadc=(float)fMap->GetSignal(idx,id); | |
197 | if(fadc > fadcmax) { fadcmax = fadc; imax = id;} | |
198 | if(fadc > (float)fCutAmplitude) { | |
199 | lthrt++; | |
200 | } // end if | |
201 | if(dfadc[k][id] > dfadcmax) { | |
202 | dfadcmax = dfadc[k][id]; | |
203 | imaxd = id; | |
204 | } // end if | |
205 | } // end for m | |
206 | it = imaxd; | |
207 | if(fMap->TestHit(idx,imax) == kEmpty) {it++; continue;} | |
208 | // cluster charge | |
209 | Int_t tstart = it-2; | |
210 | if(tstart < 0) tstart = 0; | |
211 | Bool_t ilcl = 0; | |
212 | if(lthrt >= lthrmint && lthra >= lthrmina) ilcl = 1; | |
213 | if(ilcl) { | |
214 | nofFoundClusters++; | |
215 | Int_t tstop = tstart; | |
216 | Float_t dfadcmin = 10000.; | |
217 | Int_t ij; | |
218 | for(ij=0; ij<20; ij++) { | |
219 | if(tstart+ij > 255) { tstop = 255; break; } | |
220 | fadc=(float)fMap->GetSignal(idx,tstart+ij); | |
221 | if((dfadc[k][tstart+ij] < dfadcmin) && | |
222 | (fadc > fCutAmplitude)) { | |
223 | tstop = tstart+ij+5; | |
224 | if(tstop > 255) tstop = 255; | |
225 | dfadcmin = dfadc[k][it+ij]; | |
226 | } // end if | |
227 | } // end for ij | |
42da2935 | 228 | |
50d05d7b | 229 | Float_t clusterCharge = 0.; |
230 | Float_t clusterAnode = k+0.5; | |
231 | Float_t clusterTime = 0.; | |
232 | Int_t clusterMult = 0; | |
233 | Float_t clusterPeakAmplitude = 0.; | |
234 | Int_t its,peakpos = -1; | |
235 | Float_t n, baseline; | |
236 | fResponse->GetNoiseParam(n,baseline); | |
237 | for(its=tstart; its<=tstop; its++) { | |
238 | fadc=(float)fMap->GetSignal(idx,its); | |
239 | if(fadc>baseline) fadc -= baseline; | |
240 | else fadc = 0.; | |
241 | clusterCharge += fadc; | |
242 | // as a matter of fact we should take the peak | |
243 | // pos before FFT | |
244 | // to get the list of tracks !!! | |
245 | if(fadc > clusterPeakAmplitude) { | |
246 | clusterPeakAmplitude = fadc; | |
247 | //peakpos=fMap->GetHitIndex(idx,its); | |
248 | Int_t shift = (int)(fTimeCorr/fTimeStep); | |
249 | if(its>shift && its<(fMaxNofSamples-shift)) | |
250 | peakpos = fMap->GetHitIndex(idx,its+shift); | |
251 | else peakpos = fMap->GetHitIndex(idx,its); | |
252 | if(peakpos<0) peakpos =fMap->GetHitIndex(idx,its); | |
253 | } // end if | |
254 | clusterTime += fadc*its; | |
255 | if(fadc > 0) clusterMult++; | |
256 | if(its == tstop) { | |
257 | clusterTime /= (clusterCharge/fTimeStep); // ns | |
258 | if(clusterTime>fTimeCorr) clusterTime -=fTimeCorr; | |
259 | //ns | |
260 | } // end if | |
261 | } // end for its | |
42da2935 | 262 | |
50d05d7b | 263 | Float_t clusteranodePath = (clusterAnode - fNofAnodes/2)* |
264 | anodePitch; | |
265 | Float_t clusterDriftPath = clusterTime*fDriftSpeed; | |
266 | clusterDriftPath = fSddLength-clusterDriftPath; | |
267 | if(clusterCharge <= 0.) break; | |
268 | AliITSRawClusterSDD clust(j+1,//i | |
269 | clusterAnode,clusterTime,//ff | |
270 | clusterCharge, //f | |
271 | clusterPeakAmplitude, //f | |
272 | peakpos, //i | |
273 | 0.,0.,clusterDriftPath,//fff | |
274 | clusteranodePath, //f | |
275 | clusterMult, //i | |
276 | 0,0,0,0,0,0,0);//7*i | |
277 | iTS->AddCluster(1,&clust); | |
278 | it = tstop; | |
279 | } // ilcl | |
280 | it++; | |
281 | } // while (samples) | |
282 | } // anodes | |
42da2935 | 283 | } // detectors (2) |
42da2935 | 284 | |
285 | for(i=0;i<fNofAnodes;i++) delete[] dfadc[i]; | |
286 | delete [] dfadc; | |
a1f090e0 | 287 | |
42da2935 | 288 | return; |
a1f090e0 | 289 | } |
50d05d7b | 290 | |
291 | ||
292 | ||
42da2935 | 293 | //______________________________________________________________________ |
294 | void AliITSClusterFinderSDD::Find1DClustersE(){ | |
24a1c341 | 295 | // find 1D clusters |
42da2935 | 296 | static AliITS *iTS=(AliITS*)gAlice->GetModule("ITS"); |
297 | // retrieve the parameters | |
298 | Int_t fNofMaps = fSegmentation->Npz(); | |
299 | Int_t fMaxNofSamples = fSegmentation->Npx(); | |
300 | Int_t fNofAnodes = fNofMaps/2; | |
301 | Int_t dummy=0; | |
302 | Float_t fTimeStep = fSegmentation->Dpx( dummy ); | |
303 | Float_t fSddLength = fSegmentation->Dx(); | |
304 | Float_t fDriftSpeed = fResponse->DriftSpeed(); | |
305 | Float_t anodePitch = fSegmentation->Dpz( dummy ); | |
306 | Float_t n, baseline; | |
307 | fResponse->GetNoiseParam( n, baseline ); | |
308 | // map the signal | |
50d05d7b | 309 | fMap->ClearMap(); |
42da2935 | 310 | fMap->SetThreshold( fCutAmplitude ); |
311 | fMap->FillMap(); | |
50d05d7b | 312 | |
42da2935 | 313 | Int_t nClu = 0; |
50d05d7b | 314 | // cout << "Search cluster... "<< endl; |
42da2935 | 315 | for( Int_t j=0; j<2; j++ ){ |
50d05d7b | 316 | for( Int_t k=0; k<fNofAnodes; k++ ){ |
317 | Int_t idx = j*fNofAnodes+k; | |
318 | Bool_t on = kFALSE; | |
319 | Int_t start = 0; | |
320 | Int_t nTsteps = 0; | |
321 | Float_t fmax = 0.; | |
322 | Int_t lmax = 0; | |
323 | Float_t charge = 0.; | |
324 | Float_t time = 0.; | |
325 | Float_t anode = k+0.5; | |
326 | Int_t peakpos = -1; | |
327 | for( Int_t l=0; l<fMaxNofSamples; l++ ){ | |
328 | Float_t fadc = (Float_t)fMap->GetSignal( idx, l ); | |
329 | if( fadc > 0.0 ){ | |
330 | if( on == kFALSE && l<fMaxNofSamples-4){ | |
331 | // star RawCluster (reset var.) | |
332 | Float_t fadc1 = (Float_t)fMap->GetSignal( idx, l+1 ); | |
333 | if( fadc1 < fadc ) continue; | |
334 | start = l; | |
335 | fmax = 0.; | |
336 | lmax = 0; | |
337 | time = 0.; | |
338 | charge = 0.; | |
339 | on = kTRUE; | |
340 | nTsteps = 0; | |
341 | } // end if on... | |
342 | nTsteps++ ; | |
343 | if( fadc > baseline ) fadc -= baseline; | |
344 | else fadc=0.; | |
345 | charge += fadc; | |
346 | time += fadc*l; | |
347 | if( fadc > fmax ){ | |
348 | fmax = fadc; | |
349 | lmax = l; | |
350 | Int_t shift = (Int_t)(fTimeCorr/fTimeStep + 0.5); | |
351 | if( l > shift && l < (fMaxNofSamples-shift) ) | |
352 | peakpos = fMap->GetHitIndex( idx, l+shift ); | |
353 | else | |
354 | peakpos = fMap->GetHitIndex( idx, l ); | |
355 | if( peakpos < 0) peakpos = fMap->GetHitIndex( idx, l ); | |
356 | } // end if fadc | |
357 | }else{ // end fadc>0 | |
358 | if( on == kTRUE ){ | |
359 | if( nTsteps > 2 ){ | |
360 | // min # of timesteps for a RawCluster | |
361 | // Found a RawCluster... | |
362 | Int_t stop = l-1; | |
363 | time /= (charge/fTimeStep); // ns | |
364 | // time = lmax*fTimeStep; // ns | |
365 | if( time > fTimeCorr ) time -= fTimeCorr; // ns | |
366 | Float_t anodePath = (anode - fNofAnodes/2)*anodePitch; | |
367 | Float_t driftPath = time*fDriftSpeed; | |
368 | driftPath = fSddLength-driftPath; | |
369 | AliITSRawClusterSDD clust(j+1,anode,time,charge, | |
370 | fmax, peakpos,0.,0., | |
371 | driftPath,anodePath, | |
372 | nTsteps,start,stop, | |
373 | start, stop, 1, k, k ); | |
374 | iTS->AddCluster( 1, &clust ); | |
375 | // clust.PrintInfo(); | |
376 | nClu++; | |
377 | } // end if nTsteps | |
378 | on = kFALSE; | |
379 | } // end if on==kTRUE | |
380 | } // end if fadc>0 | |
381 | } // samples | |
382 | } // anodes | |
42da2935 | 383 | } // wings |
50d05d7b | 384 | // cout << "# Rawclusters " << nClu << endl; |
42da2935 | 385 | return; |
a1f090e0 | 386 | } |
42da2935 | 387 | //_______________________________________________________________________ |
388 | Int_t AliITSClusterFinderSDD::SearchPeak(Float_t *spect,Int_t xdim,Int_t zdim, | |
50d05d7b | 389 | Int_t *peakX, Int_t *peakZ, |
390 | Float_t *peakAmp, Float_t minpeak ){ | |
42da2935 | 391 | // search peaks on a 2D cluster |
392 | Int_t npeak = 0; // # peaks | |
56fff130 | 393 | Int_t i,j; |
42da2935 | 394 | // search peaks |
395 | for( Int_t z=1; z<zdim-1; z++ ){ | |
48058160 | 396 | for( Int_t x=1; x<xdim-2; x++ ){ |
50d05d7b | 397 | Float_t sxz = spect[x*zdim+z]; |
398 | Float_t sxz1 = spect[(x+1)*zdim+z]; | |
399 | Float_t sxz2 = spect[(x-1)*zdim+z]; | |
400 | // search a local max. in s[x,z] | |
401 | if( sxz < minpeak || sxz1 <= 0 || sxz2 <= 0 ) continue; | |
402 | if( sxz >= spect[(x+1)*zdim+z ] && sxz >= spect[(x-1)*zdim+z ] && | |
403 | sxz >= spect[x*zdim +z+1] && sxz >= spect[x*zdim +z-1] && | |
404 | sxz >= spect[(x+1)*zdim+z+1] && sxz >= spect[(x+1)*zdim+z-1] && | |
405 | sxz >= spect[(x-1)*zdim+z+1] && sxz >= spect[(x-1)*zdim+z-1] ){ | |
406 | // peak found | |
407 | peakX[npeak] = x; | |
408 | peakZ[npeak] = z; | |
409 | peakAmp[npeak] = sxz; | |
410 | npeak++; | |
411 | } // end if .... | |
412 | } // end for x | |
42da2935 | 413 | } // end for z |
414 | // search groups of peaks with same amplitude. | |
415 | Int_t *flag = new Int_t[npeak]; | |
416 | for( i=0; i<npeak; i++ ) flag[i] = 0; | |
417 | for( i=0; i<npeak; i++ ){ | |
50d05d7b | 418 | for( j=0; j<npeak; j++ ){ |
419 | if( i==j) continue; | |
420 | if( flag[j] > 0 ) continue; | |
421 | if( peakAmp[i] == peakAmp[j] && | |
422 | TMath::Abs(peakX[i]-peakX[j])<=1 && | |
423 | TMath::Abs(peakZ[i]-peakZ[j])<=1 ){ | |
424 | if( flag[i] == 0) flag[i] = i+1; | |
425 | flag[j] = flag[i]; | |
426 | } // end if ... | |
427 | } // end for j | |
42da2935 | 428 | } // end for i |
50d05d7b | 429 | // make average of peak groups |
42da2935 | 430 | for( i=0; i<npeak; i++ ){ |
50d05d7b | 431 | Int_t nFlag = 1; |
432 | if( flag[i] <= 0 ) continue; | |
433 | for( j=0; j<npeak; j++ ){ | |
434 | if( i==j ) continue; | |
435 | if( flag[j] != flag[i] ) continue; | |
436 | peakX[i] += peakX[j]; | |
437 | peakZ[i] += peakZ[j]; | |
438 | nFlag++; | |
439 | npeak--; | |
440 | for( Int_t k=j; k<npeak; k++ ){ | |
441 | peakX[k] = peakX[k+1]; | |
442 | peakZ[k] = peakZ[k+1]; | |
443 | peakAmp[k] = peakAmp[k+1]; | |
444 | flag[k] = flag[k+1]; | |
445 | } // end for k | |
446 | j--; | |
447 | } // end for j | |
448 | if( nFlag > 1 ){ | |
449 | peakX[i] /= nFlag; | |
450 | peakZ[i] /= nFlag; | |
451 | } // end fi nFlag | |
42da2935 | 452 | } // end for i |
453 | delete [] flag; | |
454 | return( npeak ); | |
a1f090e0 | 455 | } |
42da2935 | 456 | //______________________________________________________________________ |
457 | void AliITSClusterFinderSDD::PeakFunc( Int_t xdim, Int_t zdim, Float_t *par, | |
50d05d7b | 458 | Float_t *spe, Float_t *integral){ |
24a1c341 | 459 | // function used to fit the clusters |
50d05d7b | 460 | // par -> parameters.. |
24a1c341 | 461 | // par[0] number of peaks. |
462 | // for each peak i=1, ..., par[0] | |
50d05d7b | 463 | // par[i] = Ampl. |
464 | // par[i+1] = xpos | |
465 | // par[i+2] = zpos | |
466 | // par[i+3] = tau | |
467 | // par[i+4] = sigma. | |
24a1c341 | 468 | Int_t electronics = fResponse->Electronics(); // 1 = PASCAL, 2 = OLA |
469 | const Int_t knParam = 5; | |
470 | Int_t npeak = (Int_t)par[0]; | |
42da2935 | 471 | |
24a1c341 | 472 | memset( spe, 0, sizeof( Float_t )*zdim*xdim ); |
42da2935 | 473 | |
24a1c341 | 474 | Int_t k = 1; |
42da2935 | 475 | for( Int_t i=0; i<npeak; i++ ){ |
24a1c341 | 476 | if( integral != 0 ) integral[i] = 0.; |
477 | Float_t sigmaA2 = par[k+4]*par[k+4]*2.; | |
bf3f2830 | 478 | Float_t t2 = par[k+3]; // PASCAL |
479 | if( electronics == 2 ) { t2 *= t2; t2 *= 2; } // OLA | |
42da2935 | 480 | for( Int_t z=0; z<zdim; z++ ){ |
481 | for( Int_t x=0; x<xdim; x++ ){ | |
24a1c341 | 482 | Float_t z2 = (z-par[k+2])*(z-par[k+2])/sigmaA2; |
483 | Float_t x2 = 0.; | |
484 | Float_t signal = 0.; | |
42da2935 | 485 | if( electronics == 1 ){ // PASCAL |
bf3f2830 | 486 | x2 = (x-par[k+1]+t2)/t2; |
42da2935 | 487 | signal = (x2>0.) ? par[k]*x2*exp(-x2+1.-z2) :0.0; // RCCR2 |
488 | // signal =(x2>0.) ? par[k]*x2*x2*exp(-2*x2+2.-z2 ):0.0;//RCCR | |
489 | }else if( electronics == 2 ) { // OLA | |
bf3f2830 | 490 | x2 = (x-par[k+1])*(x-par[k+1])/t2; |
50d05d7b | 491 | signal = par[k] * exp( -x2 - z2 ); |
492 | } else { | |
bf3f2830 | 493 | Warning("PeakFunc","Wrong SDD Electronics = %d",electronics); |
50d05d7b | 494 | // exit( 1 ); |
495 | } // end if electronicx | |
24a1c341 | 496 | spe[x*zdim+z] += signal; |
497 | if( integral != 0 ) integral[i] += signal; | |
42da2935 | 498 | } // end for x |
499 | } // end for z | |
24a1c341 | 500 | k += knParam; |
42da2935 | 501 | } // end for i |
24a1c341 | 502 | return; |
a1f090e0 | 503 | } |
42da2935 | 504 | //__________________________________________________________________________ |
505 | Float_t AliITSClusterFinderSDD::ChiSqr( Int_t xdim, Int_t zdim, Float_t *spe, | |
bf3f2830 | 506 | Float_t *speFit ) const{ |
42da2935 | 507 | // EVALUATES UNNORMALIZED CHI-SQUARED |
508 | Float_t chi2 = 0.; | |
509 | for( Int_t z=0; z<zdim; z++ ){ | |
50d05d7b | 510 | for( Int_t x=1; x<xdim-1; x++ ){ |
511 | Int_t index = x*zdim+z; | |
512 | Float_t tmp = spe[index] - speFit[index]; | |
513 | chi2 += tmp*tmp; | |
514 | } // end for x | |
42da2935 | 515 | } // end for z |
516 | return( chi2 ); | |
a1f090e0 | 517 | } |
42da2935 | 518 | //_______________________________________________________________________ |
519 | void AliITSClusterFinderSDD::Minim( Int_t xdim, Int_t zdim, Float_t *param, | |
50d05d7b | 520 | Float_t *prm0,Float_t *steprm, |
521 | Float_t *chisqr,Float_t *spe, | |
522 | Float_t *speFit ){ | |
42da2935 | 523 | // |
524 | Int_t k, nnn, mmm, i; | |
525 | Float_t p1, delta, d1, chisq1, p2, chisq2, t, p3, chisq3, a, b, p0, chisqt; | |
526 | const Int_t knParam = 5; | |
527 | Int_t npeak = (Int_t)param[0]; | |
528 | for( k=1; k<(npeak*knParam+1); k++ ) prm0[k] = param[k]; | |
529 | for( k=1; k<(npeak*knParam+1); k++ ){ | |
50d05d7b | 530 | p1 = param[k]; |
531 | delta = steprm[k]; | |
532 | d1 = delta; | |
533 | // ENSURE THAT STEP SIZE IS SENSIBLY LARGER THAN MACHINE ROUND OFF | |
534 | if( fabs( p1 ) > 1.0E-6 ) | |
535 | if ( fabs( delta/p1 ) < 1.0E-4 ) delta = p1/1000; | |
536 | else delta = (Float_t)1.0E-4; | |
537 | // EVALUATE CHI-SQUARED AT FIRST TWO SEARCH POINTS | |
538 | PeakFunc( xdim, zdim, param, speFit ); | |
539 | chisq1 = ChiSqr( xdim, zdim, spe, speFit ); | |
540 | p2 = p1+delta; | |
541 | param[k] = p2; | |
542 | PeakFunc( xdim, zdim, param, speFit ); | |
543 | chisq2 = ChiSqr( xdim, zdim, spe, speFit ); | |
544 | if( chisq1 < chisq2 ){ | |
545 | // REVERSE DIRECTION OF SEARCH IF CHI-SQUARED IS INCREASING | |
546 | delta = -delta; | |
547 | t = p1; | |
548 | p1 = p2; | |
549 | p2 = t; | |
550 | t = chisq1; | |
551 | chisq1 = chisq2; | |
552 | chisq2 = t; | |
553 | } // end if | |
554 | i = 1; nnn = 0; | |
555 | do { // INCREMENT param(K) UNTIL CHI-SQUARED STARTS TO INCREASE | |
556 | nnn++; | |
557 | p3 = p2 + delta; | |
558 | mmm = nnn - (nnn/5)*5; // multiplo de 5 | |
559 | if( mmm == 0 ){ | |
560 | d1 = delta; | |
561 | // INCREASE STEP SIZE IF STEPPING TOWARDS MINIMUM IS TOO SLOW | |
562 | delta *= 5; | |
563 | } // end if | |
564 | param[k] = p3; | |
565 | // Constrain paramiters | |
566 | Int_t kpos = (k-1) % knParam; | |
567 | switch( kpos ){ | |
568 | case 0 : | |
569 | if( param[k] <= 20 ) param[k] = fMinPeak; | |
570 | break; | |
571 | case 1 : | |
572 | if( fabs( param[k] - prm0[k] ) > 1.5 ) param[k] = prm0[k]; | |
573 | break; | |
574 | case 2 : | |
575 | if( fabs( param[k] - prm0[k] ) > 1. ) param[k] = prm0[k]; | |
576 | break; | |
577 | case 3 : | |
578 | if( param[k] < .5 ) param[k] = .5; | |
579 | break; | |
580 | case 4 : | |
581 | if( param[k] < .288 ) param[k] = .288; // 1/sqrt(12) = 0.288 | |
582 | if( param[k] > zdim*.5 ) param[k] = zdim*.5; | |
583 | break; | |
584 | }; // end switch | |
585 | PeakFunc( xdim, zdim, param, speFit ); | |
586 | chisq3 = ChiSqr( xdim, zdim, spe, speFit ); | |
587 | if( chisq3 < chisq2 && nnn < 50 ){ | |
588 | p1 = p2; | |
589 | p2 = p3; | |
590 | chisq1 = chisq2; | |
591 | chisq2 = chisq3; | |
592 | }else i=0; | |
593 | } while( i ); | |
594 | // FIND MINIMUM OF PARABOLA DEFINED BY LAST THREE POINTS | |
595 | a = chisq1*(p2-p3)+chisq2*(p3-p1)+chisq3*(p1-p2); | |
596 | b = chisq1*(p2*p2-p3*p3)+chisq2*(p3*p3-p1*p1)+chisq3*(p1*p1-p2*p2); | |
597 | if( a!=0 ) p0 = (Float_t)(0.5*b/a); | |
598 | else p0 = 10000; | |
599 | //--IN CASE OF NEARLY EQUAL CHI-SQUARED AND TOO SMALL STEP SIZE PREVENT | |
600 | // ERRONEOUS EVALUATION OF PARABOLA MINIMUM | |
601 | //---NEXT TWO LINES CAN BE OMITTED FOR HIGHER PRECISION MACHINES | |
602 | //dp = (Float_t) max (fabs(p3-p2), fabs(p2-p1)); | |
603 | //if( fabs( p2-p0 ) > dp ) p0 = p2; | |
604 | param[k] = p0; | |
605 | // Constrain paramiters | |
606 | Int_t kpos = (k-1) % knParam; | |
607 | switch( kpos ){ | |
608 | case 0 : | |
609 | if( param[k] <= 20 ) param[k] = fMinPeak; | |
610 | break; | |
611 | case 1 : | |
612 | if( fabs( param[k] - prm0[k] ) > 1.5 ) param[k] = prm0[k]; | |
613 | break; | |
614 | case 2 : | |
615 | if( fabs( param[k] - prm0[k] ) > 1. ) param[k] = prm0[k]; | |
616 | break; | |
617 | case 3 : | |
618 | if( param[k] < .5 ) param[k] = .5; | |
619 | break; | |
620 | case 4 : | |
621 | if( param[k] < .288 ) param[k] = .288; // 1/sqrt(12) = 0.288 | |
622 | if( param[k] > zdim*.5 ) param[k] = zdim*.5; | |
623 | break; | |
624 | }; // end switch | |
625 | PeakFunc( xdim, zdim, param, speFit ); | |
626 | chisqt = ChiSqr( xdim, zdim, spe, speFit ); | |
627 | // DO NOT ALLOW ERRONEOUS INTERPOLATION | |
628 | if( chisqt <= *chisqr ) *chisqr = chisqt; | |
629 | else param[k] = prm0[k]; | |
630 | // OPTIMIZE SEARCH STEP FOR EVENTUAL NEXT CALL OF MINIM | |
631 | steprm[k] = (param[k]-prm0[k])/5; | |
632 | if( steprm[k] >= d1 ) steprm[k] = d1/5; | |
42da2935 | 633 | } // end for k |
634 | // EVALUATE FIT AND CHI-SQUARED FOR OPTIMIZED PARAMETERS | |
635 | PeakFunc( xdim, zdim, param, speFit ); | |
636 | *chisqr = ChiSqr( xdim, zdim, spe, speFit ); | |
637 | return; | |
a1f090e0 | 638 | } |
42da2935 | 639 | //_________________________________________________________________________ |
640 | Int_t AliITSClusterFinderSDD::NoLinearFit( Int_t xdim, Int_t zdim, | |
50d05d7b | 641 | Float_t *param, Float_t *spe, |
642 | Int_t *niter, Float_t *chir ){ | |
42da2935 | 643 | // fit method from Comput. Phys. Commun 46(1987) 149 |
50d05d7b | 644 | const Float_t kchilmt = 0.01; // relative accuracy |
645 | const Int_t knel = 3; // for parabolic minimization | |
646 | const Int_t knstop = 50; // Max. iteration number | |
42da2935 | 647 | const Int_t knParam = 5; |
648 | Int_t npeak = (Int_t)param[0]; | |
649 | // RETURN IF NUMBER OF DEGREES OF FREEDOM IS NOT POSITIVE | |
650 | if( (xdim*zdim - npeak*knParam) <= 0 ) return( -1 ); | |
651 | Float_t degFree = (xdim*zdim - npeak*knParam)-1; | |
652 | Int_t n, k, iterNum = 0; | |
653 | Float_t *prm0 = new Float_t[npeak*knParam+1]; | |
654 | Float_t *step = new Float_t[npeak*knParam+1]; | |
655 | Float_t *schi = new Float_t[npeak*knParam+1]; | |
656 | Float_t *sprm[3]; | |
657 | sprm[0] = new Float_t[npeak*knParam+1]; | |
658 | sprm[1] = new Float_t[npeak*knParam+1]; | |
659 | sprm[2] = new Float_t[npeak*knParam+1]; | |
660 | Float_t chi0, chi1, reldif, a, b, prmin, dp; | |
661 | Float_t *speFit = new Float_t[ xdim*zdim ]; | |
662 | PeakFunc( xdim, zdim, param, speFit ); | |
663 | chi0 = ChiSqr( xdim, zdim, spe, speFit ); | |
664 | chi1 = chi0; | |
665 | for( k=1; k<(npeak*knParam+1); k++) prm0[k] = param[k]; | |
50d05d7b | 666 | for( k=1 ; k<(npeak*knParam+1); k+=knParam ){ |
667 | step[k] = param[k] / 20.0 ; | |
668 | step[k+1] = param[k+1] / 50.0; | |
669 | step[k+2] = param[k+2] / 50.0; | |
670 | step[k+3] = param[k+3] / 20.0; | |
671 | step[k+4] = param[k+4] / 20.0; | |
672 | } // end for k | |
42da2935 | 673 | Int_t out = 0; |
674 | do{ | |
50d05d7b | 675 | iterNum++; |
676 | chi0 = chi1; | |
677 | Minim( xdim, zdim, param, prm0, step, &chi1, spe, speFit ); | |
678 | reldif = ( chi1 > 0 ) ? ((Float_t) fabs( chi1-chi0)/chi1 ) : 0; | |
679 | // EXIT conditions | |
680 | if( reldif < (float) kchilmt ){ | |
681 | *chir = (chi1>0) ? (float) TMath::Sqrt (chi1/degFree) :0; | |
682 | *niter = iterNum; | |
683 | out = 0; | |
684 | break; | |
685 | } // end if | |
686 | if( (reldif < (float)(5*kchilmt)) && (iterNum > knstop) ){ | |
687 | *chir = (chi1>0) ?(float) TMath::Sqrt (chi1/degFree):0; | |
688 | *niter = iterNum; | |
689 | out = 0; | |
690 | break; | |
691 | } // end if | |
692 | if( iterNum > 5*knstop ){ | |
693 | *chir = (chi1>0) ?(float) TMath::Sqrt (chi1/degFree):0; | |
694 | *niter = iterNum; | |
695 | out = 1; | |
696 | break; | |
697 | } // end if | |
698 | if( iterNum <= knel ) continue; | |
699 | n = iterNum - (iterNum/knel)*knel; // EXTRAPOLATION LIMIT COUNTER N | |
700 | if( n > 3 || n == 0 ) continue; | |
701 | schi[n-1] = chi1; | |
702 | for( k=1; k<(npeak*knParam+1); k++ ) sprm[n-1][k] = param[k]; | |
703 | if( n != 3 ) continue; | |
704 | // -EVALUATE EXTRAPOLATED VALUE OF EACH PARAMETER BY FINDING MINIMUM OF | |
705 | // PARABOLA DEFINED BY LAST THREE CALLS OF MINIM | |
706 | for( k=1; k<(npeak*knParam+1); k++ ){ | |
707 | Float_t tmp0 = sprm[0][k]; | |
708 | Float_t tmp1 = sprm[1][k]; | |
709 | Float_t tmp2 = sprm[2][k]; | |
710 | a = schi[0]*(tmp1-tmp2) + schi[1]*(tmp2-tmp0); | |
711 | a += (schi[2]*(tmp0-tmp1)); | |
712 | b = schi[0]*(tmp1*tmp1-tmp2*tmp2); | |
713 | b += (schi[1]*(tmp2*tmp2-tmp0*tmp0)+(schi[2]* | |
714 | (tmp0*tmp0-tmp1*tmp1))); | |
715 | if ((double)a < 1.0E-6) prmin = 0; | |
716 | else prmin = (float) (0.5*b/a); | |
717 | dp = 5*(tmp2-tmp0); | |
718 | if( fabs(prmin-tmp2) > fabs(dp) ) prmin = tmp2+dp; | |
719 | param[k] = prmin; | |
720 | step[k] = dp/10; // OPTIMIZE SEARCH STEP | |
721 | } // end for k | |
42da2935 | 722 | } while( kTRUE ); |
723 | delete [] prm0; | |
724 | delete [] step; | |
725 | delete [] schi; | |
726 | delete [] sprm[0]; | |
727 | delete [] sprm[1]; | |
728 | delete [] sprm[2]; | |
729 | delete [] speFit; | |
730 | return( out ); | |
a1f090e0 | 731 | } |
50d05d7b | 732 | |
42da2935 | 733 | //______________________________________________________________________ |
734 | void AliITSClusterFinderSDD::ResolveClustersE(){ | |
735 | // The function to resolve clusters if the clusters overlapping exists | |
24a1c341 | 736 | Int_t i; |
42da2935 | 737 | static AliITS *iTS = (AliITS*)gAlice->GetModule( "ITS" ); |
738 | // get number of clusters for this module | |
739 | Int_t nofClusters = fClusters->GetEntriesFast(); | |
740 | nofClusters -= fNclusters; | |
741 | Int_t fNofMaps = fSegmentation->Npz(); | |
742 | Int_t fNofAnodes = fNofMaps/2; | |
743 | Int_t fMaxNofSamples = fSegmentation->Npx(); | |
744 | Int_t dummy=0; | |
745 | Double_t fTimeStep = fSegmentation->Dpx( dummy ); | |
746 | Double_t fSddLength = fSegmentation->Dx(); | |
747 | Double_t fDriftSpeed = fResponse->DriftSpeed(); | |
748 | Double_t anodePitch = fSegmentation->Dpz( dummy ); | |
749 | Float_t n, baseline; | |
750 | fResponse->GetNoiseParam( n, baseline ); | |
751 | Int_t electronics = fResponse->Electronics(); // 1 = PASCAL, 2 = OLA | |
50d05d7b | 752 | |
42da2935 | 753 | for( Int_t j=0; j<nofClusters; j++ ){ |
50d05d7b | 754 | // get cluster information |
755 | AliITSRawClusterSDD *clusterJ=(AliITSRawClusterSDD*) fClusters->At(j); | |
756 | Int_t astart = clusterJ->Astart(); | |
757 | Int_t astop = clusterJ->Astop(); | |
758 | Int_t tstart = clusterJ->Tstartf(); | |
759 | Int_t tstop = clusterJ->Tstopf(); | |
760 | Int_t wing = (Int_t)clusterJ->W(); | |
761 | if( wing == 2 ){ | |
762 | astart += fNofAnodes; | |
763 | astop += fNofAnodes; | |
764 | } // end if | |
765 | Int_t xdim = tstop-tstart+3; | |
766 | Int_t zdim = astop-astart+3; | |
bf3f2830 | 767 | if(xdim > 50 || zdim > 30) { |
768 | Warning("ResolveClustersE","xdim: %d , zdim: %d ",xdim,zdim); | |
769 | continue; | |
770 | } | |
50d05d7b | 771 | Float_t *sp = new Float_t[ xdim*zdim+1 ]; |
772 | memset( sp, 0, sizeof(Float_t)*(xdim*zdim+1) ); | |
773 | ||
774 | // make a local map from cluster region | |
775 | for( Int_t ianode=astart; ianode<=astop; ianode++ ){ | |
776 | for( Int_t itime=tstart; itime<=tstop; itime++ ){ | |
777 | Float_t fadc = fMap->GetSignal( ianode, itime ); | |
778 | if( fadc > baseline ) fadc -= (Double_t)baseline; | |
779 | else fadc = 0.; | |
780 | Int_t index = (itime-tstart+1)*zdim+(ianode-astart+1); | |
781 | sp[index] = fadc; | |
782 | } // time loop | |
783 | } // anode loop | |
784 | ||
785 | // search peaks on cluster | |
786 | const Int_t kNp = 150; | |
787 | Int_t peakX1[kNp]; | |
788 | Int_t peakZ1[kNp]; | |
789 | Float_t peakAmp1[kNp]; | |
790 | Int_t npeak = SearchPeak(sp,xdim,zdim,peakX1,peakZ1,peakAmp1,fMinPeak); | |
791 | ||
792 | // if multiple peaks, split cluster | |
793 | if( npeak >= 1 ) | |
794 | { | |
795 | // cout << "npeak " << npeak << endl; | |
796 | // clusterJ->PrintInfo(); | |
797 | Float_t *par = new Float_t[npeak*5+1]; | |
798 | par[0] = (Float_t)npeak; | |
48058160 | 799 | // Initial parameters in cell dimentions |
50d05d7b | 800 | Int_t k1 = 1; |
801 | for( i=0; i<npeak; i++ ){ | |
802 | par[k1] = peakAmp1[i]; | |
803 | par[k1+1] = peakX1[i]; // local time pos. [timebin] | |
804 | par[k1+2] = peakZ1[i]; // local anode pos. [anodepitch] | |
805 | if( electronics == 1 ) | |
806 | par[k1+3] = 2.; // PASCAL | |
807 | else if( electronics == 2 ) | |
808 | par[k1+3] = 0.7; // tau [timebin] OLA | |
809 | par[k1+4] = .4; // sigma [anodepich] | |
810 | k1+=5; | |
811 | } // end for i | |
812 | Int_t niter; | |
813 | Float_t chir; | |
814 | NoLinearFit( xdim, zdim, par, sp, &niter, &chir ); | |
815 | Float_t peakX[kNp]; | |
816 | Float_t peakZ[kNp]; | |
817 | Float_t sigma[kNp]; | |
818 | Float_t tau[kNp]; | |
819 | Float_t peakAmp[kNp]; | |
820 | Float_t integral[kNp]; | |
821 | //get integrals => charge for each peak | |
822 | PeakFunc( xdim, zdim, par, sp, integral ); | |
823 | k1 = 1; | |
824 | for( i=0; i<npeak; i++ ){ | |
825 | peakAmp[i] = par[k1]; | |
826 | peakX[i] = par[k1+1]; | |
827 | peakZ[i] = par[k1+2]; | |
828 | tau[i] = par[k1+3]; | |
829 | sigma[i] = par[k1+4]; | |
830 | k1+=5; | |
831 | } // end for i | |
832 | // calculate parameter for new clusters | |
833 | for( i=0; i<npeak; i++ ){ | |
834 | AliITSRawClusterSDD clusterI( *clusterJ ); | |
835 | Int_t newAnode = peakZ1[i]-1 + astart; | |
836 | Int_t newiTime = peakX1[i]-1 + tstart; | |
837 | Int_t shift = (Int_t)(fTimeCorr/fTimeStep + 0.5); | |
838 | if( newiTime > shift && newiTime < (fMaxNofSamples-shift) ) | |
839 | shift = 0; | |
840 | Int_t peakpos = fMap->GetHitIndex( newAnode, newiTime+shift ); | |
841 | clusterI.SetPeakPos( peakpos ); | |
842 | clusterI.SetPeakAmpl( peakAmp1[i] ); | |
843 | Float_t newAnodef = peakZ[i] - 0.5 + astart; | |
844 | Float_t newiTimef = peakX[i] - 1 + tstart; | |
845 | if( wing == 2 ) newAnodef -= fNofAnodes; | |
846 | Float_t anodePath = (newAnodef - fNofAnodes/2)*anodePitch; | |
847 | newiTimef *= fTimeStep; | |
848 | if( newiTimef > fTimeCorr ) newiTimef -= fTimeCorr; | |
849 | if( electronics == 1 ){ | |
48058160 | 850 | // newiTimef *= 0.999438; // PASCAL |
851 | // newiTimef += (6./fDriftSpeed - newiTimef/3000.); | |
50d05d7b | 852 | }else if( electronics == 2 ) |
853 | newiTimef *= 0.99714; // OLA | |
854 | Float_t driftPath = fSddLength - newiTimef * fDriftSpeed; | |
855 | Float_t sign = ( wing == 1 ) ? -1. : 1.; | |
856 | clusterI.SetX( driftPath*sign * 0.0001 ); | |
857 | clusterI.SetZ( anodePath * 0.0001 ); | |
858 | clusterI.SetAnode( newAnodef ); | |
859 | clusterI.SetTime( newiTimef ); | |
860 | clusterI.SetAsigma( sigma[i]*anodePitch ); | |
861 | clusterI.SetTsigma( tau[i]*fTimeStep ); | |
862 | clusterI.SetQ( integral[i] ); | |
48058160 | 863 | // clusterI.PrintInfo(); |
50d05d7b | 864 | iTS->AddCluster( 1, &clusterI ); |
865 | } // end for i | |
866 | fClusters->RemoveAt( j ); | |
867 | delete [] par; | |
48058160 | 868 | } else { // something odd |
bf3f2830 | 869 | Warning("ResolveClustersE","--- Peak not found!!!! minpeak=%d ,cluster peak= %f , module= %d",fMinPeak,clusterJ->PeakAmpl(),fModule); |
870 | clusterJ->PrintInfo(); | |
871 | Warning("ResolveClustersE"," xdim= %d zdim= %d",xdim-2,zdim-2); | |
50d05d7b | 872 | } |
873 | delete [] sp; | |
42da2935 | 874 | } // cluster loop |
875 | fClusters->Compress(); | |
50d05d7b | 876 | // fMap->ClearMap(); |
a1f090e0 | 877 | } |
50d05d7b | 878 | |
879 | ||
42da2935 | 880 | //________________________________________________________________________ |
881 | void AliITSClusterFinderSDD::GroupClusters(){ | |
882 | // group clusters | |
883 | Int_t dummy=0; | |
884 | Float_t fTimeStep = fSegmentation->Dpx(dummy); | |
885 | // get number of clusters for this module | |
886 | Int_t nofClusters = fClusters->GetEntriesFast(); | |
887 | nofClusters -= fNclusters; | |
888 | AliITSRawClusterSDD *clusterI; | |
889 | AliITSRawClusterSDD *clusterJ; | |
890 | Int_t *label = new Int_t [nofClusters]; | |
891 | Int_t i,j; | |
892 | for(i=0; i<nofClusters; i++) label[i] = 0; | |
893 | for(i=0; i<nofClusters; i++) { | |
50d05d7b | 894 | if(label[i] != 0) continue; |
895 | for(j=i+1; j<nofClusters; j++) { | |
896 | if(label[j] != 0) continue; | |
897 | clusterI = (AliITSRawClusterSDD*) fClusters->At(i); | |
898 | clusterJ = (AliITSRawClusterSDD*) fClusters->At(j); | |
899 | // 1.3 good | |
900 | if(clusterI->T() < fTimeStep*60) fDAnode = 4.2; // TB 3.2 | |
901 | if(clusterI->T() < fTimeStep*10) fDAnode = 1.5; // TB 1. | |
902 | Bool_t pair = clusterI->Brother(clusterJ,fDAnode,fDTime); | |
903 | if(!pair) continue; | |
904 | // clusterI->PrintInfo(); | |
905 | // clusterJ->PrintInfo(); | |
906 | clusterI->Add(clusterJ); | |
907 | label[j] = 1; | |
908 | fClusters->RemoveAt(j); | |
909 | j=i; // <- Ernesto | |
910 | } // J clusters | |
911 | label[i] = 1; | |
42da2935 | 912 | } // I clusters |
913 | fClusters->Compress(); | |
914 | ||
915 | delete [] label; | |
916 | return; | |
b0f5e3fc | 917 | } |
42da2935 | 918 | //________________________________________________________________________ |
919 | void AliITSClusterFinderSDD::SelectClusters(){ | |
920 | // get number of clusters for this module | |
921 | Int_t nofClusters = fClusters->GetEntriesFast(); | |
b0f5e3fc | 922 | |
42da2935 | 923 | nofClusters -= fNclusters; |
924 | Int_t i; | |
925 | for(i=0; i<nofClusters; i++) { | |
50d05d7b | 926 | AliITSRawClusterSDD *clusterI =(AliITSRawClusterSDD*) fClusters->At(i); |
927 | Int_t rmflg = 0; | |
928 | Float_t wy = 0.; | |
929 | if(clusterI->Anodes() != 0.) { | |
930 | wy = ((Float_t) clusterI->Samples())/clusterI->Anodes(); | |
931 | } // end if | |
932 | Int_t amp = (Int_t) clusterI->PeakAmpl(); | |
933 | Int_t cha = (Int_t) clusterI->Q(); | |
934 | if(amp < fMinPeak) rmflg = 1; | |
935 | if(cha < fMinCharge) rmflg = 1; | |
936 | if(wy < fMinNCells) rmflg = 1; | |
937 | //if(wy > fMaxNCells) rmflg = 1; | |
938 | if(rmflg) fClusters->RemoveAt(i); | |
42da2935 | 939 | } // I clusters |
940 | fClusters->Compress(); | |
941 | return; | |
b0f5e3fc | 942 | } |
42da2935 | 943 | //__________________________________________________________________________ |
944 | void AliITSClusterFinderSDD::ResolveClusters(){ | |
945 | // The function to resolve clusters if the clusters overlapping exists | |
946 | /* AliITS *iTS=(AliITS*)gAlice->GetModule("ITS"); | |
947 | // get number of clusters for this module | |
948 | Int_t nofClusters = fClusters->GetEntriesFast(); | |
949 | nofClusters -= fNclusters; | |
950 | //cout<<"Resolve Cl: nofClusters, fNclusters ="<<nofClusters<<"," | |
951 | // <<fNclusters<<endl; | |
952 | Int_t fNofMaps = fSegmentation->Npz(); | |
953 | Int_t fNofAnodes = fNofMaps/2; | |
954 | Int_t dummy=0; | |
955 | Double_t fTimeStep = fSegmentation->Dpx(dummy); | |
956 | Double_t fSddLength = fSegmentation->Dx(); | |
957 | Double_t fDriftSpeed = fResponse->DriftSpeed(); | |
958 | Double_t anodePitch = fSegmentation->Dpz(dummy); | |
959 | Float_t n, baseline; | |
960 | fResponse->GetNoiseParam(n,baseline); | |
961 | Float_t dzz_1A = anodePitch * anodePitch / 12; | |
962 | // fill Map of signals | |
a1f090e0 | 963 | fMap->FillMap(); |
42da2935 | 964 | Int_t j,i,ii,ianode,anode,itime; |
965 | Int_t wing,astart,astop,tstart,tstop,nanode; | |
966 | Double_t fadc,ClusterTime; | |
967 | Double_t q[400],x[400],z[400]; // digit charges and coordinates | |
968 | for(j=0; j<nofClusters; j++) { | |
50d05d7b | 969 | AliITSRawClusterSDD *clusterJ=(AliITSRawClusterSDD*) fClusters->At(j); |
970 | Int_t ndigits = 0; | |
971 | astart=clusterJ->Astart(); | |
972 | astop=clusterJ->Astop(); | |
973 | tstart=clusterJ->Tstartf(); | |
974 | tstop=clusterJ->Tstopf(); | |
975 | nanode=clusterJ->Anodes(); // <- Ernesto | |
976 | wing=(Int_t)clusterJ->W(); | |
977 | if(wing == 2) { | |
978 | astart += fNofAnodes; | |
979 | astop += fNofAnodes; | |
980 | } // end if | |
981 | // cout<<"astart,astop,tstart,tstop ="<<astart<<","<<astop<<"," | |
982 | // <<tstart<<","<<tstop<<endl; | |
983 | // clear the digit arrays | |
984 | for(ii=0; ii<400; ii++) { | |
985 | q[ii] = 0.; | |
986 | x[ii] = 0.; | |
987 | z[ii] = 0.; | |
988 | } // end for ii | |
42da2935 | 989 | |
50d05d7b | 990 | for(ianode=astart; ianode<=astop; ianode++) { |
991 | for(itime=tstart; itime<=tstop; itime++) { | |
992 | fadc=fMap->GetSignal(ianode,itime); | |
993 | if(fadc>baseline) { | |
994 | fadc-=(Double_t)baseline; | |
995 | q[ndigits] = fadc*(fTimeStep/160); // KeV | |
996 | anode = ianode; | |
997 | if(wing == 2) anode -= fNofAnodes; | |
998 | z[ndigits] = (anode + 0.5 - fNofAnodes/2)*anodePitch; | |
999 | ClusterTime = itime*fTimeStep; | |
1000 | if(ClusterTime > fTimeCorr) ClusterTime -= fTimeCorr;// ns | |
1001 | x[ndigits] = fSddLength - ClusterTime*fDriftSpeed; | |
1002 | if(wing == 1) x[ndigits] *= (-1); | |
1003 | // cout<<"ianode,itime,fadc ="<<ianode<<","<<itime<<"," | |
1004 | // <<fadc<<endl; | |
1005 | // cout<<"wing,anode,ndigits,charge ="<<wing<<"," | |
1006 | // <<anode<<","<<ndigits<<","<<q[ndigits]<<endl; | |
1007 | ndigits++; | |
1008 | continue; | |
1009 | } // end if | |
1010 | fadc=0; | |
1011 | // cout<<"fadc=0, ndigits ="<<ndigits<<endl; | |
1012 | } // time loop | |
1013 | } // anode loop | |
1014 | // cout<<"for new cluster ndigits ="<<ndigits<<endl; | |
1015 | // Fit cluster to resolve for two separate ones -------------------- | |
1016 | Double_t qq=0., xm=0., zm=0., xx=0., zz=0., xz=0.; | |
1017 | Double_t dxx=0., dzz=0., dxz=0.; | |
1018 | Double_t scl = 0., tmp, tga, elps = -1.; | |
1019 | Double_t xfit[2], zfit[2], qfit[2]; | |
1020 | Double_t pitchz = anodePitch*1.e-4; // cm | |
1021 | Double_t pitchx = fTimeStep*fDriftSpeed*1.e-4; // cm | |
1022 | Double_t sigma2; | |
1023 | Int_t nfhits; | |
1024 | Int_t nbins = ndigits; | |
1025 | Int_t separate = 0; | |
1026 | // now, all lengths are in microns | |
1027 | for (ii=0; ii<nbins; ii++) { | |
1028 | qq += q[ii]; | |
1029 | xm += x[ii]*q[ii]; | |
1030 | zm += z[ii]*q[ii]; | |
1031 | xx += x[ii]*x[ii]*q[ii]; | |
1032 | zz += z[ii]*z[ii]*q[ii]; | |
1033 | xz += x[ii]*z[ii]*q[ii]; | |
1034 | } // end for ii | |
1035 | xm /= qq; | |
1036 | zm /= qq; | |
1037 | xx /= qq; | |
1038 | zz /= qq; | |
1039 | xz /= qq; | |
1040 | dxx = xx - xm*xm; | |
1041 | dzz = zz - zm*zm; | |
1042 | dxz = xz - xm*zm; | |
42da2935 | 1043 | |
50d05d7b | 1044 | // shrink the cluster in the time direction proportionaly to the |
1045 | // dxx/dzz, which lineary depends from the drift path | |
1046 | // new Ernesto........ | |
1047 | if( nanode == 1 ){ | |
1048 | dzz = dzz_1A; // for one anode cluster dzz = anode**2/12 | |
1049 | scl = TMath::Sqrt( 7.2/(-0.57*xm*1.e-3+71.8) ); | |
1050 | } // end if | |
1051 | if( nanode == 2 ){ | |
1052 | scl = TMath::Sqrt( (-0.18*xm*1.e-3+21.3)/(-0.57*xm*1.e-3+71.8) ); | |
1053 | } // end if | |
1054 | if( nanode == 3 ){ | |
1055 | scl = TMath::Sqrt( (-0.5*xm*1.e-3+34.5)/(-0.57*xm*1.e-3+71.8) ); | |
1056 | } // end if | |
1057 | if( nanode > 3 ){ | |
1058 | scl = TMath::Sqrt( (1.3*xm*1.e-3+49.)/(-0.57*xm*1.e-3+71.8) ); | |
1059 | } // end if | |
1060 | // cout<<"1 microns: zm,dzz,xm,dxx,dxz,qq ="<<zm<<","<<dzz<<"," | |
1061 | // <<xm<<","<<dxx<<","<<dxz<<","<<qq<<endl; | |
1062 | // old Boris......... | |
1063 | // tmp=29730. - 585.*fabs(xm/1000.); | |
1064 | // scl=TMath::Sqrt(tmp/130000.); | |
a1f090e0 | 1065 | |
50d05d7b | 1066 | xm *= scl; |
1067 | xx *= scl*scl; | |
1068 | xz *= scl; | |
42da2935 | 1069 | |
50d05d7b | 1070 | dxx = xx - xm*xm; |
1071 | // dzz = zz - zm*zm; | |
1072 | dxz = xz - xm*zm; | |
1073 | // cout<<"microns: zm,dzz,xm,dxx,xz,dxz,qq ="<<zm<<","<<dzz<<"," | |
1074 | // <<xm<<","<<dxx<<","<<xz<<","<<dxz<<","<<qq<<endl; | |
1075 | // if(dzz < 7200.) dzz=7200.;//for one anode cluster dzz = anode**2/12 | |
a1f090e0 | 1076 | |
50d05d7b | 1077 | if (dxx < 0.) dxx=0.; |
1078 | // the data if no cluster overlapping (the coordunates are in cm) | |
1079 | nfhits = 1; | |
1080 | xfit[0] = xm*1.e-4; | |
1081 | zfit[0] = zm*1.e-4; | |
1082 | qfit[0] = qq; | |
1083 | // if(nbins < 7) cout<<"**** nbins ="<<nbins<<endl; | |
a1f090e0 | 1084 | |
50d05d7b | 1085 | if (nbins >= 7) { |
1086 | if (dxz==0.) tga=0.; | |
1087 | else { | |
1088 | tmp=0.5*(dzz-dxx)/dxz; | |
1089 | tga = (dxz<0.) ? tmp-TMath::Sqrt(tmp*tmp+1) : | |
1090 | tmp+TMath::Sqrt(tmp*tmp+1); | |
1091 | } // end if dxz | |
1092 | elps=(tga*tga*dxx-2*tga*dxz+dzz)/(dxx+2*tga*dxz+tga*tga*dzz); | |
1093 | // change from microns to cm | |
1094 | xm *= 1.e-4; | |
1095 | zm *= 1.e-4; | |
1096 | zz *= 1.e-8; | |
1097 | xx *= 1.e-8; | |
1098 | xz *= 1.e-8; | |
1099 | dxz *= 1.e-8; | |
1100 | dxx *= 1.e-8; | |
1101 | dzz *= 1.e-8; | |
1102 | // cout<<"cm: zm,dzz,xm,dxx,xz,dxz,qq ="<<zm<<","<<dzz<<"," | |
1103 | // <<xm<<","<<dxx<<","<<xz<<","<<dxz<<","<<qq<<endl; | |
1104 | for (i=0; i<nbins; i++) { | |
1105 | x[i] = x[i] *= scl; | |
1106 | x[i] = x[i] *= 1.e-4; | |
1107 | z[i] = z[i] *= 1.e-4; | |
1108 | } // end for i | |
1109 | // cout<<"!!! elps ="<<elps<<endl; | |
1110 | if (elps < 0.3) { // try to separate hits | |
1111 | separate = 1; | |
1112 | tmp=atan(tga); | |
1113 | Double_t cosa=cos(tmp),sina=sin(tmp); | |
1114 | Double_t a1=0., x1=0., xxx=0.; | |
1115 | for (i=0; i<nbins; i++) { | |
1116 | tmp=x[i]*cosa + z[i]*sina; | |
1117 | if (q[i] > a1) { | |
1118 | a1=q[i]; | |
1119 | x1=tmp; | |
1120 | } // end if | |
1121 | xxx += tmp*tmp*tmp*q[i]; | |
1122 | } // end for i | |
1123 | xxx /= qq; | |
1124 | Double_t z12=-sina*xm + cosa*zm; | |
1125 | sigma2=(sina*sina*xx-2*cosa*sina*xz+cosa*cosa*zz) - z12*z12; | |
1126 | xm=cosa*xm + sina*zm; | |
1127 | xx=cosa*cosa*xx + 2*cosa*sina*xz + sina*sina*zz; | |
1128 | Double_t x2=(xx - xm*x1 - sigma2)/(xm - x1); | |
1129 | Double_t r=a1*2*TMath::ACos(-1.)*sigma2/(qq*pitchx*pitchz); | |
1130 | for (i=0; i<33; i++) { // solve a system of equations | |
1131 | Double_t x1_old=x1, x2_old=x2, r_old=r; | |
1132 | Double_t c11=x1-x2; | |
1133 | Double_t c12=r; | |
1134 | Double_t c13=1-r; | |
1135 | Double_t c21=x1*x1 - x2*x2; | |
1136 | Double_t c22=2*r*x1; | |
1137 | Double_t c23=2*(1-r)*x2; | |
1138 | Double_t c31=3*sigma2*(x1-x2) + x1*x1*x1 - x2*x2*x2; | |
1139 | Double_t c32=3*r*(sigma2 + x1*x1); | |
1140 | Double_t c33=3*(1-r)*(sigma2 + x2*x2); | |
1141 | Double_t f1=-(r*x1 + (1-r)*x2 - xm); | |
1142 | Double_t f2=-(r*(sigma2+x1*x1)+(1-r)*(sigma2+x2*x2)- xx); | |
1143 | Double_t f3=-(r*x1*(3*sigma2+x1*x1)+(1-r)*x2* | |
1144 | (3*sigma2+x2*x2)-xxx); | |
1145 | Double_t d=c11*c22*c33+c21*c32*c13+c12*c23*c31- | |
1146 | c31*c22*c13 - c21*c12*c33 - c32*c23*c11; | |
1147 | if (d==0.) { | |
1148 | cout<<"*********** d=0 ***********\n"; | |
1149 | break; | |
1150 | } // end if | |
1151 | Double_t dr=f1*c22*c33 + f2*c32*c13 + c12*c23*f3 - | |
1152 | f3*c22*c13 - f2*c12*c33 - c32*c23*f1; | |
1153 | Double_t d1=c11*f2*c33 + c21*f3*c13 + f1*c23*c31 - | |
1154 | c31*f2*c13 - c21*f1*c33 - f3*c23*c11; | |
1155 | Double_t d2=c11*c22*f3 + c21*c32*f1 + c12*f2*c31 - | |
1156 | c31*c22*f1 - c21*c12*f3 - c32*f2*c11; | |
1157 | r += dr/d; | |
1158 | x1 += d1/d; | |
1159 | x2 += d2/d; | |
1160 | if (fabs(x1-x1_old) > 0.0001) continue; | |
1161 | if (fabs(x2-x2_old) > 0.0001) continue; | |
1162 | if (fabs(r-r_old)/5 > 0.001) continue; | |
1163 | a1=r*qq*pitchx*pitchz/(2*TMath::ACos(-1.)*sigma2); | |
1164 | Double_t a2=a1*(1-r)/r; | |
1165 | qfit[0]=a1; xfit[0]=x1*cosa - z12*sina; zfit[0]=x1*sina + | |
1166 | z12*cosa; | |
1167 | qfit[1]=a2; xfit[1]=x2*cosa - z12*sina; zfit[1]=x2*sina + | |
1168 | z12*cosa; | |
1169 | nfhits=2; | |
1170 | break; // Ok ! | |
1171 | } // end for i | |
1172 | if (i==33) cerr<<"No more iterations ! "<<endl; | |
1173 | } // end of attempt to separate overlapped clusters | |
1174 | } // end of nbins cut | |
1175 | if(elps < 0.) cout<<" elps=-1 ="<<elps<<endl; | |
1176 | if(elps >0. && elps< 0.3 && nfhits == 1) cout<<" small elps, nfh=1 =" | |
1177 | <<elps<<","<<nfhits<<endl; | |
1178 | if(nfhits == 2) cout<<" nfhits=2 ="<<nfhits<<endl; | |
1179 | for (i=0; i<nfhits; i++) { | |
1180 | xfit[i] *= (1.e+4/scl); | |
1181 | if(wing == 1) xfit[i] *= (-1); | |
1182 | zfit[i] *= 1.e+4; | |
1183 | // cout<<" --------- i,xfiti,zfiti,qfiti ="<<i<<"," | |
1184 | // <<xfit[i]<<","<<zfit[i]<<","<<qfit[i]<<endl; | |
1185 | } // end for i | |
1186 | Int_t ncl = nfhits; | |
1187 | if(nfhits == 1 && separate == 1) { | |
1188 | cout<<"!!!!! no separate"<<endl; | |
1189 | ncl = -2; | |
1190 | } // end if | |
1191 | if(nfhits == 2) { | |
1192 | cout << "Split cluster: " << endl; | |
1193 | clusterJ->PrintInfo(); | |
1194 | cout << " in: " << endl; | |
1195 | for (i=0; i<nfhits; i++) { | |
1196 | // AliITSRawClusterSDD *clust = new AliITSRawClusterSDD(wing, | |
42da2935 | 1197 | -1,-1,(Float_t)qfit[i],ncl,0,0, |
1198 | (Float_t)xfit[i], | |
1199 | (Float_t)zfit[i],0,0,0,0, | |
1200 | tstart,tstop,astart,astop); | |
50d05d7b | 1201 | // AliITSRawClusterSDD *clust = new AliITSRawClusterSDD(wing,-1, |
1202 | // -1,(Float_t)qfit[i],0,0,0, | |
1203 | // (Float_t)xfit[i], | |
1204 | // (Float_t)zfit[i],0,0,0,0, | |
1205 | // tstart,tstop,astart,astop,ncl); | |
1206 | // ??????????? | |
1207 | // if(wing == 1) xfit[i] *= (-1); | |
1208 | Float_t Anode = (zfit[i]/anodePitch+fNofAnodes/2-0.5); | |
1209 | Float_t Time = (fSddLength - xfit[i])/fDriftSpeed; | |
1210 | Float_t clusterPeakAmplitude = clusterJ->PeakAmpl(); | |
1211 | Float_t peakpos = clusterJ->PeakPos(); | |
1212 | Float_t clusteranodePath = (Anode - fNofAnodes/2)*anodePitch; | |
1213 | Float_t clusterDriftPath = Time*fDriftSpeed; | |
1214 | clusterDriftPath = fSddLength-clusterDriftPath; | |
1215 | AliITSRawClusterSDD *clust = new AliITSRawClusterSDD(wing,Anode, | |
1216 | Time,qfit[i], | |
42da2935 | 1217 | clusterPeakAmplitude,peakpos, |
1218 | 0.,0.,clusterDriftPath, | |
1219 | clusteranodePath,clusterJ->Samples()/2 | |
50d05d7b | 1220 | ,tstart,tstop,0,0,0,astart,astop); |
1221 | clust->PrintInfo(); | |
1222 | iTS->AddCluster(1,clust); | |
1223 | // cout<<"new cluster added: tstart,tstop,astart,astop,x,ncl =" | |
1224 | // <<tstart<<","<<tstop<<","<<astart<<","<<astop<<","<<xfit[i] | |
1225 | // <<","<<ncl<<endl; | |
1226 | delete clust; | |
1227 | }// nfhits loop | |
1228 | fClusters->RemoveAt(j); | |
42da2935 | 1229 | } // if nfhits = 2 |
1230 | } // cluster loop | |
1231 | fClusters->Compress(); | |
1232 | fMap->ClearMap(); | |
1233 | */ | |
1234 | return; | |
a1f090e0 | 1235 | } |
42da2935 | 1236 | //______________________________________________________________________ |
1237 | void AliITSClusterFinderSDD::GetRecPoints(){ | |
1238 | // get rec points | |
1239 | static AliITS *iTS=(AliITS*)gAlice->GetModule("ITS"); | |
1240 | // get number of clusters for this module | |
1241 | Int_t nofClusters = fClusters->GetEntriesFast(); | |
1242 | nofClusters -= fNclusters; | |
1243 | const Float_t kconvGeV = 1.e-6; // GeV -> KeV | |
1244 | const Float_t kconv = 1.0e-4; | |
1245 | const Float_t kRMSx = 38.0*kconv; // microns->cm ITS TDR Table 1.3 | |
1246 | const Float_t kRMSz = 28.0*kconv; // microns->cm ITS TDR Table 1.3 | |
ee86d557 | 1247 | Int_t i,j; |
42da2935 | 1248 | Int_t ix, iz, idx=-1; |
1249 | AliITSdigitSDD *dig=0; | |
1250 | Int_t ndigits=fDigits->GetEntriesFast(); | |
1251 | for(i=0; i<nofClusters; i++) { | |
50d05d7b | 1252 | AliITSRawClusterSDD *clusterI = (AliITSRawClusterSDD*)fClusters->At(i); |
1253 | if(!clusterI) Error("SDD: GetRecPoints","i clusterI ",i,clusterI); | |
1254 | if(clusterI) idx=clusterI->PeakPos(); | |
1255 | if(idx>ndigits) Error("SDD: GetRecPoints","idx ndigits",idx,ndigits); | |
1256 | // try peak neighbours - to be done | |
1257 | if(idx&&idx<= ndigits) dig =(AliITSdigitSDD*)fDigits->UncheckedAt(idx); | |
507cf1a7 | 1258 | //// debug |
1259 | // cout<<"R.C. Anode = "<<clusterI->A()<<"; Time= "<<clusterI->T()<<endl; | |
1260 | fSegmentation->LocalToDet(clusterI->X(),clusterI->Z(),ix,iz); | |
1261 | // cout<<"From R.C. coordinates- Anode: "<<iz<<" and time: "<<ix<<endl; | |
1262 | // end debug | |
1263 | Int_t trks[10]; | |
1264 | Int_t notr=-1; | |
1265 | Int_t deger = 0; | |
1266 | if(!dig) { | |
1267 | Warning("GetRecPoints","Cannot assign the track number\n"); | |
1268 | } | |
1269 | else { | |
1270 | fSegmentation->LocalToDet(clusterI->X(),clusterI->Z(),ix,iz); | |
1271 | Int_t signal[30]; | |
1272 | for(Int_t kk=0;kk<9;kk++)trks[kk]=-2; | |
1273 | AliITSdigitSDD * pdig = 0; | |
1274 | for(Int_t itime=ix-1;itime<=ix+1;itime++){ | |
1275 | if(itime<0 || itime>=fSegmentation->Npx())continue; | |
1276 | for(Int_t ianod=iz-1;ianod<=iz+1;ianod++){ | |
1277 | if(ianod<0 || ianod>=fSegmentation->Npz())continue; | |
1278 | if(iz==(fSegmentation->Npz())/2 && ianod<iz)continue; | |
1279 | if(iz==(fSegmentation->Npz())/2-1 && ianod>iz)continue; | |
1280 | pdig = (AliITSdigitSDD*)fMap->GetHit(ianod,itime); | |
1281 | if(pdig){ | |
1282 | for(Int_t kk=0;kk<3;kk++){ | |
1283 | if(kk == 0 || (kk>0 && pdig->fTracks[kk]>=0)){ | |
1284 | notr++; | |
1285 | trks[notr]=pdig->fTracks[kk]; | |
1286 | signal[notr]=pdig->fSignal; | |
1287 | } | |
1288 | } | |
1289 | } | |
1290 | } | |
1291 | } // for(itime.... | |
1292 | if((dig->fCoord1<(iz-1) || dig->fCoord1>(iz+1)) | |
1293 | && (dig->fCoord2<(ix-1) || dig->fCoord2>(ix+1)) | |
1294 | && dig->fTracks[0]>=-2){ | |
1295 | notr++; | |
1296 | trks[notr]=dig->fTracks[0]; | |
1297 | signal[notr]=dig->fSignal; | |
1298 | } | |
1299 | for(Int_t ii=0; ii<notr;ii++){ | |
1300 | for(Int_t jj=ii+1; jj<=notr; jj++){ | |
1301 | if(trks[ii] == trks[jj]){ | |
1302 | signal[ii]+=signal[jj]; | |
1303 | signal[jj]=-100; | |
1304 | trks[jj]=-jj-100; | |
1305 | deger++; | |
1306 | } | |
1307 | } | |
1308 | } | |
1309 | Int_t ordtmp; | |
1310 | for(Int_t ii=0; ii<notr;ii++){ | |
1311 | Int_t maxi = ii; | |
1312 | for(Int_t jj=ii+1; jj<=notr; jj++){ | |
1313 | if(signal[jj]>signal[maxi])maxi=jj; | |
1314 | } | |
1315 | ordtmp = trks[ii]; | |
1316 | trks[ii]=trks[maxi]; | |
1317 | trks[maxi]=ordtmp; | |
1318 | ordtmp = signal[ii]; | |
1319 | signal[ii]=signal[maxi]; | |
1320 | signal[maxi]=ordtmp; | |
1321 | } | |
1322 | } | |
1323 | notr-=deger; | |
1324 | notr++; | |
1325 | /* | |
1326 | if(!dig) { | |
50d05d7b | 1327 | // try cog |
1328 | fSegmentation->GetPadIxz(clusterI->X(),clusterI->Z(),ix,iz); | |
1329 | dig = (AliITSdigitSDD*)fMap->GetHit(iz-1,ix-1); | |
1330 | // if null try neighbours | |
1331 | if (!dig) dig = (AliITSdigitSDD*)fMap->GetHit(iz-1,ix); | |
1332 | if (!dig) dig = (AliITSdigitSDD*)fMap->GetHit(iz-1,ix+1); | |
1333 | if (!dig) printf("SDD: cannot assign the track number!\n"); | |
1334 | } // end if !dig | |
507cf1a7 | 1335 | */ |
50d05d7b | 1336 | AliITSRecPoint rnew; |
1337 | rnew.SetX(clusterI->X()); | |
1338 | rnew.SetZ(clusterI->Z()); | |
1339 | rnew.SetQ(clusterI->Q()); // in KeV - should be ADC | |
507cf1a7 | 1340 | // cout<<"Cluster # "<<i<< " - X,Z,Q= "<<clusterI->X()<<" "<<clusterI->Z()<<" "<<clusterI->Q()<<"; Digit n= "<<idx<<endl; |
50d05d7b | 1341 | rnew.SetdEdX(kconvGeV*clusterI->Q()); |
1342 | rnew.SetSigmaX2(kRMSx*kRMSx); | |
1343 | rnew.SetSigmaZ2(kRMSz*kRMSz); | |
507cf1a7 | 1344 | if(notr>3)notr=3; |
1345 | if(notr>=0)for(j=0;j<notr;j++)rnew.fTracks[j]=trks[j]; | |
1346 | /* | |
ee86d557 | 1347 | if(dig){ |
507cf1a7 | 1348 | for(j=0;j<dig->GetNTracks();j++){ |
1349 | if(j>0 && j%4==0)cout<<endl; | |
1350 | } | |
1351 | cout<<endl; | |
ee86d557 | 1352 | rnew.fTracks[0] = dig->fTracks[0]; |
507cf1a7 | 1353 | cout<<" "<<dig->fTracks[0]<<" assigned to rp 0 "<<rnew.fTracks[0]<<endl; |
ee86d557 | 1354 | rnew.fTracks[1] = -3; |
1355 | rnew.fTracks[2] = -3; | |
1356 | j=1; | |
1357 | while(rnew.fTracks[0]==dig->fTracks[j] && | |
1358 | j<dig->GetNTracks()) j++; | |
1359 | if(j<dig->GetNTracks()){ | |
1360 | rnew.fTracks[1] = dig->fTracks[j]; | |
507cf1a7 | 1361 | cout<<" Digit "<<j<<" "<<dig->fTracks[j]<<" assigned to rp 1 "<<rnew.fTracks[1]<<endl; |
f8d9a5b8 | 1362 | while((rnew.fTracks[0]==dig->fTracks[j] || |
1363 | rnew.fTracks[1]==dig->fTracks[j] )&& | |
ee86d557 | 1364 | j<dig->GetNTracks()) j++; |
507cf1a7 | 1365 | if(j<dig->GetNTracks()) { |
1366 | rnew.fTracks[2] = dig->fTracks[j]; | |
1367 | cout<<" Digit "<<j<<" "<<dig->fTracks[j]<<" assigned to rp 2 "<<rnew.fTracks[2]<<endl; | |
1368 | } | |
ee86d557 | 1369 | } // end if |
1370 | } // end if | |
507cf1a7 | 1371 | */ |
1372 | ||
50d05d7b | 1373 | iTS->AddRecPoint(rnew); |
42da2935 | 1374 | } // I clusters |
50d05d7b | 1375 | // fMap->ClearMap(); |
b0f5e3fc | 1376 | } |
42da2935 | 1377 | //______________________________________________________________________ |
1378 | void AliITSClusterFinderSDD::FindRawClusters(Int_t mod){ | |
1379 | // find raw clusters | |
50d05d7b | 1380 | |
1381 | fModule = mod; | |
1382 | ||
a1f090e0 | 1383 | Find1DClustersE(); |
b0f5e3fc | 1384 | GroupClusters(); |
1385 | SelectClusters(); | |
a1f090e0 | 1386 | ResolveClustersE(); |
b0f5e3fc | 1387 | GetRecPoints(); |
1388 | } | |
42da2935 | 1389 | //_______________________________________________________________________ |
bf3f2830 | 1390 | void AliITSClusterFinderSDD::Print() const{ |
42da2935 | 1391 | // Print SDD cluster finder Parameters |
1392 | ||
1393 | cout << "**************************************************" << endl; | |
1394 | cout << " Silicon Drift Detector Cluster Finder Parameters " << endl; | |
1395 | cout << "**************************************************" << endl; | |
1396 | cout << "Number of Clusters: " << fNclusters << endl; | |
1397 | cout << "Anode Tolerance: " << fDAnode << endl; | |
1398 | cout << "Time Tolerance: " << fDTime << endl; | |
1399 | cout << "Time correction (electronics): " << fTimeCorr << endl; | |
1400 | cout << "Cut Amplitude (threshold): " << fCutAmplitude << endl; | |
1401 | cout << "Minimum Amplitude: " << fMinPeak << endl; | |
1402 | cout << "Minimum Charge: " << fMinCharge << endl; | |
1403 | cout << "Minimum number of cells/clusters: " << fMinNCells << endl; | |
1404 | cout << "Maximum number of cells/clusters: " << fMaxNCells << endl; | |
1405 | cout << "**************************************************" << endl; | |
a1f090e0 | 1406 | } |