1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
17 #include "AliITSClusterFinderSDD.h"
22 ClassImp(AliITSClusterFinderSDD)
24 //----------------------------------------------------------
25 AliITSClusterFinderSDD::AliITSClusterFinderSDD
26 (AliITSsegmentation *seg, AliITSresponse *response, TClonesArray *digits, TClonesArray *recp)
33 fNclusters= fClusters->GetEntriesFast();
34 printf("SDD: fNclusters %d\n",fNclusters);
43 //_____________________________________________________________________________
44 AliITSClusterFinderSDD::AliITSClusterFinderSDD()
61 //__________________________________________________________________________
62 AliITSClusterFinderSDD::AliITSClusterFinderSDD(const AliITSClusterFinderSDD &source){
64 if(&source == this) return;
65 this->fClusters = source.fClusters ;
66 this->fNclusters = source.fNclusters ;
67 this->fMap = source.fMap ;
68 this->fCutAmplitude = source.fCutAmplitude ;
69 this->fDAnode = source.fDAnode ;
70 this->fDTime = source.fDTime ;
71 this->fMinPeak = source.fMinPeak ;
72 this->fMinNCells = source.fMinNCells ;
76 //_________________________________________________________________________
77 AliITSClusterFinderSDD&
78 AliITSClusterFinderSDD::operator=(const AliITSClusterFinderSDD &source) {
79 // Assignment operator
80 if(&source == this) return *this;
81 this->fClusters = source.fClusters ;
82 this->fNclusters = source.fNclusters ;
83 this->fMap = source.fMap ;
84 this->fCutAmplitude = source.fCutAmplitude ;
85 this->fDAnode = source.fDAnode ;
86 this->fDTime = source.fDTime ;
87 this->fMinPeak = source.fMinPeak ;
88 this->fMinNCells = source.fMinNCells ;
92 //_____________________________________________________________________________
93 void AliITSClusterFinderSDD::SetMap()
96 if(!fMap) fMap=new AliITSMapA2(fSegmentation);
99 //_____________________________________________________________________________
100 void AliITSClusterFinderSDD::FillMap()
103 // fCoord2 = time sample
105 if (!fDigits) return;
107 Int_t ndigits = fDigits->GetEntriesFast();
108 //printf("FillMap: ndigits %d\n",ndigits);
109 if (!ndigits) return;
113 for(ndig=0; ndig<ndigits; ndig++) {
114 dig = (AliITSdigitSDD*)fDigits->UncheckedAt(ndig);
115 Double_t signal=dig->fSignal;
116 //printf("FillMap: ndig fCoord1 fCoord2 signal %d %d %d %f\n",ndig,dig->fCoord1,dig->fCoord2,signal);
117 fMap->SetHit(dig->fCoord1,dig->fCoord2,signal);
122 //_____________________________________________________________________________
124 void AliITSClusterFinderSDD::Find1DClusters()
128 AliITS *iTS=(AliITS*)gAlice->GetModule("ITS");
130 // retrieve the parameters
131 Int_t fNofMaps = fSegmentation->Npz();
132 Int_t fMaxNofSamples = fSegmentation->Npx();
133 Int_t fNofAnodes = fNofMaps/2;
135 Float_t fTimeStep = fSegmentation->Dpx(dummy);
136 Float_t fSddLength = fSegmentation->Dx();
137 Float_t fDriftSpeed = fResponse->DriftSpeed();
139 Float_t anodePitch = fSegmentation->Dpz(dummy);
143 // Piergiorgio's code - do not subtract baseline since we start
144 // from digits and do not duplicate arrays, i.e. use fMap instead
145 // of Float_t fadc[2*fNofAnodes][fMaxNofSamples];
148 Int_t nofFoundClusters = 0;
149 Float_t dfadc[fNofMaps][fMaxNofSamples];
150 Float_t fadc, fadc1, fadc2;
153 for(k=0;k<fNofAnodes;k++) {
154 idx = j*fNofAnodes+k;
155 // signal (fadc) & derivative (dfadc)
156 for(l=0; l<fMaxNofSamples; l++) {
157 fadc2=(Float_t)fMap->GetSignal(idx,l);
158 fadc1=(Float_t)fMap->GetSignal(idx,l-1);
159 if(l>0) dfadc[k][l-1] = fadc2-fadc1;
163 for(k=0;k<fNofAnodes;k++) {
164 idx = j*fNofAnodes+k;
169 while(it <= fMaxNofSamples-3) {
170 // cout << "sample: " << it << endl;
176 Float_t fadcmax = 0.;
177 Float_t dfadcmax = 0.;
179 // if(it >= 60) lthrmina = 2;
180 // if(it >= 100) lthrmina = 3;
182 //if(it >= 60) lthrmint = 3;
183 //if(it >= 100) lthrmint = 4;
189 if(id>=fMaxNofSamples) break;
190 fadc=fMap->GetSignal(idx,id);
193 if(fadc > fCutAmplitude) { lthra++; lthrt++; }
196 if(dfadc[k][id] > dfadcmax) {
197 dfadcmax = dfadc[k][id];
202 // skip if no signal over threshold
203 if(fMap->GetSignal(idx,imax) < fCutAmplitude) {it++; continue;}
206 if(fMap->GetSignal(idx-1,imax) > fCutAmplitude) lthra++;
209 if(fMap->GetSignal(idx+1,imax) > fCutAmplitude) lthra++;
212 if(fMap->GetSignal(idx,imax-1) > fCutAmplitude) lthrt++;
214 if(imax<fMaxNofSamples)
215 if(fMap->GetSignal(idx,imax+1) > fCutAmplitude) lthrt++;
221 if(lthrt >= lthrmint && lthra >= lthrmina) ilcl = 1;
225 Int_t tstop = tstart;
226 Float_t dfadcmin = 10000.;
228 for(ij=0; ij<10; ij++) {
229 if(dfadc[k][it+ij] < dfadcmin) {
231 dfadcmin = dfadc[k][it+ij];
235 Float_t clusterCharge = 0.;
236 Float_t clusterAnode = k+0.5;
237 Float_t clusterTime = 0.;
238 Float_t clusterMult = 0.;
239 Float_t clusterPeakAmplitude = 0.;
241 for(its=tstart; its<=tstop; its++) {
242 fadc=fMap->GetSignal(idx,its);
243 clusterCharge += fadc;
244 if(fadc > clusterPeakAmplitude) clusterPeakAmplitude = fadc;
245 clusterTime += fadc*its;
248 clusterTime /= (clusterCharge/fTimeStep); // ns
249 clusterCharge *= (fTimeStep/160.); // keV
250 if(clusterTime > 58.2) clusterTime -= 58.2; // ns
253 cout << "Warning: cluster with negative time " << clusterTime << ", peak ampl.: " << clusterPeakAmplitude << ", mult: " << clusterMult << ", charge: " << clusterCharge << endl;
254 cout << "Anode: " << k << ", tstart: " << tstart << ", tstop: " << tstop << ", Charge: " << clusterCharge << endl;
259 // cout << "Anode: " << k << ", tstart: " << tstart << ", tstop: " << tstop << ", Charge: " << clusterCharge << endl;
261 Float_t clusteranodePath = (0.06 + clusterAnode - fNofAnodes/2)*anodePitch;
262 Float_t clusterDriftPath = clusterTime*fDriftSpeed;
263 clusterDriftPath = fSddLength-clusterDriftPath;
265 if(clusterCharge < 0.) break;
267 //printf("wing clusterMult clusterAnode clusterTime %d %f %f %f \n",j+1,clusterMult, clusterAnode, clusterTime);
269 AliITSRawClusterSDD *clust = new AliITSRawClusterSDD(j+1,clusterAnode,clusterTime,clusterCharge,clusterPeakAmplitude,0.,0.,clusterDriftPath,clusteranodePath,clusterMult);
270 //fClusters->Add(point);
271 iTS->AddCluster(1,clust);
281 Int_t nofClusters = fClusters->GetEntriesFast();
282 nofClusters -= fNclusters;
284 //printf("SDD- Find1Dclust: fNclusters nofClusters %d %d \n",fNclusters, nofClusters);
292 //_____________________________________________________________________________
293 void AliITSClusterFinderSDD::GroupClusters()
297 Float_t fTimeStep = fSegmentation->Dpx(dummy);
300 // get number of clusters for this module
301 Int_t nofClusters = fClusters->GetEntriesFast();
302 nofClusters -= fNclusters;
304 //printf("SDD- GroupClusters: fNclusters nofClusters %d %d \n",fNclusters, nofClusters);
306 AliITSRawClusterSDD *clusterI;
307 AliITSRawClusterSDD *clusterJ;
309 Int_t label[nofClusters];
311 for(i=0; i<nofClusters; i++) label[i] = 0;
312 for(i=0; i<nofClusters; i++) {
313 if(label[i] != 0) continue;
314 for(j=i+1; j<nofClusters; j++) {
315 if(label[j] != 0) continue;
316 clusterI = (AliITSRawClusterSDD*) fClusters->At(i);
317 clusterJ = (AliITSRawClusterSDD*) fClusters->At(j);
319 if(clusterI->T() < fTimeStep*60) fDAnode = 3.2;
320 if(clusterI->T() < fTimeStep*10) fDAnode = 1.2;
321 Bool_t pair = clusterI->Brother(clusterJ,fDAnode,fDTime);
323 // clusterI->Print();
324 // clusterJ->Print();
325 clusterI->Add(clusterJ);
327 fClusters->RemoveAt(j);
331 fClusters->Compress();
336 //_____________________________________________________________________________
338 void AliITSClusterFinderSDD::SelectClusters()
340 // get number of clusters for this module
341 Int_t nofClusters = fClusters->GetEntriesFast();
342 nofClusters -= fNclusters;
344 //printf("SDD- SelectClusters: fNclusters nofClusters %d %d \n",fNclusters, nofClusters);
347 for(i=0; i<nofClusters; i++) {
348 AliITSRawClusterSDD *clusterI = (AliITSRawClusterSDD*) fClusters->At(i);
351 if(clusterI->Anodes() != 0.) {
352 wy = ((Float_t) clusterI->Samples())/clusterI->Anodes();
354 Float_t amp = clusterI->PeakAmpl();
355 if(amp < fMinPeak) rmflg = 1;
356 if(wy < fMinNCells) rmflg = 1;
357 if(rmflg) fClusters->RemoveAt(i);
359 fClusters->Compress();
364 //_____________________________________________________________________________
366 void AliITSClusterFinderSDD::GetRecPoints()
369 //static Int_t counter=0;
371 AliITS *iTS=(AliITS*)gAlice->GetModule("ITS");
373 // get number of clusters for this module
374 Int_t nofClusters = fClusters->GetEntriesFast();
375 nofClusters -= fNclusters;
377 //printf("SDD- GetRecPoints: fNclusters nofClusters %d %d \n",fNclusters, nofClusters);
379 // const Float_t kdEdXtoQ = 2.778e+2; // KeV -> number of e-hole pairs in Si
380 const Float_t kconvGeV = 1.e-6; // GeV -> KeV
381 const Float_t kconv = 1.0e-4;
382 const Float_t kRMSx = 38.0*kconv; // microns->cm ITS TDR Table 1.3
383 const Float_t kRMSz = 28.0*kconv; // microns->cm ITS TDR Table 1.3
386 for(i=0; i<nofClusters; i++) {
387 AliITSRawClusterSDD *clusterI = (AliITSRawClusterSDD*) fClusters->At(i);
389 rnew.SetX(clusterI->X());
390 rnew.SetZ(clusterI->Z());
391 rnew.SetQ(clusterI->Q()); // in KeV - should be ADC
392 //rnew.SetdEdX((clusterI->Q())/kdEdXtoQ);
393 rnew.SetdEdX(kconvGeV*clusterI->Q());
394 rnew.SetSigmaX2(kRMSx*kRMSx);
395 rnew.SetSigmaZ2(kRMSz*kRMSz);
396 rnew.SetProbability(1.);
397 iTS->AddRecPoint(rnew);
400 //printf("counter %d\n",counter);
404 //_____________________________________________________________________________
406 void AliITSClusterFinderSDD::FindRawClusters()