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