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