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 "AliITSClusterFinderSPD.h"
18 #include "AliITSMapA1.h"
24 ClassImp(AliITSClusterFinderSPD)
26 //----------------------------------------------------------
27 AliITSClusterFinderSPD::AliITSClusterFinderSPD
28 (AliITSsegmentation *seg, TClonesArray *digits, TClonesArray *recp)
34 fNclusters= fClusters->GetEntriesFast();
41 //_____________________________________________________________________________
42 AliITSClusterFinderSPD::AliITSClusterFinderSPD()
56 //_____________________________________________________________________________
57 AliITSClusterFinderSPD::~AliITSClusterFinderSPD()
60 if (fMap) delete fMap;
64 //__________________________________________________________________________
65 AliITSClusterFinderSPD::AliITSClusterFinderSPD(const AliITSClusterFinderSPD &source){
67 if(&source == this) return;
68 this->fClusters = source.fClusters ;
69 this->fNclusters = source.fNclusters ;
70 this->fMap = source.fMap ;
71 this->fDz = source.fDz ;
72 this->fDx = source.fDx ;
73 this->fMinNCells = source.fMinNCells ;
77 //_________________________________________________________________________
78 AliITSClusterFinderSPD&
79 AliITSClusterFinderSPD::operator=(const AliITSClusterFinderSPD &source) {
80 // Assignment operator
81 if(&source == this) return *this;
82 this->fClusters = source.fClusters ;
83 this->fNclusters = source.fNclusters ;
84 this->fMap = source.fMap ;
85 this->fDz = source.fDz ;
86 this->fDx = source.fDx ;
87 this->fMinNCells = source.fMinNCells ;
91 //_____________________________________________________________________________
92 void AliITSClusterFinderSPD::SetMap()
95 if(!fMap) fMap=new AliITSMapA1(fSegmentation,fDigits);
99 //_____________________________________________________________________________
101 void AliITSClusterFinderSPD::Find1DClusters()
103 // Find one dimensional clusters, i.e.
104 // in r*phi(x) direction for each colunm in z direction
106 AliITS *iTS=(AliITS*)gAlice->GetModule("ITS");
108 // retrieve the parameters
109 Int_t fNofPixels = fSegmentation->Npz();
110 Int_t fMaxNofSamples = fSegmentation->Npx();
112 // read in digits -> do not apply threshold
113 // signal in fired pixels is always 1
116 Int_t nofFoundClusters = 0;
119 for(k=0;k<fNofPixels;k++) {
121 Int_t mmax = 10; // a size of the window for the cluster finding
123 for(it=0;it<fMaxNofSamples;it++) {
131 for(m=0;m<mmax;m++) { // find the cluster inside the window
133 if(id >= fMaxNofSamples) break; // ! no possible for the fadc
135 if(fMap->TestHit(k,id) == kUnused) { // start of the cluster
137 if(lclx == 1) xstart = id;
141 if(lclx > 0 && fMap->TestHit(k,id) == kEmpty) {
142 // end of cluster if a gap exists
150 if(lclx == 0 && ilcl == 0) it = id; // no cluster in the window,
151 // continue the "it" loop
153 if(id >= fMaxNofSamples && lclx == 0) break; // the x row finished
155 if(id < fMaxNofSamples && ilcl == 0 && lclx > 0) {
156 // cluster end is outside of the window,
157 mmax += 5; // increase mmax and repeat the cluster
162 if(id >= fMaxNofSamples && lclx > 0) { // the x row finished but
163 xstop = fMaxNofSamples - 1; // the end cluster exists
167 // --- Calculate z and x coordinates for one dimensional clusters
169 if(ilcl == 1) { // new cluster exists
173 Float_t clusterCharge = 0.;
174 Float_t zpitch = fSegmentation->Dpz(k+1);
175 Float_t clusterZ, dummyX;
177 fSegmentation->GetPadCxz(dummy,k,dummyX,clusterZ);
178 Float_t zstart = clusterZ - 0.5*zpitch;
179 Float_t zstop = clusterZ + 0.5*zpitch;
180 Float_t clusterX = 0.;
181 Int_t xstartfull = xstart;
182 Int_t xstopfull = xstop;
183 Int_t clusterSizeX = lclx;
184 Int_t clusterSizeZ = 1;
187 for(its=xstart; its<=xstop; its++) {
189 if (fMap->GetHitIndex(k,its)>=0) firedpixel=1;
190 clusterCharge += firedpixel;
191 clusterX +=its + 0.5;
193 Float_t fRphiPitch = fSegmentation->Dpx(dummy);
194 clusterX /= (clusterSizeX/fRphiPitch); // center of gravity for x
197 //printf("ClusterZ ClusterX %f %f \n",clusterZ, clusterX);
199 // Int_t nclusters = fClusters->GetEntriesFast();
200 // cout << nclusters << " clusters" << endl;
201 // cout<< "Create point"<<endl;
203 // Write the points (coordinates and some cluster information) to the
204 // AliITSRawClusterSPD object
206 AliITSRawClusterSPD *clust = new AliITSRawClusterSPD(clusterZ,clusterX,clusterCharge,clusterSizeZ,clusterSizeX,xstart,xstop,xstartfull,xstopfull,zstart,zstop,k);
207 // fClusters->Add(point);
208 iTS->AddCluster(0,clust);
209 // cout << "Cluster at Ladder: " << fLadder << ", Detector: " <<fDetector<<endl;
211 // cout<<" end of cluster finding for Z pixel "<<endl;
213 } // new cluster (ilcl=1)
214 } // X direction loop (it)
215 } // Z direction loop (k)
222 //_____________________________________________________________________________
223 void AliITSClusterFinderSPD::GroupClusters()
225 // Find two dimensional clusters, i.e. group one dimensional clusters
226 // into two dimensional ones (go both in x and z directions).
228 // get number of clusters for this module
229 Int_t nofClusters = fClusters->GetEntriesFast();
230 nofClusters -= fNclusters;
232 AliITSRawClusterSPD *clusterI;
233 AliITSRawClusterSPD *clusterJ;
235 Int_t *label=new Int_t[nofClusters];
237 for(i=0; i<nofClusters; i++) label[i] = 0;
238 for(i=0; i<nofClusters; i++) {
239 if(label[i] != 0) continue;
240 for(j=i+1; j<nofClusters; j++) {
241 if(label[j] != 0) continue;
242 clusterI = (AliITSRawClusterSPD*) fClusters->At(i);
243 clusterJ = (AliITSRawClusterSPD*) fClusters->At(j);
244 Bool_t pair = clusterI->Brother(clusterJ,fDz,fDx);
247 // if((clusterI->XStop() == clusterJ->XStart()-1)||(clusterI->XStart()==clusterJ->XStop()+1)) cout<<"!! Diagonal cluster"<<endl;
249 cout << "clusters " << i << "," << j << " before grouping" << endl;
250 clusterI->PrintInfo();
251 clusterJ->PrintInfo();
253 clusterI->Add(clusterJ);
254 // cout << "remove cluster " << j << endl;
256 fClusters->RemoveAt(j);
258 cout << "cluster " << i << " after grouping" << endl;
259 clusterI->PrintInfo();
265 fClusters->Compress();
266 //Int_t totalNofClusters = fClusters->GetEntriesFast();
267 //cout << " Nomber of clusters at the group end ="<< totalNofClusters<<endl;
275 //_____________________________________________________________________________
277 void AliITSClusterFinderSPD::GetRecPoints()
280 AliITS *iTS=(AliITS*)gAlice->GetModule("ITS");
282 // get number of clusters for this module
283 Int_t nofClusters = fClusters->GetEntriesFast();
284 nofClusters -= fNclusters;
287 const Float_t kconv = 1.0e-4;
288 const Float_t kRMSx = 12.0*kconv; // microns -> cm ITS TDR Table 1.3
289 const Float_t kRMSz = 70.0*kconv; // microns -> cm ITS TDR Table 1.3
291 Float_t spdLength = fSegmentation->Dz();
292 Float_t spdWidth = fSegmentation->Dx();
295 for(i=0; i<nofClusters; i++) {
296 AliITSRawClusterSPD *clusterI = (AliITSRawClusterSPD*) fClusters->At(i);
297 fSegmentation->GetPadIxz(clusterI->X(),clusterI->Z(),ix,iz);
298 AliITSdigitSPD *dig = (AliITSdigitSPD*)fMap->GetHit(iz-1,ix-1);
300 rnew.SetX((clusterI->X() - spdWidth/2)*kconv);
301 rnew.SetZ((clusterI->Z() - spdLength/2)*kconv);
304 rnew.SetSigmaX2(kRMSx*kRMSx);
305 rnew.SetSigmaZ2(kRMSz*kRMSz);
306 rnew.fTracks[0]=dig->fTracks[0];
307 rnew.fTracks[1]=dig->fTracks[1];
308 rnew.fTracks[2]=dig->fTracks[2];
309 iTS->AddRecPoint(rnew);
315 //_____________________________________________________________________________
317 void AliITSClusterFinderSPD::FindRawClusters()