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