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 **************************************************************************/
21 #include "AliITSClusterFinderSPD.h"
22 #include "AliITSMapA1.h"
24 #include "AliITSdigit.h"
25 #include "AliITSRawCluster.h"
26 #include "AliITSRecPoint.h"
27 #include "AliITSsegmentation.h"
28 #include "AliITSresponse.h"
33 ClassImp(AliITSClusterFinderSPD)
35 //----------------------------------------------------------
36 AliITSClusterFinderSPD::AliITSClusterFinderSPD
37 (AliITSsegmentation *seg, TClonesArray *digits, TClonesArray *recp)
43 fNclusters= fClusters->GetEntriesFast();
50 //_____________________________________________________________________________
51 AliITSClusterFinderSPD::AliITSClusterFinderSPD()
65 //_____________________________________________________________________________
66 AliITSClusterFinderSPD::~AliITSClusterFinderSPD()
69 if (fMap) delete fMap;
73 //__________________________________________________________________________
74 AliITSClusterFinderSPD::AliITSClusterFinderSPD(const AliITSClusterFinderSPD &source){
76 if(&source == this) return;
77 this->fClusters = source.fClusters ;
78 this->fNclusters = source.fNclusters ;
79 this->fMap = source.fMap ;
80 this->fDz = source.fDz ;
81 this->fDx = source.fDx ;
82 this->fMinNCells = source.fMinNCells ;
86 //_________________________________________________________________________
87 AliITSClusterFinderSPD&
88 AliITSClusterFinderSPD::operator=(const AliITSClusterFinderSPD &source) {
89 // Assignment operator
90 if(&source == this) return *this;
91 this->fClusters = source.fClusters ;
92 this->fNclusters = source.fNclusters ;
93 this->fMap = source.fMap ;
94 this->fDz = source.fDz ;
95 this->fDx = source.fDx ;
96 this->fMinNCells = source.fMinNCells ;
100 //_____________________________________________________________________________
101 void AliITSClusterFinderSPD::SetMap()
105 if(!fMap) fMap=new AliITSMapA1(fSegmentation,fDigits);
109 //_____________________________________________________________________________
111 void AliITSClusterFinderSPD::Find1DClusters()
113 // Find one dimensional clusters, i.e.
114 // in r*phi(x) direction for each colunm in z direction
116 AliITS *iTS=(AliITS*)gAlice->GetModule("ITS");
118 // retrieve the parameters
119 Int_t fNofPixels = fSegmentation->Npz();
120 Int_t fMaxNofSamples = fSegmentation->Npx();
122 // read in digits -> do not apply threshold
123 // signal in fired pixels is always 1
127 Int_t nofFoundClusters = 0;
130 for(k=0;k<fNofPixels;k++) {
132 Int_t mmax = 10; // a size of the window for the cluster finding
134 for(it=0;it<fMaxNofSamples;it++) {
142 for(m=0;m<mmax;m++) { // find the cluster inside the window
144 if(id >= fMaxNofSamples) break; // ! no possible for the fadc
146 if(fMap->TestHit(k,id) == kUnused) { // start of the cluster
148 if(lclx == 1) xstart = id;
152 if(lclx > 0 && fMap->TestHit(k,id) == kEmpty) {
153 // end of cluster if a gap exists
161 if(lclx == 0 && ilcl == 0) it = id; // no cluster in the window,
162 // continue the "it" loop
164 if(id >= fMaxNofSamples && lclx == 0) break; // the x row finished
166 if(id < fMaxNofSamples && ilcl == 0 && lclx > 0) {
167 // cluster end is outside of the window,
168 mmax += 5; // increase mmax and repeat the cluster
173 if(id >= fMaxNofSamples && lclx > 0) { // the x row finished but
174 xstop = fMaxNofSamples - 1; // the end cluster exists
178 // --- Calculate z and x coordinates for one dimensional clusters
180 if(ilcl == 1) { // new cluster exists
184 Float_t clusterCharge = 0.;
185 Float_t zpitch = fSegmentation->Dpz(k+1);
186 Float_t clusterZ, dummyX;
188 fSegmentation->GetPadCxz(dummy,k,dummyX,clusterZ);
189 Float_t zstart = clusterZ - 0.5*zpitch;
190 Float_t zstop = clusterZ + 0.5*zpitch;
191 Float_t clusterX = 0.;
192 Int_t xstartfull = xstart;
193 Int_t xstopfull = xstop;
194 Int_t clusterSizeX = lclx;
195 Int_t clusterSizeZ = 1;
198 for(its=xstart; its<=xstop; its++) {
200 if (fMap->GetHitIndex(k,its)>=0) firedpixel=1;
201 clusterCharge += firedpixel;
202 clusterX +=its + 0.5;
204 Float_t fRphiPitch = fSegmentation->Dpx(dummy);
205 clusterX /= (clusterSizeX/fRphiPitch); // center of gravity for x
207 // Write the points (coordinates and some cluster information) to the
208 // AliITSRawClusterSPD object
210 AliITSRawClusterSPD *clust = new AliITSRawClusterSPD(clusterZ,clusterX,clusterCharge,clusterSizeZ,clusterSizeX,xstart,xstop,xstartfull,xstopfull,zstart,zstop,k);
212 iTS->AddCluster(0,clust);
214 } // new cluster (ilcl=1)
215 } // X direction loop (it)
216 } // Z direction loop (k)
223 //_____________________________________________________________________________
224 void AliITSClusterFinderSPD::GroupClusters()
226 // Find two dimensional clusters, i.e. group one dimensional clusters
227 // into two dimensional ones (go both in x and z directions).
229 // get number of clusters for this module
230 Int_t nofClusters = fClusters->GetEntriesFast();
231 nofClusters -= fNclusters;
233 AliITSRawClusterSPD *clusterI;
234 AliITSRawClusterSPD *clusterJ;
236 Int_t *label=new Int_t[nofClusters];
238 for(i=0; i<nofClusters; i++) label[i] = 0;
239 for(i=0; i<nofClusters; i++) {
240 if(label[i] != 0) continue;
241 for(j=i+1; j<nofClusters; j++) {
242 if(label[j] != 0) continue;
243 clusterI = (AliITSRawClusterSPD*) fClusters->At(i);
244 clusterJ = (AliITSRawClusterSPD*) fClusters->At(j);
245 Bool_t pair = clusterI->Brother(clusterJ,fDz,fDx);
248 // if((clusterI->XStop() == clusterJ->XStart()-1)||(clusterI->XStart()==clusterJ->XStop()+1)) cout<<"!! Diagonal cluster"<<endl;
251 cout << "clusters " << i << "," << j << " before grouping" << endl;
252 clusterI->PrintInfo();
253 clusterJ->PrintInfo();
256 clusterI->Add(clusterJ);
257 // cout << "remove cluster " << j << endl;
259 fClusters->RemoveAt(j);
262 cout << "cluster " << i << " after grouping" << endl;
263 clusterI->PrintInfo();
270 fClusters->Compress();
273 Int_t totalNofClusters = fClusters->GetEntriesFast();
274 cout << " Nomber of clusters at the group end ="<< totalNofClusters<<endl;
283 //_____________________________________________________________________________
285 void AliITSClusterFinderSPD::TracksInCluster()
288 // Find tracks creating one cluster
290 // get number of clusters for this module
291 Int_t nofClusters = fClusters->GetEntriesFast();
292 nofClusters -= fNclusters;
294 Int_t i, ix, iz, jx, jz, xstart, xstop, zstart, zstop, nclx, nclz;
295 const Int_t trmax = 100;
296 Int_t cltracks[trmax], itr, tracki, ii, is, js, ie, ntr, tr0, tr1, tr2;
298 for(i=0; i<nofClusters; i++) {
300 memset(cltracks,-1,sizeof(int)*trmax);
303 AliITSRawClusterSPD *clusterI = (AliITSRawClusterSPD*) fClusters->At(i);
305 nclx = clusterI->NclX();
306 nclz = clusterI->NclZ();
307 xstart = clusterI->XStartf();
308 xstop = clusterI->XStopf();
309 zstart = clusterI->Zend()-nclz+1;
310 zstop = clusterI->Zend();
313 for(iz=0; iz<nclz; iz++) {
315 for(ix=0; ix<nclx; ix++) {
317 ind = fMap->GetHitIndex(jz,jx);
321 if(ind == 0 && iz >= 0 && ix > 0) {
324 if(ind == 0 && iz > 0 && ix >= 0) {
327 if(ind == 0 && iz == 0 && ix == 0 && i > 0) {
331 AliITSdigitSPD *dig = (AliITSdigitSPD*)fMap->GetHit(jz,jx);
335 track0=dig->fTracks[0];
336 track1=dig->fTracks[1];
337 track2=dig->fTracks[2];
340 for(itr=0; itr<3; itr++) {
341 tracki = dig->fTracks[itr];
346 if(ii < 99) cltracks[ii-1] = tracki;
352 for(is=0; is<trmax; is++) {
353 if(cltracks[is]<0) continue;
354 for(js=is+1; js<trmax; js++) {
355 if(cltracks[js]<0) continue;
356 if(cltracks[js]==cltracks[is]) cltracks[js]=-5;
361 for(ie=0; ie<trmax; ie++) {
362 if(cltracks[ie] >= 0) {
364 if(ntr==1) tr0=cltracks[ie];
365 if(ntr==2) tr1=cltracks[ie];
366 if(ntr==3) tr2=cltracks[ie];
370 if(ntr == 0) ntr = 1;
372 clusterI->SetNTracks(ntr);
373 clusterI->SetTracks(tr0,tr1,tr2);
378 //_____________________________________________________________________________
380 void AliITSClusterFinderSPD::GetRecPoints()
383 AliITS *iTS=(AliITS*)gAlice->GetModule("ITS");
385 // get number of clusters for this module
386 Int_t nofClusters = fClusters->GetEntriesFast();
387 nofClusters -= fNclusters;
388 const Float_t kconv = 1.0e-4;
389 const Float_t kRMSx = 12.0*kconv; // microns -> cm ITS TDR Table 1.3
390 const Float_t kRMSz = 70.0*kconv; // microns -> cm ITS TDR Table 1.3
392 Float_t spdLength = fSegmentation->Dz();
393 Float_t spdWidth = fSegmentation->Dx();
396 Int_t track0, track1, track2;
398 for(i=0; i<nofClusters; i++) {
400 AliITSRawClusterSPD *clusterI = (AliITSRawClusterSPD*) fClusters->At(i);
401 clusterI->GetTracks(track0, track1, track2);
404 rnew.SetX((clusterI->X() - spdWidth/2)*kconv);
405 rnew.SetZ((clusterI->Z() - spdLength/2)*kconv);
408 rnew.SetSigmaX2(kRMSx*kRMSx);
409 rnew.SetSigmaZ2(kRMSz*kRMSz);
410 rnew.fTracks[0]=track0;
411 rnew.fTracks[1]=track1;
412 rnew.fTracks[2]=track2;
413 iTS->AddRecPoint(rnew);
419 //_____________________________________________________________________________
421 void AliITSClusterFinderSPD::FindRawClusters()