]>
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 | $Id$ | |
17 | */ | |
18 | /////////////////////////////////////////////////////////////////////////// | |
19 | // Cluster finder // | |
20 | // for Silicon // | |
21 | // Drift Detector // | |
22 | ////////////////////////////////////////////////////////////////////////// | |
23 | ||
24 | ||
25 | #include "AliITSClusterFinderSDD.h" | |
26 | #include "AliITSMapA1.h" | |
27 | #include "AliITSRawClusterSDD.h" | |
28 | #include "AliITSRecPoint.h" | |
29 | #include "AliITSdigitSDD.h" | |
30 | #include "AliITSDetTypeRec.h" | |
31 | #include "AliITSCalibrationSDD.h" | |
32 | #include "AliITSsegmentationSDD.h" | |
33 | #include "AliLog.h" | |
34 | ||
35 | ClassImp(AliITSClusterFinderSDD) | |
36 | ||
37 | //______________________________________________________________________ | |
38 | AliITSClusterFinderSDD::AliITSClusterFinderSDD(): | |
39 | AliITSClusterFinder(), | |
40 | fNclusters(0), | |
41 | fDAnode(0.0), | |
42 | fDTime(0.0), | |
43 | fTimeCorr(0.0), | |
44 | fCutAmplitude(0), | |
45 | fMinPeak(0), | |
46 | fMinCharge(0), | |
47 | fMinNCells(0), | |
48 | fMaxNCells(0){ | |
49 | // default constructor | |
50 | } | |
51 | //______________________________________________________________________ | |
52 | AliITSClusterFinderSDD::AliITSClusterFinderSDD(AliITSDetTypeRec* dettyp, | |
53 | TClonesArray *digits, | |
54 | TClonesArray *recp): | |
55 | AliITSClusterFinder(dettyp), | |
56 | fNclusters(0), | |
57 | fDAnode(0.0), | |
58 | fDTime(0.0), | |
59 | fTimeCorr(0.0), | |
60 | fCutAmplitude(0), | |
61 | fMinPeak(0), | |
62 | fMinCharge(0), | |
63 | fMinNCells(0), | |
64 | fMaxNCells(0){ | |
65 | // standard constructor | |
66 | ||
67 | SetDigits(digits); | |
68 | SetClusters(recp); | |
69 | SetCutAmplitude(fDetTypeRec->GetITSgeom()->GetStartSDD()); | |
70 | SetDAnode(); | |
71 | SetDTime(); | |
72 | SetMinPeak((Int_t)((AliITSCalibrationSDD*)GetResp(fDetTypeRec->GetITSgeom()->GetStartSDD()))->GetNoiseAfterElectronics(0)*5); | |
73 | SetMinNCells(); | |
74 | SetMaxNCells(); | |
75 | SetTimeCorr(); | |
76 | SetMinCharge(); | |
77 | SetMap(new AliITSMapA1(GetSeg(),Digits(),fCutAmplitude)); | |
78 | } | |
79 | //______________________________________________________________________ | |
80 | void AliITSClusterFinderSDD::SetCutAmplitude(Int_t mod,Double_t nsigma){ | |
81 | // set the signal threshold for cluster finder | |
82 | Double_t baseline,noiseAfterEl; | |
83 | ||
84 | AliITSresponseSDD* res = (AliITSresponseSDD*)((AliITSCalibrationSDD*)GetResp(mod))->GetResponse(); | |
85 | const char *option=res->ZeroSuppOption(); | |
86 | Int_t nanodes = GetResp(mod)->Wings()*GetResp(mod)->Channels()*GetResp(mod)->Chips(); | |
87 | fCutAmplitude.Set(nanodes); | |
88 | for(Int_t ian=0;ian<nanodes;ian++){ | |
89 | noiseAfterEl = ((AliITSCalibrationSDD*)GetResp(mod))->GetNoiseAfterElectronics(ian); | |
90 | if((strstr(option,"1D")) || (strstr(option,"2D"))){ | |
91 | fCutAmplitude[ian] = (Int_t)(nsigma*noiseAfterEl); | |
92 | } | |
93 | else{ | |
94 | baseline=GetResp(mod)->GetBaseline(ian); | |
95 | fCutAmplitude[ian] = (Int_t)((baseline + nsigma*noiseAfterEl)); | |
96 | } | |
97 | } | |
98 | } | |
99 | //______________________________________________________________________ | |
100 | void AliITSClusterFinderSDD::Find1DClusters(){ | |
101 | // find 1D clusters | |
102 | ||
103 | // retrieve the parameters | |
104 | Int_t fNofMaps = GetSeg()->Npz(); | |
105 | Int_t fMaxNofSamples = GetSeg()->Npx(); | |
106 | Int_t fNofAnodes = fNofMaps/2; | |
107 | Int_t dummy = 0; | |
108 | Double_t fTimeStep = GetSeg()->Dpx(dummy); | |
109 | Double_t fSddLength = GetSeg()->Dx(); | |
110 | Double_t anodePitch = GetSeg()->Dpz(dummy); | |
111 | AliITSCalibrationSDD* cal = (AliITSCalibrationSDD*)GetResp(fModule); | |
112 | AliITSresponseSDD* res = (AliITSresponseSDD*)((AliITSCalibrationSDD*)GetResp(fModule))->GetResponse(); | |
113 | const char *option=res->ZeroSuppOption(); | |
114 | ||
115 | // map the signal | |
116 | Map()->ClearMap(); | |
117 | Map()->SetThresholdArr(fCutAmplitude); | |
118 | Map()->FillMap2(); | |
119 | ||
120 | Int_t nofFoundClusters = 0; | |
121 | Int_t i; | |
122 | Double_t **dfadc = new Double_t*[fNofAnodes]; | |
123 | for(i=0;i<fNofAnodes;i++) dfadc[i] = new Double_t[fMaxNofSamples]; | |
124 | Double_t fadc = 0.; | |
125 | Double_t fadc1 = 0.; | |
126 | Double_t fadc2 = 0.; | |
127 | Int_t j,k,idx,l,m; | |
128 | for(j=0;j<2;j++) { | |
129 | for(k=0;k<fNofAnodes;k++) { | |
130 | idx = j*fNofAnodes+k; | |
131 | // signal (fadc) & derivative (dfadc) | |
132 | dfadc[k][255]=0.; | |
133 | for(l=0; l<fMaxNofSamples; l++) { | |
134 | fadc2=(Double_t)Map()->GetSignal(idx,l); | |
135 | if(l>0) fadc1=(Double_t)Map()->GetSignal(idx,l-1); | |
136 | if(l>0) dfadc[k][l-1] = fadc2-fadc1; | |
137 | } // samples | |
138 | } // anodes | |
139 | ||
140 | for(k=0;k<fNofAnodes;k++) { | |
141 | AliDebug(5,Form("Anode: %d, Wing: %d",k+1,j+1)); | |
142 | idx = j*fNofAnodes+k; | |
143 | Int_t imax = 0; | |
144 | Int_t imaxd = 0; | |
145 | Int_t it = 0; | |
146 | while(it <= fMaxNofSamples-3) { | |
147 | imax = it; | |
148 | imaxd = it; | |
149 | // maximum of signal | |
150 | Double_t fadcmax = 0.; | |
151 | Double_t dfadcmax = 0.; | |
152 | Int_t lthrmina = 1; | |
153 | Int_t lthrmint = 3; | |
154 | Int_t lthra = 1; | |
155 | Int_t lthrt = 0; | |
156 | for(m=0;m<20;m++) { | |
157 | Int_t id = it+m; | |
158 | if(id>=fMaxNofSamples) break; | |
159 | fadc=(float)Map()->GetSignal(idx,id); | |
160 | if(fadc > fadcmax) { fadcmax = fadc; imax = id;} | |
161 | if(fadc > (float)fCutAmplitude[idx])lthrt++; | |
162 | if(dfadc[k][id] > dfadcmax) { | |
163 | dfadcmax = dfadc[k][id]; | |
164 | imaxd = id; | |
165 | } // end if | |
166 | } // end for m | |
167 | it = imaxd; | |
168 | if(Map()->TestHit(idx,imax) == kEmpty) {it++; continue;} | |
169 | // cluster charge | |
170 | Int_t tstart = it-2; | |
171 | if(tstart < 0) tstart = 0; | |
172 | Bool_t ilcl = 0; | |
173 | if(lthrt >= lthrmint && lthra >= lthrmina) ilcl = 1; | |
174 | if(ilcl) { | |
175 | nofFoundClusters++; | |
176 | Int_t tstop = tstart; | |
177 | Double_t dfadcmin = 10000.; | |
178 | Int_t ij; | |
179 | for(ij=0; ij<20; ij++) { | |
180 | if(tstart+ij > 255) { tstop = 255; break; } | |
181 | fadc=(float)Map()->GetSignal(idx,tstart+ij); | |
182 | if((dfadc[k][tstart+ij] < dfadcmin) && | |
183 | (fadc > fCutAmplitude[idx])) { | |
184 | tstop = tstart+ij+5; | |
185 | if(tstop > 255) tstop = 255; | |
186 | dfadcmin = dfadc[k][it+ij]; | |
187 | } // end if | |
188 | } // end for ij | |
189 | ||
190 | Double_t clusterCharge = 0.; | |
191 | Double_t clusterAnode = k+0.5; | |
192 | Double_t clusterTime = 0.; | |
193 | Int_t clusterMult = 0; | |
194 | Double_t clusterPeakAmplitude = 0.; | |
195 | Int_t its,peakpos = -1; | |
196 | ||
197 | for(its=tstart; its<=tstop; its++) { | |
198 | fadc=(float)Map()->GetSignal(idx,its); | |
199 | if(!((strstr(option,"1D")) || (strstr(option,"2D")))){ | |
200 | Double_t baseline=GetResp(fModule)->GetBaseline(idx); | |
201 | if(fadc>baseline) fadc -= baseline; | |
202 | else fadc = 0.; | |
203 | } | |
204 | clusterCharge += fadc; | |
205 | // as a matter of fact we should take the peak | |
206 | // pos before FFT | |
207 | // to get the list of tracks !!! | |
208 | if(fadc > clusterPeakAmplitude) { | |
209 | clusterPeakAmplitude = fadc; | |
210 | //peakpos=Map()->GetHitIndex(idx,its); | |
211 | Int_t shift = (int)(fTimeCorr/fTimeStep); | |
212 | if(its>shift && its<(fMaxNofSamples-shift)) | |
213 | peakpos = Map()->GetHitIndex(idx,its+shift); | |
214 | else peakpos = Map()->GetHitIndex(idx,its); | |
215 | if(peakpos<0) peakpos =Map()->GetHitIndex(idx,its); | |
216 | } // end if | |
217 | clusterTime += fadc*its; | |
218 | if(fadc > 0) clusterMult++; | |
219 | if(its == tstop) { | |
220 | clusterTime /= (clusterCharge/fTimeStep); // ns | |
221 | if(clusterTime>fTimeCorr) clusterTime -=fTimeCorr; | |
222 | //ns | |
223 | } // end if | |
224 | } // end for its | |
225 | ||
226 | Double_t clusteranodePath = (clusterAnode - fNofAnodes/2)* | |
227 | anodePitch; | |
228 | Double_t clusterDriftPath = (Double_t)cal->GetDriftPath(clusterTime,clusteranodePath); | |
229 | clusterDriftPath = fSddLength-clusterDriftPath; | |
230 | if(clusterCharge <= 0.) break; | |
231 | AliITSRawClusterSDD clust(j+1,//i | |
232 | clusterAnode,clusterTime,//ff | |
233 | clusterCharge, //f | |
234 | clusterPeakAmplitude, //f | |
235 | peakpos, //i | |
236 | 0.,0.,clusterDriftPath,//fff | |
237 | clusteranodePath, //f | |
238 | clusterMult, //i | |
239 | 0,0,0,0,0,0,0);//7*i | |
240 | fDetTypeRec->AddCluster(1,&clust); | |
241 | it = tstop; | |
242 | } // ilcl | |
243 | it++; | |
244 | } // while (samples) | |
245 | } // anodes | |
246 | } // detectors (2) | |
247 | ||
248 | for(i=0;i<fNofAnodes;i++) delete[] dfadc[i]; | |
249 | delete [] dfadc; | |
250 | ||
251 | return; | |
252 | } | |
253 | //______________________________________________________________________ | |
254 | void AliITSClusterFinderSDD::Find1DClustersE(){ | |
255 | // find 1D clusters | |
256 | // retrieve the parameters | |
257 | Int_t fNofMaps = GetSeg()->Npz(); | |
258 | Int_t fMaxNofSamples = GetSeg()->Npx(); | |
259 | Int_t fNofAnodes = fNofMaps/2; | |
260 | Int_t dummy=0; | |
261 | Double_t fTimeStep = GetSeg()->Dpx( dummy ); | |
262 | Double_t fSddLength = GetSeg()->Dx(); | |
263 | Double_t anodePitch = GetSeg()->Dpz( dummy ); | |
264 | AliITSCalibrationSDD* cal = (AliITSCalibrationSDD*)GetResp(fModule); | |
265 | Map()->ClearMap(); | |
266 | Map()->SetThresholdArr( fCutAmplitude ); | |
267 | Map()->FillMap2(); | |
268 | ||
269 | AliITSresponseSDD* res = (AliITSresponseSDD*)cal->GetResponse(); | |
270 | const char *option=res->ZeroSuppOption(); | |
271 | ||
272 | Int_t nClu = 0; | |
273 | // cout << "Search cluster... "<< endl; | |
274 | for( Int_t j=0; j<2; j++ ){ | |
275 | for( Int_t k=0; k<fNofAnodes; k++ ){ | |
276 | Int_t idx = j*fNofAnodes+k; | |
277 | Bool_t on = kFALSE; | |
278 | Int_t start = 0; | |
279 | Int_t nTsteps = 0; | |
280 | Double_t fmax = 0.; | |
281 | Int_t lmax = 0; | |
282 | Double_t charge = 0.; | |
283 | Double_t time = 0.; | |
284 | Double_t anode = k+0.5; | |
285 | Int_t peakpos = -1; | |
286 | for( Int_t l=0; l<fMaxNofSamples; l++ ){ | |
287 | Double_t fadc = (Double_t)Map()->GetSignal( idx, l ); | |
288 | if( fadc > 0.0 ){ | |
289 | if( on == kFALSE && l<fMaxNofSamples-4){ | |
290 | // star RawCluster (reset var.) | |
291 | Double_t fadc1 = (Double_t)Map()->GetSignal( idx, l+1 ); | |
292 | if( fadc1 < fadc ) continue; | |
293 | start = l; | |
294 | fmax = 0.; | |
295 | lmax = 0; | |
296 | time = 0.; | |
297 | charge = 0.; | |
298 | on = kTRUE; | |
299 | nTsteps = 0; | |
300 | } // end if on... | |
301 | nTsteps++ ; | |
302 | if(!((strstr(option,"1D")) || (strstr(option,"2D")))){ | |
303 | Double_t baseline=GetResp(fModule)->GetBaseline(idx); | |
304 | if( fadc > baseline ) fadc -= baseline; | |
305 | else fadc=0.; | |
306 | } | |
307 | charge += fadc; | |
308 | time += fadc*l; | |
309 | if( fadc > fmax ){ | |
310 | fmax = fadc; | |
311 | lmax = l; | |
312 | Int_t shift = (Int_t)(fTimeCorr/fTimeStep + 0.5); | |
313 | if( l > shift && l < (fMaxNofSamples-shift) ) | |
314 | peakpos = Map()->GetHitIndex( idx, l+shift ); | |
315 | else | |
316 | peakpos = Map()->GetHitIndex( idx, l ); | |
317 | if( peakpos < 0) peakpos = Map()->GetHitIndex(idx,l); | |
318 | } // end if fadc | |
319 | }else{ // end fadc>0 | |
320 | if( on == kTRUE ){ | |
321 | if( nTsteps > 2 ){ | |
322 | // min # of timesteps for a RawCluster | |
323 | // Found a RawCluster... | |
324 | Int_t stop = l-1; | |
325 | time /= (charge/fTimeStep); // ns | |
326 | // time = lmax*fTimeStep; // ns | |
327 | if( time > fTimeCorr ) time -= fTimeCorr; // ns | |
328 | Double_t anodePath =(anode-fNofAnodes/2)*anodePitch; | |
329 | ||
330 | Double_t driftPath = (Double_t)cal->GetDriftPath(time,anodePath); | |
331 | driftPath = fSddLength-driftPath; | |
332 | AliITSRawClusterSDD clust(j+1,anode,time,charge, | |
333 | fmax, peakpos,0.,0., | |
334 | driftPath,anodePath, | |
335 | nTsteps,start,stop, | |
336 | start, stop, 1, k, k ); | |
337 | fDetTypeRec->AddCluster( 1, &clust ); | |
338 | if(AliDebugLevel()>=5) clust.PrintInfo(); | |
339 | nClu++; | |
340 | } // end if nTsteps | |
341 | on = kFALSE; | |
342 | } // end if on==kTRUE | |
343 | } // end if fadc>0 | |
344 | } // samples | |
345 | } // anodes | |
346 | } // wings | |
347 | AliDebug(3,Form("# Rawclusters %d",nClu)); | |
348 | return; | |
349 | } | |
350 | //_______________________________________________________________________ | |
351 | Int_t AliITSClusterFinderSDD::SearchPeak(Double_t *spect,Int_t xdim,Int_t zdim, | |
352 | Int_t *peakX, Int_t *peakZ, | |
353 | Double_t *peakAmp, Double_t minpeak ){ | |
354 | // search peaks on a 2D cluster | |
355 | Int_t npeak = 0; // # peaks | |
356 | Int_t i,j; | |
357 | // search peaks | |
358 | for( Int_t z=1; z<zdim-1; z++ ){ | |
359 | for( Int_t x=1; x<xdim-2; x++ ){ | |
360 | Double_t sxz = spect[x*zdim+z]; | |
361 | Double_t sxz1 = spect[(x+1)*zdim+z]; | |
362 | Double_t sxz2 = spect[(x-1)*zdim+z]; | |
363 | // search a local max. in s[x,z] | |
364 | if( sxz < minpeak || sxz1 <= 0 || sxz2 <= 0 ) continue; | |
365 | if( sxz >= spect[(x+1)*zdim+z ] && sxz >= spect[(x-1)*zdim+z ] && | |
366 | sxz >= spect[x*zdim +z+1] && sxz >= spect[x*zdim +z-1] && | |
367 | sxz >= spect[(x+1)*zdim+z+1] && sxz >= spect[(x+1)*zdim+z-1] && | |
368 | sxz >= spect[(x-1)*zdim+z+1] && sxz >= spect[(x-1)*zdim+z-1] ){ | |
369 | // peak found | |
370 | peakX[npeak] = x; | |
371 | peakZ[npeak] = z; | |
372 | peakAmp[npeak] = sxz; | |
373 | npeak++; | |
374 | } // end if .... | |
375 | } // end for x | |
376 | } // end for z | |
377 | // search groups of peaks with same amplitude. | |
378 | Int_t *flag = new Int_t[npeak]; | |
379 | for( i=0; i<npeak; i++ ) flag[i] = 0; | |
380 | for( i=0; i<npeak; i++ ){ | |
381 | for( j=0; j<npeak; j++ ){ | |
382 | if( i==j) continue; | |
383 | if( flag[j] > 0 ) continue; | |
384 | if( peakAmp[i] == peakAmp[j] && | |
385 | TMath::Abs(peakX[i]-peakX[j])<=1 && | |
386 | TMath::Abs(peakZ[i]-peakZ[j])<=1 ){ | |
387 | if( flag[i] == 0) flag[i] = i+1; | |
388 | flag[j] = flag[i]; | |
389 | } // end if ... | |
390 | } // end for j | |
391 | } // end for i | |
392 | // make average of peak groups | |
393 | for( i=0; i<npeak; i++ ){ | |
394 | Int_t nFlag = 1; | |
395 | if( flag[i] <= 0 ) continue; | |
396 | for( j=0; j<npeak; j++ ){ | |
397 | if( i==j ) continue; | |
398 | if( flag[j] != flag[i] ) continue; | |
399 | peakX[i] += peakX[j]; | |
400 | peakZ[i] += peakZ[j]; | |
401 | nFlag++; | |
402 | npeak--; | |
403 | for( Int_t k=j; k<npeak; k++ ){ | |
404 | peakX[k] = peakX[k+1]; | |
405 | peakZ[k] = peakZ[k+1]; | |
406 | peakAmp[k] = peakAmp[k+1]; | |
407 | flag[k] = flag[k+1]; | |
408 | } // end for k | |
409 | j--; | |
410 | } // end for j | |
411 | if( nFlag > 1 ){ | |
412 | peakX[i] /= nFlag; | |
413 | peakZ[i] /= nFlag; | |
414 | } // end fi nFlag | |
415 | } // end for i | |
416 | delete [] flag; | |
417 | return( npeak ); | |
418 | } | |
419 | //______________________________________________________________________ | |
420 | void AliITSClusterFinderSDD::PeakFunc( Int_t xdim, Int_t zdim, Double_t *par, | |
421 | Double_t *spe, Double_t *integral){ | |
422 | // function used to fit the clusters | |
423 | // par -> parameters.. | |
424 | // par[0] number of peaks. | |
425 | // for each peak i=1, ..., par[0] | |
426 | // par[i] = Ampl. | |
427 | // par[i+1] = xpos | |
428 | // par[i+2] = zpos | |
429 | // par[i+3] = tau | |
430 | // par[i+4] = sigma. | |
431 | Int_t electronics = GetResp(fModule)->GetElectronics(); // 1 = PASCAL, 2 = OLA | |
432 | const Int_t knParam = 5; | |
433 | Int_t npeak = (Int_t)par[0]; | |
434 | ||
435 | memset( spe, 0, sizeof( Double_t )*zdim*xdim ); | |
436 | ||
437 | Int_t k = 1; | |
438 | for( Int_t i=0; i<npeak; i++ ){ | |
439 | if( integral != 0 ) integral[i] = 0.; | |
440 | Double_t sigmaA2 = par[k+4]*par[k+4]*2.; | |
441 | Double_t t2 = par[k+3]; // PASCAL | |
442 | if( electronics == 2 ) { t2 *= t2; t2 *= 2; } // OLA | |
443 | for( Int_t z=0; z<zdim; z++ ){ | |
444 | for( Int_t x=0; x<xdim; x++ ){ | |
445 | Double_t z2 = (z-par[k+2])*(z-par[k+2])/sigmaA2; | |
446 | Double_t x2 = 0.; | |
447 | Double_t signal = 0.; | |
448 | if( electronics == 1 ){ // PASCAL | |
449 | x2 = (x-par[k+1]+t2)/t2; | |
450 | signal = (x2>0.) ? par[k]*x2*exp(-x2+1.-z2) :0.0; // RCCR2 | |
451 | // signal =(x2>0.) ? par[k]*x2*x2*exp(-2*x2+2.-z2 ):0.0;//RCCR | |
452 | }else if( electronics == 2 ) { // OLA | |
453 | x2 = (x-par[k+1])*(x-par[k+1])/t2; | |
454 | signal = par[k] * exp( -x2 - z2 ); | |
455 | } else { | |
456 | Warning("PeakFunc","Wrong SDD Electronics = %d", | |
457 | electronics); | |
458 | // exit( 1 ); | |
459 | } // end if electronicx | |
460 | spe[x*zdim+z] += signal; | |
461 | if( integral != 0 ) integral[i] += signal; | |
462 | } // end for x | |
463 | } // end for z | |
464 | k += knParam; | |
465 | } // end for i | |
466 | return; | |
467 | } | |
468 | //__________________________________________________________________________ | |
469 | Double_t AliITSClusterFinderSDD::ChiSqr( Int_t xdim, Int_t zdim, Double_t *spe, | |
470 | Double_t *speFit ) const{ | |
471 | // EVALUATES UNNORMALIZED CHI-SQUARED | |
472 | Double_t chi2 = 0.; | |
473 | for( Int_t z=0; z<zdim; z++ ){ | |
474 | for( Int_t x=1; x<xdim-1; x++ ){ | |
475 | Int_t index = x*zdim+z; | |
476 | Double_t tmp = spe[index] - speFit[index]; | |
477 | chi2 += tmp*tmp; | |
478 | } // end for x | |
479 | } // end for z | |
480 | return( chi2 ); | |
481 | } | |
482 | //_______________________________________________________________________ | |
483 | void AliITSClusterFinderSDD::Minim( Int_t xdim, Int_t zdim, Double_t *param, | |
484 | Double_t *prm0,Double_t *steprm, | |
485 | Double_t *chisqr,Double_t *spe, | |
486 | Double_t *speFit ){ | |
487 | // | |
488 | Int_t k, nnn, mmm, i; | |
489 | Double_t p1, delta, d1, chisq1, p2, chisq2, t, p3, chisq3, a, b, p0, chisqt; | |
490 | const Int_t knParam = 5; | |
491 | Int_t npeak = (Int_t)param[0]; | |
492 | for( k=1; k<(npeak*knParam+1); k++ ) prm0[k] = param[k]; | |
493 | for( k=1; k<(npeak*knParam+1); k++ ){ | |
494 | p1 = param[k]; | |
495 | delta = steprm[k]; | |
496 | d1 = delta; | |
497 | // ENSURE THAT STEP SIZE IS SENSIBLY LARGER THAN MACHINE ROUND OFF | |
498 | if( TMath::Abs( p1 ) > 1.0E-6 ) | |
499 | if ( TMath::Abs( delta/p1 ) < 1.0E-4 ) delta = p1/1000; | |
500 | else delta = (Double_t)1.0E-4; | |
501 | // EVALUATE CHI-SQUARED AT FIRST TWO SEARCH POINTS | |
502 | PeakFunc( xdim, zdim, param, speFit ); | |
503 | chisq1 = ChiSqr( xdim, zdim, spe, speFit ); | |
504 | p2 = p1+delta; | |
505 | param[k] = p2; | |
506 | PeakFunc( xdim, zdim, param, speFit ); | |
507 | chisq2 = ChiSqr( xdim, zdim, spe, speFit ); | |
508 | if( chisq1 < chisq2 ){ | |
509 | // REVERSE DIRECTION OF SEARCH IF CHI-SQUARED IS INCREASING | |
510 | delta = -delta; | |
511 | t = p1; | |
512 | p1 = p2; | |
513 | p2 = t; | |
514 | t = chisq1; | |
515 | chisq1 = chisq2; | |
516 | chisq2 = t; | |
517 | } // end if | |
518 | i = 1; nnn = 0; | |
519 | do { // INCREMENT param(K) UNTIL CHI-SQUARED STARTS TO INCREASE | |
520 | nnn++; | |
521 | p3 = p2 + delta; | |
522 | mmm = nnn - (nnn/5)*5; // multiplo de 5 | |
523 | if( mmm == 0 ){ | |
524 | d1 = delta; | |
525 | // INCREASE STEP SIZE IF STEPPING TOWARDS MINIMUM IS TOO SLOW | |
526 | delta *= 5; | |
527 | } // end if | |
528 | param[k] = p3; | |
529 | // Constrain paramiters | |
530 | Int_t kpos = (k-1) % knParam; | |
531 | switch( kpos ){ | |
532 | case 0 : | |
533 | if( param[k] <= 20 ) param[k] = fMinPeak; | |
534 | break; | |
535 | case 1 : | |
536 | if( TMath::Abs( param[k] - prm0[k] ) > 1.5 ) param[k] = prm0[k]; | |
537 | break; | |
538 | case 2 : | |
539 | if( TMath::Abs( param[k] - prm0[k] ) > 1. ) param[k] = prm0[k]; | |
540 | break; | |
541 | case 3 : | |
542 | if( param[k] < .5 ) param[k] = .5; | |
543 | break; | |
544 | case 4 : | |
545 | if( param[k] < .288 ) param[k] = .288;// 1/sqrt(12) = 0.288 | |
546 | if( param[k] > zdim*.5 ) param[k] = zdim*.5; | |
547 | break; | |
548 | }; // end switch | |
549 | PeakFunc( xdim, zdim, param, speFit ); | |
550 | chisq3 = ChiSqr( xdim, zdim, spe, speFit ); | |
551 | if( chisq3 < chisq2 && nnn < 50 ){ | |
552 | p1 = p2; | |
553 | p2 = p3; | |
554 | chisq1 = chisq2; | |
555 | chisq2 = chisq3; | |
556 | }else i=0; | |
557 | } while( i ); | |
558 | // FIND MINIMUM OF PARABOLA DEFINED BY LAST THREE POINTS | |
559 | a = chisq1*(p2-p3)+chisq2*(p3-p1)+chisq3*(p1-p2); | |
560 | b = chisq1*(p2*p2-p3*p3)+chisq2*(p3*p3-p1*p1)+chisq3*(p1*p1-p2*p2); | |
561 | if( a!=0 ) p0 = (Double_t)(0.5*b/a); | |
562 | else p0 = 10000; | |
563 | //--IN CASE OF NEARLY EQUAL CHI-SQUARED AND TOO SMALL STEP SIZE PREVENT | |
564 | // ERRONEOUS EVALUATION OF PARABOLA MINIMUM | |
565 | //---NEXT TWO LINES CAN BE OMITTED FOR HIGHER PRECISION MACHINES | |
566 | //dp = (Double_t) max (TMath::Abs(p3-p2), TMath::Abs(p2-p1)); | |
567 | //if( TMath::Abs( p2-p0 ) > dp ) p0 = p2; | |
568 | param[k] = p0; | |
569 | // Constrain paramiters | |
570 | Int_t kpos = (k-1) % knParam; | |
571 | switch( kpos ){ | |
572 | case 0 : | |
573 | if( param[k] <= 20 ) param[k] = fMinPeak; | |
574 | break; | |
575 | case 1 : | |
576 | if( TMath::Abs( param[k] - prm0[k] ) > 1.5 ) param[k] = prm0[k]; | |
577 | break; | |
578 | case 2 : | |
579 | if( TMath::Abs( param[k] - prm0[k] ) > 1. ) param[k] = prm0[k]; | |
580 | break; | |
581 | case 3 : | |
582 | if( param[k] < .5 ) param[k] = .5; | |
583 | break; | |
584 | case 4 : | |
585 | if( param[k] < .288 ) param[k] = .288; // 1/sqrt(12) = 0.288 | |
586 | if( param[k] > zdim*.5 ) param[k] = zdim*.5; | |
587 | break; | |
588 | }; // end switch | |
589 | PeakFunc( xdim, zdim, param, speFit ); | |
590 | chisqt = ChiSqr( xdim, zdim, spe, speFit ); | |
591 | // DO NOT ALLOW ERRONEOUS INTERPOLATION | |
592 | if( chisqt <= *chisqr ) *chisqr = chisqt; | |
593 | else param[k] = prm0[k]; | |
594 | // OPTIMIZE SEARCH STEP FOR EVENTUAL NEXT CALL OF MINIM | |
595 | steprm[k] = (param[k]-prm0[k])/5; | |
596 | if( steprm[k] >= d1 ) steprm[k] = d1/5; | |
597 | } // end for k | |
598 | // EVALUATE FIT AND CHI-SQUARED FOR OPTIMIZED PARAMETERS | |
599 | PeakFunc( xdim, zdim, param, speFit ); | |
600 | *chisqr = ChiSqr( xdim, zdim, spe, speFit ); | |
601 | return; | |
602 | } | |
603 | //_________________________________________________________________________ | |
604 | Int_t AliITSClusterFinderSDD::NoLinearFit( Int_t xdim, Int_t zdim, | |
605 | Double_t *param, Double_t *spe, | |
606 | Int_t *niter, Double_t *chir ){ | |
607 | // fit method from Comput. Phys. Commun 46(1987) 149 | |
608 | const Double_t kchilmt = 0.01; // relative accuracy | |
609 | const Int_t knel = 3; // for parabolic minimization | |
610 | const Int_t knstop = 50; // Max. iteration number | |
611 | const Int_t knParam = 5; | |
612 | Int_t npeak = (Int_t)param[0]; | |
613 | // RETURN IF NUMBER OF DEGREES OF FREEDOM IS NOT POSITIVE | |
614 | if( (xdim*zdim - npeak*knParam) <= 0 ) return( -1 ); | |
615 | Double_t degFree = (xdim*zdim - npeak*knParam)-1; | |
616 | Int_t n, k, iterNum = 0; | |
617 | Double_t *prm0 = new Double_t[npeak*knParam+1]; | |
618 | Double_t *step = new Double_t[npeak*knParam+1]; | |
619 | Double_t *schi = new Double_t[npeak*knParam+1]; | |
620 | Double_t *sprm[3]; | |
621 | sprm[0] = new Double_t[npeak*knParam+1]; | |
622 | sprm[1] = new Double_t[npeak*knParam+1]; | |
623 | sprm[2] = new Double_t[npeak*knParam+1]; | |
624 | Double_t chi0, chi1, reldif, a, b, prmin, dp; | |
625 | Double_t *speFit = new Double_t[ xdim*zdim ]; | |
626 | PeakFunc( xdim, zdim, param, speFit ); | |
627 | chi0 = ChiSqr( xdim, zdim, spe, speFit ); | |
628 | chi1 = chi0; | |
629 | for( k=1; k<(npeak*knParam+1); k++) prm0[k] = param[k]; | |
630 | for( k=1 ; k<(npeak*knParam+1); k+=knParam ){ | |
631 | step[k] = param[k] / 20.0 ; | |
632 | step[k+1] = param[k+1] / 50.0; | |
633 | step[k+2] = param[k+2] / 50.0; | |
634 | step[k+3] = param[k+3] / 20.0; | |
635 | step[k+4] = param[k+4] / 20.0; | |
636 | } // end for k | |
637 | Int_t out = 0; | |
638 | do{ | |
639 | iterNum++; | |
640 | chi0 = chi1; | |
641 | Minim( xdim, zdim, param, prm0, step, &chi1, spe, speFit ); | |
642 | reldif = ( chi1 > 0 ) ? ((Double_t) TMath::Abs( chi1-chi0)/chi1 ) : 0; | |
643 | // EXIT conditions | |
644 | if( reldif < (float) kchilmt ){ | |
645 | *chir = (chi1>0) ? (float) TMath::Sqrt (chi1/degFree) :0; | |
646 | *niter = iterNum; | |
647 | out = 0; | |
648 | break; | |
649 | } // end if | |
650 | if( (reldif < (float)(5*kchilmt)) && (iterNum > knstop) ){ | |
651 | *chir = (chi1>0) ?(float) TMath::Sqrt (chi1/degFree):0; | |
652 | *niter = iterNum; | |
653 | out = 0; | |
654 | break; | |
655 | } // end if | |
656 | if( iterNum > 5*knstop ){ | |
657 | *chir = (chi1>0) ?(float) TMath::Sqrt (chi1/degFree):0; | |
658 | *niter = iterNum; | |
659 | out = 1; | |
660 | break; | |
661 | } // end if | |
662 | if( iterNum <= knel ) continue; | |
663 | n = iterNum - (iterNum/knel)*knel; // EXTRAPOLATION LIMIT COUNTER N | |
664 | if( n > 3 || n == 0 ) continue; | |
665 | schi[n-1] = chi1; | |
666 | for( k=1; k<(npeak*knParam+1); k++ ) sprm[n-1][k] = param[k]; | |
667 | if( n != 3 ) continue; | |
668 | // -EVALUATE EXTRAPOLATED VALUE OF EACH PARAMETER BY FINDING MINIMUM OF | |
669 | // PARABOLA DEFINED BY LAST THREE CALLS OF MINIM | |
670 | for( k=1; k<(npeak*knParam+1); k++ ){ | |
671 | Double_t tmp0 = sprm[0][k]; | |
672 | Double_t tmp1 = sprm[1][k]; | |
673 | Double_t tmp2 = sprm[2][k]; | |
674 | a = schi[0]*(tmp1-tmp2) + schi[1]*(tmp2-tmp0); | |
675 | a += (schi[2]*(tmp0-tmp1)); | |
676 | b = schi[0]*(tmp1*tmp1-tmp2*tmp2); | |
677 | b += (schi[1]*(tmp2*tmp2-tmp0*tmp0)+(schi[2]* | |
678 | (tmp0*tmp0-tmp1*tmp1))); | |
679 | if ((double)a < 1.0E-6) prmin = 0; | |
680 | else prmin = (float) (0.5*b/a); | |
681 | dp = 5*(tmp2-tmp0); | |
682 | if( TMath::Abs(prmin-tmp2) > TMath::Abs(dp) ) prmin = tmp2+dp; | |
683 | param[k] = prmin; | |
684 | step[k] = dp/10; // OPTIMIZE SEARCH STEP | |
685 | } // end for k | |
686 | } while( kTRUE ); | |
687 | delete [] prm0; | |
688 | delete [] step; | |
689 | delete [] schi; | |
690 | delete [] sprm[0]; | |
691 | delete [] sprm[1]; | |
692 | delete [] sprm[2]; | |
693 | delete [] speFit; | |
694 | return( out ); | |
695 | } | |
696 | ||
697 | //______________________________________________________________________ | |
698 | void AliITSClusterFinderSDD::ResolveClusters(){ | |
699 | // The function to resolve clusters if the clusters overlapping exists | |
700 | Int_t i; | |
701 | // get number of clusters for this module | |
702 | Int_t nofClusters = NClusters(); | |
703 | nofClusters -= fNclusters; | |
704 | Int_t fNofMaps = GetSeg()->Npz(); | |
705 | Int_t fNofAnodes = fNofMaps/2; | |
706 | //Int_t fMaxNofSamples = GetSeg()->Npx(); | |
707 | Int_t dummy=0; | |
708 | Double_t fTimeStep = GetSeg()->Dpx( dummy ); | |
709 | Double_t fSddLength = GetSeg()->Dx(); | |
710 | Double_t anodePitch = GetSeg()->Dpz( dummy ); | |
711 | Int_t electronics =GetResp(fModule)->GetElectronics(); // 1 = PASCAL, 2 = OLA | |
712 | AliITSCalibrationSDD* cal = (AliITSCalibrationSDD*)GetResp(fModule); | |
713 | AliITSresponseSDD* res = (AliITSresponseSDD*)cal->GetResponse(); | |
714 | const char *option=res->ZeroSuppOption(); | |
715 | ||
716 | ||
717 | for( Int_t j=0; j<nofClusters; j++ ){ | |
718 | // get cluster information | |
719 | AliITSRawClusterSDD *clusterJ=(AliITSRawClusterSDD*) Cluster(j); | |
720 | Int_t astart = clusterJ->Astart(); | |
721 | Int_t astop = clusterJ->Astop(); | |
722 | Int_t tstart = clusterJ->Tstartf(); | |
723 | Int_t tstop = clusterJ->Tstopf(); | |
724 | Int_t wing = (Int_t)clusterJ->W(); | |
725 | if( wing == 2 ){ | |
726 | astart += fNofAnodes; | |
727 | astop += fNofAnodes; | |
728 | } // end if | |
729 | Int_t xdim = tstop-tstart+3; | |
730 | Int_t zdim = astop-astart+3; | |
731 | if( xdim > 50 || zdim > 30 ) { | |
732 | Warning("ResolveClusters","xdim: %d , zdim: %d ",xdim,zdim); | |
733 | continue; | |
734 | } | |
735 | Double_t *sp = new Double_t[ xdim*zdim+1 ]; | |
736 | memset( sp, 0, sizeof(Double_t)*(xdim*zdim+1) ); | |
737 | ||
738 | // make a local map from cluster region | |
739 | for( Int_t ianode=astart; ianode<=astop; ianode++ ){ | |
740 | for( Int_t itime=tstart; itime<=tstop; itime++ ){ | |
741 | Double_t fadc = Map()->GetSignal( ianode, itime ); | |
742 | if(!((strstr(option,"1D")) || (strstr(option,"2D")))){ | |
743 | Double_t baseline=GetResp(fModule)->GetBaseline(ianode); | |
744 | if( fadc > baseline ) fadc -= (Double_t)baseline; | |
745 | else fadc = 0.; | |
746 | } | |
747 | Int_t index = (itime-tstart+1)*zdim+(ianode-astart+1); | |
748 | sp[index] = fadc; | |
749 | } // time loop | |
750 | } // anode loop | |
751 | ||
752 | // search peaks on cluster | |
753 | const Int_t kNp = 150; | |
754 | Int_t peakX1[kNp]; | |
755 | Int_t peakZ1[kNp]; | |
756 | Double_t peakAmp1[kNp]; | |
757 | Int_t npeak = SearchPeak(sp,xdim,zdim,peakX1,peakZ1,peakAmp1,fMinPeak); | |
758 | ||
759 | // if multiple peaks, split cluster | |
760 | if( npeak >= 1 ){ | |
761 | // cout << "npeak " << npeak << endl; | |
762 | // clusterJ->PrintInfo(); | |
763 | Double_t *par = new Double_t[npeak*5+1]; | |
764 | par[0] = (Double_t)npeak; | |
765 | // Initial parameters in cell dimentions | |
766 | Int_t k1 = 1; | |
767 | for( i=0; i<npeak; i++ ){ | |
768 | par[k1] = peakAmp1[i]; | |
769 | par[k1+1] = peakX1[i]; // local time pos. [timebin] | |
770 | par[k1+2] = peakZ1[i]; // local anode pos. [anodepitch] | |
771 | if( electronics == 1 ) par[k1+3] = 2.; // PASCAL | |
772 | else if(electronics==2) par[k1+3] = 0.7;//tau [timebin] OLA | |
773 | par[k1+4] = .4; // sigma [anodepich] | |
774 | k1 += 5; | |
775 | } // end for i | |
776 | Int_t niter; | |
777 | Double_t chir; | |
778 | NoLinearFit( xdim, zdim, par, sp, &niter, &chir ); | |
779 | Double_t peakX[kNp]; | |
780 | Double_t peakZ[kNp]; | |
781 | Double_t sigma[kNp]; | |
782 | Double_t tau[kNp]; | |
783 | Double_t peakAmp[kNp]; | |
784 | Double_t integral[kNp]; | |
785 | //get integrals => charge for each peak | |
786 | PeakFunc( xdim, zdim, par, sp, integral ); | |
787 | k1 = 1; | |
788 | for( i=0; i<npeak; i++ ){ | |
789 | peakAmp[i] = par[k1]; | |
790 | peakX[i] = par[k1+1]; | |
791 | peakZ[i] = par[k1+2]; | |
792 | tau[i] = par[k1+3]; | |
793 | sigma[i] = par[k1+4]; | |
794 | k1+=5; | |
795 | } // end for i | |
796 | // calculate parameter for new clusters | |
797 | for( i=0; i<npeak; i++ ){ | |
798 | AliITSRawClusterSDD clusterI( *clusterJ ); | |
799 | ||
800 | Int_t newAnode = peakZ1[i]-1 + astart; | |
801 | ||
802 | // Int_t newiTime = peakX1[i]-1 + tstart; | |
803 | // Int_t shift = (Int_t)(fTimeCorr/fTimeStep + 0.5); | |
804 | // if( newiTime > shift && newiTime < (fMaxNofSamples-shift) ) | |
805 | // shift = 0; | |
806 | // Int_t peakpos = Map()->GetHitIndex(newAnode,newiTime+shift ); | |
807 | // clusterI.SetPeakPos( peakpos ); | |
808 | ||
809 | clusterI.SetPeakAmpl( peakAmp1[i] ); | |
810 | Double_t newAnodef = peakZ[i] - 0.5 + astart; | |
811 | Double_t newiTimef = peakX[i] - 1 + tstart; | |
812 | if( wing == 2 ) newAnodef -= fNofAnodes; | |
813 | Double_t anodePath = (newAnodef - fNofAnodes/2)*anodePitch; | |
814 | newiTimef *= fTimeStep; | |
815 | if( newiTimef > fTimeCorr ) newiTimef -= fTimeCorr; | |
816 | if( electronics == 1 ){ | |
817 | // newiTimef *= 0.999438; // PASCAL | |
818 | // newiTimef += (6./fDriftSpeed - newiTimef/3000.); | |
819 | }else if( electronics == 2 ) | |
820 | newiTimef *= 0.99714; // OLA | |
821 | ||
822 | Int_t timeBin = (Int_t)(newiTimef/fTimeStep+0.5); | |
823 | Int_t peakpos = Map()->GetHitIndex( newAnode, timeBin ); | |
824 | if( peakpos < 0 ) { | |
825 | for( Int_t ii=0; ii<3; ii++ ) { | |
826 | peakpos = Map()->GetHitIndex( newAnode, timeBin+ii ); | |
827 | if( peakpos > 0 ) break; | |
828 | peakpos = Map()->GetHitIndex( newAnode, timeBin-ii ); | |
829 | if( peakpos > 0 ) break; | |
830 | } | |
831 | } | |
832 | ||
833 | if( peakpos < 0 ) { | |
834 | //Warning("ResolveClusters", | |
835 | // "Digit not found for cluster"); | |
836 | //if(AliDebugLevel()>=3) clusterI.PrintInfo(); | |
837 | continue; | |
838 | } | |
839 | clusterI.SetPeakPos( peakpos ); | |
840 | Float_t dp = cal->GetDriftPath(newiTimef,anodePath); | |
841 | Double_t driftPath = fSddLength - (Double_t)dp; | |
842 | Double_t sign = ( wing == 1 ) ? -1. : 1.; | |
843 | Double_t xcoord = driftPath*sign * 0.0001; | |
844 | Double_t zcoord = anodePath * 0.0001; | |
845 | CorrectPosition(zcoord,xcoord); | |
846 | clusterI.SetX( xcoord ); | |
847 | clusterI.SetZ( zcoord ); | |
848 | clusterI.SetAnode( newAnodef ); | |
849 | clusterI.SetTime( newiTimef ); | |
850 | clusterI.SetAsigma( sigma[i]*anodePitch ); | |
851 | clusterI.SetTsigma( tau[i]*fTimeStep ); | |
852 | clusterI.SetQ( integral[i] ); | |
853 | ||
854 | fDetTypeRec->AddCluster( 1, &clusterI ); | |
855 | } // end for i | |
856 | Clusters()->RemoveAt( j ); | |
857 | delete [] par; | |
858 | } else { // something odd | |
859 | Warning( "ResolveClusters", | |
860 | "--- Peak not found!!!! minpeak=%d ,cluster peak= %f" | |
861 | " , module= %d", | |
862 | fMinPeak, clusterJ->PeakAmpl(),GetModule()); | |
863 | clusterJ->PrintInfo(); | |
864 | Warning( "ResolveClusters"," xdim= %d zdim= %d", xdim-2, zdim-2 ); | |
865 | } | |
866 | delete [] sp; | |
867 | } // cluster loop | |
868 | Clusters()->Compress(); | |
869 | // Map()->ClearMap(); | |
870 | } | |
871 | //________________________________________________________________________ | |
872 | void AliITSClusterFinderSDD::GroupClusters(){ | |
873 | // group clusters | |
874 | Int_t dummy=0; | |
875 | Double_t fTimeStep = GetSeg()->Dpx(dummy); | |
876 | // get number of clusters for this module | |
877 | Int_t nofClusters = NClusters(); | |
878 | nofClusters -= fNclusters; | |
879 | AliITSRawClusterSDD *clusterI; | |
880 | AliITSRawClusterSDD *clusterJ; | |
881 | Int_t *label = new Int_t [nofClusters]; | |
882 | Int_t i,j; | |
883 | for(i=0; i<nofClusters; i++) label[i] = 0; | |
884 | for(i=0; i<nofClusters; i++) { | |
885 | if(label[i] != 0) continue; | |
886 | for(j=i+1; j<nofClusters; j++) { | |
887 | if(label[j] != 0) continue; | |
888 | clusterI = (AliITSRawClusterSDD*) Cluster(i); | |
889 | clusterJ = (AliITSRawClusterSDD*) Cluster(j); | |
890 | // 1.3 good | |
891 | if(clusterI->T() < fTimeStep*60) fDAnode = 4.2; // TB 3.2 | |
892 | if(clusterI->T() < fTimeStep*10) fDAnode = 1.5; // TB 1. | |
893 | Bool_t pair = clusterI->Brother(clusterJ,fDAnode,fDTime); | |
894 | if(!pair) continue; | |
895 | if(AliDebugLevel()>=4){ | |
896 | clusterI->PrintInfo(); | |
897 | clusterJ->PrintInfo(); | |
898 | } // end if AliDebugLevel | |
899 | clusterI->Add(clusterJ); | |
900 | label[j] = 1; | |
901 | Clusters()->RemoveAt(j); | |
902 | j=i; // <- Ernesto | |
903 | } // J clusters | |
904 | label[i] = 1; | |
905 | } // I clusters | |
906 | Clusters()->Compress(); | |
907 | ||
908 | delete [] label; | |
909 | return; | |
910 | } | |
911 | //________________________________________________________________________ | |
912 | void AliITSClusterFinderSDD::SelectClusters(){ | |
913 | // get number of clusters for this module | |
914 | Int_t nofClusters = NClusters(); | |
915 | ||
916 | nofClusters -= fNclusters; | |
917 | Int_t i; | |
918 | for(i=0; i<nofClusters; i++) { | |
919 | AliITSRawClusterSDD *clusterI =(AliITSRawClusterSDD*) Cluster(i); | |
920 | Int_t rmflg = 0; | |
921 | Double_t wy = 0.; | |
922 | if(clusterI->Anodes() != 0.) { | |
923 | wy = ((Double_t) clusterI->Samples())/clusterI->Anodes(); | |
924 | } // end if | |
925 | Int_t amp = (Int_t) clusterI->PeakAmpl(); | |
926 | Int_t cha = (Int_t) clusterI->Q(); | |
927 | if(amp < fMinPeak) rmflg = 1; | |
928 | if(cha < fMinCharge) rmflg = 1; | |
929 | if(wy < fMinNCells) rmflg = 1; | |
930 | //if(wy > fMaxNCells) rmflg = 1; | |
931 | if(rmflg) Clusters()->RemoveAt(i); | |
932 | } // I clusters | |
933 | Clusters()->Compress(); | |
934 | return; | |
935 | } | |
936 | ||
937 | //______________________________________________________________________ | |
938 | void AliITSClusterFinderSDD::GetRecPoints(){ | |
939 | // get rec points | |
940 | ||
941 | // get number of clusters for this module | |
942 | Int_t nofClusters = NClusters(); | |
943 | nofClusters -= fNclusters; | |
944 | const Double_t kconvGeV = 1.e-6; // GeV -> KeV | |
945 | const Double_t kconv = 1.0e-4; | |
946 | const Double_t kRMSx = 38.0*kconv; // microns->cm ITS TDR Table 1.3 | |
947 | const Double_t kRMSz = 28.0*kconv; // microns->cm ITS TDR Table 1.3 | |
948 | Int_t i; | |
949 | Int_t ix, iz, idx=-1; | |
950 | AliITSdigitSDD *dig=0; | |
951 | Int_t ndigits=NDigits(); | |
952 | ||
953 | Int_t lay,lad,det; | |
954 | fDetTypeRec->GetITSgeom()->GetModuleId(fModule,lay,lad,det); | |
955 | Int_t ind=(lad-1)*fDetTypeRec->GetITSgeom()->GetNdetectors(lay)+(det-1); | |
956 | Int_t lyr=(lay-1); | |
957 | ||
958 | ||
959 | for(i=0; i<nofClusters; i++) { | |
960 | AliITSRawClusterSDD *clusterI = (AliITSRawClusterSDD*)Cluster(i); | |
961 | if(!clusterI) Error("SDD: GetRecPoints","i clusterI ",i,clusterI); | |
962 | if(clusterI) idx=clusterI->PeakPos(); | |
963 | if(idx>ndigits) Error("SDD: GetRecPoints","idx ndigits",idx,ndigits); | |
964 | // try peak neighbours - to be done | |
965 | if(idx&&idx<= ndigits) dig =(AliITSdigitSDD*)GetDigit(idx); | |
966 | if(!dig) { | |
967 | // try cog | |
968 | GetSeg()->GetPadIxz(clusterI->X(),clusterI->Z(),ix,iz); | |
969 | dig = (AliITSdigitSDD*)Map()->GetHit(iz-1,ix-1); | |
970 | // if null try neighbours | |
971 | if (!dig) dig = (AliITSdigitSDD*)Map()->GetHit(iz-1,ix); | |
972 | if (!dig) dig = (AliITSdigitSDD*)Map()->GetHit(iz-1,ix+1); | |
973 | if (!dig) printf("SDD: cannot assign the track number!\n"); | |
974 | } // end if !dig | |
975 | ||
976 | Int_t lab[4] = {-3141593,-3141593,-3141593,ind}; | |
977 | if (dig) { | |
978 | lab[0] = dig->GetTrack(0); | |
979 | lab[1] = dig->GetTrack(1); | |
980 | lab[2] = dig->GetTrack(2); | |
981 | } | |
982 | Float_t hit[5] = {clusterI->X(),clusterI->Z(),kRMSx*kRMSx,kRMSz*kRMSz,clusterI->Q()}; | |
983 | Int_t info[3] = {0,0,lyr}; | |
984 | ||
985 | AliITSRecPoint rnew(lab,hit,info,kTRUE); | |
986 | rnew.SetdEdX(kconvGeV*clusterI->Q()); | |
987 | ||
988 | fDetTypeRec->AddRecPoint(rnew); | |
989 | } // I clusters | |
990 | // Map()->ClearMap(); | |
991 | } | |
992 | //______________________________________________________________________ | |
993 | void AliITSClusterFinderSDD::FindRawClusters(Int_t mod){ | |
994 | // find raw clusters | |
995 | ||
996 | SetModule(mod); | |
997 | SetCutAmplitude(mod); | |
998 | Int_t nanodes=GetSeg()->Npz(); | |
999 | Int_t noise=0; | |
1000 | for(Int_t i=0;i<nanodes;i++){ | |
1001 | noise+=(Int_t)(((AliITSCalibrationSDD*)GetResp(mod))->GetNoiseAfterElectronics(i)); | |
1002 | } | |
1003 | SetMinPeak((noise/nanodes)*5); | |
1004 | Find1DClustersE(); | |
1005 | GroupClusters(); | |
1006 | SelectClusters(); | |
1007 | ResolveClusters(); | |
1008 | GetRecPoints(); | |
1009 | } | |
1010 | //_______________________________________________________________________ | |
1011 | void AliITSClusterFinderSDD::PrintStatus() const{ | |
1012 | // Print SDD cluster finder Parameters | |
1013 | ||
1014 | cout << "**************************************************" << endl; | |
1015 | cout << " Silicon Drift Detector Cluster Finder Parameters " << endl; | |
1016 | cout << "**************************************************" << endl; | |
1017 | cout << "Number of Clusters: " << fNclusters << endl; | |
1018 | cout << "Anode Tolerance: " << fDAnode << endl; | |
1019 | cout << "Time Tolerance: " << fDTime << endl; | |
1020 | cout << "Time correction (electronics): " << fTimeCorr << endl; | |
1021 | cout << "Cut Amplitude (threshold): " << fCutAmplitude[0] << endl; | |
1022 | cout << "Minimum Amplitude: " << fMinPeak << endl; | |
1023 | cout << "Minimum Charge: " << fMinCharge << endl; | |
1024 | cout << "Minimum number of cells/clusters: " << fMinNCells << endl; | |
1025 | cout << "Maximum number of cells/clusters: " << fMaxNCells << endl; | |
1026 | cout << "**************************************************" << endl; | |
1027 | } | |
1028 | ||
1029 | //_________________________________________________________________________ | |
1030 | void AliITSClusterFinderSDD::CorrectPosition(Double_t &z, Double_t&y){ | |
1031 | //correction of coordinates using the maps stored in the DB | |
1032 | ||
1033 | AliITSCalibrationSDD* cal = (AliITSCalibrationSDD*)GetResp(fModule); | |
1034 | static const Int_t nbint = cal->GetMapTimeNBin(); | |
1035 | static const Int_t nbina = cal->Chips()*cal->Channels(); | |
1036 | Float_t stepa = (GetSeg()->Dpz(0))/10000.; //anode pitch in cm | |
1037 | Float_t stept = (GetSeg()->Dx()/cal->GetMapTimeNBin()/2.)/10.; | |
1038 | ||
1039 | Int_t bint = TMath::Abs((Int_t)(y/stept)); | |
1040 | if(y>=0) bint+=(Int_t)(nbint/2.); | |
1041 | if(bint>nbint) AliError("Wrong bin number!"); | |
1042 | ||
1043 | Int_t bina = TMath::Abs((Int_t)(z/stepa)); | |
1044 | if(z>=0) bina+=(Int_t)(nbina/2.); | |
1045 | if(bina>nbina) AliError("Wrong bin number!"); | |
1046 | ||
1047 | Double_t devz = (Double_t)cal->GetMapACell(bina,bint)/10000.; | |
1048 | Double_t devx = (Double_t)cal->GetMapTCell(bina,bint)/10000.; | |
1049 | z+=devz; | |
1050 | y+=devx; | |
1051 | ||
1052 | } |